documentation.d.ts 3.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875
  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. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** 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 */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** 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 */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** 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 */
  689. static readonly GEQUAL: number;
  690. /** 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 */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  823. static readonly SCALEMODE_FLOOR: number;
  824. /** Defines that texture rescaling will look for the nearest power of 2 size */
  825. static readonly SCALEMODE_NEAREST: number;
  826. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  827. static readonly SCALEMODE_CEILING: number;
  828. /**
  829. * The dirty texture flag value
  830. */
  831. static readonly MATERIAL_TextureDirtyFlag: number;
  832. /**
  833. * The dirty light flag value
  834. */
  835. static readonly MATERIAL_LightDirtyFlag: number;
  836. /**
  837. * The dirty fresnel flag value
  838. */
  839. static readonly MATERIAL_FresnelDirtyFlag: number;
  840. /**
  841. * The dirty attribute flag value
  842. */
  843. static readonly MATERIAL_AttributesDirtyFlag: number;
  844. /**
  845. * The dirty misc flag value
  846. */
  847. static readonly MATERIAL_MiscDirtyFlag: number;
  848. /**
  849. * The all dirty flag value
  850. */
  851. static readonly MATERIAL_AllDirtyFlag: number;
  852. /**
  853. * Returns the triangle fill mode
  854. */
  855. static readonly MATERIAL_TriangleFillMode: number;
  856. /**
  857. * Returns the wireframe mode
  858. */
  859. static readonly MATERIAL_WireFrameFillMode: number;
  860. /**
  861. * Returns the point fill mode
  862. */
  863. static readonly MATERIAL_PointFillMode: number;
  864. /**
  865. * Returns the point list draw mode
  866. */
  867. static readonly MATERIAL_PointListDrawMode: number;
  868. /**
  869. * Returns the line list draw mode
  870. */
  871. static readonly MATERIAL_LineListDrawMode: number;
  872. /**
  873. * Returns the line loop draw mode
  874. */
  875. static readonly MATERIAL_LineLoopDrawMode: number;
  876. /**
  877. * Returns the line strip draw mode
  878. */
  879. static readonly MATERIAL_LineStripDrawMode: number;
  880. /**
  881. * Returns the triangle strip draw mode
  882. */
  883. static readonly MATERIAL_TriangleStripDrawMode: number;
  884. /**
  885. * Returns the triangle fan draw mode
  886. */
  887. static readonly MATERIAL_TriangleFanDrawMode: number;
  888. /**
  889. * Stores the clock-wise side orientation
  890. */
  891. static readonly MATERIAL_ClockWiseSideOrientation: number;
  892. /**
  893. * Stores the counter clock-wise side orientation
  894. */
  895. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  896. /**
  897. * Nothing
  898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  899. */
  900. static readonly ACTION_NothingTrigger: number;
  901. /**
  902. * On pick
  903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  904. */
  905. static readonly ACTION_OnPickTrigger: number;
  906. /**
  907. * On left pick
  908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  909. */
  910. static readonly ACTION_OnLeftPickTrigger: number;
  911. /**
  912. * On right pick
  913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  914. */
  915. static readonly ACTION_OnRightPickTrigger: number;
  916. /**
  917. * On center pick
  918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  919. */
  920. static readonly ACTION_OnCenterPickTrigger: number;
  921. /**
  922. * On pick down
  923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  924. */
  925. static readonly ACTION_OnPickDownTrigger: number;
  926. /**
  927. * On double pick
  928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  929. */
  930. static readonly ACTION_OnDoublePickTrigger: number;
  931. /**
  932. * On pick up
  933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  934. */
  935. static readonly ACTION_OnPickUpTrigger: number;
  936. /**
  937. * On pick out.
  938. * This trigger will only be raised if you also declared a OnPickDown
  939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickOutTrigger: number;
  942. /**
  943. * On long press
  944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnLongPressTrigger: number;
  947. /**
  948. * On pointer over
  949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPointerOverTrigger: number;
  952. /**
  953. * On pointer out
  954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPointerOutTrigger: number;
  957. /**
  958. * On every frame
  959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnEveryFrameTrigger: number;
  962. /**
  963. * On intersection enter
  964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnIntersectionEnterTrigger: number;
  967. /**
  968. * On intersection exit
  969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnIntersectionExitTrigger: number;
  972. /**
  973. * On key down
  974. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnKeyDownTrigger: number;
  977. /**
  978. * On key up
  979. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnKeyUpTrigger: number;
  982. /**
  983. * Billboard mode will only apply to Y axis
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  986. /**
  987. * Billboard mode will apply to all axes
  988. */
  989. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  990. /**
  991. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  994. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  995. * Test order :
  996. * Is the bounding sphere outside the frustum ?
  997. * If not, are the bounding box vertices outside the frustum ?
  998. * It not, then the cullable object is in the frustum.
  999. */
  1000. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1001. /** Culling strategy : Bounding Sphere Only.
  1002. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1003. * It's also less accurate than the standard because some not visible objects can still be selected.
  1004. * Test : is the bounding sphere outside the frustum ?
  1005. * If not, then the cullable object is in the frustum.
  1006. */
  1007. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1008. /** Culling strategy : Optimistic Inclusion.
  1009. * This in an inclusion test first, then the standard exclusion test.
  1010. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1011. * 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.
  1012. * Anyway, it's as accurate as the standard strategy.
  1013. * Test :
  1014. * Is the cullable object bounding sphere center in the frustum ?
  1015. * If not, apply the default culling strategy.
  1016. */
  1017. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1018. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1019. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1020. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1021. * 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.
  1022. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1023. * Test :
  1024. * Is the cullable object bounding sphere center in the frustum ?
  1025. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1026. */
  1027. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1028. /**
  1029. * No logging while loading
  1030. */
  1031. static readonly SCENELOADER_NO_LOGGING: number;
  1032. /**
  1033. * Minimal logging while loading
  1034. */
  1035. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1036. /**
  1037. * Summary logging while loading
  1038. */
  1039. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1040. /**
  1041. * Detailled logging while loading
  1042. */
  1043. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1044. }
  1045. }
  1046. declare module BABYLON {
  1047. /**
  1048. * This represents the required contract to create a new type of texture loader.
  1049. */
  1050. export interface IInternalTextureLoader {
  1051. /**
  1052. * Defines wether the loader supports cascade loading the different faces.
  1053. */
  1054. supportCascades: boolean;
  1055. /**
  1056. * This returns if the loader support the current file information.
  1057. * @param extension defines the file extension of the file being loaded
  1058. * @returns true if the loader can load the specified file
  1059. */
  1060. canLoad(extension: string): boolean;
  1061. /**
  1062. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1063. * @param data contains the texture data
  1064. * @param texture defines the BabylonJS internal texture
  1065. * @param createPolynomials will be true if polynomials have been requested
  1066. * @param onLoad defines the callback to trigger once the texture is ready
  1067. * @param onError defines the callback to trigger in case of error
  1068. */
  1069. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1070. /**
  1071. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1072. * @param data contains the texture data
  1073. * @param texture defines the BabylonJS internal texture
  1074. * @param callback defines the method to call once ready to upload
  1075. */
  1076. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1077. }
  1078. }
  1079. declare module BABYLON {
  1080. /**
  1081. * Class used to store and describe the pipeline context associated with an effect
  1082. */
  1083. export interface IPipelineContext {
  1084. /**
  1085. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1086. */
  1087. isAsync: boolean;
  1088. /**
  1089. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1090. */
  1091. isReady: boolean;
  1092. /** @hidden */
  1093. _getVertexShaderCode(): string | null;
  1094. /** @hidden */
  1095. _getFragmentShaderCode(): string | null;
  1096. /** @hidden */
  1097. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1098. }
  1099. }
  1100. declare module BABYLON {
  1101. /**
  1102. * Class used to store gfx data (like WebGLBuffer)
  1103. */
  1104. export class DataBuffer {
  1105. /**
  1106. * Gets or sets the number of objects referencing this buffer
  1107. */
  1108. references: number;
  1109. /** Gets or sets the size of the underlying buffer */
  1110. capacity: number;
  1111. /**
  1112. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1113. */
  1114. is32Bits: boolean;
  1115. /**
  1116. * Gets the underlying buffer
  1117. */
  1118. get underlyingResource(): any;
  1119. }
  1120. }
  1121. declare module BABYLON {
  1122. /** @hidden */
  1123. export interface IShaderProcessor {
  1124. attributeProcessor?: (attribute: string) => string;
  1125. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1126. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1127. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1128. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1129. lineProcessor?: (line: string, isFragment: boolean) => string;
  1130. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1131. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1132. }
  1133. }
  1134. declare module BABYLON {
  1135. /** @hidden */
  1136. export interface ProcessingOptions {
  1137. defines: string[];
  1138. indexParameters: any;
  1139. isFragment: boolean;
  1140. shouldUseHighPrecisionShader: boolean;
  1141. supportsUniformBuffers: boolean;
  1142. shadersRepository: string;
  1143. includesShadersStore: {
  1144. [key: string]: string;
  1145. };
  1146. processor?: IShaderProcessor;
  1147. version: string;
  1148. platformName: string;
  1149. lookForClosingBracketForUniformBuffer?: boolean;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /** @hidden */
  1154. export class ShaderCodeNode {
  1155. line: string;
  1156. children: ShaderCodeNode[];
  1157. additionalDefineKey?: string;
  1158. additionalDefineValue?: string;
  1159. isValid(preprocessors: {
  1160. [key: string]: string;
  1161. }): boolean;
  1162. process(preprocessors: {
  1163. [key: string]: string;
  1164. }, options: ProcessingOptions): string;
  1165. }
  1166. }
  1167. declare module BABYLON {
  1168. /** @hidden */
  1169. export class ShaderCodeCursor {
  1170. private _lines;
  1171. lineIndex: number;
  1172. get currentLine(): string;
  1173. get canRead(): boolean;
  1174. set lines(value: string[]);
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1180. process(preprocessors: {
  1181. [key: string]: string;
  1182. }, options: ProcessingOptions): string;
  1183. }
  1184. }
  1185. declare module BABYLON {
  1186. /** @hidden */
  1187. export class ShaderDefineExpression {
  1188. isTrue(preprocessors: {
  1189. [key: string]: string;
  1190. }): boolean;
  1191. private static _OperatorPriority;
  1192. private static _Stack;
  1193. static postfixToInfix(postfix: string[]): string;
  1194. static infixToPostfix(infix: string): string[];
  1195. }
  1196. }
  1197. declare module BABYLON {
  1198. /** @hidden */
  1199. export class ShaderCodeTestNode extends ShaderCodeNode {
  1200. testExpression: ShaderDefineExpression;
  1201. isValid(preprocessors: {
  1202. [key: string]: string;
  1203. }): boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1209. define: string;
  1210. not: boolean;
  1211. constructor(define: string, not?: boolean);
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module BABYLON {
  1218. /** @hidden */
  1219. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1220. leftOperand: ShaderDefineExpression;
  1221. rightOperand: ShaderDefineExpression;
  1222. isTrue(preprocessors: {
  1223. [key: string]: string;
  1224. }): boolean;
  1225. }
  1226. }
  1227. declare module BABYLON {
  1228. /** @hidden */
  1229. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1230. leftOperand: ShaderDefineExpression;
  1231. rightOperand: ShaderDefineExpression;
  1232. isTrue(preprocessors: {
  1233. [key: string]: string;
  1234. }): boolean;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /** @hidden */
  1239. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1240. define: string;
  1241. operand: string;
  1242. testValue: string;
  1243. constructor(define: string, operand: string, testValue: string);
  1244. isTrue(preprocessors: {
  1245. [key: string]: string;
  1246. }): boolean;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to enable access to offline support
  1252. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1253. */
  1254. export interface IOfflineProvider {
  1255. /**
  1256. * Gets a boolean indicating if scene must be saved in the database
  1257. */
  1258. enableSceneOffline: boolean;
  1259. /**
  1260. * Gets a boolean indicating if textures must be saved in the database
  1261. */
  1262. enableTexturesOffline: boolean;
  1263. /**
  1264. * Open the offline support and make it available
  1265. * @param successCallback defines the callback to call on success
  1266. * @param errorCallback defines the callback to call on error
  1267. */
  1268. open(successCallback: () => void, errorCallback: () => void): void;
  1269. /**
  1270. * Loads an image from the offline support
  1271. * @param url defines the url to load from
  1272. * @param image defines the target DOM image
  1273. */
  1274. loadImage(url: string, image: HTMLImageElement): void;
  1275. /**
  1276. * Loads a file from offline support
  1277. * @param url defines the URL to load from
  1278. * @param sceneLoaded defines a callback to call on success
  1279. * @param progressCallBack defines a callback to call when progress changed
  1280. * @param errorCallback defines a callback to call on error
  1281. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1282. */
  1283. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1284. }
  1285. }
  1286. declare module BABYLON {
  1287. /**
  1288. * Class used to help managing file picking and drag'n'drop
  1289. * File Storage
  1290. */
  1291. export class FilesInputStore {
  1292. /**
  1293. * List of files ready to be loaded
  1294. */
  1295. static FilesToLoad: {
  1296. [key: string]: File;
  1297. };
  1298. }
  1299. }
  1300. declare module BABYLON {
  1301. /**
  1302. * Class used to define a retry strategy when error happens while loading assets
  1303. */
  1304. export class RetryStrategy {
  1305. /**
  1306. * Function used to defines an exponential back off strategy
  1307. * @param maxRetries defines the maximum number of retries (3 by default)
  1308. * @param baseInterval defines the interval between retries
  1309. * @returns the strategy function to use
  1310. */
  1311. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1312. }
  1313. }
  1314. declare module BABYLON {
  1315. /**
  1316. * @ignore
  1317. * Application error to support additional information when loading a file
  1318. */
  1319. export abstract class BaseError extends Error {
  1320. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1321. }
  1322. }
  1323. declare module BABYLON {
  1324. /** @ignore */
  1325. export class LoadFileError extends BaseError {
  1326. request?: WebRequest;
  1327. file?: File;
  1328. /**
  1329. * Creates a new LoadFileError
  1330. * @param message defines the message of the error
  1331. * @param request defines the optional web request
  1332. * @param file defines the optional file
  1333. */
  1334. constructor(message: string, object?: WebRequest | File);
  1335. }
  1336. /** @ignore */
  1337. export class RequestFileError extends BaseError {
  1338. request: WebRequest;
  1339. /**
  1340. * Creates a new LoadFileError
  1341. * @param message defines the message of the error
  1342. * @param request defines the optional web request
  1343. */
  1344. constructor(message: string, request: WebRequest);
  1345. }
  1346. /** @ignore */
  1347. export class ReadFileError extends BaseError {
  1348. file: File;
  1349. /**
  1350. * Creates a new ReadFileError
  1351. * @param message defines the message of the error
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, file: File);
  1355. }
  1356. /**
  1357. * @hidden
  1358. */
  1359. export class FileTools {
  1360. /**
  1361. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1362. */
  1363. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1364. /**
  1365. * Gets or sets the base URL to use to load assets
  1366. */
  1367. static BaseUrl: string;
  1368. /**
  1369. * Default behaviour for cors in the application.
  1370. * It can be a string if the expected behavior is identical in the entire app.
  1371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1372. */
  1373. static CorsBehavior: string | ((url: string | string[]) => string);
  1374. /**
  1375. * Gets or sets a function used to pre-process url before using them to load assets
  1376. */
  1377. static PreprocessUrl: (url: string) => string;
  1378. /**
  1379. * Removes unwanted characters from an url
  1380. * @param url defines the url to clean
  1381. * @returns the cleaned url
  1382. */
  1383. private static _CleanUrl;
  1384. /**
  1385. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1386. * @param url define the url we are trying
  1387. * @param element define the dom element where to configure the cors policy
  1388. */
  1389. static SetCorsBehavior(url: string | string[], element: {
  1390. crossOrigin: string | null;
  1391. }): void;
  1392. /**
  1393. * Loads an image as an HTMLImageElement.
  1394. * @param input url string, ArrayBuffer, or Blob to load
  1395. * @param onLoad callback called when the image successfully loads
  1396. * @param onError callback called when the image fails to load
  1397. * @param offlineProvider offline provider for caching
  1398. * @param mimeType optional mime type
  1399. * @returns the HTMLImageElement of the loaded image
  1400. */
  1401. 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>;
  1402. /**
  1403. * Reads a file from a File object
  1404. * @param file defines the file to load
  1405. * @param onSuccess defines the callback to call when data is loaded
  1406. * @param onProgress defines the callback to call during loading process
  1407. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1408. * @param onError defines the callback to call when an error occurs
  1409. * @returns a file request object
  1410. */
  1411. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1412. /**
  1413. * Loads a file from a url
  1414. * @param url url to load
  1415. * @param onSuccess callback called when the file successfully loads
  1416. * @param onProgress callback called while file is loading (if the server supports this mode)
  1417. * @param offlineProvider defines the offline provider for caching
  1418. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1419. * @param onError callback called when the file fails to load
  1420. * @returns a file request object
  1421. */
  1422. 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;
  1423. /**
  1424. * Loads a file
  1425. * @param url url to load
  1426. * @param onSuccess callback called when the file successfully loads
  1427. * @param onProgress callback called while file is loading (if the server supports this mode)
  1428. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1429. * @param onError callback called when the file fails to load
  1430. * @param onOpened callback called when the web request is opened
  1431. * @returns a file request object
  1432. */
  1433. 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;
  1434. /**
  1435. * Checks if the loaded document was accessed via `file:`-Protocol.
  1436. * @returns boolean
  1437. */
  1438. static IsFileURL(): boolean;
  1439. }
  1440. }
  1441. declare module BABYLON {
  1442. /** @hidden */
  1443. export class ShaderProcessor {
  1444. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1445. private static _ProcessPrecision;
  1446. private static _ExtractOperation;
  1447. private static _BuildSubExpression;
  1448. private static _BuildExpression;
  1449. private static _MoveCursorWithinIf;
  1450. private static _MoveCursor;
  1451. private static _EvaluatePreProcessors;
  1452. private static _PreparePreProcessors;
  1453. private static _ProcessShaderConversion;
  1454. private static _ProcessIncludes;
  1455. /**
  1456. * Loads a file from a url
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param offlineProvider defines the offline provider for caching
  1461. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1462. * @param onError callback called when the file fails to load
  1463. * @returns a file request object
  1464. * @hidden
  1465. */
  1466. 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;
  1467. }
  1468. }
  1469. declare module BABYLON {
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IColor4Like {
  1474. r: float;
  1475. g: float;
  1476. b: float;
  1477. a: float;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IColor3Like {
  1483. r: float;
  1484. g: float;
  1485. b: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IVector4Like {
  1491. x: float;
  1492. y: float;
  1493. z: float;
  1494. w: float;
  1495. }
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IVector3Like {
  1500. x: float;
  1501. y: float;
  1502. z: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector2Like {
  1508. x: float;
  1509. y: float;
  1510. }
  1511. /**
  1512. * @hidden
  1513. */
  1514. export interface IMatrixLike {
  1515. toArray(): DeepImmutable<Float32Array>;
  1516. updateFlag: int;
  1517. }
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IViewportLike {
  1522. x: float;
  1523. y: float;
  1524. width: float;
  1525. height: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IPlaneLike {
  1531. normal: IVector3Like;
  1532. d: float;
  1533. normalize(): void;
  1534. }
  1535. }
  1536. declare module BABYLON {
  1537. /**
  1538. * Interface used to define common properties for effect fallbacks
  1539. */
  1540. export interface IEffectFallbacks {
  1541. /**
  1542. * Removes the defines that should be removed when falling back.
  1543. * @param currentDefines defines the current define statements for the shader.
  1544. * @param effect defines the current effect we try to compile
  1545. * @returns The resulting defines with defines of the current rank removed.
  1546. */
  1547. reduce(currentDefines: string, effect: Effect): string;
  1548. /**
  1549. * Removes the fallback from the bound mesh.
  1550. */
  1551. unBindMesh(): void;
  1552. /**
  1553. * Checks to see if more fallbacks are still availible.
  1554. */
  1555. hasMoreFallbacks: boolean;
  1556. }
  1557. }
  1558. declare module BABYLON {
  1559. /**
  1560. * Class used to evalaute queries containing `and` and `or` operators
  1561. */
  1562. export class AndOrNotEvaluator {
  1563. /**
  1564. * Evaluate a query
  1565. * @param query defines the query to evaluate
  1566. * @param evaluateCallback defines the callback used to filter result
  1567. * @returns true if the query matches
  1568. */
  1569. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1570. private static _HandleParenthesisContent;
  1571. private static _SimplifyNegation;
  1572. }
  1573. }
  1574. declare module BABYLON {
  1575. /**
  1576. * Class used to store custom tags
  1577. */
  1578. export class Tags {
  1579. /**
  1580. * Adds support for tags on the given object
  1581. * @param obj defines the object to use
  1582. */
  1583. static EnableFor(obj: any): void;
  1584. /**
  1585. * Removes tags support
  1586. * @param obj defines the object to use
  1587. */
  1588. static DisableFor(obj: any): void;
  1589. /**
  1590. * Gets a boolean indicating if the given object has tags
  1591. * @param obj defines the object to use
  1592. * @returns a boolean
  1593. */
  1594. static HasTags(obj: any): boolean;
  1595. /**
  1596. * Gets the tags available on a given object
  1597. * @param obj defines the object to use
  1598. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1599. * @returns the tags
  1600. */
  1601. static GetTags(obj: any, asString?: boolean): any;
  1602. /**
  1603. * Adds tags to an object
  1604. * @param obj defines the object to use
  1605. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1606. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1607. */
  1608. static AddTagsTo(obj: any, tagsString: string): void;
  1609. /**
  1610. * @hidden
  1611. */
  1612. static _AddTagTo(obj: any, tag: string): void;
  1613. /**
  1614. * Removes specific tags from a specific object
  1615. * @param obj defines the object to use
  1616. * @param tagsString defines the tags to remove
  1617. */
  1618. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1619. /**
  1620. * @hidden
  1621. */
  1622. static _RemoveTagFrom(obj: any, tag: string): void;
  1623. /**
  1624. * Defines if tags hosted on an object match a given query
  1625. * @param obj defines the object to use
  1626. * @param tagsQuery defines the tag query
  1627. * @returns a boolean
  1628. */
  1629. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1630. }
  1631. }
  1632. declare module BABYLON {
  1633. /**
  1634. * Scalar computation library
  1635. */
  1636. export class Scalar {
  1637. /**
  1638. * Two pi constants convenient for computation.
  1639. */
  1640. static TwoPi: number;
  1641. /**
  1642. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1643. * @param a number
  1644. * @param b number
  1645. * @param epsilon (default = 1.401298E-45)
  1646. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1647. */
  1648. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1649. /**
  1650. * Returns a string : the upper case translation of the number i to hexadecimal.
  1651. * @param i number
  1652. * @returns the upper case translation of the number i to hexadecimal.
  1653. */
  1654. static ToHex(i: number): string;
  1655. /**
  1656. * Returns -1 if value is negative and +1 is value is positive.
  1657. * @param value the value
  1658. * @returns the value itself if it's equal to zero.
  1659. */
  1660. static Sign(value: number): number;
  1661. /**
  1662. * Returns the value itself if it's between min and max.
  1663. * Returns min if the value is lower than min.
  1664. * Returns max if the value is greater than max.
  1665. * @param value the value to clmap
  1666. * @param min the min value to clamp to (default: 0)
  1667. * @param max the max value to clamp to (default: 1)
  1668. * @returns the clamped value
  1669. */
  1670. static Clamp(value: number, min?: number, max?: number): number;
  1671. /**
  1672. * the log2 of value.
  1673. * @param value the value to compute log2 of
  1674. * @returns the log2 of value.
  1675. */
  1676. static Log2(value: number): number;
  1677. /**
  1678. * Loops the value, so that it is never larger than length and never smaller than 0.
  1679. *
  1680. * This is similar to the modulo operator but it works with floating point numbers.
  1681. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1682. * With t = 5 and length = 2.5, the result would be 0.0.
  1683. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1684. * @param value the value
  1685. * @param length the length
  1686. * @returns the looped value
  1687. */
  1688. static Repeat(value: number, length: number): number;
  1689. /**
  1690. * Normalize the value between 0.0 and 1.0 using min and max values
  1691. * @param value value to normalize
  1692. * @param min max to normalize between
  1693. * @param max min to normalize between
  1694. * @returns the normalized value
  1695. */
  1696. static Normalize(value: number, min: number, max: number): number;
  1697. /**
  1698. * Denormalize the value from 0.0 and 1.0 using min and max values
  1699. * @param normalized value to denormalize
  1700. * @param min max to denormalize between
  1701. * @param max min to denormalize between
  1702. * @returns the denormalized value
  1703. */
  1704. static Denormalize(normalized: number, min: number, max: number): number;
  1705. /**
  1706. * Calculates the shortest difference between two given angles given in degrees.
  1707. * @param current current angle in degrees
  1708. * @param target target angle in degrees
  1709. * @returns the delta
  1710. */
  1711. static DeltaAngle(current: number, target: number): number;
  1712. /**
  1713. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1714. * @param tx value
  1715. * @param length length
  1716. * @returns The returned value will move back and forth between 0 and length
  1717. */
  1718. static PingPong(tx: number, length: number): number;
  1719. /**
  1720. * Interpolates between min and max with smoothing at the limits.
  1721. *
  1722. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1723. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1724. * @param from from
  1725. * @param to to
  1726. * @param tx value
  1727. * @returns the smooth stepped value
  1728. */
  1729. static SmoothStep(from: number, to: number, tx: number): number;
  1730. /**
  1731. * Moves a value current towards target.
  1732. *
  1733. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1734. * Negative values of maxDelta pushes the value away from target.
  1735. * @param current current value
  1736. * @param target target value
  1737. * @param maxDelta max distance to move
  1738. * @returns resulting value
  1739. */
  1740. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1741. /**
  1742. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1743. *
  1744. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1745. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1746. * @param current current value
  1747. * @param target target value
  1748. * @param maxDelta max distance to move
  1749. * @returns resulting angle
  1750. */
  1751. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1752. /**
  1753. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  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 Lerp(start: number, end: number, amount: number): number;
  1760. /**
  1761. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1762. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static LerpAngle(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1771. * @param a start value
  1772. * @param b target value
  1773. * @param value value between a and b
  1774. * @returns the inverseLerp value
  1775. */
  1776. static InverseLerp(a: number, b: number, value: number): number;
  1777. /**
  1778. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1779. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1780. * @param value1 spline value
  1781. * @param tangent1 spline value
  1782. * @param value2 spline value
  1783. * @param tangent2 spline value
  1784. * @param amount input value
  1785. * @returns hermite result
  1786. */
  1787. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1788. /**
  1789. * Returns a random float number between and min and max values
  1790. * @param min min value of random
  1791. * @param max max value of random
  1792. * @returns random value
  1793. */
  1794. static RandomRange(min: number, max: number): number;
  1795. /**
  1796. * This function returns percentage of a number in a given range.
  1797. *
  1798. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1799. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1800. * @param number to convert to percentage
  1801. * @param min min range
  1802. * @param max max range
  1803. * @returns the percentage
  1804. */
  1805. static RangeToPercent(number: number, min: number, max: number): number;
  1806. /**
  1807. * This function returns number that corresponds to the percentage in a given range.
  1808. *
  1809. * PercentToRange(0.34,0,100) will return 34.
  1810. * @param percent to convert to number
  1811. * @param min min range
  1812. * @param max max range
  1813. * @returns the number
  1814. */
  1815. static PercentToRange(percent: number, min: number, max: number): number;
  1816. /**
  1817. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1818. * @param angle The angle to normalize in radian.
  1819. * @return The converted angle.
  1820. */
  1821. static NormalizeRadians(angle: number): number;
  1822. }
  1823. }
  1824. declare module BABYLON {
  1825. /**
  1826. * Constant used to convert a value to gamma space
  1827. * @ignorenaming
  1828. */
  1829. export const ToGammaSpace: number;
  1830. /**
  1831. * Constant used to convert a value to linear space
  1832. * @ignorenaming
  1833. */
  1834. export const ToLinearSpace = 2.2;
  1835. /**
  1836. * Constant used to define the minimal number value in Babylon.js
  1837. * @ignorenaming
  1838. */
  1839. let Epsilon: number;
  1840. }
  1841. declare module BABYLON {
  1842. /**
  1843. * Class used to represent a viewport on screen
  1844. */
  1845. export class Viewport {
  1846. /** viewport left coordinate */
  1847. x: number;
  1848. /** viewport top coordinate */
  1849. y: number;
  1850. /**viewport width */
  1851. width: number;
  1852. /** viewport height */
  1853. height: number;
  1854. /**
  1855. * Creates a Viewport object located at (x, y) and sized (width, height)
  1856. * @param x defines viewport left coordinate
  1857. * @param y defines viewport top coordinate
  1858. * @param width defines the viewport width
  1859. * @param height defines the viewport height
  1860. */
  1861. constructor(
  1862. /** viewport left coordinate */
  1863. x: number,
  1864. /** viewport top coordinate */
  1865. y: number,
  1866. /**viewport width */
  1867. width: number,
  1868. /** viewport height */
  1869. height: number);
  1870. /**
  1871. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1872. * @param renderWidth defines the rendering width
  1873. * @param renderHeight defines the rendering height
  1874. * @returns a new Viewport
  1875. */
  1876. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1877. /**
  1878. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1879. * @param renderWidth defines the rendering width
  1880. * @param renderHeight defines the rendering height
  1881. * @param ref defines the target viewport
  1882. * @returns the current viewport
  1883. */
  1884. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1885. /**
  1886. * Returns a new Viewport copied from the current one
  1887. * @returns a new Viewport
  1888. */
  1889. clone(): Viewport;
  1890. }
  1891. }
  1892. declare module BABYLON {
  1893. /**
  1894. * Class containing a set of static utilities functions for arrays.
  1895. */
  1896. export class ArrayTools {
  1897. /**
  1898. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1899. * @param size the number of element to construct and put in the array
  1900. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1901. * @returns a new array filled with new objects
  1902. */
  1903. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1904. }
  1905. }
  1906. declare module BABYLON {
  1907. /**
  1908. * Represens a plane by the equation ax + by + cz + d = 0
  1909. */
  1910. export class Plane {
  1911. private static _TmpMatrix;
  1912. /**
  1913. * Normal of the plane (a,b,c)
  1914. */
  1915. normal: Vector3;
  1916. /**
  1917. * d component of the plane
  1918. */
  1919. d: number;
  1920. /**
  1921. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1922. * @param a a component of the plane
  1923. * @param b b component of the plane
  1924. * @param c c component of the plane
  1925. * @param d d component of the plane
  1926. */
  1927. constructor(a: number, b: number, c: number, d: number);
  1928. /**
  1929. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1930. */
  1931. asArray(): number[];
  1932. /**
  1933. * @returns a new plane copied from the current Plane.
  1934. */
  1935. clone(): Plane;
  1936. /**
  1937. * @returns the string "Plane".
  1938. */
  1939. getClassName(): string;
  1940. /**
  1941. * @returns the Plane hash code.
  1942. */
  1943. getHashCode(): number;
  1944. /**
  1945. * Normalize the current Plane in place.
  1946. * @returns the updated Plane.
  1947. */
  1948. normalize(): Plane;
  1949. /**
  1950. * Applies a transformation the plane and returns the result
  1951. * @param transformation the transformation matrix to be applied to the plane
  1952. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1953. */
  1954. transform(transformation: DeepImmutable<Matrix>): Plane;
  1955. /**
  1956. * Compute the dot product between the point and the plane normal
  1957. * @param point point to calculate the dot product with
  1958. * @returns the dot product (float) of the point coordinates and the plane normal.
  1959. */
  1960. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1961. /**
  1962. * Updates the current Plane from the plane defined by the three given points.
  1963. * @param point1 one of the points used to contruct the plane
  1964. * @param point2 one of the points used to contruct the plane
  1965. * @param point3 one of the points used to contruct the plane
  1966. * @returns the updated Plane.
  1967. */
  1968. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1969. /**
  1970. * Checks if the plane is facing a given direction
  1971. * @param direction the direction to check if the plane is facing
  1972. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1973. * @returns True is the vector "direction" is the same side than the plane normal.
  1974. */
  1975. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  1976. /**
  1977. * Calculates the distance to a point
  1978. * @param point point to calculate distance to
  1979. * @returns the signed distance (float) from the given point to the Plane.
  1980. */
  1981. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  1982. /**
  1983. * Creates a plane from an array
  1984. * @param array the array to create a plane from
  1985. * @returns a new Plane from the given array.
  1986. */
  1987. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  1988. /**
  1989. * Creates a plane from three points
  1990. * @param point1 point used to create the plane
  1991. * @param point2 point used to create the plane
  1992. * @param point3 point used to create the plane
  1993. * @returns a new Plane defined by the three given points.
  1994. */
  1995. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1996. /**
  1997. * Creates a plane from an origin point and a normal
  1998. * @param origin origin of the plane to be constructed
  1999. * @param normal normal of the plane to be constructed
  2000. * @returns a new Plane the normal vector to this plane at the given origin point.
  2001. * Note : the vector "normal" is updated because normalized.
  2002. */
  2003. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  2004. /**
  2005. * Calculates the distance from a plane and a point
  2006. * @param origin origin of the plane to be constructed
  2007. * @param normal normal of the plane to be constructed
  2008. * @param point point to calculate distance to
  2009. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2010. */
  2011. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2012. }
  2013. }
  2014. declare module BABYLON {
  2015. /**
  2016. * Class representing a vector containing 2 coordinates
  2017. */
  2018. export class Vector2 {
  2019. /** defines the first coordinate */
  2020. x: number;
  2021. /** defines the second coordinate */
  2022. y: number;
  2023. /**
  2024. * Creates a new Vector2 from the given x and y coordinates
  2025. * @param x defines the first coordinate
  2026. * @param y defines the second coordinate
  2027. */
  2028. constructor(
  2029. /** defines the first coordinate */
  2030. x?: number,
  2031. /** defines the second coordinate */
  2032. y?: number);
  2033. /**
  2034. * Gets a string with the Vector2 coordinates
  2035. * @returns a string with the Vector2 coordinates
  2036. */
  2037. toString(): string;
  2038. /**
  2039. * Gets class name
  2040. * @returns the string "Vector2"
  2041. */
  2042. getClassName(): string;
  2043. /**
  2044. * Gets current vector hash code
  2045. * @returns the Vector2 hash code as a number
  2046. */
  2047. getHashCode(): number;
  2048. /**
  2049. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2050. * @param array defines the source array
  2051. * @param index defines the offset in source array
  2052. * @returns the current Vector2
  2053. */
  2054. toArray(array: FloatArray, index?: number): Vector2;
  2055. /**
  2056. * Copy the current vector to an array
  2057. * @returns a new array with 2 elements: the Vector2 coordinates.
  2058. */
  2059. asArray(): number[];
  2060. /**
  2061. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2062. * @param source defines the source Vector2
  2063. * @returns the current updated Vector2
  2064. */
  2065. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2066. /**
  2067. * Sets the Vector2 coordinates with the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns the current updated Vector2
  2071. */
  2072. copyFromFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Sets the Vector2 coordinates with the given floats
  2075. * @param x defines the first coordinate
  2076. * @param y defines the second coordinate
  2077. * @returns the current updated Vector2
  2078. */
  2079. set(x: number, y: number): Vector2;
  2080. /**
  2081. * Add another vector with the current one
  2082. * @param otherVector defines the other vector
  2083. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2084. */
  2085. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2086. /**
  2087. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2088. * @param otherVector defines the other vector
  2089. * @param result defines the target vector
  2090. * @returns the unmodified current Vector2
  2091. */
  2092. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2093. /**
  2094. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2095. * @param otherVector defines the other vector
  2096. * @returns the current updated Vector2
  2097. */
  2098. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2099. /**
  2100. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2101. * @param otherVector defines the other vector
  2102. * @returns a new Vector2
  2103. */
  2104. addVector3(otherVector: Vector3): Vector2;
  2105. /**
  2106. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2107. * @param otherVector defines the other vector
  2108. * @returns a new Vector2
  2109. */
  2110. subtract(otherVector: Vector2): Vector2;
  2111. /**
  2112. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2113. * @param otherVector defines the other vector
  2114. * @param result defines the target vector
  2115. * @returns the unmodified current Vector2
  2116. */
  2117. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2118. /**
  2119. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2120. * @param otherVector defines the other vector
  2121. * @returns the current updated Vector2
  2122. */
  2123. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2124. /**
  2125. * Multiplies in place the current Vector2 coordinates by the given ones
  2126. * @param otherVector defines the other vector
  2127. * @returns the current updated Vector2
  2128. */
  2129. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2130. /**
  2131. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2132. * @param otherVector defines the other vector
  2133. * @returns a new Vector2
  2134. */
  2135. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2136. /**
  2137. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2138. * @param otherVector defines the other vector
  2139. * @param result defines the target vector
  2140. * @returns the unmodified current Vector2
  2141. */
  2142. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2143. /**
  2144. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2145. * @param x defines the first coordinate
  2146. * @param y defines the second coordinate
  2147. * @returns a new Vector2
  2148. */
  2149. multiplyByFloats(x: number, y: number): Vector2;
  2150. /**
  2151. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2
  2154. */
  2155. divide(otherVector: Vector2): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Divides the current Vector2 coordinates by the given ones
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Gets a new Vector2 with current Vector2 negated coordinates
  2171. * @returns a new Vector2
  2172. */
  2173. negate(): Vector2;
  2174. /**
  2175. * Negate this vector in place
  2176. * @returns this
  2177. */
  2178. negateInPlace(): Vector2;
  2179. /**
  2180. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2181. * @param result defines the Vector3 object where to store the result
  2182. * @returns the current Vector2
  2183. */
  2184. negateToRef(result: Vector2): Vector2;
  2185. /**
  2186. * Multiply the Vector2 coordinates by scale
  2187. * @param scale defines the scaling factor
  2188. * @returns the current updated Vector2
  2189. */
  2190. scaleInPlace(scale: number): Vector2;
  2191. /**
  2192. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2193. * @param scale defines the scaling factor
  2194. * @returns a new Vector2
  2195. */
  2196. scale(scale: number): Vector2;
  2197. /**
  2198. * Scale the current Vector2 values by a factor to a given Vector2
  2199. * @param scale defines the scale factor
  2200. * @param result defines the Vector2 object where to store the result
  2201. * @returns the unmodified current Vector2
  2202. */
  2203. scaleToRef(scale: number, result: Vector2): Vector2;
  2204. /**
  2205. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2206. * @param scale defines the scale factor
  2207. * @param result defines the Vector2 object where to store the result
  2208. * @returns the unmodified current Vector2
  2209. */
  2210. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2211. /**
  2212. * Gets a boolean if two vectors are equals
  2213. * @param otherVector defines the other vector
  2214. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2215. */
  2216. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2217. /**
  2218. * Gets a boolean if two vectors are equals (using an epsilon value)
  2219. * @param otherVector defines the other vector
  2220. * @param epsilon defines the minimal distance to consider equality
  2221. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2222. */
  2223. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2224. /**
  2225. * Gets a new Vector2 from current Vector2 floored values
  2226. * @returns a new Vector2
  2227. */
  2228. floor(): Vector2;
  2229. /**
  2230. * Gets a new Vector2 from current Vector2 floored values
  2231. * @returns a new Vector2
  2232. */
  2233. fract(): Vector2;
  2234. /**
  2235. * Gets the length of the vector
  2236. * @returns the vector length (float)
  2237. */
  2238. length(): number;
  2239. /**
  2240. * Gets the vector squared length
  2241. * @returns the vector squared length (float)
  2242. */
  2243. lengthSquared(): number;
  2244. /**
  2245. * Normalize the vector
  2246. * @returns the current updated Vector2
  2247. */
  2248. normalize(): Vector2;
  2249. /**
  2250. * Gets a new Vector2 copied from the Vector2
  2251. * @returns a new Vector2
  2252. */
  2253. clone(): Vector2;
  2254. /**
  2255. * Gets a new Vector2(0, 0)
  2256. * @returns a new Vector2
  2257. */
  2258. static Zero(): Vector2;
  2259. /**
  2260. * Gets a new Vector2(1, 1)
  2261. * @returns a new Vector2
  2262. */
  2263. static One(): Vector2;
  2264. /**
  2265. * Gets a new Vector2 set from the given index element of the given array
  2266. * @param array defines the data source
  2267. * @param offset defines the offset in the data source
  2268. * @returns a new Vector2
  2269. */
  2270. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2271. /**
  2272. * Sets "result" from the given index element of the given array
  2273. * @param array defines the data source
  2274. * @param offset defines the offset in the data source
  2275. * @param result defines the target vector
  2276. */
  2277. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2278. /**
  2279. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2280. * @param value1 defines 1st point of control
  2281. * @param value2 defines 2nd point of control
  2282. * @param value3 defines 3rd point of control
  2283. * @param value4 defines 4th point of control
  2284. * @param amount defines the interpolation factor
  2285. * @returns a new Vector2
  2286. */
  2287. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2288. /**
  2289. * 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".
  2290. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2291. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2292. * @param value defines the value to clamp
  2293. * @param min defines the lower limit
  2294. * @param max defines the upper limit
  2295. * @returns a new Vector2
  2296. */
  2297. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2298. /**
  2299. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2300. * @param value1 defines the 1st control point
  2301. * @param tangent1 defines the outgoing tangent
  2302. * @param value2 defines the 2nd control point
  2303. * @param tangent2 defines the incoming tangent
  2304. * @param amount defines the interpolation factor
  2305. * @returns a new Vector2
  2306. */
  2307. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2308. /**
  2309. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2310. * @param start defines the start vector
  2311. * @param end defines the end vector
  2312. * @param amount defines the interpolation factor
  2313. * @returns a new Vector2
  2314. */
  2315. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2316. /**
  2317. * Gets the dot product of the vector "left" and the vector "right"
  2318. * @param left defines first vector
  2319. * @param right defines second vector
  2320. * @returns the dot product (float)
  2321. */
  2322. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2323. /**
  2324. * Returns a new Vector2 equal to the normalized given vector
  2325. * @param vector defines the vector to normalize
  2326. * @returns a new Vector2
  2327. */
  2328. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2329. /**
  2330. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2331. * @param left defines 1st vector
  2332. * @param right defines 2nd vector
  2333. * @returns a new Vector2
  2334. */
  2335. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2336. /**
  2337. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2338. * @param left defines 1st vector
  2339. * @param right defines 2nd vector
  2340. * @returns a new Vector2
  2341. */
  2342. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2343. /**
  2344. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2345. * @param vector defines the vector to transform
  2346. * @param transformation defines the matrix to apply
  2347. * @returns a new Vector2
  2348. */
  2349. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2350. /**
  2351. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2352. * @param vector defines the vector to transform
  2353. * @param transformation defines the matrix to apply
  2354. * @param result defines the target vector
  2355. */
  2356. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2357. /**
  2358. * Determines if a given vector is included in a triangle
  2359. * @param p defines the vector to test
  2360. * @param p0 defines 1st triangle point
  2361. * @param p1 defines 2nd triangle point
  2362. * @param p2 defines 3rd triangle point
  2363. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2364. */
  2365. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2366. /**
  2367. * Gets the distance between the vectors "value1" and "value2"
  2368. * @param value1 defines first vector
  2369. * @param value2 defines second vector
  2370. * @returns the distance between vectors
  2371. */
  2372. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2373. /**
  2374. * Returns the squared distance between the vectors "value1" and "value2"
  2375. * @param value1 defines first vector
  2376. * @param value2 defines second vector
  2377. * @returns the squared distance between vectors
  2378. */
  2379. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2380. /**
  2381. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2382. * @param value1 defines first vector
  2383. * @param value2 defines second vector
  2384. * @returns a new Vector2
  2385. */
  2386. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2387. /**
  2388. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2389. * @param p defines the middle point
  2390. * @param segA defines one point of the segment
  2391. * @param segB defines the other point of the segment
  2392. * @returns the shortest distance
  2393. */
  2394. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2395. }
  2396. /**
  2397. * Class used to store (x,y,z) vector representation
  2398. * A Vector3 is the main object used in 3D geometry
  2399. * It can represent etiher the coordinates of a point the space, either a direction
  2400. * Reminder: js uses a left handed forward facing system
  2401. */
  2402. export class Vector3 {
  2403. /**
  2404. * Defines the first coordinates (on X axis)
  2405. */
  2406. x: number;
  2407. /**
  2408. * Defines the second coordinates (on Y axis)
  2409. */
  2410. y: number;
  2411. /**
  2412. * Defines the third coordinates (on Z axis)
  2413. */
  2414. z: number;
  2415. private static _UpReadOnly;
  2416. private static _ZeroReadOnly;
  2417. /**
  2418. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2419. * @param x defines the first coordinates (on X axis)
  2420. * @param y defines the second coordinates (on Y axis)
  2421. * @param z defines the third coordinates (on Z axis)
  2422. */
  2423. constructor(
  2424. /**
  2425. * Defines the first coordinates (on X axis)
  2426. */
  2427. x?: number,
  2428. /**
  2429. * Defines the second coordinates (on Y axis)
  2430. */
  2431. y?: number,
  2432. /**
  2433. * Defines the third coordinates (on Z axis)
  2434. */
  2435. z?: number);
  2436. /**
  2437. * Creates a string representation of the Vector3
  2438. * @returns a string with the Vector3 coordinates.
  2439. */
  2440. toString(): string;
  2441. /**
  2442. * Gets the class name
  2443. * @returns the string "Vector3"
  2444. */
  2445. getClassName(): string;
  2446. /**
  2447. * Creates the Vector3 hash code
  2448. * @returns a number which tends to be unique between Vector3 instances
  2449. */
  2450. getHashCode(): number;
  2451. /**
  2452. * Creates an array containing three elements : the coordinates of the Vector3
  2453. * @returns a new array of numbers
  2454. */
  2455. asArray(): number[];
  2456. /**
  2457. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2458. * @param array defines the destination array
  2459. * @param index defines the offset in the destination array
  2460. * @returns the current Vector3
  2461. */
  2462. toArray(array: FloatArray, index?: number): Vector3;
  2463. /**
  2464. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2465. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2466. */
  2467. toQuaternion(): Quaternion;
  2468. /**
  2469. * Adds the given vector to the current Vector3
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2474. /**
  2475. * Adds the given coordinates to the current Vector3
  2476. * @param x defines the x coordinate of the operand
  2477. * @param y defines the y coordinate of the operand
  2478. * @param z defines the z coordinate of the operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2482. /**
  2483. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2484. * @param otherVector defines the second operand
  2485. * @returns the resulting Vector3
  2486. */
  2487. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2488. /**
  2489. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2490. * @param otherVector defines the second operand
  2491. * @param result defines the Vector3 object where to store the result
  2492. * @returns the current Vector3
  2493. */
  2494. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2495. /**
  2496. * Subtract the given vector from the current Vector3
  2497. * @param otherVector defines the second operand
  2498. * @returns the current updated Vector3
  2499. */
  2500. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2501. /**
  2502. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2503. * @param otherVector defines the second operand
  2504. * @returns the resulting Vector3
  2505. */
  2506. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2507. /**
  2508. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2509. * @param otherVector defines the second operand
  2510. * @param result defines the Vector3 object where to store the result
  2511. * @returns the current Vector3
  2512. */
  2513. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2514. /**
  2515. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2516. * @param x defines the x coordinate of the operand
  2517. * @param y defines the y coordinate of the operand
  2518. * @param z defines the z coordinate of the operand
  2519. * @returns the resulting Vector3
  2520. */
  2521. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2522. /**
  2523. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2524. * @param x defines the x coordinate of the operand
  2525. * @param y defines the y coordinate of the operand
  2526. * @param z defines the z coordinate of the operand
  2527. * @param result defines the Vector3 object where to store the result
  2528. * @returns the current Vector3
  2529. */
  2530. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2531. /**
  2532. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2533. * @returns a new Vector3
  2534. */
  2535. negate(): Vector3;
  2536. /**
  2537. * Negate this vector in place
  2538. * @returns this
  2539. */
  2540. negateInPlace(): Vector3;
  2541. /**
  2542. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2543. * @param result defines the Vector3 object where to store the result
  2544. * @returns the current Vector3
  2545. */
  2546. negateToRef(result: Vector3): Vector3;
  2547. /**
  2548. * Multiplies the Vector3 coordinates by the float "scale"
  2549. * @param scale defines the multiplier factor
  2550. * @returns the current updated Vector3
  2551. */
  2552. scaleInPlace(scale: number): Vector3;
  2553. /**
  2554. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2555. * @param scale defines the multiplier factor
  2556. * @returns a new Vector3
  2557. */
  2558. scale(scale: number): Vector3;
  2559. /**
  2560. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2561. * @param scale defines the multiplier factor
  2562. * @param result defines the Vector3 object where to store the result
  2563. * @returns the current Vector3
  2564. */
  2565. scaleToRef(scale: number, result: Vector3): Vector3;
  2566. /**
  2567. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2568. * @param scale defines the scale factor
  2569. * @param result defines the Vector3 object where to store the result
  2570. * @returns the unmodified current Vector3
  2571. */
  2572. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2573. /**
  2574. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2575. * @param origin defines the origin of the projection ray
  2576. * @param plane defines the plane to project to
  2577. * @returns the projected vector3
  2578. */
  2579. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2580. /**
  2581. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2582. * @param origin defines the origin of the projection ray
  2583. * @param plane defines the plane to project to
  2584. * @param result defines the Vector3 where to store the result
  2585. */
  2586. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2587. /**
  2588. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2589. * @param otherVector defines the second operand
  2590. * @returns true if both vectors are equals
  2591. */
  2592. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2593. /**
  2594. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2595. * @param otherVector defines the second operand
  2596. * @param epsilon defines the minimal distance to define values as equals
  2597. * @returns true if both vectors are distant less than epsilon
  2598. */
  2599. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2600. /**
  2601. * Returns true if the current Vector3 coordinates equals the given floats
  2602. * @param x defines the x coordinate of the operand
  2603. * @param y defines the y coordinate of the operand
  2604. * @param z defines the z coordinate of the operand
  2605. * @returns true if both vectors are equals
  2606. */
  2607. equalsToFloats(x: number, y: number, z: number): boolean;
  2608. /**
  2609. * Multiplies the current Vector3 coordinates by the given ones
  2610. * @param otherVector defines the second operand
  2611. * @returns the current updated Vector3
  2612. */
  2613. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2614. /**
  2615. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2616. * @param otherVector defines the second operand
  2617. * @returns the new Vector3
  2618. */
  2619. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2620. /**
  2621. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2622. * @param otherVector defines the second operand
  2623. * @param result defines the Vector3 object where to store the result
  2624. * @returns the current Vector3
  2625. */
  2626. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2627. /**
  2628. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2629. * @param x defines the x coordinate of the operand
  2630. * @param y defines the y coordinate of the operand
  2631. * @param z defines the z coordinate of the operand
  2632. * @returns the new Vector3
  2633. */
  2634. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2635. /**
  2636. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2637. * @param otherVector defines the second operand
  2638. * @returns the new Vector3
  2639. */
  2640. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2643. * @param otherVector defines the second operand
  2644. * @param result defines the Vector3 object where to store the result
  2645. * @returns the current Vector3
  2646. */
  2647. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2648. /**
  2649. * Divides the current Vector3 coordinates by the given ones.
  2650. * @param otherVector defines the second operand
  2651. * @returns the current updated Vector3
  2652. */
  2653. divideInPlace(otherVector: Vector3): Vector3;
  2654. /**
  2655. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2656. * @param other defines the second operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2660. /**
  2661. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2662. * @param other defines the second operand
  2663. * @returns the current updated Vector3
  2664. */
  2665. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2666. /**
  2667. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2668. * @param x defines the x coordinate of the operand
  2669. * @param y defines the y coordinate of the operand
  2670. * @param z defines the z coordinate of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2674. /**
  2675. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the current updated Vector3
  2680. */
  2681. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2684. * Check if is non uniform within a certain amount of decimal places to account for this
  2685. * @param epsilon the amount the values can differ
  2686. * @returns if the the vector is non uniform to a certain number of decimal places
  2687. */
  2688. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2689. /**
  2690. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2691. */
  2692. get isNonUniform(): boolean;
  2693. /**
  2694. * Gets a new Vector3 from current Vector3 floored values
  2695. * @returns a new Vector3
  2696. */
  2697. floor(): Vector3;
  2698. /**
  2699. * Gets a new Vector3 from current Vector3 floored values
  2700. * @returns a new Vector3
  2701. */
  2702. fract(): Vector3;
  2703. /**
  2704. * Gets the length of the Vector3
  2705. * @returns the length of the Vector3
  2706. */
  2707. length(): number;
  2708. /**
  2709. * Gets the squared length of the Vector3
  2710. * @returns squared length of the Vector3
  2711. */
  2712. lengthSquared(): number;
  2713. /**
  2714. * Normalize the current Vector3.
  2715. * Please note that this is an in place operation.
  2716. * @returns the current updated Vector3
  2717. */
  2718. normalize(): Vector3;
  2719. /**
  2720. * Reorders the x y z properties of the vector in place
  2721. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2722. * @returns the current updated vector
  2723. */
  2724. reorderInPlace(order: string): this;
  2725. /**
  2726. * Rotates the vector around 0,0,0 by a quaternion
  2727. * @param quaternion the rotation quaternion
  2728. * @param result vector to store the result
  2729. * @returns the resulting vector
  2730. */
  2731. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2732. /**
  2733. * Rotates a vector around a given point
  2734. * @param quaternion the rotation quaternion
  2735. * @param point the point to rotate around
  2736. * @param result vector to store the result
  2737. * @returns the resulting vector
  2738. */
  2739. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2740. /**
  2741. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2742. * The cross product is then orthogonal to both current and "other"
  2743. * @param other defines the right operand
  2744. * @returns the cross product
  2745. */
  2746. cross(other: Vector3): Vector3;
  2747. /**
  2748. * Normalize the current Vector3 with the given input length.
  2749. * Please note that this is an in place operation.
  2750. * @param len the length of the vector
  2751. * @returns the current updated Vector3
  2752. */
  2753. normalizeFromLength(len: number): Vector3;
  2754. /**
  2755. * Normalize the current Vector3 to a new vector
  2756. * @returns the new Vector3
  2757. */
  2758. normalizeToNew(): Vector3;
  2759. /**
  2760. * Normalize the current Vector3 to the reference
  2761. * @param reference define the Vector3 to update
  2762. * @returns the updated Vector3
  2763. */
  2764. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2765. /**
  2766. * Creates a new Vector3 copied from the current Vector3
  2767. * @returns the new Vector3
  2768. */
  2769. clone(): Vector3;
  2770. /**
  2771. * Copies the given vector coordinates to the current Vector3 ones
  2772. * @param source defines the source Vector3
  2773. * @returns the current updated Vector3
  2774. */
  2775. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Copies the given floats to the current Vector3 coordinates
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. copyFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Copies the given floats to the current Vector3 coordinates
  2786. * @param x defines the x coordinate of the operand
  2787. * @param y defines the y coordinate of the operand
  2788. * @param z defines the z coordinate of the operand
  2789. * @returns the current updated Vector3
  2790. */
  2791. set(x: number, y: number, z: number): Vector3;
  2792. /**
  2793. * Copies the given float to the current Vector3 coordinates
  2794. * @param v defines the x, y and z coordinates of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. setAll(v: number): Vector3;
  2798. /**
  2799. * Get the clip factor between two vectors
  2800. * @param vector0 defines the first operand
  2801. * @param vector1 defines the second operand
  2802. * @param axis defines the axis to use
  2803. * @param size defines the size along the axis
  2804. * @returns the clip factor
  2805. */
  2806. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2807. /**
  2808. * Get angle between two vectors
  2809. * @param vector0 angle between vector0 and vector1
  2810. * @param vector1 angle between vector0 and vector1
  2811. * @param normal direction of the normal
  2812. * @return the angle between vector0 and vector1
  2813. */
  2814. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2815. /**
  2816. * Returns a new Vector3 set from the index "offset" of the given array
  2817. * @param array defines the source array
  2818. * @param offset defines the offset in the source array
  2819. * @returns the new Vector3
  2820. */
  2821. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2822. /**
  2823. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2824. * @param array defines the source array
  2825. * @param offset defines the offset in the source array
  2826. * @returns the new Vector3
  2827. * @deprecated Please use FromArray instead.
  2828. */
  2829. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2832. * @param array defines the source array
  2833. * @param offset defines the offset in the source array
  2834. * @param result defines the Vector3 where to store the result
  2835. */
  2836. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2837. /**
  2838. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2839. * @param array defines the source array
  2840. * @param offset defines the offset in the source array
  2841. * @param result defines the Vector3 where to store the result
  2842. * @deprecated Please use FromArrayToRef instead.
  2843. */
  2844. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2845. /**
  2846. * Sets the given vector "result" with the given floats.
  2847. * @param x defines the x coordinate of the source
  2848. * @param y defines the y coordinate of the source
  2849. * @param z defines the z coordinate of the source
  2850. * @param result defines the Vector3 where to store the result
  2851. */
  2852. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2853. /**
  2854. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2855. * @returns a new empty Vector3
  2856. */
  2857. static Zero(): Vector3;
  2858. /**
  2859. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2860. * @returns a new unit Vector3
  2861. */
  2862. static One(): Vector3;
  2863. /**
  2864. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2865. * @returns a new up Vector3
  2866. */
  2867. static Up(): Vector3;
  2868. /**
  2869. * Gets a up Vector3 that must not be updated
  2870. */
  2871. static get UpReadOnly(): DeepImmutable<Vector3>;
  2872. /**
  2873. * Gets a zero Vector3 that must not be updated
  2874. */
  2875. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2876. /**
  2877. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2878. * @returns a new down Vector3
  2879. */
  2880. static Down(): Vector3;
  2881. /**
  2882. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2883. * @param rightHandedSystem is the scene right-handed (negative z)
  2884. * @returns a new forward Vector3
  2885. */
  2886. static Forward(rightHandedSystem?: boolean): Vector3;
  2887. /**
  2888. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2889. * @param rightHandedSystem is the scene right-handed (negative-z)
  2890. * @returns a new forward Vector3
  2891. */
  2892. static Backward(rightHandedSystem?: boolean): Vector3;
  2893. /**
  2894. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2895. * @returns a new right Vector3
  2896. */
  2897. static Right(): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2900. * @returns a new left Vector3
  2901. */
  2902. static Left(): Vector3;
  2903. /**
  2904. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2905. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2906. * @param vector defines the Vector3 to transform
  2907. * @param transformation defines the transformation matrix
  2908. * @returns the transformed Vector3
  2909. */
  2910. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2911. /**
  2912. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2913. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2914. * @param vector defines the Vector3 to transform
  2915. * @param transformation defines the transformation matrix
  2916. * @param result defines the Vector3 where to store the result
  2917. */
  2918. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2919. /**
  2920. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2921. * This method computes tranformed coordinates only, not transformed direction vectors
  2922. * @param x define the x coordinate of the source vector
  2923. * @param y define the y coordinate of the source vector
  2924. * @param z define the z coordinate of the source vector
  2925. * @param transformation defines the transformation matrix
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2931. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2932. * @param vector defines the Vector3 to transform
  2933. * @param transformation defines the transformation matrix
  2934. * @returns the new Vector3
  2935. */
  2936. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2937. /**
  2938. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2939. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2940. * @param vector defines the Vector3 to transform
  2941. * @param transformation defines the transformation matrix
  2942. * @param result defines the Vector3 where to store the result
  2943. */
  2944. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2945. /**
  2946. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2947. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2948. * @param x define the x coordinate of the source vector
  2949. * @param y define the y coordinate of the source vector
  2950. * @param z define the z coordinate of the source vector
  2951. * @param transformation defines the transformation matrix
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2957. * @param value1 defines the first control point
  2958. * @param value2 defines the second control point
  2959. * @param value3 defines the third control point
  2960. * @param value4 defines the fourth control point
  2961. * @param amount defines the amount on the spline to use
  2962. * @returns the new Vector3
  2963. */
  2964. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2965. /**
  2966. * 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"
  2967. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2968. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2969. * @param value defines the current value
  2970. * @param min defines the lower range value
  2971. * @param max defines the upper range value
  2972. * @returns the new Vector3
  2973. */
  2974. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2975. /**
  2976. * 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"
  2977. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2978. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2979. * @param value defines the current value
  2980. * @param min defines the lower range value
  2981. * @param max defines the upper range value
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2985. /**
  2986. * Checks if a given vector is inside a specific range
  2987. * @param v defines the vector to test
  2988. * @param min defines the minimum range
  2989. * @param max defines the maximum range
  2990. */
  2991. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2992. /**
  2993. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2994. * @param value1 defines the first control point
  2995. * @param tangent1 defines the first tangent vector
  2996. * @param value2 defines the second control point
  2997. * @param tangent2 defines the second tangent vector
  2998. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2999. * @returns the new Vector3
  3000. */
  3001. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3004. * @param start defines the start value
  3005. * @param end defines the end value
  3006. * @param amount max defines amount between both (between 0 and 1)
  3007. * @returns the new Vector3
  3008. */
  3009. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3010. /**
  3011. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3012. * @param start defines the start value
  3013. * @param end defines the end value
  3014. * @param amount max defines amount between both (between 0 and 1)
  3015. * @param result defines the Vector3 where to store the result
  3016. */
  3017. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3018. /**
  3019. * Returns the dot product (float) between the vectors "left" and "right"
  3020. * @param left defines the left operand
  3021. * @param right defines the right operand
  3022. * @returns the dot product
  3023. */
  3024. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3025. /**
  3026. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3027. * The cross product is then orthogonal to both "left" and "right"
  3028. * @param left defines the left operand
  3029. * @param right defines the right operand
  3030. * @returns the cross product
  3031. */
  3032. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Sets the given vector "result" with the cross product of "left" and "right"
  3035. * The cross product is then orthogonal to both "left" and "right"
  3036. * @param left defines the left operand
  3037. * @param right defines the right operand
  3038. * @param result defines the Vector3 where to store the result
  3039. */
  3040. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3041. /**
  3042. * Returns a new Vector3 as the normalization of the given vector
  3043. * @param vector defines the Vector3 to normalize
  3044. * @returns the new Vector3
  3045. */
  3046. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3047. /**
  3048. * Sets the given vector "result" with the normalization of the given first vector
  3049. * @param vector defines the Vector3 to normalize
  3050. * @param result defines the Vector3 where to store the result
  3051. */
  3052. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3053. /**
  3054. * Project a Vector3 onto screen space
  3055. * @param vector defines the Vector3 to project
  3056. * @param world defines the world matrix to use
  3057. * @param transform defines the transform (view x projection) matrix to use
  3058. * @param viewport defines the screen viewport to use
  3059. * @returns the new Vector3
  3060. */
  3061. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3062. /** @hidden */
  3063. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3064. /**
  3065. * Unproject from screen space to object space
  3066. * @param source defines the screen space Vector3 to use
  3067. * @param viewportWidth defines the current width of the viewport
  3068. * @param viewportHeight defines the current height of the viewport
  3069. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3070. * @param transform defines the transform (view x projection) matrix to use
  3071. * @returns the new Vector3
  3072. */
  3073. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3074. /**
  3075. * Unproject from screen space to object space
  3076. * @param source defines the screen space Vector3 to use
  3077. * @param viewportWidth defines the current width of the viewport
  3078. * @param viewportHeight defines the current height of the viewport
  3079. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3080. * @param view defines the view matrix to use
  3081. * @param projection defines the projection matrix to use
  3082. * @returns the new Vector3
  3083. */
  3084. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3085. /**
  3086. * Unproject from screen space to object space
  3087. * @param source defines the screen space Vector3 to use
  3088. * @param viewportWidth defines the current width of the viewport
  3089. * @param viewportHeight defines the current height of the viewport
  3090. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3091. * @param view defines the view matrix to use
  3092. * @param projection defines the projection matrix to use
  3093. * @param result defines the Vector3 where to store the result
  3094. */
  3095. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3096. /**
  3097. * Unproject from screen space to object space
  3098. * @param sourceX defines the screen space x coordinate to use
  3099. * @param sourceY defines the screen space y coordinate to use
  3100. * @param sourceZ defines the screen space z coordinate to use
  3101. * @param viewportWidth defines the current width of the viewport
  3102. * @param viewportHeight defines the current height of the viewport
  3103. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3104. * @param view defines the view matrix to use
  3105. * @param projection defines the projection matrix to use
  3106. * @param result defines the Vector3 where to store the result
  3107. */
  3108. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3109. /**
  3110. * Gets the minimal coordinate values between two Vector3
  3111. * @param left defines the first operand
  3112. * @param right defines the second operand
  3113. * @returns the new Vector3
  3114. */
  3115. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3116. /**
  3117. * Gets the maximal coordinate values between two Vector3
  3118. * @param left defines the first operand
  3119. * @param right defines the second operand
  3120. * @returns the new Vector3
  3121. */
  3122. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Returns the distance between the vectors "value1" and "value2"
  3125. * @param value1 defines the first operand
  3126. * @param value2 defines the second operand
  3127. * @returns the distance
  3128. */
  3129. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3130. /**
  3131. * Returns the squared distance between the vectors "value1" and "value2"
  3132. * @param value1 defines the first operand
  3133. * @param value2 defines the second operand
  3134. * @returns the squared distance
  3135. */
  3136. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3137. /**
  3138. * Returns a new Vector3 located at the center between "value1" and "value2"
  3139. * @param value1 defines the first operand
  3140. * @param value2 defines the second operand
  3141. * @returns the new Vector3
  3142. */
  3143. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3144. /**
  3145. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3146. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3147. * to something in order to rotate it from its local system to the given target system
  3148. * Note: axis1, axis2 and axis3 are normalized during this operation
  3149. * @param axis1 defines the first axis
  3150. * @param axis2 defines the second axis
  3151. * @param axis3 defines the third axis
  3152. * @returns a new Vector3
  3153. */
  3154. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3155. /**
  3156. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3157. * @param axis1 defines the first axis
  3158. * @param axis2 defines the second axis
  3159. * @param axis3 defines the third axis
  3160. * @param ref defines the Vector3 where to store the result
  3161. */
  3162. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3163. }
  3164. /**
  3165. * Vector4 class created for EulerAngle class conversion to Quaternion
  3166. */
  3167. export class Vector4 {
  3168. /** x value of the vector */
  3169. x: number;
  3170. /** y value of the vector */
  3171. y: number;
  3172. /** z value of the vector */
  3173. z: number;
  3174. /** w value of the vector */
  3175. w: number;
  3176. /**
  3177. * Creates a Vector4 object from the given floats.
  3178. * @param x x value of the vector
  3179. * @param y y value of the vector
  3180. * @param z z value of the vector
  3181. * @param w w value of the vector
  3182. */
  3183. constructor(
  3184. /** x value of the vector */
  3185. x: number,
  3186. /** y value of the vector */
  3187. y: number,
  3188. /** z value of the vector */
  3189. z: number,
  3190. /** w value of the vector */
  3191. w: number);
  3192. /**
  3193. * Returns the string with the Vector4 coordinates.
  3194. * @returns a string containing all the vector values
  3195. */
  3196. toString(): string;
  3197. /**
  3198. * Returns the string "Vector4".
  3199. * @returns "Vector4"
  3200. */
  3201. getClassName(): string;
  3202. /**
  3203. * Returns the Vector4 hash code.
  3204. * @returns a unique hash code
  3205. */
  3206. getHashCode(): number;
  3207. /**
  3208. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3209. * @returns the resulting array
  3210. */
  3211. asArray(): number[];
  3212. /**
  3213. * Populates the given array from the given index with the Vector4 coordinates.
  3214. * @param array array to populate
  3215. * @param index index of the array to start at (default: 0)
  3216. * @returns the Vector4.
  3217. */
  3218. toArray(array: FloatArray, index?: number): Vector4;
  3219. /**
  3220. * Adds the given vector to the current Vector4.
  3221. * @param otherVector the vector to add
  3222. * @returns the updated Vector4.
  3223. */
  3224. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3225. /**
  3226. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3227. * @param otherVector the vector to add
  3228. * @returns the resulting vector
  3229. */
  3230. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3233. * @param otherVector the vector to add
  3234. * @param result the vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Subtract in place the given vector from the current Vector4.
  3240. * @param otherVector the vector to subtract
  3241. * @returns the updated Vector4.
  3242. */
  3243. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3246. * @param otherVector the vector to add
  3247. * @returns the new vector with the result
  3248. */
  3249. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3252. * @param otherVector the vector to subtract
  3253. * @param result the vector to store the result
  3254. * @returns the current Vector4.
  3255. */
  3256. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3257. /**
  3258. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3259. */
  3260. /**
  3261. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3262. * @param x value to subtract
  3263. * @param y value to subtract
  3264. * @param z value to subtract
  3265. * @param w value to subtract
  3266. * @returns new vector containing the result
  3267. */
  3268. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3269. /**
  3270. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3271. * @param x value to subtract
  3272. * @param y value to subtract
  3273. * @param z value to subtract
  3274. * @param w value to subtract
  3275. * @param result the vector to store the result in
  3276. * @returns the current Vector4.
  3277. */
  3278. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3279. /**
  3280. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3281. * @returns a new vector with the negated values
  3282. */
  3283. negate(): Vector4;
  3284. /**
  3285. * Negate this vector in place
  3286. * @returns this
  3287. */
  3288. negateInPlace(): Vector4;
  3289. /**
  3290. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3291. * @param result defines the Vector3 object where to store the result
  3292. * @returns the current Vector4
  3293. */
  3294. negateToRef(result: Vector4): Vector4;
  3295. /**
  3296. * Multiplies the current Vector4 coordinates by scale (float).
  3297. * @param scale the number to scale with
  3298. * @returns the updated Vector4.
  3299. */
  3300. scaleInPlace(scale: number): Vector4;
  3301. /**
  3302. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3303. * @param scale the number to scale with
  3304. * @returns a new vector with the result
  3305. */
  3306. scale(scale: number): Vector4;
  3307. /**
  3308. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3309. * @param scale the number to scale with
  3310. * @param result a vector to store the result in
  3311. * @returns the current Vector4.
  3312. */
  3313. scaleToRef(scale: number, result: Vector4): Vector4;
  3314. /**
  3315. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3316. * @param scale defines the scale factor
  3317. * @param result defines the Vector4 object where to store the result
  3318. * @returns the unmodified current Vector4
  3319. */
  3320. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3321. /**
  3322. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3323. * @param otherVector the vector to compare against
  3324. * @returns true if they are equal
  3325. */
  3326. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3327. /**
  3328. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3329. * @param otherVector vector to compare against
  3330. * @param epsilon (Default: very small number)
  3331. * @returns true if they are equal
  3332. */
  3333. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3334. /**
  3335. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3336. * @param x x value to compare against
  3337. * @param y y value to compare against
  3338. * @param z z value to compare against
  3339. * @param w w value to compare against
  3340. * @returns true if equal
  3341. */
  3342. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3343. /**
  3344. * Multiplies in place the current Vector4 by the given one.
  3345. * @param otherVector vector to multiple with
  3346. * @returns the updated Vector4.
  3347. */
  3348. multiplyInPlace(otherVector: Vector4): Vector4;
  3349. /**
  3350. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3351. * @param otherVector vector to multiple with
  3352. * @returns resulting new vector
  3353. */
  3354. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3355. /**
  3356. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3357. * @param otherVector vector to multiple with
  3358. * @param result vector to store the result
  3359. * @returns the current Vector4.
  3360. */
  3361. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3364. * @param x x value multiply with
  3365. * @param y y value multiply with
  3366. * @param z z value multiply with
  3367. * @param w w value multiply with
  3368. * @returns resulting new vector
  3369. */
  3370. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3371. /**
  3372. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3373. * @param otherVector vector to devide with
  3374. * @returns resulting new vector
  3375. */
  3376. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3379. * @param otherVector vector to devide with
  3380. * @param result vector to store the result
  3381. * @returns the current Vector4.
  3382. */
  3383. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3384. /**
  3385. * Divides the current Vector3 coordinates by the given ones.
  3386. * @param otherVector vector to devide with
  3387. * @returns the updated Vector3.
  3388. */
  3389. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3390. /**
  3391. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3392. * @param other defines the second operand
  3393. * @returns the current updated Vector4
  3394. */
  3395. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3396. /**
  3397. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3398. * @param other defines the second operand
  3399. * @returns the current updated Vector4
  3400. */
  3401. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Gets a new Vector4 from current Vector4 floored values
  3404. * @returns a new Vector4
  3405. */
  3406. floor(): Vector4;
  3407. /**
  3408. * Gets a new Vector4 from current Vector3 floored values
  3409. * @returns a new Vector4
  3410. */
  3411. fract(): Vector4;
  3412. /**
  3413. * Returns the Vector4 length (float).
  3414. * @returns the length
  3415. */
  3416. length(): number;
  3417. /**
  3418. * Returns the Vector4 squared length (float).
  3419. * @returns the length squared
  3420. */
  3421. lengthSquared(): number;
  3422. /**
  3423. * Normalizes in place the Vector4.
  3424. * @returns the updated Vector4.
  3425. */
  3426. normalize(): Vector4;
  3427. /**
  3428. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3429. * @returns this converted to a new vector3
  3430. */
  3431. toVector3(): Vector3;
  3432. /**
  3433. * Returns a new Vector4 copied from the current one.
  3434. * @returns the new cloned vector
  3435. */
  3436. clone(): Vector4;
  3437. /**
  3438. * Updates the current Vector4 with the given one coordinates.
  3439. * @param source the source vector to copy from
  3440. * @returns the updated Vector4.
  3441. */
  3442. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Updates the current Vector4 coordinates with the given floats.
  3445. * @param x float to copy from
  3446. * @param y float to copy from
  3447. * @param z float to copy from
  3448. * @param w float to copy from
  3449. * @returns the updated Vector4.
  3450. */
  3451. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3452. /**
  3453. * Updates the current Vector4 coordinates with the given floats.
  3454. * @param x float to set from
  3455. * @param y float to set from
  3456. * @param z float to set from
  3457. * @param w float to set from
  3458. * @returns the updated Vector4.
  3459. */
  3460. set(x: number, y: number, z: number, w: number): Vector4;
  3461. /**
  3462. * Copies the given float to the current Vector3 coordinates
  3463. * @param v defines the x, y, z and w coordinates of the operand
  3464. * @returns the current updated Vector3
  3465. */
  3466. setAll(v: number): Vector4;
  3467. /**
  3468. * Returns a new Vector4 set from the starting index of the given array.
  3469. * @param array the array to pull values from
  3470. * @param offset the offset into the array to start at
  3471. * @returns the new vector
  3472. */
  3473. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3474. /**
  3475. * Updates the given vector "result" from the starting index of the given array.
  3476. * @param array the array to pull values from
  3477. * @param offset the offset into the array to start at
  3478. * @param result the vector to store the result in
  3479. */
  3480. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3481. /**
  3482. * Updates the given vector "result" from the starting index of the given Float32Array.
  3483. * @param array the array to pull values from
  3484. * @param offset the offset into the array to start at
  3485. * @param result the vector to store the result in
  3486. */
  3487. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3488. /**
  3489. * Updates the given vector "result" coordinates from the given floats.
  3490. * @param x float to set from
  3491. * @param y float to set from
  3492. * @param z float to set from
  3493. * @param w float to set from
  3494. * @param result the vector to the floats in
  3495. */
  3496. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3497. /**
  3498. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3499. * @returns the new vector
  3500. */
  3501. static Zero(): Vector4;
  3502. /**
  3503. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3504. * @returns the new vector
  3505. */
  3506. static One(): Vector4;
  3507. /**
  3508. * Returns a new normalized Vector4 from the given one.
  3509. * @param vector the vector to normalize
  3510. * @returns the vector
  3511. */
  3512. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3513. /**
  3514. * Updates the given vector "result" from the normalization of the given one.
  3515. * @param vector the vector to normalize
  3516. * @param result the vector to store the result in
  3517. */
  3518. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3519. /**
  3520. * Returns a vector with the minimum values from the left and right vectors
  3521. * @param left left vector to minimize
  3522. * @param right right vector to minimize
  3523. * @returns a new vector with the minimum of the left and right vector values
  3524. */
  3525. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3526. /**
  3527. * Returns a vector with the maximum values from the left and right vectors
  3528. * @param left left vector to maximize
  3529. * @param right right vector to maximize
  3530. * @returns a new vector with the maximum of the left and right vector values
  3531. */
  3532. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3533. /**
  3534. * Returns the distance (float) between the vectors "value1" and "value2".
  3535. * @param value1 value to calulate the distance between
  3536. * @param value2 value to calulate the distance between
  3537. * @return the distance between the two vectors
  3538. */
  3539. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3540. /**
  3541. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3542. * @param value1 value to calulate the distance between
  3543. * @param value2 value to calulate the distance between
  3544. * @return the distance between the two vectors squared
  3545. */
  3546. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3547. /**
  3548. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3549. * @param value1 value to calulate the center between
  3550. * @param value2 value to calulate the center between
  3551. * @return the center between the two vectors
  3552. */
  3553. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3554. /**
  3555. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3556. * This methods computes transformed normalized direction vectors only.
  3557. * @param vector the vector to transform
  3558. * @param transformation the transformation matrix to apply
  3559. * @returns the new vector
  3560. */
  3561. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3562. /**
  3563. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3564. * This methods computes transformed normalized direction vectors only.
  3565. * @param vector the vector to transform
  3566. * @param transformation the transformation matrix to apply
  3567. * @param result the vector to store the result in
  3568. */
  3569. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3570. /**
  3571. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3572. * This methods computes transformed normalized direction vectors only.
  3573. * @param x value to transform
  3574. * @param y value to transform
  3575. * @param z value to transform
  3576. * @param w value to transform
  3577. * @param transformation the transformation matrix to apply
  3578. * @param result the vector to store the results in
  3579. */
  3580. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3581. /**
  3582. * Creates a new Vector4 from a Vector3
  3583. * @param source defines the source data
  3584. * @param w defines the 4th component (default is 0)
  3585. * @returns a new Vector4
  3586. */
  3587. static FromVector3(source: Vector3, w?: number): Vector4;
  3588. }
  3589. /**
  3590. * Class used to store quaternion data
  3591. * @see https://en.wikipedia.org/wiki/Quaternion
  3592. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3593. */
  3594. export class Quaternion {
  3595. /** defines the first component (0 by default) */
  3596. x: number;
  3597. /** defines the second component (0 by default) */
  3598. y: number;
  3599. /** defines the third component (0 by default) */
  3600. z: number;
  3601. /** defines the fourth component (1.0 by default) */
  3602. w: number;
  3603. /**
  3604. * Creates a new Quaternion from the given floats
  3605. * @param x defines the first component (0 by default)
  3606. * @param y defines the second component (0 by default)
  3607. * @param z defines the third component (0 by default)
  3608. * @param w defines the fourth component (1.0 by default)
  3609. */
  3610. constructor(
  3611. /** defines the first component (0 by default) */
  3612. x?: number,
  3613. /** defines the second component (0 by default) */
  3614. y?: number,
  3615. /** defines the third component (0 by default) */
  3616. z?: number,
  3617. /** defines the fourth component (1.0 by default) */
  3618. w?: number);
  3619. /**
  3620. * Gets a string representation for the current quaternion
  3621. * @returns a string with the Quaternion coordinates
  3622. */
  3623. toString(): string;
  3624. /**
  3625. * Gets the class name of the quaternion
  3626. * @returns the string "Quaternion"
  3627. */
  3628. getClassName(): string;
  3629. /**
  3630. * Gets a hash code for this quaternion
  3631. * @returns the quaternion hash code
  3632. */
  3633. getHashCode(): number;
  3634. /**
  3635. * Copy the quaternion to an array
  3636. * @returns a new array populated with 4 elements from the quaternion coordinates
  3637. */
  3638. asArray(): number[];
  3639. /**
  3640. * Check if two quaternions are equals
  3641. * @param otherQuaternion defines the second operand
  3642. * @return true if the current quaternion and the given one coordinates are strictly equals
  3643. */
  3644. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3645. /**
  3646. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3647. * @param otherQuaternion defines the other quaternion
  3648. * @param epsilon defines the minimal distance to consider equality
  3649. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3650. */
  3651. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3652. /**
  3653. * Clone the current quaternion
  3654. * @returns a new quaternion copied from the current one
  3655. */
  3656. clone(): Quaternion;
  3657. /**
  3658. * Copy a quaternion to the current one
  3659. * @param other defines the other quaternion
  3660. * @returns the updated current quaternion
  3661. */
  3662. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3663. /**
  3664. * Updates the current quaternion with the given float coordinates
  3665. * @param x defines the x coordinate
  3666. * @param y defines the y coordinate
  3667. * @param z defines the z coordinate
  3668. * @param w defines the w coordinate
  3669. * @returns the updated current quaternion
  3670. */
  3671. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3672. /**
  3673. * Updates the current quaternion from the given float coordinates
  3674. * @param x defines the x coordinate
  3675. * @param y defines the y coordinate
  3676. * @param z defines the z coordinate
  3677. * @param w defines the w coordinate
  3678. * @returns the updated current quaternion
  3679. */
  3680. set(x: number, y: number, z: number, w: number): Quaternion;
  3681. /**
  3682. * Adds two quaternions
  3683. * @param other defines the second operand
  3684. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3685. */
  3686. add(other: DeepImmutable<Quaternion>): Quaternion;
  3687. /**
  3688. * Add a quaternion to the current one
  3689. * @param other defines the quaternion to add
  3690. * @returns the current quaternion
  3691. */
  3692. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3693. /**
  3694. * Subtract two quaternions
  3695. * @param other defines the second operand
  3696. * @returns a new quaternion as the subtraction result of the given one from the current one
  3697. */
  3698. subtract(other: Quaternion): Quaternion;
  3699. /**
  3700. * Multiplies the current quaternion by a scale factor
  3701. * @param value defines the scale factor
  3702. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3703. */
  3704. scale(value: number): Quaternion;
  3705. /**
  3706. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3707. * @param scale defines the scale factor
  3708. * @param result defines the Quaternion object where to store the result
  3709. * @returns the unmodified current quaternion
  3710. */
  3711. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3712. /**
  3713. * Multiplies in place the current quaternion by a scale factor
  3714. * @param value defines the scale factor
  3715. * @returns the current modified quaternion
  3716. */
  3717. scaleInPlace(value: number): Quaternion;
  3718. /**
  3719. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3720. * @param scale defines the scale factor
  3721. * @param result defines the Quaternion object where to store the result
  3722. * @returns the unmodified current quaternion
  3723. */
  3724. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3725. /**
  3726. * Multiplies two quaternions
  3727. * @param q1 defines the second operand
  3728. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3729. */
  3730. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3731. /**
  3732. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3733. * @param q1 defines the second operand
  3734. * @param result defines the target quaternion
  3735. * @returns the current quaternion
  3736. */
  3737. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3738. /**
  3739. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3740. * @param q1 defines the second operand
  3741. * @returns the currentupdated quaternion
  3742. */
  3743. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3744. /**
  3745. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3746. * @param ref defines the target quaternion
  3747. * @returns the current quaternion
  3748. */
  3749. conjugateToRef(ref: Quaternion): Quaternion;
  3750. /**
  3751. * Conjugates in place (1-q) the current quaternion
  3752. * @returns the current updated quaternion
  3753. */
  3754. conjugateInPlace(): Quaternion;
  3755. /**
  3756. * Conjugates in place (1-q) the current quaternion
  3757. * @returns a new quaternion
  3758. */
  3759. conjugate(): Quaternion;
  3760. /**
  3761. * Gets length of current quaternion
  3762. * @returns the quaternion length (float)
  3763. */
  3764. length(): number;
  3765. /**
  3766. * Normalize in place the current quaternion
  3767. * @returns the current updated quaternion
  3768. */
  3769. normalize(): Quaternion;
  3770. /**
  3771. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3772. * @param order is a reserved parameter and is ignore for now
  3773. * @returns a new Vector3 containing the Euler angles
  3774. */
  3775. toEulerAngles(order?: string): Vector3;
  3776. /**
  3777. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3778. * @param result defines the vector which will be filled with the Euler angles
  3779. * @param order is a reserved parameter and is ignore for now
  3780. * @returns the current unchanged quaternion
  3781. */
  3782. toEulerAnglesToRef(result: Vector3): Quaternion;
  3783. /**
  3784. * Updates the given rotation matrix with the current quaternion values
  3785. * @param result defines the target matrix
  3786. * @returns the current unchanged quaternion
  3787. */
  3788. toRotationMatrix(result: Matrix): Quaternion;
  3789. /**
  3790. * Updates the current quaternion from the given rotation matrix values
  3791. * @param matrix defines the source matrix
  3792. * @returns the current updated quaternion
  3793. */
  3794. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3795. /**
  3796. * Creates a new quaternion from a rotation matrix
  3797. * @param matrix defines the source matrix
  3798. * @returns a new quaternion created from the given rotation matrix values
  3799. */
  3800. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3801. /**
  3802. * Updates the given quaternion with the given rotation matrix values
  3803. * @param matrix defines the source matrix
  3804. * @param result defines the target quaternion
  3805. */
  3806. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3807. /**
  3808. * Returns the dot product (float) between the quaternions "left" and "right"
  3809. * @param left defines the left operand
  3810. * @param right defines the right operand
  3811. * @returns the dot product
  3812. */
  3813. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3814. /**
  3815. * Checks if the two quaternions are close to each other
  3816. * @param quat0 defines the first quaternion to check
  3817. * @param quat1 defines the second quaternion to check
  3818. * @returns true if the two quaternions are close to each other
  3819. */
  3820. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3821. /**
  3822. * Creates an empty quaternion
  3823. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3824. */
  3825. static Zero(): Quaternion;
  3826. /**
  3827. * Inverse a given quaternion
  3828. * @param q defines the source quaternion
  3829. * @returns a new quaternion as the inverted current quaternion
  3830. */
  3831. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Inverse a given quaternion
  3834. * @param q defines the source quaternion
  3835. * @param result the quaternion the result will be stored in
  3836. * @returns the result quaternion
  3837. */
  3838. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3839. /**
  3840. * Creates an identity quaternion
  3841. * @returns the identity quaternion
  3842. */
  3843. static Identity(): Quaternion;
  3844. /**
  3845. * Gets a boolean indicating if the given quaternion is identity
  3846. * @param quaternion defines the quaternion to check
  3847. * @returns true if the quaternion is identity
  3848. */
  3849. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3850. /**
  3851. * Creates a quaternion from a rotation around an axis
  3852. * @param axis defines the axis to use
  3853. * @param angle defines the angle to use
  3854. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3855. */
  3856. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3857. /**
  3858. * Creates a rotation around an axis and stores it into the given quaternion
  3859. * @param axis defines the axis to use
  3860. * @param angle defines the angle to use
  3861. * @param result defines the target quaternion
  3862. * @returns the target quaternion
  3863. */
  3864. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3865. /**
  3866. * Creates a new quaternion from data stored into an array
  3867. * @param array defines the data source
  3868. * @param offset defines the offset in the source array where the data starts
  3869. * @returns a new quaternion
  3870. */
  3871. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3872. /**
  3873. * Updates the given quaternion "result" from the starting index of the given array.
  3874. * @param array the array to pull values from
  3875. * @param offset the offset into the array to start at
  3876. * @param result the quaternion to store the result in
  3877. */
  3878. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3879. /**
  3880. * Create a quaternion from Euler rotation angles
  3881. * @param x Pitch
  3882. * @param y Yaw
  3883. * @param z Roll
  3884. * @returns the new Quaternion
  3885. */
  3886. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3887. /**
  3888. * Updates a quaternion from Euler rotation angles
  3889. * @param x Pitch
  3890. * @param y Yaw
  3891. * @param z Roll
  3892. * @param result the quaternion to store the result
  3893. * @returns the updated quaternion
  3894. */
  3895. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3896. /**
  3897. * Create a quaternion from Euler rotation vector
  3898. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3899. * @returns the new Quaternion
  3900. */
  3901. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3902. /**
  3903. * Updates a quaternion from Euler rotation vector
  3904. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3905. * @param result the quaternion to store the result
  3906. * @returns the updated quaternion
  3907. */
  3908. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3909. /**
  3910. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3911. * @param yaw defines the rotation around Y axis
  3912. * @param pitch defines the rotation around X axis
  3913. * @param roll defines the rotation around Z axis
  3914. * @returns the new quaternion
  3915. */
  3916. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3917. /**
  3918. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3919. * @param yaw defines the rotation around Y axis
  3920. * @param pitch defines the rotation around X axis
  3921. * @param roll defines the rotation around Z axis
  3922. * @param result defines the target quaternion
  3923. */
  3924. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3925. /**
  3926. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3927. * @param alpha defines the rotation around first axis
  3928. * @param beta defines the rotation around second axis
  3929. * @param gamma defines the rotation around third axis
  3930. * @returns the new quaternion
  3931. */
  3932. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3935. * @param alpha defines the rotation around first axis
  3936. * @param beta defines the rotation around second axis
  3937. * @param gamma defines the rotation around third axis
  3938. * @param result defines the target quaternion
  3939. */
  3940. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3941. /**
  3942. * 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)
  3943. * @param axis1 defines the first axis
  3944. * @param axis2 defines the second axis
  3945. * @param axis3 defines the third axis
  3946. * @returns the new quaternion
  3947. */
  3948. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3949. /**
  3950. * 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
  3951. * @param axis1 defines the first axis
  3952. * @param axis2 defines the second axis
  3953. * @param axis3 defines the third axis
  3954. * @param ref defines the target quaternion
  3955. */
  3956. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3957. /**
  3958. * Interpolates between two quaternions
  3959. * @param left defines first quaternion
  3960. * @param right defines second quaternion
  3961. * @param amount defines the gradient to use
  3962. * @returns the new interpolated quaternion
  3963. */
  3964. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3965. /**
  3966. * Interpolates between two quaternions and stores it into a target quaternion
  3967. * @param left defines first quaternion
  3968. * @param right defines second quaternion
  3969. * @param amount defines the gradient to use
  3970. * @param result defines the target quaternion
  3971. */
  3972. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3973. /**
  3974. * Interpolate between two quaternions using Hermite interpolation
  3975. * @param value1 defines first quaternion
  3976. * @param tangent1 defines the incoming tangent
  3977. * @param value2 defines second quaternion
  3978. * @param tangent2 defines the outgoing tangent
  3979. * @param amount defines the target quaternion
  3980. * @returns the new interpolated quaternion
  3981. */
  3982. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3983. }
  3984. /**
  3985. * Class used to store matrix data (4x4)
  3986. */
  3987. export class Matrix {
  3988. private static _updateFlagSeed;
  3989. private static _identityReadOnly;
  3990. private _isIdentity;
  3991. private _isIdentityDirty;
  3992. private _isIdentity3x2;
  3993. private _isIdentity3x2Dirty;
  3994. /**
  3995. * Gets the update flag of the matrix which is an unique number for the matrix.
  3996. * It will be incremented every time the matrix data change.
  3997. * You can use it to speed the comparison between two versions of the same matrix.
  3998. */
  3999. updateFlag: number;
  4000. private readonly _m;
  4001. /**
  4002. * Gets the internal data of the matrix
  4003. */
  4004. get m(): DeepImmutable<Float32Array>;
  4005. /** @hidden */
  4006. _markAsUpdated(): void;
  4007. /** @hidden */
  4008. private _updateIdentityStatus;
  4009. /**
  4010. * Creates an empty matrix (filled with zeros)
  4011. */
  4012. constructor();
  4013. /**
  4014. * Check if the current matrix is identity
  4015. * @returns true is the matrix is the identity matrix
  4016. */
  4017. isIdentity(): boolean;
  4018. /**
  4019. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4020. * @returns true is the matrix is the identity matrix
  4021. */
  4022. isIdentityAs3x2(): boolean;
  4023. /**
  4024. * Gets the determinant of the matrix
  4025. * @returns the matrix determinant
  4026. */
  4027. determinant(): number;
  4028. /**
  4029. * Returns the matrix as a Float32Array
  4030. * @returns the matrix underlying array
  4031. */
  4032. toArray(): DeepImmutable<Float32Array>;
  4033. /**
  4034. * Returns the matrix as a Float32Array
  4035. * @returns the matrix underlying array.
  4036. */
  4037. asArray(): DeepImmutable<Float32Array>;
  4038. /**
  4039. * Inverts the current matrix in place
  4040. * @returns the current inverted matrix
  4041. */
  4042. invert(): Matrix;
  4043. /**
  4044. * Sets all the matrix elements to zero
  4045. * @returns the current matrix
  4046. */
  4047. reset(): Matrix;
  4048. /**
  4049. * Adds the current matrix with a second one
  4050. * @param other defines the matrix to add
  4051. * @returns a new matrix as the addition of the current matrix and the given one
  4052. */
  4053. add(other: DeepImmutable<Matrix>): Matrix;
  4054. /**
  4055. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4056. * @param other defines the matrix to add
  4057. * @param result defines the target matrix
  4058. * @returns the current matrix
  4059. */
  4060. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4061. /**
  4062. * Adds in place the given matrix to the current matrix
  4063. * @param other defines the second operand
  4064. * @returns the current updated matrix
  4065. */
  4066. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4067. /**
  4068. * Sets the given matrix to the current inverted Matrix
  4069. * @param other defines the target matrix
  4070. * @returns the unmodified current matrix
  4071. */
  4072. invertToRef(other: Matrix): Matrix;
  4073. /**
  4074. * add a value at the specified position in the current Matrix
  4075. * @param index the index of the value within the matrix. between 0 and 15.
  4076. * @param value the value to be added
  4077. * @returns the current updated matrix
  4078. */
  4079. addAtIndex(index: number, value: number): Matrix;
  4080. /**
  4081. * mutiply the specified position in the current Matrix by a value
  4082. * @param index the index of the value within the matrix. between 0 and 15.
  4083. * @param value the value to be added
  4084. * @returns the current updated matrix
  4085. */
  4086. multiplyAtIndex(index: number, value: number): Matrix;
  4087. /**
  4088. * Inserts the translation vector (using 3 floats) in the current matrix
  4089. * @param x defines the 1st component of the translation
  4090. * @param y defines the 2nd component of the translation
  4091. * @param z defines the 3rd component of the translation
  4092. * @returns the current updated matrix
  4093. */
  4094. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4095. /**
  4096. * Adds the translation vector (using 3 floats) in the current matrix
  4097. * @param x defines the 1st component of the translation
  4098. * @param y defines the 2nd component of the translation
  4099. * @param z defines the 3rd component of the translation
  4100. * @returns the current updated matrix
  4101. */
  4102. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4103. /**
  4104. * Inserts the translation vector in the current matrix
  4105. * @param vector3 defines the translation to insert
  4106. * @returns the current updated matrix
  4107. */
  4108. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4109. /**
  4110. * Gets the translation value of the current matrix
  4111. * @returns a new Vector3 as the extracted translation from the matrix
  4112. */
  4113. getTranslation(): Vector3;
  4114. /**
  4115. * Fill a Vector3 with the extracted translation from the matrix
  4116. * @param result defines the Vector3 where to store the translation
  4117. * @returns the current matrix
  4118. */
  4119. getTranslationToRef(result: Vector3): Matrix;
  4120. /**
  4121. * Remove rotation and scaling part from the matrix
  4122. * @returns the updated matrix
  4123. */
  4124. removeRotationAndScaling(): Matrix;
  4125. /**
  4126. * Multiply two matrices
  4127. * @param other defines the second operand
  4128. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4129. */
  4130. multiply(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Copy the current matrix from the given one
  4133. * @param other defines the source matrix
  4134. * @returns the current updated matrix
  4135. */
  4136. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4137. /**
  4138. * Populates the given array from the starting index with the current matrix values
  4139. * @param array defines the target array
  4140. * @param offset defines the offset in the target array where to start storing values
  4141. * @returns the current matrix
  4142. */
  4143. copyToArray(array: Float32Array, offset?: number): Matrix;
  4144. /**
  4145. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4146. * @param other defines the second operand
  4147. * @param result defines the matrix where to store the multiplication
  4148. * @returns the current matrix
  4149. */
  4150. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4151. /**
  4152. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4153. * @param other defines the second operand
  4154. * @param result defines the array where to store the multiplication
  4155. * @param offset defines the offset in the target array where to start storing values
  4156. * @returns the current matrix
  4157. */
  4158. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4159. /**
  4160. * Check equality between this matrix and a second one
  4161. * @param value defines the second matrix to compare
  4162. * @returns true is the current matrix and the given one values are strictly equal
  4163. */
  4164. equals(value: DeepImmutable<Matrix>): boolean;
  4165. /**
  4166. * Clone the current matrix
  4167. * @returns a new matrix from the current matrix
  4168. */
  4169. clone(): Matrix;
  4170. /**
  4171. * Returns the name of the current matrix class
  4172. * @returns the string "Matrix"
  4173. */
  4174. getClassName(): string;
  4175. /**
  4176. * Gets the hash code of the current matrix
  4177. * @returns the hash code
  4178. */
  4179. getHashCode(): number;
  4180. /**
  4181. * Decomposes the current Matrix into a translation, rotation and scaling components
  4182. * @param scale defines the scale vector3 given as a reference to update
  4183. * @param rotation defines the rotation quaternion given as a reference to update
  4184. * @param translation defines the translation vector3 given as a reference to update
  4185. * @returns true if operation was successful
  4186. */
  4187. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4188. /**
  4189. * Gets specific row of the matrix
  4190. * @param index defines the number of the row to get
  4191. * @returns the index-th row of the current matrix as a new Vector4
  4192. */
  4193. getRow(index: number): Nullable<Vector4>;
  4194. /**
  4195. * Sets the index-th row of the current matrix to the vector4 values
  4196. * @param index defines the number of the row to set
  4197. * @param row defines the target vector4
  4198. * @returns the updated current matrix
  4199. */
  4200. setRow(index: number, row: Vector4): Matrix;
  4201. /**
  4202. * Compute the transpose of the matrix
  4203. * @returns the new transposed matrix
  4204. */
  4205. transpose(): Matrix;
  4206. /**
  4207. * Compute the transpose of the matrix and store it in a given matrix
  4208. * @param result defines the target matrix
  4209. * @returns the current matrix
  4210. */
  4211. transposeToRef(result: Matrix): Matrix;
  4212. /**
  4213. * Sets the index-th row of the current matrix with the given 4 x float values
  4214. * @param index defines the row index
  4215. * @param x defines the x component to set
  4216. * @param y defines the y component to set
  4217. * @param z defines the z component to set
  4218. * @param w defines the w component to set
  4219. * @returns the updated current matrix
  4220. */
  4221. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4222. /**
  4223. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4224. * @param scale defines the scale factor
  4225. * @returns a new matrix
  4226. */
  4227. scale(scale: number): Matrix;
  4228. /**
  4229. * Scale the current matrix values by a factor to a given result matrix
  4230. * @param scale defines the scale factor
  4231. * @param result defines the matrix to store the result
  4232. * @returns the current matrix
  4233. */
  4234. scaleToRef(scale: number, result: Matrix): Matrix;
  4235. /**
  4236. * Scale the current matrix values by a factor and add the result to a given matrix
  4237. * @param scale defines the scale factor
  4238. * @param result defines the Matrix to store the result
  4239. * @returns the current matrix
  4240. */
  4241. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4242. /**
  4243. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4244. * @param ref matrix to store the result
  4245. */
  4246. toNormalMatrix(ref: Matrix): void;
  4247. /**
  4248. * Gets only rotation part of the current matrix
  4249. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4250. */
  4251. getRotationMatrix(): Matrix;
  4252. /**
  4253. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4254. * @param result defines the target matrix to store data to
  4255. * @returns the current matrix
  4256. */
  4257. getRotationMatrixToRef(result: Matrix): Matrix;
  4258. /**
  4259. * Toggles model matrix from being right handed to left handed in place and vice versa
  4260. */
  4261. toggleModelMatrixHandInPlace(): void;
  4262. /**
  4263. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4264. */
  4265. toggleProjectionMatrixHandInPlace(): void;
  4266. /**
  4267. * Creates a matrix from an array
  4268. * @param array defines the source array
  4269. * @param offset defines an offset in the source array
  4270. * @returns a new Matrix set from the starting index of the given array
  4271. */
  4272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4273. /**
  4274. * Copy the content of an array into a given matrix
  4275. * @param array defines the source array
  4276. * @param offset defines an offset in the source array
  4277. * @param result defines the target matrix
  4278. */
  4279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4280. /**
  4281. * Stores an array into a matrix after having multiplied each component by a given factor
  4282. * @param array defines the source array
  4283. * @param offset defines the offset in the source array
  4284. * @param scale defines the scaling factor
  4285. * @param result defines the target matrix
  4286. */
  4287. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4288. /**
  4289. * Gets an identity matrix that must not be updated
  4290. */
  4291. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4292. /**
  4293. * Stores a list of values (16) inside a given matrix
  4294. * @param initialM11 defines 1st value of 1st row
  4295. * @param initialM12 defines 2nd value of 1st row
  4296. * @param initialM13 defines 3rd value of 1st row
  4297. * @param initialM14 defines 4th value of 1st row
  4298. * @param initialM21 defines 1st value of 2nd row
  4299. * @param initialM22 defines 2nd value of 2nd row
  4300. * @param initialM23 defines 3rd value of 2nd row
  4301. * @param initialM24 defines 4th value of 2nd row
  4302. * @param initialM31 defines 1st value of 3rd row
  4303. * @param initialM32 defines 2nd value of 3rd row
  4304. * @param initialM33 defines 3rd value of 3rd row
  4305. * @param initialM34 defines 4th value of 3rd row
  4306. * @param initialM41 defines 1st value of 4th row
  4307. * @param initialM42 defines 2nd value of 4th row
  4308. * @param initialM43 defines 3rd value of 4th row
  4309. * @param initialM44 defines 4th value of 4th row
  4310. * @param result defines the target matrix
  4311. */
  4312. 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;
  4313. /**
  4314. * Creates new matrix from a list of values (16)
  4315. * @param initialM11 defines 1st value of 1st row
  4316. * @param initialM12 defines 2nd value of 1st row
  4317. * @param initialM13 defines 3rd value of 1st row
  4318. * @param initialM14 defines 4th value of 1st row
  4319. * @param initialM21 defines 1st value of 2nd row
  4320. * @param initialM22 defines 2nd value of 2nd row
  4321. * @param initialM23 defines 3rd value of 2nd row
  4322. * @param initialM24 defines 4th value of 2nd row
  4323. * @param initialM31 defines 1st value of 3rd row
  4324. * @param initialM32 defines 2nd value of 3rd row
  4325. * @param initialM33 defines 3rd value of 3rd row
  4326. * @param initialM34 defines 4th value of 3rd row
  4327. * @param initialM41 defines 1st value of 4th row
  4328. * @param initialM42 defines 2nd value of 4th row
  4329. * @param initialM43 defines 3rd value of 4th row
  4330. * @param initialM44 defines 4th value of 4th row
  4331. * @returns the new matrix
  4332. */
  4333. 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;
  4334. /**
  4335. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4336. * @param scale defines the scale vector3
  4337. * @param rotation defines the rotation quaternion
  4338. * @param translation defines the translation vector3
  4339. * @returns a new matrix
  4340. */
  4341. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4342. /**
  4343. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4344. * @param scale defines the scale vector3
  4345. * @param rotation defines the rotation quaternion
  4346. * @param translation defines the translation vector3
  4347. * @param result defines the target matrix
  4348. */
  4349. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4350. /**
  4351. * Creates a new identity matrix
  4352. * @returns a new identity matrix
  4353. */
  4354. static Identity(): Matrix;
  4355. /**
  4356. * Creates a new identity matrix and stores the result in a given matrix
  4357. * @param result defines the target matrix
  4358. */
  4359. static IdentityToRef(result: Matrix): void;
  4360. /**
  4361. * Creates a new zero matrix
  4362. * @returns a new zero matrix
  4363. */
  4364. static Zero(): Matrix;
  4365. /**
  4366. * Creates a new rotation matrix for "angle" radians around the X axis
  4367. * @param angle defines the angle (in radians) to use
  4368. * @return the new matrix
  4369. */
  4370. static RotationX(angle: number): Matrix;
  4371. /**
  4372. * Creates a new matrix as the invert of a given matrix
  4373. * @param source defines the source matrix
  4374. * @returns the new matrix
  4375. */
  4376. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4377. /**
  4378. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4379. * @param angle defines the angle (in radians) to use
  4380. * @param result defines the target matrix
  4381. */
  4382. static RotationXToRef(angle: number, result: Matrix): void;
  4383. /**
  4384. * Creates a new rotation matrix for "angle" radians around the Y axis
  4385. * @param angle defines the angle (in radians) to use
  4386. * @return the new matrix
  4387. */
  4388. static RotationY(angle: number): Matrix;
  4389. /**
  4390. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4391. * @param angle defines the angle (in radians) to use
  4392. * @param result defines the target matrix
  4393. */
  4394. static RotationYToRef(angle: number, result: Matrix): void;
  4395. /**
  4396. * Creates a new rotation matrix for "angle" radians around the Z axis
  4397. * @param angle defines the angle (in radians) to use
  4398. * @return the new matrix
  4399. */
  4400. static RotationZ(angle: number): Matrix;
  4401. /**
  4402. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4403. * @param angle defines the angle (in radians) to use
  4404. * @param result defines the target matrix
  4405. */
  4406. static RotationZToRef(angle: number, result: Matrix): void;
  4407. /**
  4408. * Creates a new rotation matrix for "angle" radians around the given axis
  4409. * @param axis defines the axis to use
  4410. * @param angle defines the angle (in radians) to use
  4411. * @return the new matrix
  4412. */
  4413. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4414. /**
  4415. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4416. * @param axis defines the axis to use
  4417. * @param angle defines the angle (in radians) to use
  4418. * @param result defines the target matrix
  4419. */
  4420. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4421. /**
  4422. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4423. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4424. * @param from defines the vector to align
  4425. * @param to defines the vector to align to
  4426. * @param result defines the target matrix
  4427. */
  4428. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4429. /**
  4430. * Creates a rotation matrix
  4431. * @param yaw defines the yaw angle in radians (Y axis)
  4432. * @param pitch defines the pitch angle in radians (X axis)
  4433. * @param roll defines the roll angle in radians (X axis)
  4434. * @returns the new rotation matrix
  4435. */
  4436. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4437. /**
  4438. * Creates a rotation matrix and stores it in a given matrix
  4439. * @param yaw defines the yaw angle in radians (Y axis)
  4440. * @param pitch defines the pitch angle in radians (X axis)
  4441. * @param roll defines the roll angle in radians (X axis)
  4442. * @param result defines the target matrix
  4443. */
  4444. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4445. /**
  4446. * Creates a scaling matrix
  4447. * @param x defines the scale factor on X axis
  4448. * @param y defines the scale factor on Y axis
  4449. * @param z defines the scale factor on Z axis
  4450. * @returns the new matrix
  4451. */
  4452. static Scaling(x: number, y: number, z: number): Matrix;
  4453. /**
  4454. * Creates a scaling matrix and stores it in a given matrix
  4455. * @param x defines the scale factor on X axis
  4456. * @param y defines the scale factor on Y axis
  4457. * @param z defines the scale factor on Z axis
  4458. * @param result defines the target matrix
  4459. */
  4460. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4461. /**
  4462. * Creates a translation matrix
  4463. * @param x defines the translation on X axis
  4464. * @param y defines the translation on Y axis
  4465. * @param z defines the translationon Z axis
  4466. * @returns the new matrix
  4467. */
  4468. static Translation(x: number, y: number, z: number): Matrix;
  4469. /**
  4470. * Creates a translation matrix and stores it in a given matrix
  4471. * @param x defines the translation on X axis
  4472. * @param y defines the translation on Y axis
  4473. * @param z defines the translationon Z axis
  4474. * @param result defines the target matrix
  4475. */
  4476. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4477. /**
  4478. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4479. * @param startValue defines the start value
  4480. * @param endValue defines the end value
  4481. * @param gradient defines the gradient factor
  4482. * @returns the new matrix
  4483. */
  4484. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4485. /**
  4486. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4487. * @param startValue defines the start value
  4488. * @param endValue defines the end value
  4489. * @param gradient defines the gradient factor
  4490. * @param result defines the Matrix object where to store data
  4491. */
  4492. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4493. /**
  4494. * Builds a new matrix whose values are computed by:
  4495. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4496. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4497. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4498. * @param startValue defines the first matrix
  4499. * @param endValue defines the second matrix
  4500. * @param gradient defines the gradient between the two matrices
  4501. * @returns the new matrix
  4502. */
  4503. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4504. /**
  4505. * Update a matrix to values which are computed by:
  4506. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4507. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4508. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4509. * @param startValue defines the first matrix
  4510. * @param endValue defines the second matrix
  4511. * @param gradient defines the gradient between the two matrices
  4512. * @param result defines the target matrix
  4513. */
  4514. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4515. /**
  4516. * 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"
  4517. * This function works in left handed mode
  4518. * @param eye defines the final position of the entity
  4519. * @param target defines where the entity should look at
  4520. * @param up defines the up vector for the entity
  4521. * @returns the new matrix
  4522. */
  4523. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4524. /**
  4525. * 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".
  4526. * This function works in left handed mode
  4527. * @param eye defines the final position of the entity
  4528. * @param target defines where the entity should look at
  4529. * @param up defines the up vector for the entity
  4530. * @param result defines the target matrix
  4531. */
  4532. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4533. /**
  4534. * 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"
  4535. * This function works in right handed mode
  4536. * @param eye defines the final position of the entity
  4537. * @param target defines where the entity should look at
  4538. * @param up defines the up vector for the entity
  4539. * @returns the new matrix
  4540. */
  4541. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4542. /**
  4543. * 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".
  4544. * This function works in right handed mode
  4545. * @param eye defines the final position of the entity
  4546. * @param target defines where the entity should look at
  4547. * @param up defines the up vector for the entity
  4548. * @param result defines the target matrix
  4549. */
  4550. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Create a left-handed orthographic projection matrix
  4553. * @param width defines the viewport width
  4554. * @param height defines the viewport height
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a left-handed orthographic projection matrix
  4558. */
  4559. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Store a left-handed orthographic projection to a given matrix
  4562. * @param width defines the viewport width
  4563. * @param height defines the viewport height
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. */
  4568. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4569. /**
  4570. * Create a left-handed orthographic projection matrix
  4571. * @param left defines the viewport left coordinate
  4572. * @param right defines the viewport right coordinate
  4573. * @param bottom defines the viewport bottom coordinate
  4574. * @param top defines the viewport top coordinate
  4575. * @param znear defines the near clip plane
  4576. * @param zfar defines the far clip plane
  4577. * @returns a new matrix as a left-handed orthographic projection matrix
  4578. */
  4579. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4580. /**
  4581. * Stores a left-handed orthographic projection into a given matrix
  4582. * @param left defines the viewport left coordinate
  4583. * @param right defines the viewport right coordinate
  4584. * @param bottom defines the viewport bottom coordinate
  4585. * @param top defines the viewport top coordinate
  4586. * @param znear defines the near clip plane
  4587. * @param zfar defines the far clip plane
  4588. * @param result defines the target matrix
  4589. */
  4590. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4591. /**
  4592. * Creates a right-handed orthographic projection matrix
  4593. * @param left defines the viewport left coordinate
  4594. * @param right defines the viewport right coordinate
  4595. * @param bottom defines the viewport bottom coordinate
  4596. * @param top defines the viewport top coordinate
  4597. * @param znear defines the near clip plane
  4598. * @param zfar defines the far clip plane
  4599. * @returns a new matrix as a right-handed orthographic projection matrix
  4600. */
  4601. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4602. /**
  4603. * Stores a right-handed orthographic projection into a given matrix
  4604. * @param left defines the viewport left coordinate
  4605. * @param right defines the viewport right coordinate
  4606. * @param bottom defines the viewport bottom coordinate
  4607. * @param top defines the viewport top coordinate
  4608. * @param znear defines the near clip plane
  4609. * @param zfar defines the far clip plane
  4610. * @param result defines the target matrix
  4611. */
  4612. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4613. /**
  4614. * Creates a left-handed perspective projection matrix
  4615. * @param width defines the viewport width
  4616. * @param height defines the viewport height
  4617. * @param znear defines the near clip plane
  4618. * @param zfar defines the far clip plane
  4619. * @returns a new matrix as a left-handed perspective projection matrix
  4620. */
  4621. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4622. /**
  4623. * Creates a left-handed perspective projection matrix
  4624. * @param fov defines the horizontal field of view
  4625. * @param aspect defines the aspect ratio
  4626. * @param znear defines the near clip plane
  4627. * @param zfar defines the far clip plane
  4628. * @returns a new matrix as a left-handed perspective projection matrix
  4629. */
  4630. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4631. /**
  4632. * Stores a left-handed perspective projection into a given matrix
  4633. * @param fov defines the horizontal field of view
  4634. * @param aspect defines the aspect ratio
  4635. * @param znear defines the near clip plane
  4636. * @param zfar defines the far clip plane
  4637. * @param result defines the target matrix
  4638. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4639. */
  4640. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4641. /**
  4642. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4643. * @param fov defines the horizontal field of view
  4644. * @param aspect defines the aspect ratio
  4645. * @param znear defines the near clip plane
  4646. * @param zfar not used as infinity is used as far clip
  4647. * @param result defines the target matrix
  4648. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4649. */
  4650. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4651. /**
  4652. * Creates a right-handed perspective projection matrix
  4653. * @param fov defines the horizontal field of view
  4654. * @param aspect defines the aspect ratio
  4655. * @param znear defines the near clip plane
  4656. * @param zfar defines the far clip plane
  4657. * @returns a new matrix as a right-handed perspective projection matrix
  4658. */
  4659. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4660. /**
  4661. * Stores a right-handed perspective projection into a given matrix
  4662. * @param fov defines the horizontal field of view
  4663. * @param aspect defines the aspect ratio
  4664. * @param znear defines the near clip plane
  4665. * @param zfar defines the far clip plane
  4666. * @param result defines the target matrix
  4667. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4668. */
  4669. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4670. /**
  4671. * Stores a right-handed perspective projection into a given matrix
  4672. * @param fov defines the horizontal field of view
  4673. * @param aspect defines the aspect ratio
  4674. * @param znear defines the near clip plane
  4675. * @param zfar not used as infinity is used as far clip
  4676. * @param result defines the target matrix
  4677. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4678. */
  4679. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4680. /**
  4681. * Stores a perspective projection for WebVR info a given matrix
  4682. * @param fov defines the field of view
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @param result defines the target matrix
  4686. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4687. */
  4688. static PerspectiveFovWebVRToRef(fov: {
  4689. upDegrees: number;
  4690. downDegrees: number;
  4691. leftDegrees: number;
  4692. rightDegrees: number;
  4693. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4694. /**
  4695. * Computes a complete transformation matrix
  4696. * @param viewport defines the viewport to use
  4697. * @param world defines the world matrix
  4698. * @param view defines the view matrix
  4699. * @param projection defines the projection matrix
  4700. * @param zmin defines the near clip plane
  4701. * @param zmax defines the far clip plane
  4702. * @returns the transformation matrix
  4703. */
  4704. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4705. /**
  4706. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4707. * @param matrix defines the matrix to use
  4708. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4709. */
  4710. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4711. /**
  4712. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4713. * @param matrix defines the matrix to use
  4714. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4715. */
  4716. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4717. /**
  4718. * Compute the transpose of a given matrix
  4719. * @param matrix defines the matrix to transpose
  4720. * @returns the new matrix
  4721. */
  4722. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4723. /**
  4724. * Compute the transpose of a matrix and store it in a target matrix
  4725. * @param matrix defines the matrix to transpose
  4726. * @param result defines the target matrix
  4727. */
  4728. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4729. /**
  4730. * Computes a reflection matrix from a plane
  4731. * @param plane defines the reflection plane
  4732. * @returns a new matrix
  4733. */
  4734. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4735. /**
  4736. * Computes a reflection matrix from a plane
  4737. * @param plane defines the reflection plane
  4738. * @param result defines the target matrix
  4739. */
  4740. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4741. /**
  4742. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4743. * @param xaxis defines the value of the 1st axis
  4744. * @param yaxis defines the value of the 2nd axis
  4745. * @param zaxis defines the value of the 3rd axis
  4746. * @param result defines the target matrix
  4747. */
  4748. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4749. /**
  4750. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4751. * @param quat defines the quaternion to use
  4752. * @param result defines the target matrix
  4753. */
  4754. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4755. }
  4756. /**
  4757. * @hidden
  4758. */
  4759. export class TmpVectors {
  4760. static Vector2: Vector2[];
  4761. static Vector3: Vector3[];
  4762. static Vector4: Vector4[];
  4763. static Quaternion: Quaternion[];
  4764. static Matrix: Matrix[];
  4765. }
  4766. }
  4767. declare module BABYLON {
  4768. /**
  4769. * Defines potential orientation for back face culling
  4770. */
  4771. export enum Orientation {
  4772. /**
  4773. * Clockwise
  4774. */
  4775. CW = 0,
  4776. /** Counter clockwise */
  4777. CCW = 1
  4778. }
  4779. /** Class used to represent a Bezier curve */
  4780. export class BezierCurve {
  4781. /**
  4782. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4783. * @param t defines the time
  4784. * @param x1 defines the left coordinate on X axis
  4785. * @param y1 defines the left coordinate on Y axis
  4786. * @param x2 defines the right coordinate on X axis
  4787. * @param y2 defines the right coordinate on Y axis
  4788. * @returns the interpolated value
  4789. */
  4790. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4791. }
  4792. /**
  4793. * Defines angle representation
  4794. */
  4795. export class Angle {
  4796. private _radians;
  4797. /**
  4798. * Creates an Angle object of "radians" radians (float).
  4799. * @param radians the angle in radians
  4800. */
  4801. constructor(radians: number);
  4802. /**
  4803. * Get value in degrees
  4804. * @returns the Angle value in degrees (float)
  4805. */
  4806. degrees(): number;
  4807. /**
  4808. * Get value in radians
  4809. * @returns the Angle value in radians (float)
  4810. */
  4811. radians(): number;
  4812. /**
  4813. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4814. * @param a defines first vector
  4815. * @param b defines second vector
  4816. * @returns a new Angle
  4817. */
  4818. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4819. /**
  4820. * Gets a new Angle object from the given float in radians
  4821. * @param radians defines the angle value in radians
  4822. * @returns a new Angle
  4823. */
  4824. static FromRadians(radians: number): Angle;
  4825. /**
  4826. * Gets a new Angle object from the given float in degrees
  4827. * @param degrees defines the angle value in degrees
  4828. * @returns a new Angle
  4829. */
  4830. static FromDegrees(degrees: number): Angle;
  4831. }
  4832. /**
  4833. * This represents an arc in a 2d space.
  4834. */
  4835. export class Arc2 {
  4836. /** Defines the start point of the arc */
  4837. startPoint: Vector2;
  4838. /** Defines the mid point of the arc */
  4839. midPoint: Vector2;
  4840. /** Defines the end point of the arc */
  4841. endPoint: Vector2;
  4842. /**
  4843. * Defines the center point of the arc.
  4844. */
  4845. centerPoint: Vector2;
  4846. /**
  4847. * Defines the radius of the arc.
  4848. */
  4849. radius: number;
  4850. /**
  4851. * Defines the angle of the arc (from mid point to end point).
  4852. */
  4853. angle: Angle;
  4854. /**
  4855. * Defines the start angle of the arc (from start point to middle point).
  4856. */
  4857. startAngle: Angle;
  4858. /**
  4859. * Defines the orientation of the arc (clock wise/counter clock wise).
  4860. */
  4861. orientation: Orientation;
  4862. /**
  4863. * Creates an Arc object from the three given points : start, middle and end.
  4864. * @param startPoint Defines the start point of the arc
  4865. * @param midPoint Defines the midlle point of the arc
  4866. * @param endPoint Defines the end point of the arc
  4867. */
  4868. constructor(
  4869. /** Defines the start point of the arc */
  4870. startPoint: Vector2,
  4871. /** Defines the mid point of the arc */
  4872. midPoint: Vector2,
  4873. /** Defines the end point of the arc */
  4874. endPoint: Vector2);
  4875. }
  4876. /**
  4877. * Represents a 2D path made up of multiple 2D points
  4878. */
  4879. export class Path2 {
  4880. private _points;
  4881. private _length;
  4882. /**
  4883. * If the path start and end point are the same
  4884. */
  4885. closed: boolean;
  4886. /**
  4887. * Creates a Path2 object from the starting 2D coordinates x and y.
  4888. * @param x the starting points x value
  4889. * @param y the starting points y value
  4890. */
  4891. constructor(x: number, y: number);
  4892. /**
  4893. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4894. * @param x the added points x value
  4895. * @param y the added points y value
  4896. * @returns the updated Path2.
  4897. */
  4898. addLineTo(x: number, y: number): Path2;
  4899. /**
  4900. * 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.
  4901. * @param midX middle point x value
  4902. * @param midY middle point y value
  4903. * @param endX end point x value
  4904. * @param endY end point y value
  4905. * @param numberOfSegments (default: 36)
  4906. * @returns the updated Path2.
  4907. */
  4908. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4909. /**
  4910. * Closes the Path2.
  4911. * @returns the Path2.
  4912. */
  4913. close(): Path2;
  4914. /**
  4915. * Gets the sum of the distance between each sequential point in the path
  4916. * @returns the Path2 total length (float).
  4917. */
  4918. length(): number;
  4919. /**
  4920. * Gets the points which construct the path
  4921. * @returns the Path2 internal array of points.
  4922. */
  4923. getPoints(): Vector2[];
  4924. /**
  4925. * Retreives the point at the distance aways from the starting point
  4926. * @param normalizedLengthPosition the length along the path to retreive the point from
  4927. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4928. */
  4929. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4930. /**
  4931. * Creates a new path starting from an x and y position
  4932. * @param x starting x value
  4933. * @param y starting y value
  4934. * @returns a new Path2 starting at the coordinates (x, y).
  4935. */
  4936. static StartingAt(x: number, y: number): Path2;
  4937. }
  4938. /**
  4939. * Represents a 3D path made up of multiple 3D points
  4940. */
  4941. export class Path3D {
  4942. /**
  4943. * an array of Vector3, the curve axis of the Path3D
  4944. */
  4945. path: Vector3[];
  4946. private _curve;
  4947. private _distances;
  4948. private _tangents;
  4949. private _normals;
  4950. private _binormals;
  4951. private _raw;
  4952. private _alignTangentsWithPath;
  4953. private readonly _pointAtData;
  4954. /**
  4955. * new Path3D(path, normal, raw)
  4956. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4957. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4958. * @param path an array of Vector3, the curve axis of the Path3D
  4959. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4960. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4961. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4962. */
  4963. constructor(
  4964. /**
  4965. * an array of Vector3, the curve axis of the Path3D
  4966. */
  4967. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4968. /**
  4969. * Returns the Path3D array of successive Vector3 designing its curve.
  4970. * @returns the Path3D array of successive Vector3 designing its curve.
  4971. */
  4972. getCurve(): Vector3[];
  4973. /**
  4974. * Returns the Path3D array of successive Vector3 designing its curve.
  4975. * @returns the Path3D array of successive Vector3 designing its curve.
  4976. */
  4977. getPoints(): Vector3[];
  4978. /**
  4979. * @returns the computed length (float) of the path.
  4980. */
  4981. length(): number;
  4982. /**
  4983. * Returns an array populated with tangent vectors on each Path3D curve point.
  4984. * @returns an array populated with tangent vectors on each Path3D curve point.
  4985. */
  4986. getTangents(): Vector3[];
  4987. /**
  4988. * Returns an array populated with normal vectors on each Path3D curve point.
  4989. * @returns an array populated with normal vectors on each Path3D curve point.
  4990. */
  4991. getNormals(): Vector3[];
  4992. /**
  4993. * Returns an array populated with binormal vectors on each Path3D curve point.
  4994. * @returns an array populated with binormal vectors on each Path3D curve point.
  4995. */
  4996. getBinormals(): Vector3[];
  4997. /**
  4998. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4999. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5000. */
  5001. getDistances(): number[];
  5002. /**
  5003. * Returns an interpolated point along this path
  5004. * @param position the position of the point along this path, from 0.0 to 1.0
  5005. * @returns a new Vector3 as the point
  5006. */
  5007. getPointAt(position: number): Vector3;
  5008. /**
  5009. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5010. * @param position the position of the point along this path, from 0.0 to 1.0
  5011. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5012. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5013. */
  5014. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5015. /**
  5016. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5017. * @param position the position of the point along this path, from 0.0 to 1.0
  5018. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5019. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5020. */
  5021. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5022. /**
  5023. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5024. * @param position the position of the point along this path, from 0.0 to 1.0
  5025. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5026. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5027. */
  5028. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5029. /**
  5030. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5031. * @param position the position of the point along this path, from 0.0 to 1.0
  5032. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5033. */
  5034. getDistanceAt(position: number): number;
  5035. /**
  5036. * Returns the array index of the previous point of an interpolated point along this path
  5037. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5038. * @returns the array index
  5039. */
  5040. getPreviousPointIndexAt(position: number): number;
  5041. /**
  5042. * 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)
  5043. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5044. * @returns the sub position
  5045. */
  5046. getSubPositionAt(position: number): number;
  5047. /**
  5048. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5049. * @param target the vector of which to get the closest position to
  5050. * @returns the position of the closest virtual point on this path to the target vector
  5051. */
  5052. getClosestPositionTo(target: Vector3): number;
  5053. /**
  5054. * Returns a sub path (slice) of this path
  5055. * @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
  5056. * @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
  5057. * @returns a sub path (slice) of this path
  5058. */
  5059. slice(start?: number, end?: number): Path3D;
  5060. /**
  5061. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5062. * @param path path which all values are copied into the curves points
  5063. * @param firstNormal which should be projected onto the curve
  5064. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5065. * @returns the same object updated.
  5066. */
  5067. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5068. private _compute;
  5069. private _getFirstNonNullVector;
  5070. private _getLastNonNullVector;
  5071. private _normalVector;
  5072. /**
  5073. * Updates the point at data for an interpolated point along this curve
  5074. * @param position the position of the point along this curve, from 0.0 to 1.0
  5075. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5076. * @returns the (updated) point at data
  5077. */
  5078. private _updatePointAtData;
  5079. /**
  5080. * Updates the point at data from the specified parameters
  5081. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5082. * @param point the interpolated point
  5083. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5084. */
  5085. private _setPointAtData;
  5086. /**
  5087. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5088. */
  5089. private _updateInterpolationMatrix;
  5090. }
  5091. /**
  5092. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5093. * A Curve3 is designed from a series of successive Vector3.
  5094. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5095. */
  5096. export class Curve3 {
  5097. private _points;
  5098. private _length;
  5099. /**
  5100. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5101. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5102. * @param v1 (Vector3) the control point
  5103. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5104. * @param nbPoints (integer) the wanted number of points in the curve
  5105. * @returns the created Curve3
  5106. */
  5107. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5108. /**
  5109. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5110. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5111. * @param v1 (Vector3) the first control point
  5112. * @param v2 (Vector3) the second control point
  5113. * @param v3 (Vector3) the end point of the Cubic Bezier
  5114. * @param nbPoints (integer) the wanted number of points in the curve
  5115. * @returns the created Curve3
  5116. */
  5117. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5118. /**
  5119. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5120. * @param p1 (Vector3) the origin point of the Hermite Spline
  5121. * @param t1 (Vector3) the tangent vector at the origin point
  5122. * @param p2 (Vector3) the end point of the Hermite Spline
  5123. * @param t2 (Vector3) the tangent vector at the end point
  5124. * @param nbPoints (integer) the wanted number of points in the curve
  5125. * @returns the created Curve3
  5126. */
  5127. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5128. /**
  5129. * Returns a Curve3 object along a CatmullRom Spline curve :
  5130. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5131. * @param nbPoints (integer) the wanted number of points between each curve control points
  5132. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5133. * @returns the created Curve3
  5134. */
  5135. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5136. /**
  5137. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5138. * A Curve3 is designed from a series of successive Vector3.
  5139. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5140. * @param points points which make up the curve
  5141. */
  5142. constructor(points: Vector3[]);
  5143. /**
  5144. * @returns the Curve3 stored array of successive Vector3
  5145. */
  5146. getPoints(): Vector3[];
  5147. /**
  5148. * @returns the computed length (float) of the curve.
  5149. */
  5150. length(): number;
  5151. /**
  5152. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5153. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5154. * curveA and curveB keep unchanged.
  5155. * @param curve the curve to continue from this curve
  5156. * @returns the newly constructed curve
  5157. */
  5158. continue(curve: DeepImmutable<Curve3>): Curve3;
  5159. private _computeLength;
  5160. }
  5161. }
  5162. declare module BABYLON {
  5163. /**
  5164. * This represents the main contract an easing function should follow.
  5165. * Easing functions are used throughout the animation system.
  5166. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5167. */
  5168. export interface IEasingFunction {
  5169. /**
  5170. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5171. * of the easing function.
  5172. * The link below provides some of the most common examples of easing functions.
  5173. * @see https://easings.net/
  5174. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5175. * @returns the corresponding value on the curve defined by the easing function
  5176. */
  5177. ease(gradient: number): number;
  5178. }
  5179. /**
  5180. * Base class used for every default easing function.
  5181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5182. */
  5183. export class EasingFunction implements IEasingFunction {
  5184. /**
  5185. * Interpolation follows the mathematical formula associated with the easing function.
  5186. */
  5187. static readonly EASINGMODE_EASEIN: number;
  5188. /**
  5189. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5190. */
  5191. static readonly EASINGMODE_EASEOUT: number;
  5192. /**
  5193. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5194. */
  5195. static readonly EASINGMODE_EASEINOUT: number;
  5196. private _easingMode;
  5197. /**
  5198. * Sets the easing mode of the current function.
  5199. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5200. */
  5201. setEasingMode(easingMode: number): void;
  5202. /**
  5203. * Gets the current easing mode.
  5204. * @returns the easing mode
  5205. */
  5206. getEasingMode(): number;
  5207. /**
  5208. * @hidden
  5209. */
  5210. easeInCore(gradient: number): number;
  5211. /**
  5212. * Given an input gradient between 0 and 1, this returns the corresponding value
  5213. * of the easing function.
  5214. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5215. * @returns the corresponding value on the curve defined by the easing function
  5216. */
  5217. ease(gradient: number): number;
  5218. }
  5219. /**
  5220. * Easing function with a circle shape (see link below).
  5221. * @see https://easings.net/#easeInCirc
  5222. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5223. */
  5224. export class CircleEase extends EasingFunction implements IEasingFunction {
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a ease back shape (see link below).
  5230. * @see https://easings.net/#easeInBack
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class BackEase extends EasingFunction implements IEasingFunction {
  5234. /** Defines the amplitude of the function */
  5235. amplitude: number;
  5236. /**
  5237. * Instantiates a back ease easing
  5238. * @see https://easings.net/#easeInBack
  5239. * @param amplitude Defines the amplitude of the function
  5240. */
  5241. constructor(
  5242. /** Defines the amplitude of the function */
  5243. amplitude?: number);
  5244. /** @hidden */
  5245. easeInCore(gradient: number): number;
  5246. }
  5247. /**
  5248. * Easing function with a bouncing shape (see link below).
  5249. * @see https://easings.net/#easeInBounce
  5250. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5251. */
  5252. export class BounceEase extends EasingFunction implements IEasingFunction {
  5253. /** Defines the number of bounces */
  5254. bounces: number;
  5255. /** Defines the amplitude of the bounce */
  5256. bounciness: number;
  5257. /**
  5258. * Instantiates a bounce easing
  5259. * @see https://easings.net/#easeInBounce
  5260. * @param bounces Defines the number of bounces
  5261. * @param bounciness Defines the amplitude of the bounce
  5262. */
  5263. constructor(
  5264. /** Defines the number of bounces */
  5265. bounces?: number,
  5266. /** Defines the amplitude of the bounce */
  5267. bounciness?: number);
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a power of 3 shape (see link below).
  5273. * @see https://easings.net/#easeInCubic
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class CubicEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with an elastic shape (see link below).
  5282. * @see https://easings.net/#easeInElastic
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the number of oscillations*/
  5287. oscillations: number;
  5288. /** Defines the amplitude of the oscillations*/
  5289. springiness: number;
  5290. /**
  5291. * Instantiates an elastic easing function
  5292. * @see https://easings.net/#easeInElastic
  5293. * @param oscillations Defines the number of oscillations
  5294. * @param springiness Defines the amplitude of the oscillations
  5295. */
  5296. constructor(
  5297. /** Defines the number of oscillations*/
  5298. oscillations?: number,
  5299. /** Defines the amplitude of the oscillations*/
  5300. springiness?: number);
  5301. /** @hidden */
  5302. easeInCore(gradient: number): number;
  5303. }
  5304. /**
  5305. * Easing function with an exponential shape (see link below).
  5306. * @see https://easings.net/#easeInExpo
  5307. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5308. */
  5309. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5310. /** Defines the exponent of the function */
  5311. exponent: number;
  5312. /**
  5313. * Instantiates an exponential easing function
  5314. * @see https://easings.net/#easeInExpo
  5315. * @param exponent Defines the exponent of the function
  5316. */
  5317. constructor(
  5318. /** Defines the exponent of the function */
  5319. exponent?: number);
  5320. /** @hidden */
  5321. easeInCore(gradient: number): number;
  5322. }
  5323. /**
  5324. * Easing function with a power shape (see link below).
  5325. * @see https://easings.net/#easeInQuad
  5326. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5327. */
  5328. export class PowerEase extends EasingFunction implements IEasingFunction {
  5329. /** Defines the power of the function */
  5330. power: number;
  5331. /**
  5332. * Instantiates an power base easing function
  5333. * @see https://easings.net/#easeInQuad
  5334. * @param power Defines the power of the function
  5335. */
  5336. constructor(
  5337. /** Defines the power of the function */
  5338. power?: number);
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with a power of 2 shape (see link below).
  5344. * @see https://easings.net/#easeInQuad
  5345. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5348. /** @hidden */
  5349. easeInCore(gradient: number): number;
  5350. }
  5351. /**
  5352. * Easing function with a power of 4 shape (see link below).
  5353. * @see https://easings.net/#easeInQuart
  5354. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5355. */
  5356. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5357. /** @hidden */
  5358. easeInCore(gradient: number): number;
  5359. }
  5360. /**
  5361. * Easing function with a power of 5 shape (see link below).
  5362. * @see https://easings.net/#easeInQuint
  5363. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5364. */
  5365. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5366. /** @hidden */
  5367. easeInCore(gradient: number): number;
  5368. }
  5369. /**
  5370. * Easing function with a sin shape (see link below).
  5371. * @see https://easings.net/#easeInSine
  5372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5373. */
  5374. export class SineEase extends EasingFunction implements IEasingFunction {
  5375. /** @hidden */
  5376. easeInCore(gradient: number): number;
  5377. }
  5378. /**
  5379. * Easing function with a bezier shape (see link below).
  5380. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5382. */
  5383. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5384. /** Defines the x component of the start tangent in the bezier curve */
  5385. x1: number;
  5386. /** Defines the y component of the start tangent in the bezier curve */
  5387. y1: number;
  5388. /** Defines the x component of the end tangent in the bezier curve */
  5389. x2: number;
  5390. /** Defines the y component of the end tangent in the bezier curve */
  5391. y2: number;
  5392. /**
  5393. * Instantiates a bezier function
  5394. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5395. * @param x1 Defines the x component of the start tangent in the bezier curve
  5396. * @param y1 Defines the y component of the start tangent in the bezier curve
  5397. * @param x2 Defines the x component of the end tangent in the bezier curve
  5398. * @param y2 Defines the y component of the end tangent in the bezier curve
  5399. */
  5400. constructor(
  5401. /** Defines the x component of the start tangent in the bezier curve */
  5402. x1?: number,
  5403. /** Defines the y component of the start tangent in the bezier curve */
  5404. y1?: number,
  5405. /** Defines the x component of the end tangent in the bezier curve */
  5406. x2?: number,
  5407. /** Defines the y component of the end tangent in the bezier curve */
  5408. y2?: number);
  5409. /** @hidden */
  5410. easeInCore(gradient: number): number;
  5411. }
  5412. }
  5413. declare module BABYLON {
  5414. /**
  5415. * Class used to hold a RBG color
  5416. */
  5417. export class Color3 {
  5418. /**
  5419. * Defines the red component (between 0 and 1, default is 0)
  5420. */
  5421. r: number;
  5422. /**
  5423. * Defines the green component (between 0 and 1, default is 0)
  5424. */
  5425. g: number;
  5426. /**
  5427. * Defines the blue component (between 0 and 1, default is 0)
  5428. */
  5429. b: number;
  5430. /**
  5431. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5432. * @param r defines the red component (between 0 and 1, default is 0)
  5433. * @param g defines the green component (between 0 and 1, default is 0)
  5434. * @param b defines the blue component (between 0 and 1, default is 0)
  5435. */
  5436. constructor(
  5437. /**
  5438. * Defines the red component (between 0 and 1, default is 0)
  5439. */
  5440. r?: number,
  5441. /**
  5442. * Defines the green component (between 0 and 1, default is 0)
  5443. */
  5444. g?: number,
  5445. /**
  5446. * Defines the blue component (between 0 and 1, default is 0)
  5447. */
  5448. b?: number);
  5449. /**
  5450. * Creates a string with the Color3 current values
  5451. * @returns the string representation of the Color3 object
  5452. */
  5453. toString(): string;
  5454. /**
  5455. * Returns the string "Color3"
  5456. * @returns "Color3"
  5457. */
  5458. getClassName(): string;
  5459. /**
  5460. * Compute the Color3 hash code
  5461. * @returns an unique number that can be used to hash Color3 objects
  5462. */
  5463. getHashCode(): number;
  5464. /**
  5465. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5466. * @param array defines the array where to store the r,g,b components
  5467. * @param index defines an optional index in the target array to define where to start storing values
  5468. * @returns the current Color3 object
  5469. */
  5470. toArray(array: FloatArray, index?: number): Color3;
  5471. /**
  5472. * Returns a new Color4 object from the current Color3 and the given alpha
  5473. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5474. * @returns a new Color4 object
  5475. */
  5476. toColor4(alpha?: number): Color4;
  5477. /**
  5478. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5479. * @returns the new array
  5480. */
  5481. asArray(): number[];
  5482. /**
  5483. * Returns the luminance value
  5484. * @returns a float value
  5485. */
  5486. toLuminance(): number;
  5487. /**
  5488. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5489. * @param otherColor defines the second operand
  5490. * @returns the new Color3 object
  5491. */
  5492. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5493. /**
  5494. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5495. * @param otherColor defines the second operand
  5496. * @param result defines the Color3 object where to store the result
  5497. * @returns the current Color3
  5498. */
  5499. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5500. /**
  5501. * Determines equality between Color3 objects
  5502. * @param otherColor defines the second operand
  5503. * @returns true if the rgb values are equal to the given ones
  5504. */
  5505. equals(otherColor: DeepImmutable<Color3>): boolean;
  5506. /**
  5507. * Determines equality between the current Color3 object and a set of r,b,g values
  5508. * @param r defines the red component to check
  5509. * @param g defines the green component to check
  5510. * @param b defines the blue component to check
  5511. * @returns true if the rgb values are equal to the given ones
  5512. */
  5513. equalsFloats(r: number, g: number, b: number): boolean;
  5514. /**
  5515. * Multiplies in place each rgb value by scale
  5516. * @param scale defines the scaling factor
  5517. * @returns the updated Color3
  5518. */
  5519. scale(scale: number): Color3;
  5520. /**
  5521. * Multiplies the rgb values by scale and stores the result into "result"
  5522. * @param scale defines the scaling factor
  5523. * @param result defines the Color3 object where to store the result
  5524. * @returns the unmodified current Color3
  5525. */
  5526. scaleToRef(scale: number, result: Color3): Color3;
  5527. /**
  5528. * Scale the current Color3 values by a factor and add the result to a given Color3
  5529. * @param scale defines the scale factor
  5530. * @param result defines color to store the result into
  5531. * @returns the unmodified current Color3
  5532. */
  5533. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5534. /**
  5535. * Clamps the rgb values by the min and max values and stores the result into "result"
  5536. * @param min defines minimum clamping value (default is 0)
  5537. * @param max defines maximum clamping value (default is 1)
  5538. * @param result defines color to store the result into
  5539. * @returns the original Color3
  5540. */
  5541. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5542. /**
  5543. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5544. * @param otherColor defines the second operand
  5545. * @returns the new Color3
  5546. */
  5547. add(otherColor: DeepImmutable<Color3>): Color3;
  5548. /**
  5549. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5550. * @param otherColor defines the second operand
  5551. * @param result defines Color3 object to store the result into
  5552. * @returns the unmodified current Color3
  5553. */
  5554. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5555. /**
  5556. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5557. * @param otherColor defines the second operand
  5558. * @returns the new Color3
  5559. */
  5560. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5561. /**
  5562. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5563. * @param otherColor defines the second operand
  5564. * @param result defines Color3 object to store the result into
  5565. * @returns the unmodified current Color3
  5566. */
  5567. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5568. /**
  5569. * Copy the current object
  5570. * @returns a new Color3 copied the current one
  5571. */
  5572. clone(): Color3;
  5573. /**
  5574. * Copies the rgb values from the source in the current Color3
  5575. * @param source defines the source Color3 object
  5576. * @returns the updated Color3 object
  5577. */
  5578. copyFrom(source: DeepImmutable<Color3>): Color3;
  5579. /**
  5580. * Updates the Color3 rgb values from the given floats
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @returns the current Color3 object
  5585. */
  5586. copyFromFloats(r: number, g: number, b: number): Color3;
  5587. /**
  5588. * Updates the Color3 rgb values from the given floats
  5589. * @param r defines the red component to read from
  5590. * @param g defines the green component to read from
  5591. * @param b defines the blue component to read from
  5592. * @returns the current Color3 object
  5593. */
  5594. set(r: number, g: number, b: number): Color3;
  5595. /**
  5596. * Compute the Color3 hexadecimal code as a string
  5597. * @returns a string containing the hexadecimal representation of the Color3 object
  5598. */
  5599. toHexString(): string;
  5600. /**
  5601. * Computes a new Color3 converted from the current one to linear space
  5602. * @returns a new Color3 object
  5603. */
  5604. toLinearSpace(): Color3;
  5605. /**
  5606. * Converts current color in rgb space to HSV values
  5607. * @returns a new color3 representing the HSV values
  5608. */
  5609. toHSV(): Color3;
  5610. /**
  5611. * Converts current color in rgb space to HSV values
  5612. * @param result defines the Color3 where to store the HSV values
  5613. */
  5614. toHSVToRef(result: Color3): void;
  5615. /**
  5616. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5617. * @param convertedColor defines the Color3 object where to store the linear space version
  5618. * @returns the unmodified Color3
  5619. */
  5620. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5621. /**
  5622. * Computes a new Color3 converted from the current one to gamma space
  5623. * @returns a new Color3 object
  5624. */
  5625. toGammaSpace(): Color3;
  5626. /**
  5627. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5628. * @param convertedColor defines the Color3 object where to store the gamma space version
  5629. * @returns the unmodified Color3
  5630. */
  5631. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5632. private static _BlackReadOnly;
  5633. /**
  5634. * Convert Hue, saturation and value to a Color3 (RGB)
  5635. * @param hue defines the hue
  5636. * @param saturation defines the saturation
  5637. * @param value defines the value
  5638. * @param result defines the Color3 where to store the RGB values
  5639. */
  5640. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5641. /**
  5642. * Creates a new Color3 from the string containing valid hexadecimal values
  5643. * @param hex defines a string containing valid hexadecimal values
  5644. * @returns a new Color3 object
  5645. */
  5646. static FromHexString(hex: string): Color3;
  5647. /**
  5648. * Creates a new Color3 from the starting index of the given array
  5649. * @param array defines the source array
  5650. * @param offset defines an offset in the source array
  5651. * @returns a new Color3 object
  5652. */
  5653. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5654. /**
  5655. * Creates a new Color3 from integer values (< 256)
  5656. * @param r defines the red component to read from (value between 0 and 255)
  5657. * @param g defines the green component to read from (value between 0 and 255)
  5658. * @param b defines the blue component to read from (value between 0 and 255)
  5659. * @returns a new Color3 object
  5660. */
  5661. static FromInts(r: number, g: number, b: number): Color3;
  5662. /**
  5663. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5664. * @param start defines the start Color3 value
  5665. * @param end defines the end Color3 value
  5666. * @param amount defines the gradient value between start and end
  5667. * @returns a new Color3 object
  5668. */
  5669. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5670. /**
  5671. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5672. * @param left defines the start value
  5673. * @param right defines the end value
  5674. * @param amount defines the gradient factor
  5675. * @param result defines the Color3 object where to store the result
  5676. */
  5677. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5678. /**
  5679. * Returns a Color3 value containing a red color
  5680. * @returns a new Color3 object
  5681. */
  5682. static Red(): Color3;
  5683. /**
  5684. * Returns a Color3 value containing a green color
  5685. * @returns a new Color3 object
  5686. */
  5687. static Green(): Color3;
  5688. /**
  5689. * Returns a Color3 value containing a blue color
  5690. * @returns a new Color3 object
  5691. */
  5692. static Blue(): Color3;
  5693. /**
  5694. * Returns a Color3 value containing a black color
  5695. * @returns a new Color3 object
  5696. */
  5697. static Black(): Color3;
  5698. /**
  5699. * Gets a Color3 value containing a black color that must not be updated
  5700. */
  5701. static get BlackReadOnly(): DeepImmutable<Color3>;
  5702. /**
  5703. * Returns a Color3 value containing a white color
  5704. * @returns a new Color3 object
  5705. */
  5706. static White(): Color3;
  5707. /**
  5708. * Returns a Color3 value containing a purple color
  5709. * @returns a new Color3 object
  5710. */
  5711. static Purple(): Color3;
  5712. /**
  5713. * Returns a Color3 value containing a magenta color
  5714. * @returns a new Color3 object
  5715. */
  5716. static Magenta(): Color3;
  5717. /**
  5718. * Returns a Color3 value containing a yellow color
  5719. * @returns a new Color3 object
  5720. */
  5721. static Yellow(): Color3;
  5722. /**
  5723. * Returns a Color3 value containing a gray color
  5724. * @returns a new Color3 object
  5725. */
  5726. static Gray(): Color3;
  5727. /**
  5728. * Returns a Color3 value containing a teal color
  5729. * @returns a new Color3 object
  5730. */
  5731. static Teal(): Color3;
  5732. /**
  5733. * Returns a Color3 value containing a random color
  5734. * @returns a new Color3 object
  5735. */
  5736. static Random(): Color3;
  5737. }
  5738. /**
  5739. * Class used to hold a RBGA color
  5740. */
  5741. export class Color4 {
  5742. /**
  5743. * Defines the red component (between 0 and 1, default is 0)
  5744. */
  5745. r: number;
  5746. /**
  5747. * Defines the green component (between 0 and 1, default is 0)
  5748. */
  5749. g: number;
  5750. /**
  5751. * Defines the blue component (between 0 and 1, default is 0)
  5752. */
  5753. b: number;
  5754. /**
  5755. * Defines the alpha component (between 0 and 1, default is 1)
  5756. */
  5757. a: number;
  5758. /**
  5759. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5760. * @param r defines the red component (between 0 and 1, default is 0)
  5761. * @param g defines the green component (between 0 and 1, default is 0)
  5762. * @param b defines the blue component (between 0 and 1, default is 0)
  5763. * @param a defines the alpha component (between 0 and 1, default is 1)
  5764. */
  5765. constructor(
  5766. /**
  5767. * Defines the red component (between 0 and 1, default is 0)
  5768. */
  5769. r?: number,
  5770. /**
  5771. * Defines the green component (between 0 and 1, default is 0)
  5772. */
  5773. g?: number,
  5774. /**
  5775. * Defines the blue component (between 0 and 1, default is 0)
  5776. */
  5777. b?: number,
  5778. /**
  5779. * Defines the alpha component (between 0 and 1, default is 1)
  5780. */
  5781. a?: number);
  5782. /**
  5783. * Adds in place the given Color4 values to the current Color4 object
  5784. * @param right defines the second operand
  5785. * @returns the current updated Color4 object
  5786. */
  5787. addInPlace(right: DeepImmutable<Color4>): Color4;
  5788. /**
  5789. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5790. * @returns the new array
  5791. */
  5792. asArray(): number[];
  5793. /**
  5794. * Stores from the starting index in the given array the Color4 successive values
  5795. * @param array defines the array where to store the r,g,b components
  5796. * @param index defines an optional index in the target array to define where to start storing values
  5797. * @returns the current Color4 object
  5798. */
  5799. toArray(array: number[], index?: number): Color4;
  5800. /**
  5801. * Determines equality between Color4 objects
  5802. * @param otherColor defines the second operand
  5803. * @returns true if the rgba values are equal to the given ones
  5804. */
  5805. equals(otherColor: DeepImmutable<Color4>): boolean;
  5806. /**
  5807. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5808. * @param right defines the second operand
  5809. * @returns a new Color4 object
  5810. */
  5811. add(right: DeepImmutable<Color4>): Color4;
  5812. /**
  5813. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5814. * @param right defines the second operand
  5815. * @returns a new Color4 object
  5816. */
  5817. subtract(right: DeepImmutable<Color4>): Color4;
  5818. /**
  5819. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5820. * @param right defines the second operand
  5821. * @param result defines the Color4 object where to store the result
  5822. * @returns the current Color4 object
  5823. */
  5824. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5825. /**
  5826. * Creates a new Color4 with the current Color4 values multiplied by scale
  5827. * @param scale defines the scaling factor to apply
  5828. * @returns a new Color4 object
  5829. */
  5830. scale(scale: number): Color4;
  5831. /**
  5832. * Multiplies the current Color4 values by scale and stores the result in "result"
  5833. * @param scale defines the scaling factor to apply
  5834. * @param result defines the Color4 object where to store the result
  5835. * @returns the current unmodified Color4
  5836. */
  5837. scaleToRef(scale: number, result: Color4): Color4;
  5838. /**
  5839. * Scale the current Color4 values by a factor and add the result to a given Color4
  5840. * @param scale defines the scale factor
  5841. * @param result defines the Color4 object where to store the result
  5842. * @returns the unmodified current Color4
  5843. */
  5844. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5845. /**
  5846. * Clamps the rgb values by the min and max values and stores the result into "result"
  5847. * @param min defines minimum clamping value (default is 0)
  5848. * @param max defines maximum clamping value (default is 1)
  5849. * @param result defines color to store the result into.
  5850. * @returns the cuurent Color4
  5851. */
  5852. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5853. /**
  5854. * Multipy an Color4 value by another and return a new Color4 object
  5855. * @param color defines the Color4 value to multiply by
  5856. * @returns a new Color4 object
  5857. */
  5858. multiply(color: Color4): Color4;
  5859. /**
  5860. * Multipy a Color4 value by another and push the result in a reference value
  5861. * @param color defines the Color4 value to multiply by
  5862. * @param result defines the Color4 to fill the result in
  5863. * @returns the result Color4
  5864. */
  5865. multiplyToRef(color: Color4, result: Color4): Color4;
  5866. /**
  5867. * Creates a string with the Color4 current values
  5868. * @returns the string representation of the Color4 object
  5869. */
  5870. toString(): string;
  5871. /**
  5872. * Returns the string "Color4"
  5873. * @returns "Color4"
  5874. */
  5875. getClassName(): string;
  5876. /**
  5877. * Compute the Color4 hash code
  5878. * @returns an unique number that can be used to hash Color4 objects
  5879. */
  5880. getHashCode(): number;
  5881. /**
  5882. * Creates a new Color4 copied from the current one
  5883. * @returns a new Color4 object
  5884. */
  5885. clone(): Color4;
  5886. /**
  5887. * Copies the given Color4 values into the current one
  5888. * @param source defines the source Color4 object
  5889. * @returns the current updated Color4 object
  5890. */
  5891. copyFrom(source: Color4): Color4;
  5892. /**
  5893. * Copies the given float values into the current one
  5894. * @param r defines the red component to read from
  5895. * @param g defines the green component to read from
  5896. * @param b defines the blue component to read from
  5897. * @param a defines the alpha component to read from
  5898. * @returns the current updated Color4 object
  5899. */
  5900. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5901. /**
  5902. * Copies the given float values into the current one
  5903. * @param r defines the red component to read from
  5904. * @param g defines the green component to read from
  5905. * @param b defines the blue component to read from
  5906. * @param a defines the alpha component to read from
  5907. * @returns the current updated Color4 object
  5908. */
  5909. set(r: number, g: number, b: number, a: number): Color4;
  5910. /**
  5911. * Compute the Color4 hexadecimal code as a string
  5912. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5913. * @returns a string containing the hexadecimal representation of the Color4 object
  5914. */
  5915. toHexString(returnAsColor3?: boolean): string;
  5916. /**
  5917. * Computes a new Color4 converted from the current one to linear space
  5918. * @returns a new Color4 object
  5919. */
  5920. toLinearSpace(): Color4;
  5921. /**
  5922. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5923. * @param convertedColor defines the Color4 object where to store the linear space version
  5924. * @returns the unmodified Color4
  5925. */
  5926. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5927. /**
  5928. * Computes a new Color4 converted from the current one to gamma space
  5929. * @returns a new Color4 object
  5930. */
  5931. toGammaSpace(): Color4;
  5932. /**
  5933. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5934. * @param convertedColor defines the Color4 object where to store the gamma space version
  5935. * @returns the unmodified Color4
  5936. */
  5937. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5938. /**
  5939. * Creates a new Color4 from the string containing valid hexadecimal values
  5940. * @param hex defines a string containing valid hexadecimal values
  5941. * @returns a new Color4 object
  5942. */
  5943. static FromHexString(hex: string): Color4;
  5944. /**
  5945. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5946. * @param left defines the start value
  5947. * @param right defines the end value
  5948. * @param amount defines the gradient factor
  5949. * @returns a new Color4 object
  5950. */
  5951. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5952. /**
  5953. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5954. * @param left defines the start value
  5955. * @param right defines the end value
  5956. * @param amount defines the gradient factor
  5957. * @param result defines the Color4 object where to store data
  5958. */
  5959. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5960. /**
  5961. * Creates a new Color4 from a Color3 and an alpha value
  5962. * @param color3 defines the source Color3 to read from
  5963. * @param alpha defines the alpha component (1.0 by default)
  5964. * @returns a new Color4 object
  5965. */
  5966. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5967. /**
  5968. * Creates a new Color4 from the starting index element of the given array
  5969. * @param array defines the source array to read from
  5970. * @param offset defines the offset in the source array
  5971. * @returns a new Color4 object
  5972. */
  5973. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5974. /**
  5975. * Creates a new Color3 from integer values (< 256)
  5976. * @param r defines the red component to read from (value between 0 and 255)
  5977. * @param g defines the green component to read from (value between 0 and 255)
  5978. * @param b defines the blue component to read from (value between 0 and 255)
  5979. * @param a defines the alpha component to read from (value between 0 and 255)
  5980. * @returns a new Color3 object
  5981. */
  5982. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5983. /**
  5984. * Check the content of a given array and convert it to an array containing RGBA data
  5985. * If the original array was already containing count * 4 values then it is returned directly
  5986. * @param colors defines the array to check
  5987. * @param count defines the number of RGBA data to expect
  5988. * @returns an array containing count * 4 values (RGBA)
  5989. */
  5990. static CheckColors4(colors: number[], count: number): number[];
  5991. }
  5992. /**
  5993. * @hidden
  5994. */
  5995. export class TmpColors {
  5996. static Color3: Color3[];
  5997. static Color4: Color4[];
  5998. }
  5999. }
  6000. declare module BABYLON {
  6001. /**
  6002. * Defines an interface which represents an animation key frame
  6003. */
  6004. export interface IAnimationKey {
  6005. /**
  6006. * Frame of the key frame
  6007. */
  6008. frame: number;
  6009. /**
  6010. * Value at the specifies key frame
  6011. */
  6012. value: any;
  6013. /**
  6014. * The input tangent for the cubic hermite spline
  6015. */
  6016. inTangent?: any;
  6017. /**
  6018. * The output tangent for the cubic hermite spline
  6019. */
  6020. outTangent?: any;
  6021. /**
  6022. * The animation interpolation type
  6023. */
  6024. interpolation?: AnimationKeyInterpolation;
  6025. }
  6026. /**
  6027. * Enum for the animation key frame interpolation type
  6028. */
  6029. export enum AnimationKeyInterpolation {
  6030. /**
  6031. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6032. */
  6033. STEP = 1
  6034. }
  6035. }
  6036. declare module BABYLON {
  6037. /**
  6038. * Represents the range of an animation
  6039. */
  6040. export class AnimationRange {
  6041. /**The name of the animation range**/
  6042. name: string;
  6043. /**The starting frame of the animation */
  6044. from: number;
  6045. /**The ending frame of the animation*/
  6046. to: number;
  6047. /**
  6048. * Initializes the range of an animation
  6049. * @param name The name of the animation range
  6050. * @param from The starting frame of the animation
  6051. * @param to The ending frame of the animation
  6052. */
  6053. constructor(
  6054. /**The name of the animation range**/
  6055. name: string,
  6056. /**The starting frame of the animation */
  6057. from: number,
  6058. /**The ending frame of the animation*/
  6059. to: number);
  6060. /**
  6061. * Makes a copy of the animation range
  6062. * @returns A copy of the animation range
  6063. */
  6064. clone(): AnimationRange;
  6065. }
  6066. }
  6067. declare module BABYLON {
  6068. /**
  6069. * Composed of a frame, and an action function
  6070. */
  6071. export class AnimationEvent {
  6072. /** The frame for which the event is triggered **/
  6073. frame: number;
  6074. /** The event to perform when triggered **/
  6075. action: (currentFrame: number) => void;
  6076. /** Specifies if the event should be triggered only once**/
  6077. onlyOnce?: boolean | undefined;
  6078. /**
  6079. * Specifies if the animation event is done
  6080. */
  6081. isDone: boolean;
  6082. /**
  6083. * Initializes the animation event
  6084. * @param frame The frame for which the event is triggered
  6085. * @param action The event to perform when triggered
  6086. * @param onlyOnce Specifies if the event should be triggered only once
  6087. */
  6088. constructor(
  6089. /** The frame for which the event is triggered **/
  6090. frame: number,
  6091. /** The event to perform when triggered **/
  6092. action: (currentFrame: number) => void,
  6093. /** Specifies if the event should be triggered only once**/
  6094. onlyOnce?: boolean | undefined);
  6095. /** @hidden */
  6096. _clone(): AnimationEvent;
  6097. }
  6098. }
  6099. declare module BABYLON {
  6100. /**
  6101. * Interface used to define a behavior
  6102. */
  6103. export interface Behavior<T> {
  6104. /** gets or sets behavior's name */
  6105. name: string;
  6106. /**
  6107. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6108. */
  6109. init(): void;
  6110. /**
  6111. * Called when the behavior is attached to a target
  6112. * @param target defines the target where the behavior is attached to
  6113. */
  6114. attach(target: T): void;
  6115. /**
  6116. * Called when the behavior is detached from its target
  6117. */
  6118. detach(): void;
  6119. }
  6120. /**
  6121. * Interface implemented by classes supporting behaviors
  6122. */
  6123. export interface IBehaviorAware<T> {
  6124. /**
  6125. * Attach a behavior
  6126. * @param behavior defines the behavior to attach
  6127. * @returns the current host
  6128. */
  6129. addBehavior(behavior: Behavior<T>): T;
  6130. /**
  6131. * Remove a behavior from the current object
  6132. * @param behavior defines the behavior to detach
  6133. * @returns the current host
  6134. */
  6135. removeBehavior(behavior: Behavior<T>): T;
  6136. /**
  6137. * Gets a behavior using its name to search
  6138. * @param name defines the name to search
  6139. * @returns the behavior or null if not found
  6140. */
  6141. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6142. }
  6143. }
  6144. declare module BABYLON {
  6145. /**
  6146. * Defines an array and its length.
  6147. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6148. */
  6149. export interface ISmartArrayLike<T> {
  6150. /**
  6151. * The data of the array.
  6152. */
  6153. data: Array<T>;
  6154. /**
  6155. * The active length of the array.
  6156. */
  6157. length: number;
  6158. }
  6159. /**
  6160. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6161. */
  6162. export class SmartArray<T> implements ISmartArrayLike<T> {
  6163. /**
  6164. * The full set of data from the array.
  6165. */
  6166. data: Array<T>;
  6167. /**
  6168. * The active length of the array.
  6169. */
  6170. length: number;
  6171. protected _id: number;
  6172. /**
  6173. * Instantiates a Smart Array.
  6174. * @param capacity defines the default capacity of the array.
  6175. */
  6176. constructor(capacity: number);
  6177. /**
  6178. * Pushes a value at the end of the active data.
  6179. * @param value defines the object to push in the array.
  6180. */
  6181. push(value: T): void;
  6182. /**
  6183. * Iterates over the active data and apply the lambda to them.
  6184. * @param func defines the action to apply on each value.
  6185. */
  6186. forEach(func: (content: T) => void): void;
  6187. /**
  6188. * Sorts the full sets of data.
  6189. * @param compareFn defines the comparison function to apply.
  6190. */
  6191. sort(compareFn: (a: T, b: T) => number): void;
  6192. /**
  6193. * Resets the active data to an empty array.
  6194. */
  6195. reset(): void;
  6196. /**
  6197. * Releases all the data from the array as well as the array.
  6198. */
  6199. dispose(): void;
  6200. /**
  6201. * Concats the active data with a given array.
  6202. * @param array defines the data to concatenate with.
  6203. */
  6204. concat(array: any): void;
  6205. /**
  6206. * Returns the position of a value in the active data.
  6207. * @param value defines the value to find the index for
  6208. * @returns the index if found in the active data otherwise -1
  6209. */
  6210. indexOf(value: T): number;
  6211. /**
  6212. * Returns whether an element is part of the active data.
  6213. * @param value defines the value to look for
  6214. * @returns true if found in the active data otherwise false
  6215. */
  6216. contains(value: T): boolean;
  6217. private static _GlobalId;
  6218. }
  6219. /**
  6220. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6221. * The data in this array can only be present once
  6222. */
  6223. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6224. private _duplicateId;
  6225. /**
  6226. * Pushes a value at the end of the active data.
  6227. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6228. * @param value defines the object to push in the array.
  6229. */
  6230. push(value: T): void;
  6231. /**
  6232. * Pushes a value at the end of the active data.
  6233. * If the data is already present, it won t be added again
  6234. * @param value defines the object to push in the array.
  6235. * @returns true if added false if it was already present
  6236. */
  6237. pushNoDuplicate(value: T): boolean;
  6238. /**
  6239. * Resets the active data to an empty array.
  6240. */
  6241. reset(): void;
  6242. /**
  6243. * Concats the active data with a given array.
  6244. * This ensures no dupplicate will be present in the result.
  6245. * @param array defines the data to concatenate with.
  6246. */
  6247. concatWithNoDuplicate(array: any): void;
  6248. }
  6249. }
  6250. declare module BABYLON {
  6251. /**
  6252. * @ignore
  6253. * This is a list of all the different input types that are available in the application.
  6254. * Fo instance: ArcRotateCameraGamepadInput...
  6255. */
  6256. export var CameraInputTypes: {};
  6257. /**
  6258. * This is the contract to implement in order to create a new input class.
  6259. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6260. */
  6261. export interface ICameraInput<TCamera extends Camera> {
  6262. /**
  6263. * Defines the camera the input is attached to.
  6264. */
  6265. camera: Nullable<TCamera>;
  6266. /**
  6267. * Gets the class name of the current intput.
  6268. * @returns the class name
  6269. */
  6270. getClassName(): string;
  6271. /**
  6272. * Get the friendly name associated with the input class.
  6273. * @returns the input friendly name
  6274. */
  6275. getSimpleName(): string;
  6276. /**
  6277. * Attach the input controls to a specific dom element to get the input from.
  6278. * @param element Defines the element the controls should be listened from
  6279. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6280. */
  6281. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6282. /**
  6283. * Detach the current controls from the specified dom element.
  6284. * @param element Defines the element to stop listening the inputs from
  6285. */
  6286. detachControl(element: Nullable<HTMLElement>): void;
  6287. /**
  6288. * Update the current camera state depending on the inputs that have been used this frame.
  6289. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6290. */
  6291. checkInputs?: () => void;
  6292. }
  6293. /**
  6294. * Represents a map of input types to input instance or input index to input instance.
  6295. */
  6296. export interface CameraInputsMap<TCamera extends Camera> {
  6297. /**
  6298. * Accessor to the input by input type.
  6299. */
  6300. [name: string]: ICameraInput<TCamera>;
  6301. /**
  6302. * Accessor to the input by input index.
  6303. */
  6304. [idx: number]: ICameraInput<TCamera>;
  6305. }
  6306. /**
  6307. * This represents the input manager used within a camera.
  6308. * It helps dealing with all the different kind of input attached to a camera.
  6309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6310. */
  6311. export class CameraInputsManager<TCamera extends Camera> {
  6312. /**
  6313. * Defines the list of inputs attahed to the camera.
  6314. */
  6315. attached: CameraInputsMap<TCamera>;
  6316. /**
  6317. * Defines the dom element the camera is collecting inputs from.
  6318. * This is null if the controls have not been attached.
  6319. */
  6320. attachedElement: Nullable<HTMLElement>;
  6321. /**
  6322. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6323. */
  6324. noPreventDefault: boolean;
  6325. /**
  6326. * Defined the camera the input manager belongs to.
  6327. */
  6328. camera: TCamera;
  6329. /**
  6330. * Update the current camera state depending on the inputs that have been used this frame.
  6331. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6332. */
  6333. checkInputs: () => void;
  6334. /**
  6335. * Instantiate a new Camera Input Manager.
  6336. * @param camera Defines the camera the input manager blongs to
  6337. */
  6338. constructor(camera: TCamera);
  6339. /**
  6340. * Add an input method to a camera
  6341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6342. * @param input camera input method
  6343. */
  6344. add(input: ICameraInput<TCamera>): void;
  6345. /**
  6346. * Remove a specific input method from a camera
  6347. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6348. * @param inputToRemove camera input method
  6349. */
  6350. remove(inputToRemove: ICameraInput<TCamera>): void;
  6351. /**
  6352. * Remove a specific input type from a camera
  6353. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6354. * @param inputType the type of the input to remove
  6355. */
  6356. removeByType(inputType: string): void;
  6357. private _addCheckInputs;
  6358. /**
  6359. * Attach the input controls to the currently attached dom element to listen the events from.
  6360. * @param input Defines the input to attach
  6361. */
  6362. attachInput(input: ICameraInput<TCamera>): void;
  6363. /**
  6364. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6365. * @param element Defines the dom element to collect the events from
  6366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6367. */
  6368. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6369. /**
  6370. * Detach the current manager inputs controls from a specific dom element.
  6371. * @param element Defines the dom element to collect the events from
  6372. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6373. */
  6374. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6375. /**
  6376. * Rebuild the dynamic inputCheck function from the current list of
  6377. * defined inputs in the manager.
  6378. */
  6379. rebuildInputCheck(): void;
  6380. /**
  6381. * Remove all attached input methods from a camera
  6382. */
  6383. clear(): void;
  6384. /**
  6385. * Serialize the current input manager attached to a camera.
  6386. * This ensures than once parsed,
  6387. * the input associated to the camera will be identical to the current ones
  6388. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6389. */
  6390. serialize(serializedCamera: any): void;
  6391. /**
  6392. * Parses an input manager serialized JSON to restore the previous list of inputs
  6393. * and states associated to a camera.
  6394. * @param parsedCamera Defines the JSON to parse
  6395. */
  6396. parse(parsedCamera: any): void;
  6397. }
  6398. }
  6399. declare module BABYLON {
  6400. /**
  6401. * Class used to store data that will be store in GPU memory
  6402. */
  6403. export class Buffer {
  6404. private _engine;
  6405. private _buffer;
  6406. /** @hidden */
  6407. _data: Nullable<DataArray>;
  6408. private _updatable;
  6409. private _instanced;
  6410. private _divisor;
  6411. /**
  6412. * Gets the byte stride.
  6413. */
  6414. readonly byteStride: number;
  6415. /**
  6416. * Constructor
  6417. * @param engine the engine
  6418. * @param data the data to use for this buffer
  6419. * @param updatable whether the data is updatable
  6420. * @param stride the stride (optional)
  6421. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6422. * @param instanced whether the buffer is instanced (optional)
  6423. * @param useBytes set to true if the stride in in bytes (optional)
  6424. * @param divisor sets an optional divisor for instances (1 by default)
  6425. */
  6426. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6427. /**
  6428. * Create a new VertexBuffer based on the current buffer
  6429. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6430. * @param offset defines offset in the buffer (0 by default)
  6431. * @param size defines the size in floats of attributes (position is 3 for instance)
  6432. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6433. * @param instanced defines if the vertex buffer contains indexed data
  6434. * @param useBytes defines if the offset and stride are in bytes *
  6435. * @param divisor sets an optional divisor for instances (1 by default)
  6436. * @returns the new vertex buffer
  6437. */
  6438. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6439. /**
  6440. * Gets a boolean indicating if the Buffer is updatable?
  6441. * @returns true if the buffer is updatable
  6442. */
  6443. isUpdatable(): boolean;
  6444. /**
  6445. * Gets current buffer's data
  6446. * @returns a DataArray or null
  6447. */
  6448. getData(): Nullable<DataArray>;
  6449. /**
  6450. * Gets underlying native buffer
  6451. * @returns underlying native buffer
  6452. */
  6453. getBuffer(): Nullable<DataBuffer>;
  6454. /**
  6455. * Gets the stride in float32 units (i.e. byte stride / 4).
  6456. * May not be an integer if the byte stride is not divisible by 4.
  6457. * @returns the stride in float32 units
  6458. * @deprecated Please use byteStride instead.
  6459. */
  6460. getStrideSize(): number;
  6461. /**
  6462. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6463. * @param data defines the data to store
  6464. */
  6465. create(data?: Nullable<DataArray>): void;
  6466. /** @hidden */
  6467. _rebuild(): void;
  6468. /**
  6469. * Update current buffer data
  6470. * @param data defines the data to store
  6471. */
  6472. update(data: DataArray): void;
  6473. /**
  6474. * Updates the data directly.
  6475. * @param data the new data
  6476. * @param offset the new offset
  6477. * @param vertexCount the vertex count (optional)
  6478. * @param useBytes set to true if the offset is in bytes
  6479. */
  6480. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6481. /**
  6482. * Release all resources
  6483. */
  6484. dispose(): void;
  6485. }
  6486. /**
  6487. * Specialized buffer used to store vertex data
  6488. */
  6489. export class VertexBuffer {
  6490. /** @hidden */
  6491. _buffer: Buffer;
  6492. private _kind;
  6493. private _size;
  6494. private _ownsBuffer;
  6495. private _instanced;
  6496. private _instanceDivisor;
  6497. /**
  6498. * The byte type.
  6499. */
  6500. static readonly BYTE: number;
  6501. /**
  6502. * The unsigned byte type.
  6503. */
  6504. static readonly UNSIGNED_BYTE: number;
  6505. /**
  6506. * The short type.
  6507. */
  6508. static readonly SHORT: number;
  6509. /**
  6510. * The unsigned short type.
  6511. */
  6512. static readonly UNSIGNED_SHORT: number;
  6513. /**
  6514. * The integer type.
  6515. */
  6516. static readonly INT: number;
  6517. /**
  6518. * The unsigned integer type.
  6519. */
  6520. static readonly UNSIGNED_INT: number;
  6521. /**
  6522. * The float type.
  6523. */
  6524. static readonly FLOAT: number;
  6525. /**
  6526. * Gets or sets the instance divisor when in instanced mode
  6527. */
  6528. get instanceDivisor(): number;
  6529. set instanceDivisor(value: number);
  6530. /**
  6531. * Gets the byte stride.
  6532. */
  6533. readonly byteStride: number;
  6534. /**
  6535. * Gets the byte offset.
  6536. */
  6537. readonly byteOffset: number;
  6538. /**
  6539. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6540. */
  6541. readonly normalized: boolean;
  6542. /**
  6543. * Gets the data type of each component in the array.
  6544. */
  6545. readonly type: number;
  6546. /**
  6547. * Constructor
  6548. * @param engine the engine
  6549. * @param data the data to use for this vertex buffer
  6550. * @param kind the vertex buffer kind
  6551. * @param updatable whether the data is updatable
  6552. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6553. * @param stride the stride (optional)
  6554. * @param instanced whether the buffer is instanced (optional)
  6555. * @param offset the offset of the data (optional)
  6556. * @param size the number of components (optional)
  6557. * @param type the type of the component (optional)
  6558. * @param normalized whether the data contains normalized data (optional)
  6559. * @param useBytes set to true if stride and offset are in bytes (optional)
  6560. * @param divisor defines the instance divisor to use (1 by default)
  6561. */
  6562. 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);
  6563. /** @hidden */
  6564. _rebuild(): void;
  6565. /**
  6566. * Returns the kind of the VertexBuffer (string)
  6567. * @returns a string
  6568. */
  6569. getKind(): string;
  6570. /**
  6571. * Gets a boolean indicating if the VertexBuffer is updatable?
  6572. * @returns true if the buffer is updatable
  6573. */
  6574. isUpdatable(): boolean;
  6575. /**
  6576. * Gets current buffer's data
  6577. * @returns a DataArray or null
  6578. */
  6579. getData(): Nullable<DataArray>;
  6580. /**
  6581. * Gets underlying native buffer
  6582. * @returns underlying native buffer
  6583. */
  6584. getBuffer(): Nullable<DataBuffer>;
  6585. /**
  6586. * Gets the stride in float32 units (i.e. byte stride / 4).
  6587. * May not be an integer if the byte stride is not divisible by 4.
  6588. * @returns the stride in float32 units
  6589. * @deprecated Please use byteStride instead.
  6590. */
  6591. getStrideSize(): number;
  6592. /**
  6593. * Returns the offset as a multiple of the type byte length.
  6594. * @returns the offset in bytes
  6595. * @deprecated Please use byteOffset instead.
  6596. */
  6597. getOffset(): number;
  6598. /**
  6599. * Returns the number of components per vertex attribute (integer)
  6600. * @returns the size in float
  6601. */
  6602. getSize(): number;
  6603. /**
  6604. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6605. * @returns true if this buffer is instanced
  6606. */
  6607. getIsInstanced(): boolean;
  6608. /**
  6609. * Returns the instancing divisor, zero for non-instanced (integer).
  6610. * @returns a number
  6611. */
  6612. getInstanceDivisor(): number;
  6613. /**
  6614. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6615. * @param data defines the data to store
  6616. */
  6617. create(data?: DataArray): void;
  6618. /**
  6619. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6620. * This function will create a new buffer if the current one is not updatable
  6621. * @param data defines the data to store
  6622. */
  6623. update(data: DataArray): void;
  6624. /**
  6625. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6626. * Returns the directly updated WebGLBuffer.
  6627. * @param data the new data
  6628. * @param offset the new offset
  6629. * @param useBytes set to true if the offset is in bytes
  6630. */
  6631. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6632. /**
  6633. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6634. */
  6635. dispose(): void;
  6636. /**
  6637. * Enumerates each value of this vertex buffer as numbers.
  6638. * @param count the number of values to enumerate
  6639. * @param callback the callback function called for each value
  6640. */
  6641. forEach(count: number, callback: (value: number, index: number) => void): void;
  6642. /**
  6643. * Positions
  6644. */
  6645. static readonly PositionKind: string;
  6646. /**
  6647. * Normals
  6648. */
  6649. static readonly NormalKind: string;
  6650. /**
  6651. * Tangents
  6652. */
  6653. static readonly TangentKind: string;
  6654. /**
  6655. * Texture coordinates
  6656. */
  6657. static readonly UVKind: string;
  6658. /**
  6659. * Texture coordinates 2
  6660. */
  6661. static readonly UV2Kind: string;
  6662. /**
  6663. * Texture coordinates 3
  6664. */
  6665. static readonly UV3Kind: string;
  6666. /**
  6667. * Texture coordinates 4
  6668. */
  6669. static readonly UV4Kind: string;
  6670. /**
  6671. * Texture coordinates 5
  6672. */
  6673. static readonly UV5Kind: string;
  6674. /**
  6675. * Texture coordinates 6
  6676. */
  6677. static readonly UV6Kind: string;
  6678. /**
  6679. * Colors
  6680. */
  6681. static readonly ColorKind: string;
  6682. /**
  6683. * Matrix indices (for bones)
  6684. */
  6685. static readonly MatricesIndicesKind: string;
  6686. /**
  6687. * Matrix weights (for bones)
  6688. */
  6689. static readonly MatricesWeightsKind: string;
  6690. /**
  6691. * Additional matrix indices (for bones)
  6692. */
  6693. static readonly MatricesIndicesExtraKind: string;
  6694. /**
  6695. * Additional matrix weights (for bones)
  6696. */
  6697. static readonly MatricesWeightsExtraKind: string;
  6698. /**
  6699. * Deduces the stride given a kind.
  6700. * @param kind The kind string to deduce
  6701. * @returns The deduced stride
  6702. */
  6703. static DeduceStride(kind: string): number;
  6704. /**
  6705. * Gets the byte length of the given type.
  6706. * @param type the type
  6707. * @returns the number of bytes
  6708. */
  6709. static GetTypeByteLength(type: number): number;
  6710. /**
  6711. * Enumerates each value of the given parameters as numbers.
  6712. * @param data the data to enumerate
  6713. * @param byteOffset the byte offset of the data
  6714. * @param byteStride the byte stride of the data
  6715. * @param componentCount the number of components per element
  6716. * @param componentType the type of the component
  6717. * @param count the number of values to enumerate
  6718. * @param normalized whether the data is normalized
  6719. * @param callback the callback function called for each value
  6720. */
  6721. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6722. private static _GetFloatValue;
  6723. }
  6724. }
  6725. declare module BABYLON {
  6726. /**
  6727. * @hidden
  6728. */
  6729. export class IntersectionInfo {
  6730. bu: Nullable<number>;
  6731. bv: Nullable<number>;
  6732. distance: number;
  6733. faceId: number;
  6734. subMeshId: number;
  6735. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6736. }
  6737. }
  6738. declare module BABYLON {
  6739. /**
  6740. * Class used to store bounding sphere information
  6741. */
  6742. export class BoundingSphere {
  6743. /**
  6744. * Gets the center of the bounding sphere in local space
  6745. */
  6746. readonly center: Vector3;
  6747. /**
  6748. * Radius of the bounding sphere in local space
  6749. */
  6750. radius: number;
  6751. /**
  6752. * Gets the center of the bounding sphere in world space
  6753. */
  6754. readonly centerWorld: Vector3;
  6755. /**
  6756. * Radius of the bounding sphere in world space
  6757. */
  6758. radiusWorld: number;
  6759. /**
  6760. * Gets the minimum vector in local space
  6761. */
  6762. readonly minimum: Vector3;
  6763. /**
  6764. * Gets the maximum vector in local space
  6765. */
  6766. readonly maximum: Vector3;
  6767. private _worldMatrix;
  6768. private static readonly TmpVector3;
  6769. /**
  6770. * Creates a new bounding sphere
  6771. * @param min defines the minimum vector (in local space)
  6772. * @param max defines the maximum vector (in local space)
  6773. * @param worldMatrix defines the new world matrix
  6774. */
  6775. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6776. /**
  6777. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6778. * @param min defines the new minimum vector (in local space)
  6779. * @param max defines the new maximum vector (in local space)
  6780. * @param worldMatrix defines the new world matrix
  6781. */
  6782. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6783. /**
  6784. * Scale the current bounding sphere by applying a scale factor
  6785. * @param factor defines the scale factor to apply
  6786. * @returns the current bounding box
  6787. */
  6788. scale(factor: number): BoundingSphere;
  6789. /**
  6790. * Gets the world matrix of the bounding box
  6791. * @returns a matrix
  6792. */
  6793. getWorldMatrix(): DeepImmutable<Matrix>;
  6794. /** @hidden */
  6795. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6796. /**
  6797. * Tests if the bounding sphere is intersecting the frustum planes
  6798. * @param frustumPlanes defines the frustum planes to test
  6799. * @returns true if there is an intersection
  6800. */
  6801. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6802. /**
  6803. * Tests if the bounding sphere center is in between the frustum planes.
  6804. * Used for optimistic fast inclusion.
  6805. * @param frustumPlanes defines the frustum planes to test
  6806. * @returns true if the sphere center is in between the frustum planes
  6807. */
  6808. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6809. /**
  6810. * Tests if a point is inside the bounding sphere
  6811. * @param point defines the point to test
  6812. * @returns true if the point is inside the bounding sphere
  6813. */
  6814. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6815. /**
  6816. * Checks if two sphere intersct
  6817. * @param sphere0 sphere 0
  6818. * @param sphere1 sphere 1
  6819. * @returns true if the speres intersect
  6820. */
  6821. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6822. }
  6823. }
  6824. declare module BABYLON {
  6825. /**
  6826. * Class used to store bounding box information
  6827. */
  6828. export class BoundingBox implements ICullable {
  6829. /**
  6830. * Gets the 8 vectors representing the bounding box in local space
  6831. */
  6832. readonly vectors: Vector3[];
  6833. /**
  6834. * Gets the center of the bounding box in local space
  6835. */
  6836. readonly center: Vector3;
  6837. /**
  6838. * Gets the center of the bounding box in world space
  6839. */
  6840. readonly centerWorld: Vector3;
  6841. /**
  6842. * Gets the extend size in local space
  6843. */
  6844. readonly extendSize: Vector3;
  6845. /**
  6846. * Gets the extend size in world space
  6847. */
  6848. readonly extendSizeWorld: Vector3;
  6849. /**
  6850. * Gets the OBB (object bounding box) directions
  6851. */
  6852. readonly directions: Vector3[];
  6853. /**
  6854. * Gets the 8 vectors representing the bounding box in world space
  6855. */
  6856. readonly vectorsWorld: Vector3[];
  6857. /**
  6858. * Gets the minimum vector in world space
  6859. */
  6860. readonly minimumWorld: Vector3;
  6861. /**
  6862. * Gets the maximum vector in world space
  6863. */
  6864. readonly maximumWorld: Vector3;
  6865. /**
  6866. * Gets the minimum vector in local space
  6867. */
  6868. readonly minimum: Vector3;
  6869. /**
  6870. * Gets the maximum vector in local space
  6871. */
  6872. readonly maximum: Vector3;
  6873. private _worldMatrix;
  6874. private static readonly TmpVector3;
  6875. /**
  6876. * @hidden
  6877. */
  6878. _tag: number;
  6879. /**
  6880. * Creates a new bounding box
  6881. * @param min defines the minimum vector (in local space)
  6882. * @param max defines the maximum vector (in local space)
  6883. * @param worldMatrix defines the new world matrix
  6884. */
  6885. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6886. /**
  6887. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6888. * @param min defines the new minimum vector (in local space)
  6889. * @param max defines the new maximum vector (in local space)
  6890. * @param worldMatrix defines the new world matrix
  6891. */
  6892. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6893. /**
  6894. * Scale the current bounding box by applying a scale factor
  6895. * @param factor defines the scale factor to apply
  6896. * @returns the current bounding box
  6897. */
  6898. scale(factor: number): BoundingBox;
  6899. /**
  6900. * Gets the world matrix of the bounding box
  6901. * @returns a matrix
  6902. */
  6903. getWorldMatrix(): DeepImmutable<Matrix>;
  6904. /** @hidden */
  6905. _update(world: DeepImmutable<Matrix>): void;
  6906. /**
  6907. * Tests if the bounding box is intersecting the frustum planes
  6908. * @param frustumPlanes defines the frustum planes to test
  6909. * @returns true if there is an intersection
  6910. */
  6911. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6912. /**
  6913. * Tests if the bounding box is entirely inside the frustum planes
  6914. * @param frustumPlanes defines the frustum planes to test
  6915. * @returns true if there is an inclusion
  6916. */
  6917. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6918. /**
  6919. * Tests if a point is inside the bounding box
  6920. * @param point defines the point to test
  6921. * @returns true if the point is inside the bounding box
  6922. */
  6923. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6924. /**
  6925. * Tests if the bounding box intersects with a bounding sphere
  6926. * @param sphere defines the sphere to test
  6927. * @returns true if there is an intersection
  6928. */
  6929. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6930. /**
  6931. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6932. * @param min defines the min vector to use
  6933. * @param max defines the max vector to use
  6934. * @returns true if there is an intersection
  6935. */
  6936. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6937. /**
  6938. * Tests if two bounding boxes are intersections
  6939. * @param box0 defines the first box to test
  6940. * @param box1 defines the second box to test
  6941. * @returns true if there is an intersection
  6942. */
  6943. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6944. /**
  6945. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6946. * @param minPoint defines the minimum vector of the bounding box
  6947. * @param maxPoint defines the maximum vector of the bounding box
  6948. * @param sphereCenter defines the sphere center
  6949. * @param sphereRadius defines the sphere radius
  6950. * @returns true if there is an intersection
  6951. */
  6952. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6953. /**
  6954. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6955. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6956. * @param frustumPlanes defines the frustum planes to test
  6957. * @return true if there is an inclusion
  6958. */
  6959. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6960. /**
  6961. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6962. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6963. * @param frustumPlanes defines the frustum planes to test
  6964. * @return true if there is an intersection
  6965. */
  6966. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6967. }
  6968. }
  6969. declare module BABYLON {
  6970. /** @hidden */
  6971. export class Collider {
  6972. /** Define if a collision was found */
  6973. collisionFound: boolean;
  6974. /**
  6975. * Define last intersection point in local space
  6976. */
  6977. intersectionPoint: Vector3;
  6978. /**
  6979. * Define last collided mesh
  6980. */
  6981. collidedMesh: Nullable<AbstractMesh>;
  6982. private _collisionPoint;
  6983. private _planeIntersectionPoint;
  6984. private _tempVector;
  6985. private _tempVector2;
  6986. private _tempVector3;
  6987. private _tempVector4;
  6988. private _edge;
  6989. private _baseToVertex;
  6990. private _destinationPoint;
  6991. private _slidePlaneNormal;
  6992. private _displacementVector;
  6993. /** @hidden */
  6994. _radius: Vector3;
  6995. /** @hidden */
  6996. _retry: number;
  6997. private _velocity;
  6998. private _basePoint;
  6999. private _epsilon;
  7000. /** @hidden */
  7001. _velocityWorldLength: number;
  7002. /** @hidden */
  7003. _basePointWorld: Vector3;
  7004. private _velocityWorld;
  7005. private _normalizedVelocity;
  7006. /** @hidden */
  7007. _initialVelocity: Vector3;
  7008. /** @hidden */
  7009. _initialPosition: Vector3;
  7010. private _nearestDistance;
  7011. private _collisionMask;
  7012. get collisionMask(): number;
  7013. set collisionMask(mask: number);
  7014. /**
  7015. * Gets the plane normal used to compute the sliding response (in local space)
  7016. */
  7017. get slidePlaneNormal(): Vector3;
  7018. /** @hidden */
  7019. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7020. /** @hidden */
  7021. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7022. /** @hidden */
  7023. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7024. /** @hidden */
  7025. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7026. /** @hidden */
  7027. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7028. /** @hidden */
  7029. _getResponse(pos: Vector3, vel: Vector3): void;
  7030. }
  7031. }
  7032. declare module BABYLON {
  7033. /**
  7034. * Interface for cullable objects
  7035. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7036. */
  7037. export interface ICullable {
  7038. /**
  7039. * Checks if the object or part of the object is in the frustum
  7040. * @param frustumPlanes Camera near/planes
  7041. * @returns true if the object is in frustum otherwise false
  7042. */
  7043. isInFrustum(frustumPlanes: Plane[]): boolean;
  7044. /**
  7045. * Checks if a cullable object (mesh...) is in the camera frustum
  7046. * Unlike isInFrustum this cheks the full bounding box
  7047. * @param frustumPlanes Camera near/planes
  7048. * @returns true if the object is in frustum otherwise false
  7049. */
  7050. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7051. }
  7052. /**
  7053. * Info for a bounding data of a mesh
  7054. */
  7055. export class BoundingInfo implements ICullable {
  7056. /**
  7057. * Bounding box for the mesh
  7058. */
  7059. readonly boundingBox: BoundingBox;
  7060. /**
  7061. * Bounding sphere for the mesh
  7062. */
  7063. readonly boundingSphere: BoundingSphere;
  7064. private _isLocked;
  7065. private static readonly TmpVector3;
  7066. /**
  7067. * Constructs bounding info
  7068. * @param minimum min vector of the bounding box/sphere
  7069. * @param maximum max vector of the bounding box/sphere
  7070. * @param worldMatrix defines the new world matrix
  7071. */
  7072. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7073. /**
  7074. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7075. * @param min defines the new minimum vector (in local space)
  7076. * @param max defines the new maximum vector (in local space)
  7077. * @param worldMatrix defines the new world matrix
  7078. */
  7079. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7080. /**
  7081. * min vector of the bounding box/sphere
  7082. */
  7083. get minimum(): Vector3;
  7084. /**
  7085. * max vector of the bounding box/sphere
  7086. */
  7087. get maximum(): Vector3;
  7088. /**
  7089. * If the info is locked and won't be updated to avoid perf overhead
  7090. */
  7091. get isLocked(): boolean;
  7092. set isLocked(value: boolean);
  7093. /**
  7094. * Updates the bounding sphere and box
  7095. * @param world world matrix to be used to update
  7096. */
  7097. update(world: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7100. * @param center New center of the bounding info
  7101. * @param extend New extend of the bounding info
  7102. * @returns the current bounding info
  7103. */
  7104. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7105. /**
  7106. * Scale the current bounding info by applying a scale factor
  7107. * @param factor defines the scale factor to apply
  7108. * @returns the current bounding info
  7109. */
  7110. scale(factor: number): BoundingInfo;
  7111. /**
  7112. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7113. * @param frustumPlanes defines the frustum to test
  7114. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7115. * @returns true if the bounding info is in the frustum planes
  7116. */
  7117. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7118. /**
  7119. * Gets the world distance between the min and max points of the bounding box
  7120. */
  7121. get diagonalLength(): number;
  7122. /**
  7123. * Checks if a cullable object (mesh...) is in the camera frustum
  7124. * Unlike isInFrustum this cheks the full bounding box
  7125. * @param frustumPlanes Camera near/planes
  7126. * @returns true if the object is in frustum otherwise false
  7127. */
  7128. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7129. /** @hidden */
  7130. _checkCollision(collider: Collider): boolean;
  7131. /**
  7132. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7133. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7134. * @param point the point to check intersection with
  7135. * @returns if the point intersects
  7136. */
  7137. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7138. /**
  7139. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7140. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7141. * @param boundingInfo the bounding info to check intersection with
  7142. * @param precise if the intersection should be done using OBB
  7143. * @returns if the bounding info intersects
  7144. */
  7145. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7146. }
  7147. }
  7148. declare module BABYLON {
  7149. /**
  7150. * Extracts minimum and maximum values from a list of indexed positions
  7151. * @param positions defines the positions to use
  7152. * @param indices defines the indices to the positions
  7153. * @param indexStart defines the start index
  7154. * @param indexCount defines the end index
  7155. * @param bias defines bias value to add to the result
  7156. * @return minimum and maximum values
  7157. */
  7158. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7159. minimum: Vector3;
  7160. maximum: Vector3;
  7161. };
  7162. /**
  7163. * Extracts minimum and maximum values from a list of positions
  7164. * @param positions defines the positions to use
  7165. * @param start defines the start index in the positions array
  7166. * @param count defines the number of positions to handle
  7167. * @param bias defines bias value to add to the result
  7168. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7169. * @return minimum and maximum values
  7170. */
  7171. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7172. minimum: Vector3;
  7173. maximum: Vector3;
  7174. };
  7175. }
  7176. declare module BABYLON {
  7177. /** @hidden */
  7178. export class WebGLDataBuffer extends DataBuffer {
  7179. private _buffer;
  7180. constructor(resource: WebGLBuffer);
  7181. get underlyingResource(): any;
  7182. }
  7183. }
  7184. declare module BABYLON {
  7185. /** @hidden */
  7186. export class WebGLPipelineContext implements IPipelineContext {
  7187. engine: ThinEngine;
  7188. program: Nullable<WebGLProgram>;
  7189. context?: WebGLRenderingContext;
  7190. vertexShader?: WebGLShader;
  7191. fragmentShader?: WebGLShader;
  7192. isParallelCompiled: boolean;
  7193. onCompiled?: () => void;
  7194. transformFeedback?: WebGLTransformFeedback | null;
  7195. vertexCompilationError: Nullable<string>;
  7196. fragmentCompilationError: Nullable<string>;
  7197. programLinkError: Nullable<string>;
  7198. programValidationError: Nullable<string>;
  7199. get isAsync(): boolean;
  7200. get isReady(): boolean;
  7201. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7202. _getVertexShaderCode(): string | null;
  7203. _getFragmentShaderCode(): string | null;
  7204. }
  7205. }
  7206. declare module BABYLON {
  7207. interface ThinEngine {
  7208. /**
  7209. * Create an uniform buffer
  7210. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7211. * @param elements defines the content of the uniform buffer
  7212. * @returns the webGL uniform buffer
  7213. */
  7214. createUniformBuffer(elements: FloatArray): DataBuffer;
  7215. /**
  7216. * Create a dynamic uniform buffer
  7217. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7218. * @param elements defines the content of the uniform buffer
  7219. * @returns the webGL uniform buffer
  7220. */
  7221. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7222. /**
  7223. * Update an existing uniform buffer
  7224. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7225. * @param uniformBuffer defines the target uniform buffer
  7226. * @param elements defines the content to update
  7227. * @param offset defines the offset in the uniform buffer where update should start
  7228. * @param count defines the size of the data to update
  7229. */
  7230. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7231. /**
  7232. * Bind an uniform buffer to the current webGL context
  7233. * @param buffer defines the buffer to bind
  7234. */
  7235. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7236. /**
  7237. * Bind a buffer to the current webGL context at a given location
  7238. * @param buffer defines the buffer to bind
  7239. * @param location defines the index where to bind the buffer
  7240. */
  7241. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7242. /**
  7243. * Bind a specific block at a given index in a specific shader program
  7244. * @param pipelineContext defines the pipeline context to use
  7245. * @param blockName defines the block name
  7246. * @param index defines the index where to bind the block
  7247. */
  7248. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7249. }
  7250. }
  7251. declare module BABYLON {
  7252. /**
  7253. * Uniform buffer objects.
  7254. *
  7255. * Handles blocks of uniform on the GPU.
  7256. *
  7257. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7258. *
  7259. * For more information, please refer to :
  7260. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7261. */
  7262. export class UniformBuffer {
  7263. private _engine;
  7264. private _buffer;
  7265. private _data;
  7266. private _bufferData;
  7267. private _dynamic?;
  7268. private _uniformLocations;
  7269. private _uniformSizes;
  7270. private _uniformLocationPointer;
  7271. private _needSync;
  7272. private _noUBO;
  7273. private _currentEffect;
  7274. /** @hidden */
  7275. _alreadyBound: boolean;
  7276. private static _MAX_UNIFORM_SIZE;
  7277. private static _tempBuffer;
  7278. /**
  7279. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7280. * This is dynamic to allow compat with webgl 1 and 2.
  7281. * You will need to pass the name of the uniform as well as the value.
  7282. */
  7283. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7284. /**
  7285. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7286. * This is dynamic to allow compat with webgl 1 and 2.
  7287. * You will need to pass the name of the uniform as well as the value.
  7288. */
  7289. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7290. /**
  7291. * Lambda to Update a single float in a uniform buffer.
  7292. * This is dynamic to allow compat with webgl 1 and 2.
  7293. * You will need to pass the name of the uniform as well as the value.
  7294. */
  7295. updateFloat: (name: string, x: number) => void;
  7296. /**
  7297. * Lambda to Update a vec2 of float in a uniform buffer.
  7298. * This is dynamic to allow compat with webgl 1 and 2.
  7299. * You will need to pass the name of the uniform as well as the value.
  7300. */
  7301. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7302. /**
  7303. * Lambda to Update a vec3 of float in a uniform buffer.
  7304. * This is dynamic to allow compat with webgl 1 and 2.
  7305. * You will need to pass the name of the uniform as well as the value.
  7306. */
  7307. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7308. /**
  7309. * Lambda to Update a vec4 of float in a uniform buffer.
  7310. * This is dynamic to allow compat with webgl 1 and 2.
  7311. * You will need to pass the name of the uniform as well as the value.
  7312. */
  7313. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7314. /**
  7315. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7316. * This is dynamic to allow compat with webgl 1 and 2.
  7317. * You will need to pass the name of the uniform as well as the value.
  7318. */
  7319. updateMatrix: (name: string, mat: Matrix) => void;
  7320. /**
  7321. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7322. * This is dynamic to allow compat with webgl 1 and 2.
  7323. * You will need to pass the name of the uniform as well as the value.
  7324. */
  7325. updateVector3: (name: string, vector: Vector3) => void;
  7326. /**
  7327. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7328. * This is dynamic to allow compat with webgl 1 and 2.
  7329. * You will need to pass the name of the uniform as well as the value.
  7330. */
  7331. updateVector4: (name: string, vector: Vector4) => void;
  7332. /**
  7333. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7334. * This is dynamic to allow compat with webgl 1 and 2.
  7335. * You will need to pass the name of the uniform as well as the value.
  7336. */
  7337. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7338. /**
  7339. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7340. * This is dynamic to allow compat with webgl 1 and 2.
  7341. * You will need to pass the name of the uniform as well as the value.
  7342. */
  7343. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7344. /**
  7345. * Instantiates a new Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. * @param engine Define the engine the buffer is associated with
  7354. * @param data Define the data contained in the buffer
  7355. * @param dynamic Define if the buffer is updatable
  7356. */
  7357. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7358. /**
  7359. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7360. * or just falling back on setUniformXXX calls.
  7361. */
  7362. get useUbo(): boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is in sync
  7365. * with the javascript cache data.
  7366. */
  7367. get isSync(): boolean;
  7368. /**
  7369. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7370. * Also, a dynamic UniformBuffer will disable cache verification and always
  7371. * update the underlying WebGL uniform buffer to the GPU.
  7372. * @returns if Dynamic, otherwise false
  7373. */
  7374. isDynamic(): boolean;
  7375. /**
  7376. * The data cache on JS side.
  7377. * @returns the underlying data as a float array
  7378. */
  7379. getData(): Float32Array;
  7380. /**
  7381. * The underlying WebGL Uniform buffer.
  7382. * @returns the webgl buffer
  7383. */
  7384. getBuffer(): Nullable<DataBuffer>;
  7385. /**
  7386. * std140 layout specifies how to align data within an UBO structure.
  7387. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7388. * for specs.
  7389. */
  7390. private _fillAlignment;
  7391. /**
  7392. * Adds an uniform in the buffer.
  7393. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7394. * for the layout to be correct !
  7395. * @param name Name of the uniform, as used in the uniform block in the shader.
  7396. * @param size Data size, or data directly.
  7397. */
  7398. addUniform(name: string, size: number | number[]): void;
  7399. /**
  7400. * Adds a Matrix 4x4 to the uniform buffer.
  7401. * @param name Name of the uniform, as used in the uniform block in the shader.
  7402. * @param mat A 4x4 matrix.
  7403. */
  7404. addMatrix(name: string, mat: Matrix): void;
  7405. /**
  7406. * Adds a vec2 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param x Define the x component value of the vec2
  7409. * @param y Define the y component value of the vec2
  7410. */
  7411. addFloat2(name: string, x: number, y: number): void;
  7412. /**
  7413. * Adds a vec3 to the uniform buffer.
  7414. * @param name Name of the uniform, as used in the uniform block in the shader.
  7415. * @param x Define the x component value of the vec3
  7416. * @param y Define the y component value of the vec3
  7417. * @param z Define the z component value of the vec3
  7418. */
  7419. addFloat3(name: string, x: number, y: number, z: number): void;
  7420. /**
  7421. * Adds a vec3 to the uniform buffer.
  7422. * @param name Name of the uniform, as used in the uniform block in the shader.
  7423. * @param color Define the vec3 from a Color
  7424. */
  7425. addColor3(name: string, color: Color3): void;
  7426. /**
  7427. * Adds a vec4 to the uniform buffer.
  7428. * @param name Name of the uniform, as used in the uniform block in the shader.
  7429. * @param color Define the rgb components from a Color
  7430. * @param alpha Define the a component of the vec4
  7431. */
  7432. addColor4(name: string, color: Color3, alpha: number): void;
  7433. /**
  7434. * Adds a vec3 to the uniform buffer.
  7435. * @param name Name of the uniform, as used in the uniform block in the shader.
  7436. * @param vector Define the vec3 components from a Vector
  7437. */
  7438. addVector3(name: string, vector: Vector3): void;
  7439. /**
  7440. * Adds a Matrix 3x3 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix3x3(name: string): void;
  7444. /**
  7445. * Adds a Matrix 2x2 to the uniform buffer.
  7446. * @param name Name of the uniform, as used in the uniform block in the shader.
  7447. */
  7448. addMatrix2x2(name: string): void;
  7449. /**
  7450. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7451. */
  7452. create(): void;
  7453. /** @hidden */
  7454. _rebuild(): void;
  7455. /**
  7456. * Updates the WebGL Uniform Buffer on the GPU.
  7457. * If the `dynamic` flag is set to true, no cache comparison is done.
  7458. * Otherwise, the buffer will be updated only if the cache differs.
  7459. */
  7460. update(): void;
  7461. /**
  7462. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7463. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7464. * @param data Define the flattened data
  7465. * @param size Define the size of the data.
  7466. */
  7467. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7468. private _valueCache;
  7469. private _cacheMatrix;
  7470. private _updateMatrix3x3ForUniform;
  7471. private _updateMatrix3x3ForEffect;
  7472. private _updateMatrix2x2ForEffect;
  7473. private _updateMatrix2x2ForUniform;
  7474. private _updateFloatForEffect;
  7475. private _updateFloatForUniform;
  7476. private _updateFloat2ForEffect;
  7477. private _updateFloat2ForUniform;
  7478. private _updateFloat3ForEffect;
  7479. private _updateFloat3ForUniform;
  7480. private _updateFloat4ForEffect;
  7481. private _updateFloat4ForUniform;
  7482. private _updateMatrixForEffect;
  7483. private _updateMatrixForUniform;
  7484. private _updateVector3ForEffect;
  7485. private _updateVector3ForUniform;
  7486. private _updateVector4ForEffect;
  7487. private _updateVector4ForUniform;
  7488. private _updateColor3ForEffect;
  7489. private _updateColor3ForUniform;
  7490. private _updateColor4ForEffect;
  7491. private _updateColor4ForUniform;
  7492. /**
  7493. * Sets a sampler uniform on the effect.
  7494. * @param name Define the name of the sampler.
  7495. * @param texture Define the texture to set in the sampler
  7496. */
  7497. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7498. /**
  7499. * Directly updates the value of the uniform in the cache AND on the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. */
  7503. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7504. /**
  7505. * Binds this uniform buffer to an effect.
  7506. * @param effect Define the effect to bind the buffer to
  7507. * @param name Name of the uniform block in the shader.
  7508. */
  7509. bindToEffect(effect: Effect, name: string): void;
  7510. /**
  7511. * Disposes the uniform buffer.
  7512. */
  7513. dispose(): void;
  7514. }
  7515. }
  7516. declare module BABYLON {
  7517. /**
  7518. * Enum that determines the text-wrapping mode to use.
  7519. */
  7520. export enum InspectableType {
  7521. /**
  7522. * Checkbox for booleans
  7523. */
  7524. Checkbox = 0,
  7525. /**
  7526. * Sliders for numbers
  7527. */
  7528. Slider = 1,
  7529. /**
  7530. * Vector3
  7531. */
  7532. Vector3 = 2,
  7533. /**
  7534. * Quaternions
  7535. */
  7536. Quaternion = 3,
  7537. /**
  7538. * Color3
  7539. */
  7540. Color3 = 4,
  7541. /**
  7542. * String
  7543. */
  7544. String = 5
  7545. }
  7546. /**
  7547. * Interface used to define custom inspectable properties.
  7548. * This interface is used by the inspector to display custom property grids
  7549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7550. */
  7551. export interface IInspectable {
  7552. /**
  7553. * Gets the label to display
  7554. */
  7555. label: string;
  7556. /**
  7557. * Gets the name of the property to edit
  7558. */
  7559. propertyName: string;
  7560. /**
  7561. * Gets the type of the editor to use
  7562. */
  7563. type: InspectableType;
  7564. /**
  7565. * Gets the minimum value of the property when using in "slider" mode
  7566. */
  7567. min?: number;
  7568. /**
  7569. * Gets the maximum value of the property when using in "slider" mode
  7570. */
  7571. max?: number;
  7572. /**
  7573. * Gets the setp to use when using in "slider" mode
  7574. */
  7575. step?: number;
  7576. }
  7577. }
  7578. declare module BABYLON {
  7579. /**
  7580. * Class used to provide helper for timing
  7581. */
  7582. export class TimingTools {
  7583. /**
  7584. * Polyfill for setImmediate
  7585. * @param action defines the action to execute after the current execution block
  7586. */
  7587. static SetImmediate(action: () => void): void;
  7588. }
  7589. }
  7590. declare module BABYLON {
  7591. /**
  7592. * Class used to enable instatition of objects by class name
  7593. */
  7594. export class InstantiationTools {
  7595. /**
  7596. * Use this object to register external classes like custom textures or material
  7597. * to allow the laoders to instantiate them
  7598. */
  7599. static RegisteredExternalClasses: {
  7600. [key: string]: Object;
  7601. };
  7602. /**
  7603. * Tries to instantiate a new object from a given class name
  7604. * @param className defines the class name to instantiate
  7605. * @returns the new object or null if the system was not able to do the instantiation
  7606. */
  7607. static Instantiate(className: string): any;
  7608. }
  7609. }
  7610. declare module BABYLON {
  7611. /**
  7612. * Define options used to create a depth texture
  7613. */
  7614. export class DepthTextureCreationOptions {
  7615. /** Specifies whether or not a stencil should be allocated in the texture */
  7616. generateStencil?: boolean;
  7617. /** Specifies whether or not bilinear filtering is enable on the texture */
  7618. bilinearFiltering?: boolean;
  7619. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7620. comparisonFunction?: number;
  7621. /** Specifies if the created texture is a cube texture */
  7622. isCube?: boolean;
  7623. }
  7624. }
  7625. declare module BABYLON {
  7626. interface ThinEngine {
  7627. /**
  7628. * Creates a depth stencil cube texture.
  7629. * This is only available in WebGL 2.
  7630. * @param size The size of face edge in the cube texture.
  7631. * @param options The options defining the cube texture.
  7632. * @returns The cube texture
  7633. */
  7634. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7635. /**
  7636. * Creates a cube texture
  7637. * @param rootUrl defines the url where the files to load is located
  7638. * @param scene defines the current scene
  7639. * @param files defines the list of files to load (1 per face)
  7640. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7641. * @param onLoad defines an optional callback raised when the texture is loaded
  7642. * @param onError defines an optional callback raised if there is an issue to load the texture
  7643. * @param format defines the format of the data
  7644. * @param forcedExtension defines the extension to use to pick the right loader
  7645. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7646. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7647. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7648. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7649. * @returns the cube texture as an InternalTexture
  7650. */
  7651. 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;
  7652. /**
  7653. * Creates a cube texture
  7654. * @param rootUrl defines the url where the files to load is located
  7655. * @param scene defines the current scene
  7656. * @param files defines the list of files to load (1 per face)
  7657. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7658. * @param onLoad defines an optional callback raised when the texture is loaded
  7659. * @param onError defines an optional callback raised if there is an issue to load the texture
  7660. * @param format defines the format of the data
  7661. * @param forcedExtension defines the extension to use to pick the right loader
  7662. * @returns the cube texture as an InternalTexture
  7663. */
  7664. 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;
  7665. /**
  7666. * Creates a cube texture
  7667. * @param rootUrl defines the url where the files to load is located
  7668. * @param scene defines the current scene
  7669. * @param files defines the list of files to load (1 per face)
  7670. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7671. * @param onLoad defines an optional callback raised when the texture is loaded
  7672. * @param onError defines an optional callback raised if there is an issue to load the texture
  7673. * @param format defines the format of the data
  7674. * @param forcedExtension defines the extension to use to pick the right loader
  7675. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7676. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7677. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7678. * @returns the cube texture as an InternalTexture
  7679. */
  7680. 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;
  7681. /** @hidden */
  7682. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7683. /** @hidden */
  7684. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7687. /** @hidden */
  7688. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7689. /**
  7690. * @hidden
  7691. */
  7692. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7693. }
  7694. }
  7695. declare module BABYLON {
  7696. /**
  7697. * Class for creating a cube texture
  7698. */
  7699. export class CubeTexture extends BaseTexture {
  7700. private _delayedOnLoad;
  7701. /**
  7702. * Observable triggered once the texture has been loaded.
  7703. */
  7704. onLoadObservable: Observable<CubeTexture>;
  7705. /**
  7706. * The url of the texture
  7707. */
  7708. url: string;
  7709. /**
  7710. * Gets or sets the center of the bounding box associated with the cube texture.
  7711. * It must define where the camera used to render the texture was set
  7712. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7713. */
  7714. boundingBoxPosition: Vector3;
  7715. private _boundingBoxSize;
  7716. /**
  7717. * Gets or sets the size of the bounding box associated with the cube texture
  7718. * When defined, the cubemap will switch to local mode
  7719. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7720. * @example https://www.babylonjs-playground.com/#RNASML
  7721. */
  7722. set boundingBoxSize(value: Vector3);
  7723. /**
  7724. * Returns the bounding box size
  7725. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7726. */
  7727. get boundingBoxSize(): Vector3;
  7728. protected _rotationY: number;
  7729. /**
  7730. * Sets texture matrix rotation angle around Y axis in radians.
  7731. */
  7732. set rotationY(value: number);
  7733. /**
  7734. * Gets texture matrix rotation angle around Y axis radians.
  7735. */
  7736. get rotationY(): number;
  7737. /**
  7738. * Are mip maps generated for this texture or not.
  7739. */
  7740. get noMipmap(): boolean;
  7741. private _noMipmap;
  7742. private _files;
  7743. protected _forcedExtension: Nullable<string>;
  7744. private _extensions;
  7745. private _textureMatrix;
  7746. private _format;
  7747. private _createPolynomials;
  7748. /** @hidden */
  7749. _prefiltered: boolean;
  7750. /**
  7751. * Creates a cube texture from an array of image urls
  7752. * @param files defines an array of image urls
  7753. * @param scene defines the hosting scene
  7754. * @param noMipmap specifies if mip maps are not used
  7755. * @returns a cube texture
  7756. */
  7757. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7758. /**
  7759. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7760. * @param url defines the url of the prefiltered texture
  7761. * @param scene defines the scene the texture is attached to
  7762. * @param forcedExtension defines the extension of the file if different from the url
  7763. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7764. * @return the prefiltered texture
  7765. */
  7766. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7767. /**
  7768. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7769. * as prefiltered data.
  7770. * @param rootUrl defines the url of the texture or the root name of the six images
  7771. * @param null defines the scene or engine the texture is attached to
  7772. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7773. * @param noMipmap defines if mipmaps should be created or not
  7774. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7775. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7776. * @param onError defines a callback triggered in case of error during load
  7777. * @param format defines the internal format to use for the texture once loaded
  7778. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7779. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7780. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7783. * @return the cube texture
  7784. */
  7785. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, 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);
  7786. /**
  7787. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7788. */
  7789. get isPrefiltered(): boolean;
  7790. /**
  7791. * Get the current class name of the texture useful for serialization or dynamic coding.
  7792. * @returns "CubeTexture"
  7793. */
  7794. getClassName(): string;
  7795. /**
  7796. * Update the url (and optional buffer) of this texture if url was null during construction.
  7797. * @param url the url of the texture
  7798. * @param forcedExtension defines the extension to use
  7799. * @param onLoad callback called when the texture is loaded (defaults to null)
  7800. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7801. */
  7802. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7803. /**
  7804. * Delays loading of the cube texture
  7805. * @param forcedExtension defines the extension to use
  7806. */
  7807. delayLoad(forcedExtension?: string): void;
  7808. /**
  7809. * Returns the reflection texture matrix
  7810. * @returns the reflection texture matrix
  7811. */
  7812. getReflectionTextureMatrix(): Matrix;
  7813. /**
  7814. * Sets the reflection texture matrix
  7815. * @param value Reflection texture matrix
  7816. */
  7817. setReflectionTextureMatrix(value: Matrix): void;
  7818. /**
  7819. * Parses text to create a cube texture
  7820. * @param parsedTexture define the serialized text to read from
  7821. * @param scene defines the hosting scene
  7822. * @param rootUrl defines the root url of the cube texture
  7823. * @returns a cube texture
  7824. */
  7825. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7826. /**
  7827. * Makes a clone, or deep copy, of the cube texture
  7828. * @returns a new cube texture
  7829. */
  7830. clone(): CubeTexture;
  7831. }
  7832. }
  7833. declare module BABYLON {
  7834. /**
  7835. * Manages the defines for the Material
  7836. */
  7837. export class MaterialDefines {
  7838. /** @hidden */
  7839. protected _keys: string[];
  7840. private _isDirty;
  7841. /** @hidden */
  7842. _renderId: number;
  7843. /** @hidden */
  7844. _areLightsDirty: boolean;
  7845. /** @hidden */
  7846. _areLightsDisposed: boolean;
  7847. /** @hidden */
  7848. _areAttributesDirty: boolean;
  7849. /** @hidden */
  7850. _areTexturesDirty: boolean;
  7851. /** @hidden */
  7852. _areFresnelDirty: boolean;
  7853. /** @hidden */
  7854. _areMiscDirty: boolean;
  7855. /** @hidden */
  7856. _areImageProcessingDirty: boolean;
  7857. /** @hidden */
  7858. _normals: boolean;
  7859. /** @hidden */
  7860. _uvs: boolean;
  7861. /** @hidden */
  7862. _needNormals: boolean;
  7863. /** @hidden */
  7864. _needUVs: boolean;
  7865. [id: string]: any;
  7866. /**
  7867. * Specifies if the material needs to be re-calculated
  7868. */
  7869. get isDirty(): boolean;
  7870. /**
  7871. * Marks the material to indicate that it has been re-calculated
  7872. */
  7873. markAsProcessed(): void;
  7874. /**
  7875. * Marks the material to indicate that it needs to be re-calculated
  7876. */
  7877. markAsUnprocessed(): void;
  7878. /**
  7879. * Marks the material to indicate all of its defines need to be re-calculated
  7880. */
  7881. markAllAsDirty(): void;
  7882. /**
  7883. * Marks the material to indicate that image processing needs to be re-calculated
  7884. */
  7885. markAsImageProcessingDirty(): void;
  7886. /**
  7887. * Marks the material to indicate the lights need to be re-calculated
  7888. * @param disposed Defines whether the light is dirty due to dispose or not
  7889. */
  7890. markAsLightDirty(disposed?: boolean): void;
  7891. /**
  7892. * Marks the attribute state as changed
  7893. */
  7894. markAsAttributesDirty(): void;
  7895. /**
  7896. * Marks the texture state as changed
  7897. */
  7898. markAsTexturesDirty(): void;
  7899. /**
  7900. * Marks the fresnel state as changed
  7901. */
  7902. markAsFresnelDirty(): void;
  7903. /**
  7904. * Marks the misc state as changed
  7905. */
  7906. markAsMiscDirty(): void;
  7907. /**
  7908. * Rebuilds the material defines
  7909. */
  7910. rebuild(): void;
  7911. /**
  7912. * Specifies if two material defines are equal
  7913. * @param other - A material define instance to compare to
  7914. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7915. */
  7916. isEqual(other: MaterialDefines): boolean;
  7917. /**
  7918. * Clones this instance's defines to another instance
  7919. * @param other - material defines to clone values to
  7920. */
  7921. cloneTo(other: MaterialDefines): void;
  7922. /**
  7923. * Resets the material define values
  7924. */
  7925. reset(): void;
  7926. /**
  7927. * Converts the material define values to a string
  7928. * @returns - String of material define information
  7929. */
  7930. toString(): string;
  7931. }
  7932. }
  7933. declare module BABYLON {
  7934. /**
  7935. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7936. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7937. * 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;
  7938. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7939. */
  7940. export class ColorCurves {
  7941. private _dirty;
  7942. private _tempColor;
  7943. private _globalCurve;
  7944. private _highlightsCurve;
  7945. private _midtonesCurve;
  7946. private _shadowsCurve;
  7947. private _positiveCurve;
  7948. private _negativeCurve;
  7949. private _globalHue;
  7950. private _globalDensity;
  7951. private _globalSaturation;
  7952. private _globalExposure;
  7953. /**
  7954. * Gets the global Hue value.
  7955. * 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).
  7956. */
  7957. get globalHue(): number;
  7958. /**
  7959. * Sets the global Hue value.
  7960. * 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).
  7961. */
  7962. set globalHue(value: number);
  7963. /**
  7964. * Gets the global Density value.
  7965. * 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.
  7966. * Values less than zero provide a filter of opposite hue.
  7967. */
  7968. get globalDensity(): number;
  7969. /**
  7970. * Sets the global Density value.
  7971. * 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.
  7972. * Values less than zero provide a filter of opposite hue.
  7973. */
  7974. set globalDensity(value: number);
  7975. /**
  7976. * Gets the global Saturation value.
  7977. * 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.
  7978. */
  7979. get globalSaturation(): number;
  7980. /**
  7981. * Sets the global Saturation value.
  7982. * 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.
  7983. */
  7984. set globalSaturation(value: number);
  7985. /**
  7986. * Gets the global Exposure value.
  7987. * 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.
  7988. */
  7989. get globalExposure(): number;
  7990. /**
  7991. * Sets the global Exposure value.
  7992. * 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.
  7993. */
  7994. set globalExposure(value: number);
  7995. private _highlightsHue;
  7996. private _highlightsDensity;
  7997. private _highlightsSaturation;
  7998. private _highlightsExposure;
  7999. /**
  8000. * Gets the highlights Hue value.
  8001. * 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).
  8002. */
  8003. get highlightsHue(): number;
  8004. /**
  8005. * Sets the highlights Hue value.
  8006. * 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).
  8007. */
  8008. set highlightsHue(value: number);
  8009. /**
  8010. * Gets the highlights Density value.
  8011. * 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.
  8012. * Values less than zero provide a filter of opposite hue.
  8013. */
  8014. get highlightsDensity(): number;
  8015. /**
  8016. * Sets the highlights Density value.
  8017. * 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.
  8018. * Values less than zero provide a filter of opposite hue.
  8019. */
  8020. set highlightsDensity(value: number);
  8021. /**
  8022. * Gets the highlights Saturation value.
  8023. * 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.
  8024. */
  8025. get highlightsSaturation(): number;
  8026. /**
  8027. * Sets the highlights Saturation value.
  8028. * 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.
  8029. */
  8030. set highlightsSaturation(value: number);
  8031. /**
  8032. * Gets the highlights Exposure value.
  8033. * 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.
  8034. */
  8035. get highlightsExposure(): number;
  8036. /**
  8037. * Sets the highlights Exposure value.
  8038. * 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.
  8039. */
  8040. set highlightsExposure(value: number);
  8041. private _midtonesHue;
  8042. private _midtonesDensity;
  8043. private _midtonesSaturation;
  8044. private _midtonesExposure;
  8045. /**
  8046. * Gets the midtones Hue value.
  8047. * 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).
  8048. */
  8049. get midtonesHue(): number;
  8050. /**
  8051. * Sets the midtones Hue value.
  8052. * 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).
  8053. */
  8054. set midtonesHue(value: number);
  8055. /**
  8056. * Gets the midtones Density value.
  8057. * 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.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. get midtonesDensity(): number;
  8061. /**
  8062. * Sets the midtones Density value.
  8063. * 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.
  8064. * Values less than zero provide a filter of opposite hue.
  8065. */
  8066. set midtonesDensity(value: number);
  8067. /**
  8068. * Gets the midtones Saturation value.
  8069. * 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.
  8070. */
  8071. get midtonesSaturation(): number;
  8072. /**
  8073. * Sets the midtones Saturation value.
  8074. * 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.
  8075. */
  8076. set midtonesSaturation(value: number);
  8077. /**
  8078. * Gets the midtones Exposure value.
  8079. * 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.
  8080. */
  8081. get midtonesExposure(): number;
  8082. /**
  8083. * Sets the midtones Exposure value.
  8084. * 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.
  8085. */
  8086. set midtonesExposure(value: number);
  8087. private _shadowsHue;
  8088. private _shadowsDensity;
  8089. private _shadowsSaturation;
  8090. private _shadowsExposure;
  8091. /**
  8092. * Gets the shadows Hue value.
  8093. * 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).
  8094. */
  8095. get shadowsHue(): number;
  8096. /**
  8097. * Sets the shadows Hue value.
  8098. * 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).
  8099. */
  8100. set shadowsHue(value: number);
  8101. /**
  8102. * Gets the shadows Density value.
  8103. * 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.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. get shadowsDensity(): number;
  8107. /**
  8108. * Sets the shadows Density value.
  8109. * 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.
  8110. * Values less than zero provide a filter of opposite hue.
  8111. */
  8112. set shadowsDensity(value: number);
  8113. /**
  8114. * Gets the shadows Saturation value.
  8115. * 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.
  8116. */
  8117. get shadowsSaturation(): number;
  8118. /**
  8119. * Sets the shadows Saturation value.
  8120. * 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.
  8121. */
  8122. set shadowsSaturation(value: number);
  8123. /**
  8124. * Gets the shadows Exposure value.
  8125. * 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.
  8126. */
  8127. get shadowsExposure(): number;
  8128. /**
  8129. * Sets the shadows Exposure value.
  8130. * 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.
  8131. */
  8132. set shadowsExposure(value: number);
  8133. /**
  8134. * Returns the class name
  8135. * @returns The class name
  8136. */
  8137. getClassName(): string;
  8138. /**
  8139. * Binds the color curves to the shader.
  8140. * @param colorCurves The color curve to bind
  8141. * @param effect The effect to bind to
  8142. * @param positiveUniform The positive uniform shader parameter
  8143. * @param neutralUniform The neutral uniform shader parameter
  8144. * @param negativeUniform The negative uniform shader parameter
  8145. */
  8146. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8147. /**
  8148. * Prepare the list of uniforms associated with the ColorCurves effects.
  8149. * @param uniformsList The list of uniforms used in the effect
  8150. */
  8151. static PrepareUniforms(uniformsList: string[]): void;
  8152. /**
  8153. * Returns color grading data based on a hue, density, saturation and exposure value.
  8154. * @param filterHue The hue of the color filter.
  8155. * @param filterDensity The density of the color filter.
  8156. * @param saturation The saturation.
  8157. * @param exposure The exposure.
  8158. * @param result The result data container.
  8159. */
  8160. private getColorGradingDataToRef;
  8161. /**
  8162. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8163. * @param value The input slider value in range [-100,100].
  8164. * @returns Adjusted value.
  8165. */
  8166. private static applyColorGradingSliderNonlinear;
  8167. /**
  8168. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8169. * @param hue The hue (H) input.
  8170. * @param saturation The saturation (S) input.
  8171. * @param brightness The brightness (B) input.
  8172. * @result An RGBA color represented as Vector4.
  8173. */
  8174. private static fromHSBToRef;
  8175. /**
  8176. * Returns a value clamped between min and max
  8177. * @param value The value to clamp
  8178. * @param min The minimum of value
  8179. * @param max The maximum of value
  8180. * @returns The clamped value.
  8181. */
  8182. private static clamp;
  8183. /**
  8184. * Clones the current color curve instance.
  8185. * @return The cloned curves
  8186. */
  8187. clone(): ColorCurves;
  8188. /**
  8189. * Serializes the current color curve instance to a json representation.
  8190. * @return a JSON representation
  8191. */
  8192. serialize(): any;
  8193. /**
  8194. * Parses the color curve from a json representation.
  8195. * @param source the JSON source to parse
  8196. * @return The parsed curves
  8197. */
  8198. static Parse(source: any): ColorCurves;
  8199. }
  8200. }
  8201. declare module BABYLON {
  8202. /**
  8203. * Interface to follow in your material defines to integrate easily the
  8204. * Image proccessing functions.
  8205. * @hidden
  8206. */
  8207. export interface IImageProcessingConfigurationDefines {
  8208. IMAGEPROCESSING: boolean;
  8209. VIGNETTE: boolean;
  8210. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8211. VIGNETTEBLENDMODEOPAQUE: boolean;
  8212. TONEMAPPING: boolean;
  8213. TONEMAPPING_ACES: boolean;
  8214. CONTRAST: boolean;
  8215. EXPOSURE: boolean;
  8216. COLORCURVES: boolean;
  8217. COLORGRADING: boolean;
  8218. COLORGRADING3D: boolean;
  8219. SAMPLER3DGREENDEPTH: boolean;
  8220. SAMPLER3DBGRMAP: boolean;
  8221. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8222. }
  8223. /**
  8224. * @hidden
  8225. */
  8226. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8227. IMAGEPROCESSING: boolean;
  8228. VIGNETTE: boolean;
  8229. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8230. VIGNETTEBLENDMODEOPAQUE: boolean;
  8231. TONEMAPPING: boolean;
  8232. TONEMAPPING_ACES: boolean;
  8233. CONTRAST: boolean;
  8234. COLORCURVES: boolean;
  8235. COLORGRADING: boolean;
  8236. COLORGRADING3D: boolean;
  8237. SAMPLER3DGREENDEPTH: boolean;
  8238. SAMPLER3DBGRMAP: boolean;
  8239. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8240. EXPOSURE: boolean;
  8241. constructor();
  8242. }
  8243. /**
  8244. * This groups together the common properties used for image processing either in direct forward pass
  8245. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8246. * or not.
  8247. */
  8248. export class ImageProcessingConfiguration {
  8249. /**
  8250. * Default tone mapping applied in BabylonJS.
  8251. */
  8252. static readonly TONEMAPPING_STANDARD: number;
  8253. /**
  8254. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8255. * to other engines rendering to increase portability.
  8256. */
  8257. static readonly TONEMAPPING_ACES: number;
  8258. /**
  8259. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8260. */
  8261. colorCurves: Nullable<ColorCurves>;
  8262. private _colorCurvesEnabled;
  8263. /**
  8264. * Gets wether the color curves effect is enabled.
  8265. */
  8266. get colorCurvesEnabled(): boolean;
  8267. /**
  8268. * Sets wether the color curves effect is enabled.
  8269. */
  8270. set colorCurvesEnabled(value: boolean);
  8271. private _colorGradingTexture;
  8272. /**
  8273. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8274. */
  8275. get colorGradingTexture(): Nullable<BaseTexture>;
  8276. /**
  8277. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8278. */
  8279. set colorGradingTexture(value: Nullable<BaseTexture>);
  8280. private _colorGradingEnabled;
  8281. /**
  8282. * Gets wether the color grading effect is enabled.
  8283. */
  8284. get colorGradingEnabled(): boolean;
  8285. /**
  8286. * Sets wether the color grading effect is enabled.
  8287. */
  8288. set colorGradingEnabled(value: boolean);
  8289. private _colorGradingWithGreenDepth;
  8290. /**
  8291. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8292. */
  8293. get colorGradingWithGreenDepth(): boolean;
  8294. /**
  8295. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8296. */
  8297. set colorGradingWithGreenDepth(value: boolean);
  8298. private _colorGradingBGR;
  8299. /**
  8300. * Gets wether the color grading texture contains BGR values.
  8301. */
  8302. get colorGradingBGR(): boolean;
  8303. /**
  8304. * Sets wether the color grading texture contains BGR values.
  8305. */
  8306. set colorGradingBGR(value: boolean);
  8307. /** @hidden */
  8308. _exposure: number;
  8309. /**
  8310. * Gets the Exposure used in the effect.
  8311. */
  8312. get exposure(): number;
  8313. /**
  8314. * Sets the Exposure used in the effect.
  8315. */
  8316. set exposure(value: number);
  8317. private _toneMappingEnabled;
  8318. /**
  8319. * Gets wether the tone mapping effect is enabled.
  8320. */
  8321. get toneMappingEnabled(): boolean;
  8322. /**
  8323. * Sets wether the tone mapping effect is enabled.
  8324. */
  8325. set toneMappingEnabled(value: boolean);
  8326. private _toneMappingType;
  8327. /**
  8328. * Gets the type of tone mapping effect.
  8329. */
  8330. get toneMappingType(): number;
  8331. /**
  8332. * Sets the type of tone mapping effect used in BabylonJS.
  8333. */
  8334. set toneMappingType(value: number);
  8335. protected _contrast: number;
  8336. /**
  8337. * Gets the contrast used in the effect.
  8338. */
  8339. get contrast(): number;
  8340. /**
  8341. * Sets the contrast used in the effect.
  8342. */
  8343. set contrast(value: number);
  8344. /**
  8345. * Vignette stretch size.
  8346. */
  8347. vignetteStretch: number;
  8348. /**
  8349. * Vignette centre X Offset.
  8350. */
  8351. vignetteCentreX: number;
  8352. /**
  8353. * Vignette centre Y Offset.
  8354. */
  8355. vignetteCentreY: number;
  8356. /**
  8357. * Vignette weight or intensity of the vignette effect.
  8358. */
  8359. vignetteWeight: number;
  8360. /**
  8361. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8362. * if vignetteEnabled is set to true.
  8363. */
  8364. vignetteColor: Color4;
  8365. /**
  8366. * Camera field of view used by the Vignette effect.
  8367. */
  8368. vignetteCameraFov: number;
  8369. private _vignetteBlendMode;
  8370. /**
  8371. * Gets the vignette blend mode allowing different kind of effect.
  8372. */
  8373. get vignetteBlendMode(): number;
  8374. /**
  8375. * Sets the vignette blend mode allowing different kind of effect.
  8376. */
  8377. set vignetteBlendMode(value: number);
  8378. private _vignetteEnabled;
  8379. /**
  8380. * Gets wether the vignette effect is enabled.
  8381. */
  8382. get vignetteEnabled(): boolean;
  8383. /**
  8384. * Sets wether the vignette effect is enabled.
  8385. */
  8386. set vignetteEnabled(value: boolean);
  8387. private _applyByPostProcess;
  8388. /**
  8389. * Gets wether the image processing is applied through a post process or not.
  8390. */
  8391. get applyByPostProcess(): boolean;
  8392. /**
  8393. * Sets wether the image processing is applied through a post process or not.
  8394. */
  8395. set applyByPostProcess(value: boolean);
  8396. private _isEnabled;
  8397. /**
  8398. * Gets wether the image processing is enabled or not.
  8399. */
  8400. get isEnabled(): boolean;
  8401. /**
  8402. * Sets wether the image processing is enabled or not.
  8403. */
  8404. set isEnabled(value: boolean);
  8405. /**
  8406. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8407. */
  8408. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8409. /**
  8410. * Method called each time the image processing information changes requires to recompile the effect.
  8411. */
  8412. protected _updateParameters(): void;
  8413. /**
  8414. * Gets the current class name.
  8415. * @return "ImageProcessingConfiguration"
  8416. */
  8417. getClassName(): string;
  8418. /**
  8419. * Prepare the list of uniforms associated with the Image Processing effects.
  8420. * @param uniforms The list of uniforms used in the effect
  8421. * @param defines the list of defines currently in use
  8422. */
  8423. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8424. /**
  8425. * Prepare the list of samplers associated with the Image Processing effects.
  8426. * @param samplersList The list of uniforms used in the effect
  8427. * @param defines the list of defines currently in use
  8428. */
  8429. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8430. /**
  8431. * Prepare the list of defines associated to the shader.
  8432. * @param defines the list of defines to complete
  8433. * @param forPostProcess Define if we are currently in post process mode or not
  8434. */
  8435. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8436. /**
  8437. * Returns true if all the image processing information are ready.
  8438. * @returns True if ready, otherwise, false
  8439. */
  8440. isReady(): boolean;
  8441. /**
  8442. * Binds the image processing to the shader.
  8443. * @param effect The effect to bind to
  8444. * @param overrideAspectRatio Override the aspect ratio of the effect
  8445. */
  8446. bind(effect: Effect, overrideAspectRatio?: number): void;
  8447. /**
  8448. * Clones the current image processing instance.
  8449. * @return The cloned image processing
  8450. */
  8451. clone(): ImageProcessingConfiguration;
  8452. /**
  8453. * Serializes the current image processing instance to a json representation.
  8454. * @return a JSON representation
  8455. */
  8456. serialize(): any;
  8457. /**
  8458. * Parses the image processing from a json representation.
  8459. * @param source the JSON source to parse
  8460. * @return The parsed image processing
  8461. */
  8462. static Parse(source: any): ImageProcessingConfiguration;
  8463. private static _VIGNETTEMODE_MULTIPLY;
  8464. private static _VIGNETTEMODE_OPAQUE;
  8465. /**
  8466. * Used to apply the vignette as a mix with the pixel color.
  8467. */
  8468. static get VIGNETTEMODE_MULTIPLY(): number;
  8469. /**
  8470. * Used to apply the vignette as a replacement of the pixel color.
  8471. */
  8472. static get VIGNETTEMODE_OPAQUE(): number;
  8473. }
  8474. }
  8475. declare module BABYLON {
  8476. /** @hidden */
  8477. export var postprocessVertexShader: {
  8478. name: string;
  8479. shader: string;
  8480. };
  8481. }
  8482. declare module BABYLON {
  8483. interface ThinEngine {
  8484. /**
  8485. * Creates a new render target texture
  8486. * @param size defines the size of the texture
  8487. * @param options defines the options used to create the texture
  8488. * @returns a new render target texture stored in an InternalTexture
  8489. */
  8490. createRenderTargetTexture(size: number | {
  8491. width: number;
  8492. height: number;
  8493. layers?: number;
  8494. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8495. /**
  8496. * Creates a depth stencil texture.
  8497. * This is only available in WebGL 2 or with the depth texture extension available.
  8498. * @param size The size of face edge in the texture.
  8499. * @param options The options defining the texture.
  8500. * @returns The texture
  8501. */
  8502. createDepthStencilTexture(size: number | {
  8503. width: number;
  8504. height: number;
  8505. layers?: number;
  8506. }, options: DepthTextureCreationOptions): InternalTexture;
  8507. /** @hidden */
  8508. _createDepthStencilTexture(size: number | {
  8509. width: number;
  8510. height: number;
  8511. layers?: number;
  8512. }, options: DepthTextureCreationOptions): InternalTexture;
  8513. }
  8514. }
  8515. declare module BABYLON {
  8516. /** Defines supported spaces */
  8517. export enum Space {
  8518. /** Local (object) space */
  8519. LOCAL = 0,
  8520. /** World space */
  8521. WORLD = 1,
  8522. /** Bone space */
  8523. BONE = 2
  8524. }
  8525. /** Defines the 3 main axes */
  8526. export class Axis {
  8527. /** X axis */
  8528. static X: Vector3;
  8529. /** Y axis */
  8530. static Y: Vector3;
  8531. /** Z axis */
  8532. static Z: Vector3;
  8533. }
  8534. }
  8535. declare module BABYLON {
  8536. /**
  8537. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8538. * This is the base of the follow, arc rotate cameras and Free camera
  8539. * @see http://doc.babylonjs.com/features/cameras
  8540. */
  8541. export class TargetCamera extends Camera {
  8542. private static _RigCamTransformMatrix;
  8543. private static _TargetTransformMatrix;
  8544. private static _TargetFocalPoint;
  8545. /**
  8546. * Define the current direction the camera is moving to
  8547. */
  8548. cameraDirection: Vector3;
  8549. /**
  8550. * Define the current rotation the camera is rotating to
  8551. */
  8552. cameraRotation: Vector2;
  8553. /**
  8554. * When set, the up vector of the camera will be updated by the rotation of the camera
  8555. */
  8556. updateUpVectorFromRotation: boolean;
  8557. private _tmpQuaternion;
  8558. /**
  8559. * Define the current rotation of the camera
  8560. */
  8561. rotation: Vector3;
  8562. /**
  8563. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8564. */
  8565. rotationQuaternion: Quaternion;
  8566. /**
  8567. * Define the current speed of the camera
  8568. */
  8569. speed: number;
  8570. /**
  8571. * Add constraint to the camera to prevent it to move freely in all directions and
  8572. * around all axis.
  8573. */
  8574. noRotationConstraint: boolean;
  8575. /**
  8576. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8577. * panning
  8578. */
  8579. invertRotation: boolean;
  8580. /**
  8581. * Speed multiplier for inverse camera panning
  8582. */
  8583. inverseRotationSpeed: number;
  8584. /**
  8585. * Define the current target of the camera as an object or a position.
  8586. */
  8587. lockedTarget: any;
  8588. /** @hidden */
  8589. _currentTarget: Vector3;
  8590. /** @hidden */
  8591. _initialFocalDistance: number;
  8592. /** @hidden */
  8593. _viewMatrix: Matrix;
  8594. /** @hidden */
  8595. _camMatrix: Matrix;
  8596. /** @hidden */
  8597. _cameraTransformMatrix: Matrix;
  8598. /** @hidden */
  8599. _cameraRotationMatrix: Matrix;
  8600. /** @hidden */
  8601. _referencePoint: Vector3;
  8602. /** @hidden */
  8603. _transformedReferencePoint: Vector3;
  8604. protected _globalCurrentTarget: Vector3;
  8605. protected _globalCurrentUpVector: Vector3;
  8606. /** @hidden */
  8607. _reset: () => void;
  8608. private _defaultUp;
  8609. /**
  8610. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8611. * This is the base of the follow, arc rotate cameras and Free camera
  8612. * @see http://doc.babylonjs.com/features/cameras
  8613. * @param name Defines the name of the camera in the scene
  8614. * @param position Defines the start position of the camera in the scene
  8615. * @param scene Defines the scene the camera belongs to
  8616. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8617. */
  8618. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8619. /**
  8620. * Gets the position in front of the camera at a given distance.
  8621. * @param distance The distance from the camera we want the position to be
  8622. * @returns the position
  8623. */
  8624. getFrontPosition(distance: number): Vector3;
  8625. /** @hidden */
  8626. _getLockedTargetPosition(): Nullable<Vector3>;
  8627. private _storedPosition;
  8628. private _storedRotation;
  8629. private _storedRotationQuaternion;
  8630. /**
  8631. * Store current camera state of the camera (fov, position, rotation, etc..)
  8632. * @returns the camera
  8633. */
  8634. storeState(): Camera;
  8635. /**
  8636. * Restored camera state. You must call storeState() first
  8637. * @returns whether it was successful or not
  8638. * @hidden
  8639. */
  8640. _restoreStateValues(): boolean;
  8641. /** @hidden */
  8642. _initCache(): void;
  8643. /** @hidden */
  8644. _updateCache(ignoreParentClass?: boolean): void;
  8645. /** @hidden */
  8646. _isSynchronizedViewMatrix(): boolean;
  8647. /** @hidden */
  8648. _computeLocalCameraSpeed(): number;
  8649. /**
  8650. * Defines the target the camera should look at.
  8651. * @param target Defines the new target as a Vector or a mesh
  8652. */
  8653. setTarget(target: Vector3): void;
  8654. /**
  8655. * Return the current target position of the camera. This value is expressed in local space.
  8656. * @returns the target position
  8657. */
  8658. getTarget(): Vector3;
  8659. /** @hidden */
  8660. _decideIfNeedsToMove(): boolean;
  8661. /** @hidden */
  8662. _updatePosition(): void;
  8663. /** @hidden */
  8664. _checkInputs(): void;
  8665. protected _updateCameraRotationMatrix(): void;
  8666. /**
  8667. * 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)
  8668. * @returns the current camera
  8669. */
  8670. private _rotateUpVectorWithCameraRotationMatrix;
  8671. private _cachedRotationZ;
  8672. private _cachedQuaternionRotationZ;
  8673. /** @hidden */
  8674. _getViewMatrix(): Matrix;
  8675. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8676. /**
  8677. * @hidden
  8678. */
  8679. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8680. /**
  8681. * @hidden
  8682. */
  8683. _updateRigCameras(): void;
  8684. private _getRigCamPositionAndTarget;
  8685. /**
  8686. * Gets the current object class name.
  8687. * @return the class name
  8688. */
  8689. getClassName(): string;
  8690. }
  8691. }
  8692. declare module BABYLON {
  8693. /**
  8694. * Gather the list of keyboard event types as constants.
  8695. */
  8696. export class KeyboardEventTypes {
  8697. /**
  8698. * The keydown event is fired when a key becomes active (pressed).
  8699. */
  8700. static readonly KEYDOWN: number;
  8701. /**
  8702. * The keyup event is fired when a key has been released.
  8703. */
  8704. static readonly KEYUP: number;
  8705. }
  8706. /**
  8707. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8708. */
  8709. export class KeyboardInfo {
  8710. /**
  8711. * Defines the type of event (KeyboardEventTypes)
  8712. */
  8713. type: number;
  8714. /**
  8715. * Defines the related dom event
  8716. */
  8717. event: KeyboardEvent;
  8718. /**
  8719. * Instantiates a new keyboard info.
  8720. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8721. * @param type Defines the type of event (KeyboardEventTypes)
  8722. * @param event Defines the related dom event
  8723. */
  8724. constructor(
  8725. /**
  8726. * Defines the type of event (KeyboardEventTypes)
  8727. */
  8728. type: number,
  8729. /**
  8730. * Defines the related dom event
  8731. */
  8732. event: KeyboardEvent);
  8733. }
  8734. /**
  8735. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8736. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8737. */
  8738. export class KeyboardInfoPre extends KeyboardInfo {
  8739. /**
  8740. * Defines the type of event (KeyboardEventTypes)
  8741. */
  8742. type: number;
  8743. /**
  8744. * Defines the related dom event
  8745. */
  8746. event: KeyboardEvent;
  8747. /**
  8748. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8749. */
  8750. skipOnPointerObservable: boolean;
  8751. /**
  8752. * Instantiates a new keyboard pre info.
  8753. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8754. * @param type Defines the type of event (KeyboardEventTypes)
  8755. * @param event Defines the related dom event
  8756. */
  8757. constructor(
  8758. /**
  8759. * Defines the type of event (KeyboardEventTypes)
  8760. */
  8761. type: number,
  8762. /**
  8763. * Defines the related dom event
  8764. */
  8765. event: KeyboardEvent);
  8766. }
  8767. }
  8768. declare module BABYLON {
  8769. /**
  8770. * Manage the keyboard inputs to control the movement of a free camera.
  8771. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8772. */
  8773. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8774. /**
  8775. * Defines the camera the input is attached to.
  8776. */
  8777. camera: FreeCamera;
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8780. */
  8781. keysUp: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8784. */
  8785. keysUpward: number[];
  8786. /**
  8787. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8788. */
  8789. keysDown: number[];
  8790. /**
  8791. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8792. */
  8793. keysDownward: number[];
  8794. /**
  8795. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8796. */
  8797. keysLeft: number[];
  8798. /**
  8799. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8800. */
  8801. keysRight: number[];
  8802. private _keys;
  8803. private _onCanvasBlurObserver;
  8804. private _onKeyboardObserver;
  8805. private _engine;
  8806. private _scene;
  8807. /**
  8808. * Attach the input controls to a specific dom element to get the input from.
  8809. * @param element Defines the element the controls should be listened from
  8810. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8811. */
  8812. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8813. /**
  8814. * Detach the current controls from the specified dom element.
  8815. * @param element Defines the element to stop listening the inputs from
  8816. */
  8817. detachControl(element: Nullable<HTMLElement>): void;
  8818. /**
  8819. * Update the current camera state depending on the inputs that have been used this frame.
  8820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8821. */
  8822. checkInputs(): void;
  8823. /**
  8824. * Gets the class name of the current intput.
  8825. * @returns the class name
  8826. */
  8827. getClassName(): string;
  8828. /** @hidden */
  8829. _onLostFocus(): void;
  8830. /**
  8831. * Get the friendly name associated with the input class.
  8832. * @returns the input friendly name
  8833. */
  8834. getSimpleName(): string;
  8835. }
  8836. }
  8837. declare module BABYLON {
  8838. /**
  8839. * Interface describing all the common properties and methods a shadow light needs to implement.
  8840. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8841. * as well as binding the different shadow properties to the effects.
  8842. */
  8843. export interface IShadowLight extends Light {
  8844. /**
  8845. * The light id in the scene (used in scene.findLighById for instance)
  8846. */
  8847. id: string;
  8848. /**
  8849. * The position the shdow will be casted from.
  8850. */
  8851. position: Vector3;
  8852. /**
  8853. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8854. */
  8855. direction: Vector3;
  8856. /**
  8857. * The transformed position. Position of the light in world space taking parenting in account.
  8858. */
  8859. transformedPosition: Vector3;
  8860. /**
  8861. * The transformed direction. Direction of the light in world space taking parenting in account.
  8862. */
  8863. transformedDirection: Vector3;
  8864. /**
  8865. * The friendly name of the light in the scene.
  8866. */
  8867. name: string;
  8868. /**
  8869. * Defines the shadow projection clipping minimum z value.
  8870. */
  8871. shadowMinZ: number;
  8872. /**
  8873. * Defines the shadow projection clipping maximum z value.
  8874. */
  8875. shadowMaxZ: number;
  8876. /**
  8877. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8878. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8879. */
  8880. computeTransformedInformation(): boolean;
  8881. /**
  8882. * Gets the scene the light belongs to.
  8883. * @returns The scene
  8884. */
  8885. getScene(): Scene;
  8886. /**
  8887. * Callback defining a custom Projection Matrix Builder.
  8888. * This can be used to override the default projection matrix computation.
  8889. */
  8890. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8891. /**
  8892. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8893. * @param matrix The materix to updated with the projection information
  8894. * @param viewMatrix The transform matrix of the light
  8895. * @param renderList The list of mesh to render in the map
  8896. * @returns The current light
  8897. */
  8898. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8899. /**
  8900. * Gets the current depth scale used in ESM.
  8901. * @returns The scale
  8902. */
  8903. getDepthScale(): number;
  8904. /**
  8905. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8906. * @returns true if a cube texture needs to be use
  8907. */
  8908. needCube(): boolean;
  8909. /**
  8910. * Detects if the projection matrix requires to be recomputed this frame.
  8911. * @returns true if it requires to be recomputed otherwise, false.
  8912. */
  8913. needProjectionMatrixCompute(): boolean;
  8914. /**
  8915. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8916. */
  8917. forceProjectionMatrixCompute(): void;
  8918. /**
  8919. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8920. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8921. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8922. */
  8923. getShadowDirection(faceIndex?: number): Vector3;
  8924. /**
  8925. * Gets the minZ used for shadow according to both the scene and the light.
  8926. * @param activeCamera The camera we are returning the min for
  8927. * @returns the depth min z
  8928. */
  8929. getDepthMinZ(activeCamera: Camera): number;
  8930. /**
  8931. * Gets the maxZ used for shadow according to both the scene and the light.
  8932. * @param activeCamera The camera we are returning the max for
  8933. * @returns the depth max z
  8934. */
  8935. getDepthMaxZ(activeCamera: Camera): number;
  8936. }
  8937. /**
  8938. * Base implementation IShadowLight
  8939. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8940. */
  8941. export abstract class ShadowLight extends Light implements IShadowLight {
  8942. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8943. protected _position: Vector3;
  8944. protected _setPosition(value: Vector3): void;
  8945. /**
  8946. * Sets the position the shadow will be casted from. Also use as the light position for both
  8947. * point and spot lights.
  8948. */
  8949. get position(): Vector3;
  8950. /**
  8951. * Sets the position the shadow will be casted from. Also use as the light position for both
  8952. * point and spot lights.
  8953. */
  8954. set position(value: Vector3);
  8955. protected _direction: Vector3;
  8956. protected _setDirection(value: Vector3): void;
  8957. /**
  8958. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8959. * Also use as the light direction on spot and directional lights.
  8960. */
  8961. get direction(): Vector3;
  8962. /**
  8963. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8964. * Also use as the light direction on spot and directional lights.
  8965. */
  8966. set direction(value: Vector3);
  8967. protected _shadowMinZ: number;
  8968. /**
  8969. * Gets the shadow projection clipping minimum z value.
  8970. */
  8971. get shadowMinZ(): number;
  8972. /**
  8973. * Sets the shadow projection clipping minimum z value.
  8974. */
  8975. set shadowMinZ(value: number);
  8976. protected _shadowMaxZ: number;
  8977. /**
  8978. * Sets the shadow projection clipping maximum z value.
  8979. */
  8980. get shadowMaxZ(): number;
  8981. /**
  8982. * Gets the shadow projection clipping maximum z value.
  8983. */
  8984. set shadowMaxZ(value: number);
  8985. /**
  8986. * Callback defining a custom Projection Matrix Builder.
  8987. * This can be used to override the default projection matrix computation.
  8988. */
  8989. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. private _needProjectionMatrixCompute;
  8999. /**
  9000. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9001. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9002. */
  9003. computeTransformedInformation(): boolean;
  9004. /**
  9005. * Return the depth scale used for the shadow map.
  9006. * @returns the depth scale.
  9007. */
  9008. getDepthScale(): number;
  9009. /**
  9010. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9011. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9012. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9013. */
  9014. getShadowDirection(faceIndex?: number): Vector3;
  9015. /**
  9016. * Returns the ShadowLight absolute position in the World.
  9017. * @returns the position vector in world space
  9018. */
  9019. getAbsolutePosition(): Vector3;
  9020. /**
  9021. * Sets the ShadowLight direction toward the passed target.
  9022. * @param target The point to target in local space
  9023. * @returns the updated ShadowLight direction
  9024. */
  9025. setDirectionToTarget(target: Vector3): Vector3;
  9026. /**
  9027. * Returns the light rotation in euler definition.
  9028. * @returns the x y z rotation in local space.
  9029. */
  9030. getRotation(): Vector3;
  9031. /**
  9032. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9033. * @returns true if a cube texture needs to be use
  9034. */
  9035. needCube(): boolean;
  9036. /**
  9037. * Detects if the projection matrix requires to be recomputed this frame.
  9038. * @returns true if it requires to be recomputed otherwise, false.
  9039. */
  9040. needProjectionMatrixCompute(): boolean;
  9041. /**
  9042. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9043. */
  9044. forceProjectionMatrixCompute(): void;
  9045. /** @hidden */
  9046. _initCache(): void;
  9047. /** @hidden */
  9048. _isSynchronized(): boolean;
  9049. /**
  9050. * Computes the world matrix of the node
  9051. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9052. * @returns the world matrix
  9053. */
  9054. computeWorldMatrix(force?: boolean): Matrix;
  9055. /**
  9056. * Gets the minZ used for shadow according to both the scene and the light.
  9057. * @param activeCamera The camera we are returning the min for
  9058. * @returns the depth min z
  9059. */
  9060. getDepthMinZ(activeCamera: Camera): number;
  9061. /**
  9062. * Gets the maxZ used for shadow according to both the scene and the light.
  9063. * @param activeCamera The camera we are returning the max for
  9064. * @returns the depth max z
  9065. */
  9066. getDepthMaxZ(activeCamera: Camera): number;
  9067. /**
  9068. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9069. * @param matrix The materix to updated with the projection information
  9070. * @param viewMatrix The transform matrix of the light
  9071. * @param renderList The list of mesh to render in the map
  9072. * @returns The current light
  9073. */
  9074. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9075. }
  9076. }
  9077. declare module BABYLON {
  9078. /**
  9079. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9080. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9081. */
  9082. export class EffectFallbacks implements IEffectFallbacks {
  9083. private _defines;
  9084. private _currentRank;
  9085. private _maxRank;
  9086. private _mesh;
  9087. /**
  9088. * Removes the fallback from the bound mesh.
  9089. */
  9090. unBindMesh(): void;
  9091. /**
  9092. * Adds a fallback on the specified property.
  9093. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9094. * @param define The name of the define in the shader
  9095. */
  9096. addFallback(rank: number, define: string): void;
  9097. /**
  9098. * Sets the mesh to use CPU skinning when needing to fallback.
  9099. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9100. * @param mesh The mesh to use the fallbacks.
  9101. */
  9102. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9103. /**
  9104. * Checks to see if more fallbacks are still availible.
  9105. */
  9106. get hasMoreFallbacks(): boolean;
  9107. /**
  9108. * Removes the defines that should be removed when falling back.
  9109. * @param currentDefines defines the current define statements for the shader.
  9110. * @param effect defines the current effect we try to compile
  9111. * @returns The resulting defines with defines of the current rank removed.
  9112. */
  9113. reduce(currentDefines: string, effect: Effect): string;
  9114. }
  9115. }
  9116. declare module BABYLON {
  9117. /**
  9118. * "Static Class" containing the most commonly used helper while dealing with material for
  9119. * rendering purpose.
  9120. *
  9121. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9122. *
  9123. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9124. */
  9125. export class MaterialHelper {
  9126. /**
  9127. * Bind the current view position to an effect.
  9128. * @param effect The effect to be bound
  9129. * @param scene The scene the eyes position is used from
  9130. * @param variableName name of the shader variable that will hold the eye position
  9131. */
  9132. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  9133. /**
  9134. * Helps preparing the defines values about the UVs in used in the effect.
  9135. * UVs are shared as much as we can accross channels in the shaders.
  9136. * @param texture The texture we are preparing the UVs for
  9137. * @param defines The defines to update
  9138. * @param key The channel key "diffuse", "specular"... used in the shader
  9139. */
  9140. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9141. /**
  9142. * Binds a texture matrix value to its corrsponding uniform
  9143. * @param texture The texture to bind the matrix for
  9144. * @param uniformBuffer The uniform buffer receivin the data
  9145. * @param key The channel key "diffuse", "specular"... used in the shader
  9146. */
  9147. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9148. /**
  9149. * Gets the current status of the fog (should it be enabled?)
  9150. * @param mesh defines the mesh to evaluate for fog support
  9151. * @param scene defines the hosting scene
  9152. * @returns true if fog must be enabled
  9153. */
  9154. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9155. /**
  9156. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9157. * @param mesh defines the current mesh
  9158. * @param scene defines the current scene
  9159. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9160. * @param pointsCloud defines if point cloud rendering has to be turned on
  9161. * @param fogEnabled defines if fog has to be turned on
  9162. * @param alphaTest defines if alpha testing has to be turned on
  9163. * @param defines defines the current list of defines
  9164. */
  9165. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9166. /**
  9167. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9168. * @param scene defines the current scene
  9169. * @param engine defines the current engine
  9170. * @param defines specifies the list of active defines
  9171. * @param useInstances defines if instances have to be turned on
  9172. * @param useClipPlane defines if clip plane have to be turned on
  9173. */
  9174. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9175. /**
  9176. * Prepares the defines for bones
  9177. * @param mesh The mesh containing the geometry data we will draw
  9178. * @param defines The defines to update
  9179. */
  9180. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9181. /**
  9182. * Prepares the defines for morph targets
  9183. * @param mesh The mesh containing the geometry data we will draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9187. /**
  9188. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9189. * @param mesh The mesh containing the geometry data we will draw
  9190. * @param defines The defines to update
  9191. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9192. * @param useBones Precise whether bones should be used or not (override mesh info)
  9193. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9194. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9195. * @returns false if defines are considered not dirty and have not been checked
  9196. */
  9197. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9198. /**
  9199. * Prepares the defines related to multiview
  9200. * @param scene The scene we are intending to draw
  9201. * @param defines The defines to update
  9202. */
  9203. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9204. /**
  9205. * Prepares the defines related to the light information passed in parameter
  9206. * @param scene The scene we are intending to draw
  9207. * @param mesh The mesh the effect is compiling for
  9208. * @param light The light the effect is compiling for
  9209. * @param lightIndex The index of the light
  9210. * @param defines The defines to update
  9211. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9212. * @param state Defines the current state regarding what is needed (normals, etc...)
  9213. */
  9214. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9215. needNormals: boolean;
  9216. needRebuild: boolean;
  9217. shadowEnabled: boolean;
  9218. specularEnabled: boolean;
  9219. lightmapMode: boolean;
  9220. }): void;
  9221. /**
  9222. * Prepares the defines related to the light information passed in parameter
  9223. * @param scene The scene we are intending to draw
  9224. * @param mesh The mesh the effect is compiling for
  9225. * @param defines The defines to update
  9226. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9227. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9228. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9229. * @returns true if normals will be required for the rest of the effect
  9230. */
  9231. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9232. /**
  9233. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9234. * @param lightIndex defines the light index
  9235. * @param uniformsList The uniform list
  9236. * @param samplersList The sampler list
  9237. * @param projectedLightTexture defines if projected texture must be used
  9238. * @param uniformBuffersList defines an optional list of uniform buffers
  9239. */
  9240. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9241. /**
  9242. * Prepares the uniforms and samplers list to be used in the effect
  9243. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9244. * @param samplersList The sampler list
  9245. * @param defines The defines helping in the list generation
  9246. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9247. */
  9248. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9249. /**
  9250. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9251. * @param defines The defines to update while falling back
  9252. * @param fallbacks The authorized effect fallbacks
  9253. * @param maxSimultaneousLights The maximum number of lights allowed
  9254. * @param rank the current rank of the Effect
  9255. * @returns The newly affected rank
  9256. */
  9257. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9258. private static _TmpMorphInfluencers;
  9259. /**
  9260. * Prepares the list of attributes required for morph targets according to the effect defines.
  9261. * @param attribs The current list of supported attribs
  9262. * @param mesh The mesh to prepare the morph targets attributes for
  9263. * @param influencers The number of influencers
  9264. */
  9265. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9266. /**
  9267. * Prepares the list of attributes required for morph targets according to the effect defines.
  9268. * @param attribs The current list of supported attribs
  9269. * @param mesh The mesh to prepare the morph targets attributes for
  9270. * @param defines The current Defines of the effect
  9271. */
  9272. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9273. /**
  9274. * Prepares the list of attributes required for bones according to the effect defines.
  9275. * @param attribs The current list of supported attribs
  9276. * @param mesh The mesh to prepare the bones attributes for
  9277. * @param defines The current Defines of the effect
  9278. * @param fallbacks The current efffect fallback strategy
  9279. */
  9280. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9281. /**
  9282. * Check and prepare the list of attributes required for instances according to the effect defines.
  9283. * @param attribs The current list of supported attribs
  9284. * @param defines The current MaterialDefines of the effect
  9285. */
  9286. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9287. /**
  9288. * Add the list of attributes required for instances to the attribs array.
  9289. * @param attribs The current list of supported attribs
  9290. */
  9291. static PushAttributesForInstances(attribs: string[]): void;
  9292. /**
  9293. * Binds the light information to the effect.
  9294. * @param light The light containing the generator
  9295. * @param effect The effect we are binding the data to
  9296. * @param lightIndex The light index in the effect used to render
  9297. */
  9298. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9299. /**
  9300. * Binds the lights information from the scene to the effect for the given mesh.
  9301. * @param light Light to bind
  9302. * @param lightIndex Light index
  9303. * @param scene The scene where the light belongs to
  9304. * @param effect The effect we are binding the data to
  9305. * @param useSpecular Defines if specular is supported
  9306. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9307. */
  9308. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9309. /**
  9310. * Binds the lights information from the scene to the effect for the given mesh.
  9311. * @param scene The scene the lights belongs to
  9312. * @param mesh The mesh we are binding the information to render
  9313. * @param effect The effect we are binding the data to
  9314. * @param defines The generated defines for the effect
  9315. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9316. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9317. */
  9318. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9319. private static _tempFogColor;
  9320. /**
  9321. * Binds the fog information from the scene to the effect for the given mesh.
  9322. * @param scene The scene the lights belongs to
  9323. * @param mesh The mesh we are binding the information to render
  9324. * @param effect The effect we are binding the data to
  9325. * @param linearSpace Defines if the fog effect is applied in linear space
  9326. */
  9327. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9328. /**
  9329. * Binds the bones information from the mesh to the effect.
  9330. * @param mesh The mesh we are binding the information to render
  9331. * @param effect The effect we are binding the data to
  9332. */
  9333. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9334. /**
  9335. * Binds the morph targets information from the mesh to the effect.
  9336. * @param abstractMesh The mesh we are binding the information to render
  9337. * @param effect The effect we are binding the data to
  9338. */
  9339. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9340. /**
  9341. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9342. * @param defines The generated defines used in the effect
  9343. * @param effect The effect we are binding the data to
  9344. * @param scene The scene we are willing to render with logarithmic scale for
  9345. */
  9346. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9347. /**
  9348. * Binds the clip plane information from the scene to the effect.
  9349. * @param scene The scene the clip plane information are extracted from
  9350. * @param effect The effect we are binding the data to
  9351. */
  9352. static BindClipPlane(effect: Effect, scene: Scene): void;
  9353. }
  9354. }
  9355. declare module BABYLON {
  9356. /** @hidden */
  9357. export var packingFunctions: {
  9358. name: string;
  9359. shader: string;
  9360. };
  9361. }
  9362. declare module BABYLON {
  9363. /** @hidden */
  9364. export var bayerDitherFunctions: {
  9365. name: string;
  9366. shader: string;
  9367. };
  9368. }
  9369. declare module BABYLON {
  9370. /** @hidden */
  9371. export var shadowMapFragmentDeclaration: {
  9372. name: string;
  9373. shader: string;
  9374. };
  9375. }
  9376. declare module BABYLON {
  9377. /** @hidden */
  9378. export var clipPlaneFragmentDeclaration: {
  9379. name: string;
  9380. shader: string;
  9381. };
  9382. }
  9383. declare module BABYLON {
  9384. /** @hidden */
  9385. export var clipPlaneFragment: {
  9386. name: string;
  9387. shader: string;
  9388. };
  9389. }
  9390. declare module BABYLON {
  9391. /** @hidden */
  9392. export var shadowMapFragment: {
  9393. name: string;
  9394. shader: string;
  9395. };
  9396. }
  9397. declare module BABYLON {
  9398. /** @hidden */
  9399. export var shadowMapPixelShader: {
  9400. name: string;
  9401. shader: string;
  9402. };
  9403. }
  9404. declare module BABYLON {
  9405. /** @hidden */
  9406. export var bonesDeclaration: {
  9407. name: string;
  9408. shader: string;
  9409. };
  9410. }
  9411. declare module BABYLON {
  9412. /** @hidden */
  9413. export var morphTargetsVertexGlobalDeclaration: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module BABYLON {
  9419. /** @hidden */
  9420. export var morphTargetsVertexDeclaration: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module BABYLON {
  9426. /** @hidden */
  9427. export var instancesDeclaration: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module BABYLON {
  9433. /** @hidden */
  9434. export var helperFunctions: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module BABYLON {
  9440. /** @hidden */
  9441. export var shadowMapVertexDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module BABYLON {
  9447. /** @hidden */
  9448. export var clipPlaneVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module BABYLON {
  9454. /** @hidden */
  9455. export var morphTargetsVertex: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module BABYLON {
  9461. /** @hidden */
  9462. export var instancesVertex: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module BABYLON {
  9468. /** @hidden */
  9469. export var bonesVertex: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module BABYLON {
  9475. /** @hidden */
  9476. export var shadowMapVertexNormalBias: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module BABYLON {
  9482. /** @hidden */
  9483. export var shadowMapVertexMetric: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module BABYLON {
  9489. /** @hidden */
  9490. export var clipPlaneVertex: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module BABYLON {
  9496. /** @hidden */
  9497. export var shadowMapVertexShader: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module BABYLON {
  9503. /** @hidden */
  9504. export var depthBoxBlurPixelShader: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module BABYLON {
  9510. /** @hidden */
  9511. export var shadowMapFragmentSoftTransparentShadow: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module BABYLON {
  9517. /**
  9518. * Class representing a ray with position and direction
  9519. */
  9520. export class Ray {
  9521. /** origin point */
  9522. origin: Vector3;
  9523. /** direction */
  9524. direction: Vector3;
  9525. /** length of the ray */
  9526. length: number;
  9527. private static readonly TmpVector3;
  9528. private _tmpRay;
  9529. /**
  9530. * Creates a new ray
  9531. * @param origin origin point
  9532. * @param direction direction
  9533. * @param length length of the ray
  9534. */
  9535. constructor(
  9536. /** origin point */
  9537. origin: Vector3,
  9538. /** direction */
  9539. direction: Vector3,
  9540. /** length of the ray */
  9541. length?: number);
  9542. /**
  9543. * Checks if the ray intersects a box
  9544. * This does not account for the ray lenght by design to improve perfs.
  9545. * @param minimum bound of the box
  9546. * @param maximum bound of the box
  9547. * @param intersectionTreshold extra extend to be added to the box in all direction
  9548. * @returns if the box was hit
  9549. */
  9550. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9551. /**
  9552. * Checks if the ray intersects a box
  9553. * This does not account for the ray lenght by design to improve perfs.
  9554. * @param box the bounding box to check
  9555. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9556. * @returns if the box was hit
  9557. */
  9558. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9559. /**
  9560. * If the ray hits a sphere
  9561. * @param sphere the bounding sphere to check
  9562. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9563. * @returns true if it hits the sphere
  9564. */
  9565. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9566. /**
  9567. * If the ray hits a triange
  9568. * @param vertex0 triangle vertex
  9569. * @param vertex1 triangle vertex
  9570. * @param vertex2 triangle vertex
  9571. * @returns intersection information if hit
  9572. */
  9573. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9574. /**
  9575. * Checks if ray intersects a plane
  9576. * @param plane the plane to check
  9577. * @returns the distance away it was hit
  9578. */
  9579. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9580. /**
  9581. * Calculate the intercept of a ray on a given axis
  9582. * @param axis to check 'x' | 'y' | 'z'
  9583. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9584. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9585. */
  9586. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9587. /**
  9588. * Checks if ray intersects a mesh
  9589. * @param mesh the mesh to check
  9590. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9591. * @returns picking info of the intersecton
  9592. */
  9593. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9594. /**
  9595. * Checks if ray intersects a mesh
  9596. * @param meshes the meshes to check
  9597. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9598. * @param results array to store result in
  9599. * @returns Array of picking infos
  9600. */
  9601. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9602. private _comparePickingInfo;
  9603. private static smallnum;
  9604. private static rayl;
  9605. /**
  9606. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9607. * @param sega the first point of the segment to test the intersection against
  9608. * @param segb the second point of the segment to test the intersection against
  9609. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9610. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9611. */
  9612. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9613. /**
  9614. * Update the ray from viewport position
  9615. * @param x position
  9616. * @param y y position
  9617. * @param viewportWidth viewport width
  9618. * @param viewportHeight viewport height
  9619. * @param world world matrix
  9620. * @param view view matrix
  9621. * @param projection projection matrix
  9622. * @returns this ray updated
  9623. */
  9624. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9625. /**
  9626. * Creates a ray with origin and direction of 0,0,0
  9627. * @returns the new ray
  9628. */
  9629. static Zero(): Ray;
  9630. /**
  9631. * Creates a new ray from screen space and viewport
  9632. * @param x position
  9633. * @param y y position
  9634. * @param viewportWidth viewport width
  9635. * @param viewportHeight viewport height
  9636. * @param world world matrix
  9637. * @param view view matrix
  9638. * @param projection projection matrix
  9639. * @returns new ray
  9640. */
  9641. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9642. /**
  9643. * 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
  9644. * transformed to the given world matrix.
  9645. * @param origin The origin point
  9646. * @param end The end point
  9647. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9648. * @returns the new ray
  9649. */
  9650. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9651. /**
  9652. * Transforms a ray by a matrix
  9653. * @param ray ray to transform
  9654. * @param matrix matrix to apply
  9655. * @returns the resulting new ray
  9656. */
  9657. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9658. /**
  9659. * Transforms a ray by a matrix
  9660. * @param ray ray to transform
  9661. * @param matrix matrix to apply
  9662. * @param result ray to store result in
  9663. */
  9664. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9665. /**
  9666. * Unproject a ray from screen space to object space
  9667. * @param sourceX defines the screen space x coordinate to use
  9668. * @param sourceY defines the screen space y coordinate to use
  9669. * @param viewportWidth defines the current width of the viewport
  9670. * @param viewportHeight defines the current height of the viewport
  9671. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9672. * @param view defines the view matrix to use
  9673. * @param projection defines the projection matrix to use
  9674. */
  9675. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9676. }
  9677. /**
  9678. * Type used to define predicate used to select faces when a mesh intersection is detected
  9679. */
  9680. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9681. interface Scene {
  9682. /** @hidden */
  9683. _tempPickingRay: Nullable<Ray>;
  9684. /** @hidden */
  9685. _cachedRayForTransform: Ray;
  9686. /** @hidden */
  9687. _pickWithRayInverseMatrix: Matrix;
  9688. /** @hidden */
  9689. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9690. /** @hidden */
  9691. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9692. }
  9693. }
  9694. declare module BABYLON {
  9695. /**
  9696. * Groups all the scene component constants in one place to ease maintenance.
  9697. * @hidden
  9698. */
  9699. export class SceneComponentConstants {
  9700. static readonly NAME_EFFECTLAYER: string;
  9701. static readonly NAME_LAYER: string;
  9702. static readonly NAME_LENSFLARESYSTEM: string;
  9703. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9704. static readonly NAME_PARTICLESYSTEM: string;
  9705. static readonly NAME_GAMEPAD: string;
  9706. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9707. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9708. static readonly NAME_DEPTHRENDERER: string;
  9709. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9710. static readonly NAME_SPRITE: string;
  9711. static readonly NAME_OUTLINERENDERER: string;
  9712. static readonly NAME_PROCEDURALTEXTURE: string;
  9713. static readonly NAME_SHADOWGENERATOR: string;
  9714. static readonly NAME_OCTREE: string;
  9715. static readonly NAME_PHYSICSENGINE: string;
  9716. static readonly NAME_AUDIO: string;
  9717. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9718. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9719. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9720. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9721. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9722. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9723. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9724. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9725. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9726. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9727. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9728. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9729. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9730. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9731. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9732. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9733. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9734. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9735. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9736. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9737. static readonly STEP_AFTERRENDER_AUDIO: number;
  9738. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9739. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9740. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9741. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9742. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9743. static readonly STEP_POINTERMOVE_SPRITE: number;
  9744. static readonly STEP_POINTERDOWN_SPRITE: number;
  9745. static readonly STEP_POINTERUP_SPRITE: number;
  9746. }
  9747. /**
  9748. * This represents a scene component.
  9749. *
  9750. * This is used to decouple the dependency the scene is having on the different workloads like
  9751. * layers, post processes...
  9752. */
  9753. export interface ISceneComponent {
  9754. /**
  9755. * The name of the component. Each component must have a unique name.
  9756. */
  9757. name: string;
  9758. /**
  9759. * The scene the component belongs to.
  9760. */
  9761. scene: Scene;
  9762. /**
  9763. * Register the component to one instance of a scene.
  9764. */
  9765. register(): void;
  9766. /**
  9767. * Rebuilds the elements related to this component in case of
  9768. * context lost for instance.
  9769. */
  9770. rebuild(): void;
  9771. /**
  9772. * Disposes the component and the associated ressources.
  9773. */
  9774. dispose(): void;
  9775. }
  9776. /**
  9777. * This represents a SERIALIZABLE scene component.
  9778. *
  9779. * This extends Scene Component to add Serialization methods on top.
  9780. */
  9781. export interface ISceneSerializableComponent extends ISceneComponent {
  9782. /**
  9783. * Adds all the elements from the container to the scene
  9784. * @param container the container holding the elements
  9785. */
  9786. addFromContainer(container: AbstractScene): void;
  9787. /**
  9788. * Removes all the elements in the container from the scene
  9789. * @param container contains the elements to remove
  9790. * @param dispose if the removed element should be disposed (default: false)
  9791. */
  9792. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9793. /**
  9794. * Serializes the component data to the specified json object
  9795. * @param serializationObject The object to serialize to
  9796. */
  9797. serialize(serializationObject: any): void;
  9798. }
  9799. /**
  9800. * Strong typing of a Mesh related stage step action
  9801. */
  9802. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9803. /**
  9804. * Strong typing of a Evaluate Sub Mesh related stage step action
  9805. */
  9806. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9807. /**
  9808. * Strong typing of a Active Mesh related stage step action
  9809. */
  9810. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9811. /**
  9812. * Strong typing of a Camera related stage step action
  9813. */
  9814. export type CameraStageAction = (camera: Camera) => void;
  9815. /**
  9816. * Strong typing of a Camera Frame buffer related stage step action
  9817. */
  9818. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9819. /**
  9820. * Strong typing of a Render Target related stage step action
  9821. */
  9822. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9823. /**
  9824. * Strong typing of a RenderingGroup related stage step action
  9825. */
  9826. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9827. /**
  9828. * Strong typing of a Mesh Render related stage step action
  9829. */
  9830. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9831. /**
  9832. * Strong typing of a simple stage step action
  9833. */
  9834. export type SimpleStageAction = () => void;
  9835. /**
  9836. * Strong typing of a render target action.
  9837. */
  9838. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9839. /**
  9840. * Strong typing of a pointer move action.
  9841. */
  9842. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9843. /**
  9844. * Strong typing of a pointer up/down action.
  9845. */
  9846. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9847. /**
  9848. * Representation of a stage in the scene (Basically a list of ordered steps)
  9849. * @hidden
  9850. */
  9851. export class Stage<T extends Function> extends Array<{
  9852. index: number;
  9853. component: ISceneComponent;
  9854. action: T;
  9855. }> {
  9856. /**
  9857. * Hide ctor from the rest of the world.
  9858. * @param items The items to add.
  9859. */
  9860. private constructor();
  9861. /**
  9862. * Creates a new Stage.
  9863. * @returns A new instance of a Stage
  9864. */
  9865. static Create<T extends Function>(): Stage<T>;
  9866. /**
  9867. * Registers a step in an ordered way in the targeted stage.
  9868. * @param index Defines the position to register the step in
  9869. * @param component Defines the component attached to the step
  9870. * @param action Defines the action to launch during the step
  9871. */
  9872. registerStep(index: number, component: ISceneComponent, action: T): void;
  9873. /**
  9874. * Clears all the steps from the stage.
  9875. */
  9876. clear(): void;
  9877. }
  9878. }
  9879. declare module BABYLON {
  9880. interface Scene {
  9881. /** @hidden */
  9882. _pointerOverSprite: Nullable<Sprite>;
  9883. /** @hidden */
  9884. _pickedDownSprite: Nullable<Sprite>;
  9885. /** @hidden */
  9886. _tempSpritePickingRay: Nullable<Ray>;
  9887. /**
  9888. * All of the sprite managers added to this scene
  9889. * @see http://doc.babylonjs.com/babylon101/sprites
  9890. */
  9891. spriteManagers: Array<ISpriteManager>;
  9892. /**
  9893. * An event triggered when sprites rendering is about to start
  9894. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9895. */
  9896. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9897. /**
  9898. * An event triggered when sprites rendering is done
  9899. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9900. */
  9901. onAfterSpritesRenderingObservable: Observable<Scene>;
  9902. /** @hidden */
  9903. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9904. /** Launch a ray to try to pick a sprite in the scene
  9905. * @param x position on screen
  9906. * @param y position on screen
  9907. * @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
  9908. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9909. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9910. * @returns a PickingInfo
  9911. */
  9912. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9913. /** Use the given ray to pick a sprite in the scene
  9914. * @param ray The ray (in world space) to use to pick meshes
  9915. * @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
  9916. * @param fastCheck defines if the first intersection will be used (and not the closest)
  9917. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9918. * @returns a PickingInfo
  9919. */
  9920. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9921. /** @hidden */
  9922. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9923. /** Launch a ray to try to pick sprites in the scene
  9924. * @param x position on screen
  9925. * @param y position on screen
  9926. * @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
  9927. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9928. * @returns a PickingInfo array
  9929. */
  9930. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9931. /** Use the given ray to pick sprites in the scene
  9932. * @param ray The ray (in world space) to use to pick meshes
  9933. * @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
  9934. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9935. * @returns a PickingInfo array
  9936. */
  9937. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9938. /**
  9939. * Force the sprite under the pointer
  9940. * @param sprite defines the sprite to use
  9941. */
  9942. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9943. /**
  9944. * Gets the sprite under the pointer
  9945. * @returns a Sprite or null if no sprite is under the pointer
  9946. */
  9947. getPointerOverSprite(): Nullable<Sprite>;
  9948. }
  9949. /**
  9950. * Defines the sprite scene component responsible to manage sprites
  9951. * in a given scene.
  9952. */
  9953. export class SpriteSceneComponent implements ISceneComponent {
  9954. /**
  9955. * The component name helpfull to identify the component in the list of scene components.
  9956. */
  9957. readonly name: string;
  9958. /**
  9959. * The scene the component belongs to.
  9960. */
  9961. scene: Scene;
  9962. /** @hidden */
  9963. private _spritePredicate;
  9964. /**
  9965. * Creates a new instance of the component for the given scene
  9966. * @param scene Defines the scene to register the component in
  9967. */
  9968. constructor(scene: Scene);
  9969. /**
  9970. * Registers the component in a given scene
  9971. */
  9972. register(): void;
  9973. /**
  9974. * Rebuilds the elements related to this component in case of
  9975. * context lost for instance.
  9976. */
  9977. rebuild(): void;
  9978. /**
  9979. * Disposes the component and the associated ressources.
  9980. */
  9981. dispose(): void;
  9982. private _pickSpriteButKeepRay;
  9983. private _pointerMove;
  9984. private _pointerDown;
  9985. private _pointerUp;
  9986. }
  9987. }
  9988. declare module BABYLON {
  9989. /** @hidden */
  9990. export var fogFragmentDeclaration: {
  9991. name: string;
  9992. shader: string;
  9993. };
  9994. }
  9995. declare module BABYLON {
  9996. /** @hidden */
  9997. export var fogFragment: {
  9998. name: string;
  9999. shader: string;
  10000. };
  10001. }
  10002. declare module BABYLON {
  10003. /** @hidden */
  10004. export var spritesPixelShader: {
  10005. name: string;
  10006. shader: string;
  10007. };
  10008. }
  10009. declare module BABYLON {
  10010. /** @hidden */
  10011. export var fogVertexDeclaration: {
  10012. name: string;
  10013. shader: string;
  10014. };
  10015. }
  10016. declare module BABYLON {
  10017. /** @hidden */
  10018. export var spritesVertexShader: {
  10019. name: string;
  10020. shader: string;
  10021. };
  10022. }
  10023. declare module BABYLON {
  10024. /**
  10025. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10026. */
  10027. export interface ISpriteManager extends IDisposable {
  10028. /**
  10029. * Gets manager's name
  10030. */
  10031. name: string;
  10032. /**
  10033. * Restricts the camera to viewing objects with the same layerMask.
  10034. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10035. */
  10036. layerMask: number;
  10037. /**
  10038. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10039. */
  10040. isPickable: boolean;
  10041. /**
  10042. * Gets the hosting scene
  10043. */
  10044. scene: Scene;
  10045. /**
  10046. * Specifies the rendering group id for this mesh (0 by default)
  10047. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10048. */
  10049. renderingGroupId: number;
  10050. /**
  10051. * Defines the list of sprites managed by the manager.
  10052. */
  10053. sprites: Array<Sprite>;
  10054. /**
  10055. * Gets or sets the spritesheet texture
  10056. */
  10057. texture: Texture;
  10058. /** Defines the default width of a cell in the spritesheet */
  10059. cellWidth: number;
  10060. /** Defines the default height of a cell in the spritesheet */
  10061. cellHeight: number;
  10062. /**
  10063. * Tests the intersection of a sprite with a specific ray.
  10064. * @param ray The ray we are sending to test the collision
  10065. * @param camera The camera space we are sending rays in
  10066. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10067. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10068. * @returns picking info or null.
  10069. */
  10070. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10071. /**
  10072. * Intersects the sprites with a ray
  10073. * @param ray defines the ray to intersect with
  10074. * @param camera defines the current active camera
  10075. * @param predicate defines a predicate used to select candidate sprites
  10076. * @returns null if no hit or a PickingInfo array
  10077. */
  10078. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10079. /**
  10080. * Renders the list of sprites on screen.
  10081. */
  10082. render(): void;
  10083. }
  10084. /**
  10085. * Class used to manage multiple sprites on the same spritesheet
  10086. * @see http://doc.babylonjs.com/babylon101/sprites
  10087. */
  10088. export class SpriteManager implements ISpriteManager {
  10089. /** defines the manager's name */
  10090. name: string;
  10091. /** Gets the list of sprites */
  10092. sprites: Sprite[];
  10093. /** Gets or sets the rendering group id (0 by default) */
  10094. renderingGroupId: number;
  10095. /** Gets or sets camera layer mask */
  10096. layerMask: number;
  10097. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10098. fogEnabled: boolean;
  10099. /** Gets or sets a boolean indicating if the sprites are pickable */
  10100. isPickable: boolean;
  10101. /** Defines the default width of a cell in the spritesheet */
  10102. cellWidth: number;
  10103. /** Defines the default height of a cell in the spritesheet */
  10104. cellHeight: number;
  10105. /** Associative array from JSON sprite data file */
  10106. private _cellData;
  10107. /** Array of sprite names from JSON sprite data file */
  10108. private _spriteMap;
  10109. /** True when packed cell data from JSON file is ready*/
  10110. private _packedAndReady;
  10111. private _textureContent;
  10112. /**
  10113. * An event triggered when the manager is disposed.
  10114. */
  10115. onDisposeObservable: Observable<SpriteManager>;
  10116. private _onDisposeObserver;
  10117. /**
  10118. * Callback called when the manager is disposed
  10119. */
  10120. set onDispose(callback: () => void);
  10121. private _capacity;
  10122. private _fromPacked;
  10123. private _spriteTexture;
  10124. private _epsilon;
  10125. private _scene;
  10126. private _vertexData;
  10127. private _buffer;
  10128. private _vertexBuffers;
  10129. private _indexBuffer;
  10130. private _effectBase;
  10131. private _effectFog;
  10132. /**
  10133. * Gets or sets the unique id of the sprite
  10134. */
  10135. uniqueId: number;
  10136. /**
  10137. * Gets the array of sprites
  10138. */
  10139. get children(): Sprite[];
  10140. /**
  10141. * Gets the hosting scene
  10142. */
  10143. get scene(): Scene;
  10144. /**
  10145. * Gets or sets the capacity of the manager
  10146. */
  10147. get capacity(): number;
  10148. set capacity(value: number);
  10149. /**
  10150. * Gets or sets the spritesheet texture
  10151. */
  10152. get texture(): Texture;
  10153. set texture(value: Texture);
  10154. private _blendMode;
  10155. /**
  10156. * Blend mode use to render the particle, it can be any of
  10157. * the static Constants.ALPHA_x properties provided in this class.
  10158. * Default value is Constants.ALPHA_COMBINE
  10159. */
  10160. get blendMode(): number;
  10161. set blendMode(blendMode: number);
  10162. /** Disables writing to the depth buffer when rendering the sprites.
  10163. * It can be handy to disable depth writing when using textures without alpha channel
  10164. * and setting some specific blend modes.
  10165. */
  10166. disableDepthWrite: boolean;
  10167. /**
  10168. * Creates a new sprite manager
  10169. * @param name defines the manager's name
  10170. * @param imgUrl defines the sprite sheet url
  10171. * @param capacity defines the maximum allowed number of sprites
  10172. * @param cellSize defines the size of a sprite cell
  10173. * @param scene defines the hosting scene
  10174. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10175. * @param samplingMode defines the smapling mode to use with spritesheet
  10176. * @param fromPacked set to false; do not alter
  10177. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10178. */
  10179. constructor(
  10180. /** defines the manager's name */
  10181. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10182. /**
  10183. * Returns the string "SpriteManager"
  10184. * @returns "SpriteManager"
  10185. */
  10186. getClassName(): string;
  10187. private _makePacked;
  10188. private _appendSpriteVertex;
  10189. private _checkTextureAlpha;
  10190. /**
  10191. * Intersects the sprites with a ray
  10192. * @param ray defines the ray to intersect with
  10193. * @param camera defines the current active camera
  10194. * @param predicate defines a predicate used to select candidate sprites
  10195. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10196. * @returns null if no hit or a PickingInfo
  10197. */
  10198. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10199. /**
  10200. * Intersects the sprites with a ray
  10201. * @param ray defines the ray to intersect with
  10202. * @param camera defines the current active camera
  10203. * @param predicate defines a predicate used to select candidate sprites
  10204. * @returns null if no hit or a PickingInfo array
  10205. */
  10206. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10207. /**
  10208. * Render all child sprites
  10209. */
  10210. render(): void;
  10211. /**
  10212. * Release associated resources
  10213. */
  10214. dispose(): void;
  10215. }
  10216. }
  10217. declare module BABYLON {
  10218. /** Interface used by value gradients (color, factor, ...) */
  10219. export interface IValueGradient {
  10220. /**
  10221. * Gets or sets the gradient value (between 0 and 1)
  10222. */
  10223. gradient: number;
  10224. }
  10225. /** Class used to store color4 gradient */
  10226. export class ColorGradient implements IValueGradient {
  10227. /**
  10228. * Gets or sets the gradient value (between 0 and 1)
  10229. */
  10230. gradient: number;
  10231. /**
  10232. * Gets or sets first associated color
  10233. */
  10234. color1: Color4;
  10235. /**
  10236. * Gets or sets second associated color
  10237. */
  10238. color2?: Color4 | undefined;
  10239. /**
  10240. * Creates a new color4 gradient
  10241. * @param gradient gets or sets the gradient value (between 0 and 1)
  10242. * @param color1 gets or sets first associated color
  10243. * @param color2 gets or sets first second color
  10244. */
  10245. constructor(
  10246. /**
  10247. * Gets or sets the gradient value (between 0 and 1)
  10248. */
  10249. gradient: number,
  10250. /**
  10251. * Gets or sets first associated color
  10252. */
  10253. color1: Color4,
  10254. /**
  10255. * Gets or sets second associated color
  10256. */
  10257. color2?: Color4 | undefined);
  10258. /**
  10259. * Will get a color picked randomly between color1 and color2.
  10260. * If color2 is undefined then color1 will be used
  10261. * @param result defines the target Color4 to store the result in
  10262. */
  10263. getColorToRef(result: Color4): void;
  10264. }
  10265. /** Class used to store color 3 gradient */
  10266. export class Color3Gradient implements IValueGradient {
  10267. /**
  10268. * Gets or sets the gradient value (between 0 and 1)
  10269. */
  10270. gradient: number;
  10271. /**
  10272. * Gets or sets the associated color
  10273. */
  10274. color: Color3;
  10275. /**
  10276. * Creates a new color3 gradient
  10277. * @param gradient gets or sets the gradient value (between 0 and 1)
  10278. * @param color gets or sets associated color
  10279. */
  10280. constructor(
  10281. /**
  10282. * Gets or sets the gradient value (between 0 and 1)
  10283. */
  10284. gradient: number,
  10285. /**
  10286. * Gets or sets the associated color
  10287. */
  10288. color: Color3);
  10289. }
  10290. /** Class used to store factor gradient */
  10291. export class FactorGradient implements IValueGradient {
  10292. /**
  10293. * Gets or sets the gradient value (between 0 and 1)
  10294. */
  10295. gradient: number;
  10296. /**
  10297. * Gets or sets first associated factor
  10298. */
  10299. factor1: number;
  10300. /**
  10301. * Gets or sets second associated factor
  10302. */
  10303. factor2?: number | undefined;
  10304. /**
  10305. * Creates a new factor gradient
  10306. * @param gradient gets or sets the gradient value (between 0 and 1)
  10307. * @param factor1 gets or sets first associated factor
  10308. * @param factor2 gets or sets second associated factor
  10309. */
  10310. constructor(
  10311. /**
  10312. * Gets or sets the gradient value (between 0 and 1)
  10313. */
  10314. gradient: number,
  10315. /**
  10316. * Gets or sets first associated factor
  10317. */
  10318. factor1: number,
  10319. /**
  10320. * Gets or sets second associated factor
  10321. */
  10322. factor2?: number | undefined);
  10323. /**
  10324. * Will get a number picked randomly between factor1 and factor2.
  10325. * If factor2 is undefined then factor1 will be used
  10326. * @returns the picked number
  10327. */
  10328. getFactor(): number;
  10329. }
  10330. /**
  10331. * Helper used to simplify some generic gradient tasks
  10332. */
  10333. export class GradientHelper {
  10334. /**
  10335. * Gets the current gradient from an array of IValueGradient
  10336. * @param ratio defines the current ratio to get
  10337. * @param gradients defines the array of IValueGradient
  10338. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10339. */
  10340. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10341. }
  10342. }
  10343. declare module BABYLON {
  10344. /**
  10345. * Interface for the size containing width and height
  10346. */
  10347. export interface ISize {
  10348. /**
  10349. * Width
  10350. */
  10351. width: number;
  10352. /**
  10353. * Heighht
  10354. */
  10355. height: number;
  10356. }
  10357. /**
  10358. * Size containing widht and height
  10359. */
  10360. export class Size implements ISize {
  10361. /**
  10362. * Width
  10363. */
  10364. width: number;
  10365. /**
  10366. * Height
  10367. */
  10368. height: number;
  10369. /**
  10370. * Creates a Size object from the given width and height (floats).
  10371. * @param width width of the new size
  10372. * @param height height of the new size
  10373. */
  10374. constructor(width: number, height: number);
  10375. /**
  10376. * Returns a string with the Size width and height
  10377. * @returns a string with the Size width and height
  10378. */
  10379. toString(): string;
  10380. /**
  10381. * "Size"
  10382. * @returns the string "Size"
  10383. */
  10384. getClassName(): string;
  10385. /**
  10386. * Returns the Size hash code.
  10387. * @returns a hash code for a unique width and height
  10388. */
  10389. getHashCode(): number;
  10390. /**
  10391. * Updates the current size from the given one.
  10392. * @param src the given size
  10393. */
  10394. copyFrom(src: Size): void;
  10395. /**
  10396. * Updates in place the current Size from the given floats.
  10397. * @param width width of the new size
  10398. * @param height height of the new size
  10399. * @returns the updated Size.
  10400. */
  10401. copyFromFloats(width: number, height: number): Size;
  10402. /**
  10403. * Updates in place the current Size from the given floats.
  10404. * @param width width to set
  10405. * @param height height to set
  10406. * @returns the updated Size.
  10407. */
  10408. set(width: number, height: number): Size;
  10409. /**
  10410. * Multiplies the width and height by numbers
  10411. * @param w factor to multiple the width by
  10412. * @param h factor to multiple the height by
  10413. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10414. */
  10415. multiplyByFloats(w: number, h: number): Size;
  10416. /**
  10417. * Clones the size
  10418. * @returns a new Size copied from the given one.
  10419. */
  10420. clone(): Size;
  10421. /**
  10422. * True if the current Size and the given one width and height are strictly equal.
  10423. * @param other the other size to compare against
  10424. * @returns True if the current Size and the given one width and height are strictly equal.
  10425. */
  10426. equals(other: Size): boolean;
  10427. /**
  10428. * The surface of the Size : width * height (float).
  10429. */
  10430. get surface(): number;
  10431. /**
  10432. * Create a new size of zero
  10433. * @returns a new Size set to (0.0, 0.0)
  10434. */
  10435. static Zero(): Size;
  10436. /**
  10437. * Sums the width and height of two sizes
  10438. * @param otherSize size to add to this size
  10439. * @returns a new Size set as the addition result of the current Size and the given one.
  10440. */
  10441. add(otherSize: Size): Size;
  10442. /**
  10443. * Subtracts the width and height of two
  10444. * @param otherSize size to subtract to this size
  10445. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10446. */
  10447. subtract(otherSize: Size): Size;
  10448. /**
  10449. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10450. * @param start starting size to lerp between
  10451. * @param end end size to lerp between
  10452. * @param amount amount to lerp between the start and end values
  10453. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10454. */
  10455. static Lerp(start: Size, end: Size, amount: number): Size;
  10456. }
  10457. }
  10458. declare module BABYLON {
  10459. interface ThinEngine {
  10460. /**
  10461. * Creates a dynamic texture
  10462. * @param width defines the width of the texture
  10463. * @param height defines the height of the texture
  10464. * @param generateMipMaps defines if the engine should generate the mip levels
  10465. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10466. * @returns the dynamic texture inside an InternalTexture
  10467. */
  10468. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10469. /**
  10470. * Update the content of a dynamic texture
  10471. * @param texture defines the texture to update
  10472. * @param canvas defines the canvas containing the source
  10473. * @param invertY defines if data must be stored with Y axis inverted
  10474. * @param premulAlpha defines if alpha is stored as premultiplied
  10475. * @param format defines the format of the data
  10476. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10477. */
  10478. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10479. }
  10480. }
  10481. declare module BABYLON {
  10482. /**
  10483. * Helper class used to generate a canvas to manipulate images
  10484. */
  10485. export class CanvasGenerator {
  10486. /**
  10487. * Create a new canvas (or offscreen canvas depending on the context)
  10488. * @param width defines the expected width
  10489. * @param height defines the expected height
  10490. * @return a new canvas or offscreen canvas
  10491. */
  10492. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10493. }
  10494. }
  10495. declare module BABYLON {
  10496. /**
  10497. * A class extending Texture allowing drawing on a texture
  10498. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10499. */
  10500. export class DynamicTexture extends Texture {
  10501. private _generateMipMaps;
  10502. private _canvas;
  10503. private _context;
  10504. /**
  10505. * Creates a DynamicTexture
  10506. * @param name defines the name of the texture
  10507. * @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
  10508. * @param scene defines the scene where you want the texture
  10509. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10510. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10511. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10512. */
  10513. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10514. /**
  10515. * Get the current class name of the texture useful for serialization or dynamic coding.
  10516. * @returns "DynamicTexture"
  10517. */
  10518. getClassName(): string;
  10519. /**
  10520. * Gets the current state of canRescale
  10521. */
  10522. get canRescale(): boolean;
  10523. private _recreate;
  10524. /**
  10525. * Scales the texture
  10526. * @param ratio the scale factor to apply to both width and height
  10527. */
  10528. scale(ratio: number): void;
  10529. /**
  10530. * Resizes the texture
  10531. * @param width the new width
  10532. * @param height the new height
  10533. */
  10534. scaleTo(width: number, height: number): void;
  10535. /**
  10536. * Gets the context of the canvas used by the texture
  10537. * @returns the canvas context of the dynamic texture
  10538. */
  10539. getContext(): CanvasRenderingContext2D;
  10540. /**
  10541. * Clears the texture
  10542. */
  10543. clear(): void;
  10544. /**
  10545. * Updates the texture
  10546. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10547. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10548. */
  10549. update(invertY?: boolean, premulAlpha?: boolean): void;
  10550. /**
  10551. * Draws text onto the texture
  10552. * @param text defines the text to be drawn
  10553. * @param x defines the placement of the text from the left
  10554. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10555. * @param font defines the font to be used with font-style, font-size, font-name
  10556. * @param color defines the color used for the text
  10557. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10558. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10559. * @param update defines whether texture is immediately update (default is true)
  10560. */
  10561. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10562. /**
  10563. * Clones the texture
  10564. * @returns the clone of the texture.
  10565. */
  10566. clone(): DynamicTexture;
  10567. /**
  10568. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10569. * @returns a serialized dynamic texture object
  10570. */
  10571. serialize(): any;
  10572. /** @hidden */
  10573. _rebuild(): void;
  10574. }
  10575. }
  10576. declare module BABYLON {
  10577. interface ThinEngine {
  10578. /**
  10579. * Creates a raw texture
  10580. * @param data defines the data to store in the texture
  10581. * @param width defines the width of the texture
  10582. * @param height defines the height of the texture
  10583. * @param format defines the format of the data
  10584. * @param generateMipMaps defines if the engine should generate the mip levels
  10585. * @param invertY defines if data must be stored with Y axis inverted
  10586. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10587. * @param compression defines the compression used (null by default)
  10588. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10589. * @returns the raw texture inside an InternalTexture
  10590. */
  10591. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10592. /**
  10593. * Update a raw texture
  10594. * @param texture defines the texture to update
  10595. * @param data defines the data to store in the texture
  10596. * @param format defines the format of the data
  10597. * @param invertY defines if data must be stored with Y axis inverted
  10598. */
  10599. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10600. /**
  10601. * Update a raw texture
  10602. * @param texture defines the texture to update
  10603. * @param data defines the data to store in the texture
  10604. * @param format defines the format of the data
  10605. * @param invertY defines if data must be stored with Y axis inverted
  10606. * @param compression defines the compression used (null by default)
  10607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10608. */
  10609. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10610. /**
  10611. * Creates a new raw cube texture
  10612. * @param data defines the array of data to use to create each face
  10613. * @param size defines the size of the textures
  10614. * @param format defines the format of the data
  10615. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10616. * @param generateMipMaps defines if the engine should generate the mip levels
  10617. * @param invertY defines if data must be stored with Y axis inverted
  10618. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10619. * @param compression defines the compression used (null by default)
  10620. * @returns the cube texture as an InternalTexture
  10621. */
  10622. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10623. /**
  10624. * Update a raw cube texture
  10625. * @param texture defines the texture to udpdate
  10626. * @param data defines the data to store
  10627. * @param format defines the data format
  10628. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10629. * @param invertY defines if data must be stored with Y axis inverted
  10630. */
  10631. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10632. /**
  10633. * Update a raw cube texture
  10634. * @param texture defines the texture to udpdate
  10635. * @param data defines the data to store
  10636. * @param format defines the data format
  10637. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10638. * @param invertY defines if data must be stored with Y axis inverted
  10639. * @param compression defines the compression used (null by default)
  10640. */
  10641. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10642. /**
  10643. * Update a raw cube texture
  10644. * @param texture defines the texture to udpdate
  10645. * @param data defines the data to store
  10646. * @param format defines the data format
  10647. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10648. * @param invertY defines if data must be stored with Y axis inverted
  10649. * @param compression defines the compression used (null by default)
  10650. * @param level defines which level of the texture to update
  10651. */
  10652. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10653. /**
  10654. * Creates a new raw cube texture from a specified url
  10655. * @param url defines the url where the data is located
  10656. * @param scene defines the current scene
  10657. * @param size defines the size of the textures
  10658. * @param format defines the format of the data
  10659. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10660. * @param noMipmap defines if the engine should avoid generating the mip levels
  10661. * @param callback defines a callback used to extract texture data from loaded data
  10662. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10663. * @param onLoad defines a callback called when texture is loaded
  10664. * @param onError defines a callback called if there is an error
  10665. * @returns the cube texture as an InternalTexture
  10666. */
  10667. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10668. /**
  10669. * Creates a new raw cube texture from a specified url
  10670. * @param url defines the url where the data is located
  10671. * @param scene defines the current scene
  10672. * @param size defines the size of the textures
  10673. * @param format defines the format of the data
  10674. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10675. * @param noMipmap defines if the engine should avoid generating the mip levels
  10676. * @param callback defines a callback used to extract texture data from loaded data
  10677. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10678. * @param onLoad defines a callback called when texture is loaded
  10679. * @param onError defines a callback called if there is an error
  10680. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10681. * @param invertY defines if data must be stored with Y axis inverted
  10682. * @returns the cube texture as an InternalTexture
  10683. */
  10684. createRawCubeTextureFromUrl(url: string, scene: Nullable<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;
  10685. /**
  10686. * Creates a new raw 3D texture
  10687. * @param data defines the data used to create the texture
  10688. * @param width defines the width of the texture
  10689. * @param height defines the height of the texture
  10690. * @param depth defines the depth of the texture
  10691. * @param format defines the format of the texture
  10692. * @param generateMipMaps defines if the engine must generate mip levels
  10693. * @param invertY defines if data must be stored with Y axis inverted
  10694. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10695. * @param compression defines the compressed used (can be null)
  10696. * @param textureType defines the compressed used (can be null)
  10697. * @returns a new raw 3D texture (stored in an InternalTexture)
  10698. */
  10699. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10700. /**
  10701. * Update a raw 3D texture
  10702. * @param texture defines the texture to update
  10703. * @param data defines the data to store
  10704. * @param format defines the data format
  10705. * @param invertY defines if data must be stored with Y axis inverted
  10706. */
  10707. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10708. /**
  10709. * Update a raw 3D texture
  10710. * @param texture defines the texture to update
  10711. * @param data defines the data to store
  10712. * @param format defines the data format
  10713. * @param invertY defines if data must be stored with Y axis inverted
  10714. * @param compression defines the used compression (can be null)
  10715. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10716. */
  10717. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10718. /**
  10719. * Creates a new raw 2D array texture
  10720. * @param data defines the data used to create the texture
  10721. * @param width defines the width of the texture
  10722. * @param height defines the height of the texture
  10723. * @param depth defines the number of layers of the texture
  10724. * @param format defines the format of the texture
  10725. * @param generateMipMaps defines if the engine must generate mip levels
  10726. * @param invertY defines if data must be stored with Y axis inverted
  10727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10728. * @param compression defines the compressed used (can be null)
  10729. * @param textureType defines the compressed used (can be null)
  10730. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10731. */
  10732. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10733. /**
  10734. * Update a raw 2D array texture
  10735. * @param texture defines the texture to update
  10736. * @param data defines the data to store
  10737. * @param format defines the data format
  10738. * @param invertY defines if data must be stored with Y axis inverted
  10739. */
  10740. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10741. /**
  10742. * Update a raw 2D array texture
  10743. * @param texture defines the texture to update
  10744. * @param data defines the data to store
  10745. * @param format defines the data format
  10746. * @param invertY defines if data must be stored with Y axis inverted
  10747. * @param compression defines the used compression (can be null)
  10748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10749. */
  10750. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10751. }
  10752. }
  10753. declare module BABYLON {
  10754. /**
  10755. * Raw texture can help creating a texture directly from an array of data.
  10756. * This can be super useful if you either get the data from an uncompressed source or
  10757. * if you wish to create your texture pixel by pixel.
  10758. */
  10759. export class RawTexture extends Texture {
  10760. /**
  10761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10762. */
  10763. format: number;
  10764. /**
  10765. * Instantiates a new RawTexture.
  10766. * Raw texture can help creating a texture directly from an array of data.
  10767. * This can be super useful if you either get the data from an uncompressed source or
  10768. * if you wish to create your texture pixel by pixel.
  10769. * @param data define the array of data to use to create the texture
  10770. * @param width define the width of the texture
  10771. * @param height define the height of the texture
  10772. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10773. * @param scene define the scene the texture belongs to
  10774. * @param generateMipMaps define whether mip maps should be generated or not
  10775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10778. */
  10779. constructor(data: ArrayBufferView, width: number, height: number,
  10780. /**
  10781. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10782. */
  10783. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10784. /**
  10785. * Updates the texture underlying data.
  10786. * @param data Define the new data of the texture
  10787. */
  10788. update(data: ArrayBufferView): void;
  10789. /**
  10790. * Creates a luminance texture from some data.
  10791. * @param data Define the texture data
  10792. * @param width Define the width of the texture
  10793. * @param height Define the height of the texture
  10794. * @param scene Define the scene the texture belongs to
  10795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10798. * @returns the luminance texture
  10799. */
  10800. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10801. /**
  10802. * Creates a luminance alpha texture from some data.
  10803. * @param data Define the texture data
  10804. * @param width Define the width of the texture
  10805. * @param height Define the height of the texture
  10806. * @param scene Define the scene the texture belongs to
  10807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10810. * @returns the luminance alpha texture
  10811. */
  10812. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10813. /**
  10814. * Creates an alpha texture from some data.
  10815. * @param data Define the texture data
  10816. * @param width Define the width of the texture
  10817. * @param height Define the height of the texture
  10818. * @param scene Define the scene the texture belongs to
  10819. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10820. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10821. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10822. * @returns the alpha texture
  10823. */
  10824. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10825. /**
  10826. * Creates a RGB texture from some data.
  10827. * @param data Define the texture data
  10828. * @param width Define the width of the texture
  10829. * @param height Define the height of the texture
  10830. * @param scene Define the scene the texture belongs to
  10831. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10832. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10833. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10834. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10835. * @returns the RGB alpha texture
  10836. */
  10837. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10838. /**
  10839. * Creates a RGBA texture from some data.
  10840. * @param data Define the texture data
  10841. * @param width Define the width of the texture
  10842. * @param height Define the height of the texture
  10843. * @param scene Define the scene the texture belongs to
  10844. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10845. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10846. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10847. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10848. * @returns the RGBA texture
  10849. */
  10850. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10851. /**
  10852. * Creates a R texture from some data.
  10853. * @param data Define the texture data
  10854. * @param width Define the width of the texture
  10855. * @param height Define the height of the texture
  10856. * @param scene Define the scene the texture belongs to
  10857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10860. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10861. * @returns the R texture
  10862. */
  10863. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10864. }
  10865. }
  10866. declare module BABYLON {
  10867. interface AbstractScene {
  10868. /**
  10869. * The list of procedural textures added to the scene
  10870. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10871. */
  10872. proceduralTextures: Array<ProceduralTexture>;
  10873. }
  10874. /**
  10875. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10876. * in a given scene.
  10877. */
  10878. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10879. /**
  10880. * The component name helpfull to identify the component in the list of scene components.
  10881. */
  10882. readonly name: string;
  10883. /**
  10884. * The scene the component belongs to.
  10885. */
  10886. scene: Scene;
  10887. /**
  10888. * Creates a new instance of the component for the given scene
  10889. * @param scene Defines the scene to register the component in
  10890. */
  10891. constructor(scene: Scene);
  10892. /**
  10893. * Registers the component in a given scene
  10894. */
  10895. register(): void;
  10896. /**
  10897. * Rebuilds the elements related to this component in case of
  10898. * context lost for instance.
  10899. */
  10900. rebuild(): void;
  10901. /**
  10902. * Disposes the component and the associated ressources.
  10903. */
  10904. dispose(): void;
  10905. private _beforeClear;
  10906. }
  10907. }
  10908. declare module BABYLON {
  10909. interface ThinEngine {
  10910. /**
  10911. * Creates a new render target cube texture
  10912. * @param size defines the size of the texture
  10913. * @param options defines the options used to create the texture
  10914. * @returns a new render target cube texture stored in an InternalTexture
  10915. */
  10916. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10917. }
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var proceduralVertexShader: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /**
  10928. * 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.
  10929. * This is the base class of any Procedural texture and contains most of the shareable code.
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10931. */
  10932. export class ProceduralTexture extends Texture {
  10933. isCube: boolean;
  10934. /**
  10935. * Define if the texture is enabled or not (disabled texture will not render)
  10936. */
  10937. isEnabled: boolean;
  10938. /**
  10939. * Define if the texture must be cleared before rendering (default is true)
  10940. */
  10941. autoClear: boolean;
  10942. /**
  10943. * Callback called when the texture is generated
  10944. */
  10945. onGenerated: () => void;
  10946. /**
  10947. * Event raised when the texture is generated
  10948. */
  10949. onGeneratedObservable: Observable<ProceduralTexture>;
  10950. /** @hidden */
  10951. _generateMipMaps: boolean;
  10952. /** @hidden **/
  10953. _effect: Effect;
  10954. /** @hidden */
  10955. _textures: {
  10956. [key: string]: Texture;
  10957. };
  10958. /** @hidden */
  10959. protected _fallbackTexture: Nullable<Texture>;
  10960. private _size;
  10961. private _currentRefreshId;
  10962. private _frameId;
  10963. private _refreshRate;
  10964. private _vertexBuffers;
  10965. private _indexBuffer;
  10966. private _uniforms;
  10967. private _samplers;
  10968. private _fragment;
  10969. private _floats;
  10970. private _ints;
  10971. private _floatsArrays;
  10972. private _colors3;
  10973. private _colors4;
  10974. private _vectors2;
  10975. private _vectors3;
  10976. private _matrices;
  10977. private _fallbackTextureUsed;
  10978. private _fullEngine;
  10979. private _cachedDefines;
  10980. private _contentUpdateId;
  10981. private _contentData;
  10982. /**
  10983. * Instantiates a new procedural texture.
  10984. * 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.
  10985. * This is the base class of any Procedural texture and contains most of the shareable code.
  10986. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10987. * @param name Define the name of the texture
  10988. * @param size Define the size of the texture to create
  10989. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10990. * @param scene Define the scene the texture belongs to
  10991. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10992. * @param generateMipMaps Define if the texture should creates mip maps or not
  10993. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10994. */
  10995. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10996. /**
  10997. * The effect that is created when initializing the post process.
  10998. * @returns The created effect corresponding the the postprocess.
  10999. */
  11000. getEffect(): Effect;
  11001. /**
  11002. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11003. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11004. */
  11005. getContent(): Nullable<ArrayBufferView>;
  11006. private _createIndexBuffer;
  11007. /** @hidden */
  11008. _rebuild(): void;
  11009. /**
  11010. * Resets the texture in order to recreate its associated resources.
  11011. * This can be called in case of context loss
  11012. */
  11013. reset(): void;
  11014. protected _getDefines(): string;
  11015. /**
  11016. * Is the texture ready to be used ? (rendered at least once)
  11017. * @returns true if ready, otherwise, false.
  11018. */
  11019. isReady(): boolean;
  11020. /**
  11021. * Resets the refresh counter of the texture and start bak from scratch.
  11022. * Could be useful to regenerate the texture if it is setup to render only once.
  11023. */
  11024. resetRefreshCounter(): void;
  11025. /**
  11026. * Set the fragment shader to use in order to render the texture.
  11027. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11028. */
  11029. setFragment(fragment: any): void;
  11030. /**
  11031. * Define the refresh rate of the texture or the rendering frequency.
  11032. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11033. */
  11034. get refreshRate(): number;
  11035. set refreshRate(value: number);
  11036. /** @hidden */
  11037. _shouldRender(): boolean;
  11038. /**
  11039. * Get the size the texture is rendering at.
  11040. * @returns the size (texture is always squared)
  11041. */
  11042. getRenderSize(): number;
  11043. /**
  11044. * Resize the texture to new value.
  11045. * @param size Define the new size the texture should have
  11046. * @param generateMipMaps Define whether the new texture should create mip maps
  11047. */
  11048. resize(size: number, generateMipMaps: boolean): void;
  11049. private _checkUniform;
  11050. /**
  11051. * Set a texture in the shader program used to render.
  11052. * @param name Define the name of the uniform samplers as defined in the shader
  11053. * @param texture Define the texture to bind to this sampler
  11054. * @return the texture itself allowing "fluent" like uniform updates
  11055. */
  11056. setTexture(name: string, texture: Texture): ProceduralTexture;
  11057. /**
  11058. * Set a float in the shader.
  11059. * @param name Define the name of the uniform as defined in the shader
  11060. * @param value Define the value to give to the uniform
  11061. * @return the texture itself allowing "fluent" like uniform updates
  11062. */
  11063. setFloat(name: string, value: number): ProceduralTexture;
  11064. /**
  11065. * Set a int in the shader.
  11066. * @param name Define the name of the uniform as defined in the shader
  11067. * @param value Define the value to give to the uniform
  11068. * @return the texture itself allowing "fluent" like uniform updates
  11069. */
  11070. setInt(name: string, value: number): ProceduralTexture;
  11071. /**
  11072. * Set an array of floats in the shader.
  11073. * @param name Define the name of the uniform as defined in the shader
  11074. * @param value Define the value to give to the uniform
  11075. * @return the texture itself allowing "fluent" like uniform updates
  11076. */
  11077. setFloats(name: string, value: number[]): ProceduralTexture;
  11078. /**
  11079. * Set a vec3 in the shader from a Color3.
  11080. * @param name Define the name of the uniform as defined in the shader
  11081. * @param value Define the value to give to the uniform
  11082. * @return the texture itself allowing "fluent" like uniform updates
  11083. */
  11084. setColor3(name: string, value: Color3): ProceduralTexture;
  11085. /**
  11086. * Set a vec4 in the shader from a Color4.
  11087. * @param name Define the name of the uniform as defined in the shader
  11088. * @param value Define the value to give to the uniform
  11089. * @return the texture itself allowing "fluent" like uniform updates
  11090. */
  11091. setColor4(name: string, value: Color4): ProceduralTexture;
  11092. /**
  11093. * Set a vec2 in the shader from a Vector2.
  11094. * @param name Define the name of the uniform as defined in the shader
  11095. * @param value Define the value to give to the uniform
  11096. * @return the texture itself allowing "fluent" like uniform updates
  11097. */
  11098. setVector2(name: string, value: Vector2): ProceduralTexture;
  11099. /**
  11100. * Set a vec3 in the shader from a Vector3.
  11101. * @param name Define the name of the uniform as defined in the shader
  11102. * @param value Define the value to give to the uniform
  11103. * @return the texture itself allowing "fluent" like uniform updates
  11104. */
  11105. setVector3(name: string, value: Vector3): ProceduralTexture;
  11106. /**
  11107. * Set a mat4 in the shader from a MAtrix.
  11108. * @param name Define the name of the uniform as defined in the shader
  11109. * @param value Define the value to give to the uniform
  11110. * @return the texture itself allowing "fluent" like uniform updates
  11111. */
  11112. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11113. /**
  11114. * Render the texture to its associated render target.
  11115. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11116. */
  11117. render(useCameraPostProcess?: boolean): void;
  11118. /**
  11119. * Clone the texture.
  11120. * @returns the cloned texture
  11121. */
  11122. clone(): ProceduralTexture;
  11123. /**
  11124. * Dispose the texture and release its asoociated resources.
  11125. */
  11126. dispose(): void;
  11127. }
  11128. }
  11129. declare module BABYLON {
  11130. /**
  11131. * This represents the base class for particle system in Babylon.
  11132. * 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.
  11133. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11134. * @example https://doc.babylonjs.com/babylon101/particles
  11135. */
  11136. export class BaseParticleSystem {
  11137. /**
  11138. * Source color is added to the destination color without alpha affecting the result
  11139. */
  11140. static BLENDMODE_ONEONE: number;
  11141. /**
  11142. * Blend current color and particle color using particle’s alpha
  11143. */
  11144. static BLENDMODE_STANDARD: number;
  11145. /**
  11146. * Add current color and particle color multiplied by particle’s alpha
  11147. */
  11148. static BLENDMODE_ADD: number;
  11149. /**
  11150. * Multiply current color with particle color
  11151. */
  11152. static BLENDMODE_MULTIPLY: number;
  11153. /**
  11154. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11155. */
  11156. static BLENDMODE_MULTIPLYADD: number;
  11157. /**
  11158. * List of animations used by the particle system.
  11159. */
  11160. animations: Animation[];
  11161. /**
  11162. * Gets or sets the unique id of the particle system
  11163. */
  11164. uniqueId: number;
  11165. /**
  11166. * The id of the Particle system.
  11167. */
  11168. id: string;
  11169. /**
  11170. * The friendly name of the Particle system.
  11171. */
  11172. name: string;
  11173. /**
  11174. * Snippet ID if the particle system was created from the snippet server
  11175. */
  11176. snippetId: string;
  11177. /**
  11178. * The rendering group used by the Particle system to chose when to render.
  11179. */
  11180. renderingGroupId: number;
  11181. /**
  11182. * The emitter represents the Mesh or position we are attaching the particle system to.
  11183. */
  11184. emitter: Nullable<AbstractMesh | Vector3>;
  11185. /**
  11186. * The maximum number of particles to emit per frame
  11187. */
  11188. emitRate: number;
  11189. /**
  11190. * If you want to launch only a few particles at once, that can be done, as well.
  11191. */
  11192. manualEmitCount: number;
  11193. /**
  11194. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11195. */
  11196. updateSpeed: number;
  11197. /**
  11198. * The amount of time the particle system is running (depends of the overall update speed).
  11199. */
  11200. targetStopDuration: number;
  11201. /**
  11202. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11203. */
  11204. disposeOnStop: boolean;
  11205. /**
  11206. * Minimum power of emitting particles.
  11207. */
  11208. minEmitPower: number;
  11209. /**
  11210. * Maximum power of emitting particles.
  11211. */
  11212. maxEmitPower: number;
  11213. /**
  11214. * Minimum life time of emitting particles.
  11215. */
  11216. minLifeTime: number;
  11217. /**
  11218. * Maximum life time of emitting particles.
  11219. */
  11220. maxLifeTime: number;
  11221. /**
  11222. * Minimum Size of emitting particles.
  11223. */
  11224. minSize: number;
  11225. /**
  11226. * Maximum Size of emitting particles.
  11227. */
  11228. maxSize: number;
  11229. /**
  11230. * Minimum scale of emitting particles on X axis.
  11231. */
  11232. minScaleX: number;
  11233. /**
  11234. * Maximum scale of emitting particles on X axis.
  11235. */
  11236. maxScaleX: number;
  11237. /**
  11238. * Minimum scale of emitting particles on Y axis.
  11239. */
  11240. minScaleY: number;
  11241. /**
  11242. * Maximum scale of emitting particles on Y axis.
  11243. */
  11244. maxScaleY: number;
  11245. /**
  11246. * Gets or sets the minimal initial rotation in radians.
  11247. */
  11248. minInitialRotation: number;
  11249. /**
  11250. * Gets or sets the maximal initial rotation in radians.
  11251. */
  11252. maxInitialRotation: number;
  11253. /**
  11254. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11255. */
  11256. minAngularSpeed: number;
  11257. /**
  11258. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11259. */
  11260. maxAngularSpeed: number;
  11261. /**
  11262. * The texture used to render each particle. (this can be a spritesheet)
  11263. */
  11264. particleTexture: Nullable<Texture>;
  11265. /**
  11266. * The layer mask we are rendering the particles through.
  11267. */
  11268. layerMask: number;
  11269. /**
  11270. * This can help using your own shader to render the particle system.
  11271. * The according effect will be created
  11272. */
  11273. customShader: any;
  11274. /**
  11275. * By default particle system starts as soon as they are created. This prevents the
  11276. * automatic start to happen and let you decide when to start emitting particles.
  11277. */
  11278. preventAutoStart: boolean;
  11279. private _noiseTexture;
  11280. /**
  11281. * Gets or sets a texture used to add random noise to particle positions
  11282. */
  11283. get noiseTexture(): Nullable<ProceduralTexture>;
  11284. set noiseTexture(value: Nullable<ProceduralTexture>);
  11285. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11286. noiseStrength: Vector3;
  11287. /**
  11288. * Callback triggered when the particle animation is ending.
  11289. */
  11290. onAnimationEnd: Nullable<() => void>;
  11291. /**
  11292. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11293. */
  11294. blendMode: number;
  11295. /**
  11296. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11297. * to override the particles.
  11298. */
  11299. forceDepthWrite: boolean;
  11300. /** 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 */
  11301. preWarmCycles: number;
  11302. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11303. preWarmStepOffset: number;
  11304. /**
  11305. * 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)
  11306. */
  11307. spriteCellChangeSpeed: number;
  11308. /**
  11309. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11310. */
  11311. startSpriteCellID: number;
  11312. /**
  11313. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11314. */
  11315. endSpriteCellID: number;
  11316. /**
  11317. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11318. */
  11319. spriteCellWidth: number;
  11320. /**
  11321. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11322. */
  11323. spriteCellHeight: number;
  11324. /**
  11325. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11326. */
  11327. spriteRandomStartCell: boolean;
  11328. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11329. translationPivot: Vector2;
  11330. /** @hidden */
  11331. protected _isAnimationSheetEnabled: boolean;
  11332. /**
  11333. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11334. */
  11335. beginAnimationOnStart: boolean;
  11336. /**
  11337. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11338. */
  11339. beginAnimationFrom: number;
  11340. /**
  11341. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11342. */
  11343. beginAnimationTo: number;
  11344. /**
  11345. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11346. */
  11347. beginAnimationLoop: boolean;
  11348. /**
  11349. * Gets or sets a world offset applied to all particles
  11350. */
  11351. worldOffset: Vector3;
  11352. /**
  11353. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11354. */
  11355. get isAnimationSheetEnabled(): boolean;
  11356. set isAnimationSheetEnabled(value: boolean);
  11357. /**
  11358. * Get hosting scene
  11359. * @returns the scene
  11360. */
  11361. getScene(): Scene;
  11362. /**
  11363. * You can use gravity if you want to give an orientation to your particles.
  11364. */
  11365. gravity: Vector3;
  11366. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11367. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11368. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11369. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11370. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11371. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11372. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11373. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11374. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11375. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11376. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11377. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11378. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11379. /**
  11380. * Defines the delay in milliseconds before starting the system (0 by default)
  11381. */
  11382. startDelay: number;
  11383. /**
  11384. * Gets the current list of drag gradients.
  11385. * You must use addDragGradient and removeDragGradient to udpate this list
  11386. * @returns the list of drag gradients
  11387. */
  11388. getDragGradients(): Nullable<Array<FactorGradient>>;
  11389. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11390. limitVelocityDamping: number;
  11391. /**
  11392. * Gets the current list of limit velocity gradients.
  11393. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11394. * @returns the list of limit velocity gradients
  11395. */
  11396. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11397. /**
  11398. * Gets the current list of color gradients.
  11399. * You must use addColorGradient and removeColorGradient to udpate this list
  11400. * @returns the list of color gradients
  11401. */
  11402. getColorGradients(): Nullable<Array<ColorGradient>>;
  11403. /**
  11404. * Gets the current list of size gradients.
  11405. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11406. * @returns the list of size gradients
  11407. */
  11408. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11409. /**
  11410. * Gets the current list of color remap gradients.
  11411. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11412. * @returns the list of color remap gradients
  11413. */
  11414. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11415. /**
  11416. * Gets the current list of alpha remap gradients.
  11417. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11418. * @returns the list of alpha remap gradients
  11419. */
  11420. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11421. /**
  11422. * Gets the current list of life time gradients.
  11423. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11424. * @returns the list of life time gradients
  11425. */
  11426. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11427. /**
  11428. * Gets the current list of angular speed gradients.
  11429. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11430. * @returns the list of angular speed gradients
  11431. */
  11432. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11433. /**
  11434. * Gets the current list of velocity gradients.
  11435. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11436. * @returns the list of velocity gradients
  11437. */
  11438. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11439. /**
  11440. * Gets the current list of start size gradients.
  11441. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11442. * @returns the list of start size gradients
  11443. */
  11444. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11445. /**
  11446. * Gets the current list of emit rate gradients.
  11447. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11448. * @returns the list of emit rate gradients
  11449. */
  11450. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11451. /**
  11452. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11453. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11454. */
  11455. get direction1(): Vector3;
  11456. set direction1(value: Vector3);
  11457. /**
  11458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11459. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11460. */
  11461. get direction2(): Vector3;
  11462. set direction2(value: Vector3);
  11463. /**
  11464. * 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.
  11465. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11466. */
  11467. get minEmitBox(): Vector3;
  11468. set minEmitBox(value: Vector3);
  11469. /**
  11470. * 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.
  11471. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11472. */
  11473. get maxEmitBox(): Vector3;
  11474. set maxEmitBox(value: Vector3);
  11475. /**
  11476. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11477. */
  11478. color1: Color4;
  11479. /**
  11480. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11481. */
  11482. color2: Color4;
  11483. /**
  11484. * Color the particle will have at the end of its lifetime
  11485. */
  11486. colorDead: Color4;
  11487. /**
  11488. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11489. */
  11490. textureMask: Color4;
  11491. /**
  11492. * The particle emitter type defines the emitter used by the particle system.
  11493. * It can be for example box, sphere, or cone...
  11494. */
  11495. particleEmitterType: IParticleEmitterType;
  11496. /** @hidden */
  11497. _isSubEmitter: boolean;
  11498. /**
  11499. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11500. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11501. */
  11502. billboardMode: number;
  11503. protected _isBillboardBased: boolean;
  11504. /**
  11505. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11506. */
  11507. get isBillboardBased(): boolean;
  11508. set isBillboardBased(value: boolean);
  11509. /**
  11510. * The scene the particle system belongs to.
  11511. */
  11512. protected _scene: Scene;
  11513. /**
  11514. * Local cache of defines for image processing.
  11515. */
  11516. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11517. /**
  11518. * Default configuration related to image processing available in the standard Material.
  11519. */
  11520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11521. /**
  11522. * Gets the image processing configuration used either in this material.
  11523. */
  11524. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11525. /**
  11526. * Sets the Default image processing configuration used either in the this material.
  11527. *
  11528. * If sets to null, the scene one is in use.
  11529. */
  11530. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11531. /**
  11532. * Attaches a new image processing configuration to the Standard Material.
  11533. * @param configuration
  11534. */
  11535. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11536. /** @hidden */
  11537. protected _reset(): void;
  11538. /** @hidden */
  11539. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11540. /**
  11541. * Instantiates a particle system.
  11542. * 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.
  11543. * @param name The name of the particle system
  11544. */
  11545. constructor(name: string);
  11546. /**
  11547. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11550. * @returns the emitter
  11551. */
  11552. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11553. /**
  11554. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11555. * @param radius The radius of the hemisphere to emit from
  11556. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11557. * @returns the emitter
  11558. */
  11559. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11560. /**
  11561. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11562. * @param radius The radius of the sphere to emit from
  11563. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11564. * @returns the emitter
  11565. */
  11566. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11567. /**
  11568. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11569. * @param radius The radius of the sphere to emit from
  11570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11572. * @returns the emitter
  11573. */
  11574. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11575. /**
  11576. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11577. * @param radius The radius of the emission cylinder
  11578. * @param height The height of the emission cylinder
  11579. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11580. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11581. * @returns the emitter
  11582. */
  11583. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11584. /**
  11585. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11586. * @param radius The radius of the cylinder to emit from
  11587. * @param height The height of the emission cylinder
  11588. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11591. * @returns the emitter
  11592. */
  11593. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11594. /**
  11595. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11596. * @param radius The radius of the cone to emit from
  11597. * @param angle The base angle of the cone
  11598. * @returns the emitter
  11599. */
  11600. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11601. /**
  11602. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11605. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11606. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11607. * @returns the emitter
  11608. */
  11609. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11610. }
  11611. }
  11612. declare module BABYLON {
  11613. /**
  11614. * Type of sub emitter
  11615. */
  11616. export enum SubEmitterType {
  11617. /**
  11618. * Attached to the particle over it's lifetime
  11619. */
  11620. ATTACHED = 0,
  11621. /**
  11622. * Created when the particle dies
  11623. */
  11624. END = 1
  11625. }
  11626. /**
  11627. * Sub emitter class used to emit particles from an existing particle
  11628. */
  11629. export class SubEmitter {
  11630. /**
  11631. * the particle system to be used by the sub emitter
  11632. */
  11633. particleSystem: ParticleSystem;
  11634. /**
  11635. * Type of the submitter (Default: END)
  11636. */
  11637. type: SubEmitterType;
  11638. /**
  11639. * 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)
  11640. * Note: This only is supported when using an emitter of type Mesh
  11641. */
  11642. inheritDirection: boolean;
  11643. /**
  11644. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11645. */
  11646. inheritedVelocityAmount: number;
  11647. /**
  11648. * Creates a sub emitter
  11649. * @param particleSystem the particle system to be used by the sub emitter
  11650. */
  11651. constructor(
  11652. /**
  11653. * the particle system to be used by the sub emitter
  11654. */
  11655. particleSystem: ParticleSystem);
  11656. /**
  11657. * Clones the sub emitter
  11658. * @returns the cloned sub emitter
  11659. */
  11660. clone(): SubEmitter;
  11661. /**
  11662. * Serialize current object to a JSON object
  11663. * @returns the serialized object
  11664. */
  11665. serialize(): any;
  11666. /** @hidden */
  11667. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11668. /**
  11669. * Creates a new SubEmitter from a serialized JSON version
  11670. * @param serializationObject defines the JSON object to read from
  11671. * @param scene defines the hosting scene
  11672. * @param rootUrl defines the rootUrl for data loading
  11673. * @returns a new SubEmitter
  11674. */
  11675. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11676. /** Release associated resources */
  11677. dispose(): void;
  11678. }
  11679. }
  11680. declare module BABYLON {
  11681. /** @hidden */
  11682. export var imageProcessingDeclaration: {
  11683. name: string;
  11684. shader: string;
  11685. };
  11686. }
  11687. declare module BABYLON {
  11688. /** @hidden */
  11689. export var imageProcessingFunctions: {
  11690. name: string;
  11691. shader: string;
  11692. };
  11693. }
  11694. declare module BABYLON {
  11695. /** @hidden */
  11696. export var particlesPixelShader: {
  11697. name: string;
  11698. shader: string;
  11699. };
  11700. }
  11701. declare module BABYLON {
  11702. /** @hidden */
  11703. export var particlesVertexShader: {
  11704. name: string;
  11705. shader: string;
  11706. };
  11707. }
  11708. declare module BABYLON {
  11709. /**
  11710. * This represents a particle system in Babylon.
  11711. * 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.
  11712. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11713. * @example https://doc.babylonjs.com/babylon101/particles
  11714. */
  11715. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11716. /**
  11717. * Billboard mode will only apply to Y axis
  11718. */
  11719. static readonly BILLBOARDMODE_Y: number;
  11720. /**
  11721. * Billboard mode will apply to all axes
  11722. */
  11723. static readonly BILLBOARDMODE_ALL: number;
  11724. /**
  11725. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11726. */
  11727. static readonly BILLBOARDMODE_STRETCHED: number;
  11728. /**
  11729. * This function can be defined to provide custom update for active particles.
  11730. * This function will be called instead of regular update (age, position, color, etc.).
  11731. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11732. */
  11733. updateFunction: (particles: Particle[]) => void;
  11734. private _emitterWorldMatrix;
  11735. /**
  11736. * This function can be defined to specify initial direction for every new particle.
  11737. * It by default use the emitterType defined function
  11738. */
  11739. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11740. /**
  11741. * This function can be defined to specify initial position for every new particle.
  11742. * It by default use the emitterType defined function
  11743. */
  11744. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11745. /**
  11746. * @hidden
  11747. */
  11748. _inheritedVelocityOffset: Vector3;
  11749. /**
  11750. * An event triggered when the system is disposed
  11751. */
  11752. onDisposeObservable: Observable<ParticleSystem>;
  11753. private _onDisposeObserver;
  11754. /**
  11755. * Sets a callback that will be triggered when the system is disposed
  11756. */
  11757. set onDispose(callback: () => void);
  11758. private _particles;
  11759. private _epsilon;
  11760. private _capacity;
  11761. private _stockParticles;
  11762. private _newPartsExcess;
  11763. private _vertexData;
  11764. private _vertexBuffer;
  11765. private _vertexBuffers;
  11766. private _spriteBuffer;
  11767. private _indexBuffer;
  11768. private _effect;
  11769. private _customEffect;
  11770. private _cachedDefines;
  11771. private _scaledColorStep;
  11772. private _colorDiff;
  11773. private _scaledDirection;
  11774. private _scaledGravity;
  11775. private _currentRenderId;
  11776. private _alive;
  11777. private _useInstancing;
  11778. private _started;
  11779. private _stopped;
  11780. private _actualFrame;
  11781. private _scaledUpdateSpeed;
  11782. private _vertexBufferSize;
  11783. /** @hidden */
  11784. _currentEmitRateGradient: Nullable<FactorGradient>;
  11785. /** @hidden */
  11786. _currentEmitRate1: number;
  11787. /** @hidden */
  11788. _currentEmitRate2: number;
  11789. /** @hidden */
  11790. _currentStartSizeGradient: Nullable<FactorGradient>;
  11791. /** @hidden */
  11792. _currentStartSize1: number;
  11793. /** @hidden */
  11794. _currentStartSize2: number;
  11795. private readonly _rawTextureWidth;
  11796. private _rampGradientsTexture;
  11797. private _useRampGradients;
  11798. /** Gets or sets a boolean indicating that ramp gradients must be used
  11799. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11800. */
  11801. get useRampGradients(): boolean;
  11802. set useRampGradients(value: boolean);
  11803. /**
  11804. * 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.
  11805. * 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: [])
  11806. */
  11807. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11808. private _subEmitters;
  11809. /**
  11810. * @hidden
  11811. * If the particle systems emitter should be disposed when the particle system is disposed
  11812. */
  11813. _disposeEmitterOnDispose: boolean;
  11814. /**
  11815. * The current active Sub-systems, this property is used by the root particle system only.
  11816. */
  11817. activeSubSystems: Array<ParticleSystem>;
  11818. /**
  11819. * Specifies if the particles are updated in emitter local space or world space
  11820. */
  11821. isLocal: boolean;
  11822. private _rootParticleSystem;
  11823. /**
  11824. * Gets the current list of active particles
  11825. */
  11826. get particles(): Particle[];
  11827. /**
  11828. * Gets the number of particles active at the same time.
  11829. * @returns The number of active particles.
  11830. */
  11831. getActiveCount(): number;
  11832. /**
  11833. * Returns the string "ParticleSystem"
  11834. * @returns a string containing the class name
  11835. */
  11836. getClassName(): string;
  11837. /**
  11838. * Gets a boolean indicating that the system is stopping
  11839. * @returns true if the system is currently stopping
  11840. */
  11841. isStopping(): boolean;
  11842. /**
  11843. * Instantiates a particle system.
  11844. * 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.
  11845. * @param name The name of the particle system
  11846. * @param capacity The max number of particles alive at the same time
  11847. * @param scene The scene the particle system belongs to
  11848. * @param customEffect a custom effect used to change the way particles are rendered by default
  11849. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11850. * @param epsilon Offset used to render the particles
  11851. */
  11852. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11853. private _addFactorGradient;
  11854. private _removeFactorGradient;
  11855. /**
  11856. * Adds a new life time gradient
  11857. * @param gradient defines the gradient to use (between 0 and 1)
  11858. * @param factor defines the life time factor to affect to the specified gradient
  11859. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11860. * @returns the current particle system
  11861. */
  11862. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11863. /**
  11864. * Remove a specific life time gradient
  11865. * @param gradient defines the gradient to remove
  11866. * @returns the current particle system
  11867. */
  11868. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11869. /**
  11870. * Adds a new size gradient
  11871. * @param gradient defines the gradient to use (between 0 and 1)
  11872. * @param factor defines the size factor to affect to the specified gradient
  11873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11874. * @returns the current particle system
  11875. */
  11876. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11877. /**
  11878. * Remove a specific size gradient
  11879. * @param gradient defines the gradient to remove
  11880. * @returns the current particle system
  11881. */
  11882. removeSizeGradient(gradient: number): IParticleSystem;
  11883. /**
  11884. * Adds a new color remap gradient
  11885. * @param gradient defines the gradient to use (between 0 and 1)
  11886. * @param min defines the color remap minimal range
  11887. * @param max defines the color remap maximal range
  11888. * @returns the current particle system
  11889. */
  11890. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11891. /**
  11892. * Remove a specific color remap gradient
  11893. * @param gradient defines the gradient to remove
  11894. * @returns the current particle system
  11895. */
  11896. removeColorRemapGradient(gradient: number): IParticleSystem;
  11897. /**
  11898. * Adds a new alpha remap gradient
  11899. * @param gradient defines the gradient to use (between 0 and 1)
  11900. * @param min defines the alpha remap minimal range
  11901. * @param max defines the alpha remap maximal range
  11902. * @returns the current particle system
  11903. */
  11904. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11905. /**
  11906. * Remove a specific alpha remap gradient
  11907. * @param gradient defines the gradient to remove
  11908. * @returns the current particle system
  11909. */
  11910. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11911. /**
  11912. * Adds a new angular speed gradient
  11913. * @param gradient defines the gradient to use (between 0 and 1)
  11914. * @param factor defines the angular speed to affect to the specified gradient
  11915. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11916. * @returns the current particle system
  11917. */
  11918. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11919. /**
  11920. * Remove a specific angular speed gradient
  11921. * @param gradient defines the gradient to remove
  11922. * @returns the current particle system
  11923. */
  11924. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11925. /**
  11926. * Adds a new velocity gradient
  11927. * @param gradient defines the gradient to use (between 0 and 1)
  11928. * @param factor defines the velocity to affect to the specified gradient
  11929. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11930. * @returns the current particle system
  11931. */
  11932. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11933. /**
  11934. * Remove a specific velocity gradient
  11935. * @param gradient defines the gradient to remove
  11936. * @returns the current particle system
  11937. */
  11938. removeVelocityGradient(gradient: number): IParticleSystem;
  11939. /**
  11940. * Adds a new limit velocity gradient
  11941. * @param gradient defines the gradient to use (between 0 and 1)
  11942. * @param factor defines the limit velocity value to affect to the specified gradient
  11943. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11944. * @returns the current particle system
  11945. */
  11946. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11947. /**
  11948. * Remove a specific limit velocity gradient
  11949. * @param gradient defines the gradient to remove
  11950. * @returns the current particle system
  11951. */
  11952. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11953. /**
  11954. * Adds a new drag gradient
  11955. * @param gradient defines the gradient to use (between 0 and 1)
  11956. * @param factor defines the drag value to affect to the specified gradient
  11957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11958. * @returns the current particle system
  11959. */
  11960. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11961. /**
  11962. * Remove a specific drag gradient
  11963. * @param gradient defines the gradient to remove
  11964. * @returns the current particle system
  11965. */
  11966. removeDragGradient(gradient: number): IParticleSystem;
  11967. /**
  11968. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11969. * @param gradient defines the gradient to use (between 0 and 1)
  11970. * @param factor defines the emit rate value to affect to the specified gradient
  11971. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11972. * @returns the current particle system
  11973. */
  11974. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11975. /**
  11976. * Remove a specific emit rate gradient
  11977. * @param gradient defines the gradient to remove
  11978. * @returns the current particle system
  11979. */
  11980. removeEmitRateGradient(gradient: number): IParticleSystem;
  11981. /**
  11982. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11983. * @param gradient defines the gradient to use (between 0 and 1)
  11984. * @param factor defines the start size value to affect to the specified gradient
  11985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11986. * @returns the current particle system
  11987. */
  11988. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11989. /**
  11990. * Remove a specific start size gradient
  11991. * @param gradient defines the gradient to remove
  11992. * @returns the current particle system
  11993. */
  11994. removeStartSizeGradient(gradient: number): IParticleSystem;
  11995. private _createRampGradientTexture;
  11996. /**
  11997. * Gets the current list of ramp gradients.
  11998. * You must use addRampGradient and removeRampGradient to udpate this list
  11999. * @returns the list of ramp gradients
  12000. */
  12001. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12002. /** Force the system to rebuild all gradients that need to be resync */
  12003. forceRefreshGradients(): void;
  12004. private _syncRampGradientTexture;
  12005. /**
  12006. * Adds a new ramp gradient used to remap particle colors
  12007. * @param gradient defines the gradient to use (between 0 and 1)
  12008. * @param color defines the color to affect to the specified gradient
  12009. * @returns the current particle system
  12010. */
  12011. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12012. /**
  12013. * Remove a specific ramp gradient
  12014. * @param gradient defines the gradient to remove
  12015. * @returns the current particle system
  12016. */
  12017. removeRampGradient(gradient: number): ParticleSystem;
  12018. /**
  12019. * Adds a new color gradient
  12020. * @param gradient defines the gradient to use (between 0 and 1)
  12021. * @param color1 defines the color to affect to the specified gradient
  12022. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12023. * @returns this particle system
  12024. */
  12025. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12026. /**
  12027. * Remove a specific color gradient
  12028. * @param gradient defines the gradient to remove
  12029. * @returns this particle system
  12030. */
  12031. removeColorGradient(gradient: number): IParticleSystem;
  12032. private _fetchR;
  12033. protected _reset(): void;
  12034. private _resetEffect;
  12035. private _createVertexBuffers;
  12036. private _createIndexBuffer;
  12037. /**
  12038. * Gets the maximum number of particles active at the same time.
  12039. * @returns The max number of active particles.
  12040. */
  12041. getCapacity(): number;
  12042. /**
  12043. * Gets whether there are still active particles in the system.
  12044. * @returns True if it is alive, otherwise false.
  12045. */
  12046. isAlive(): boolean;
  12047. /**
  12048. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12049. * @returns True if it has been started, otherwise false.
  12050. */
  12051. isStarted(): boolean;
  12052. private _prepareSubEmitterInternalArray;
  12053. /**
  12054. * Starts the particle system and begins to emit
  12055. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12056. */
  12057. start(delay?: number): void;
  12058. /**
  12059. * Stops the particle system.
  12060. * @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.
  12061. */
  12062. stop(stopSubEmitters?: boolean): void;
  12063. /**
  12064. * Remove all active particles
  12065. */
  12066. reset(): void;
  12067. /**
  12068. * @hidden (for internal use only)
  12069. */
  12070. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12071. /**
  12072. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12073. * Its lifetime will start back at 0.
  12074. */
  12075. recycleParticle: (particle: Particle) => void;
  12076. private _stopSubEmitters;
  12077. private _createParticle;
  12078. private _removeFromRoot;
  12079. private _emitFromParticle;
  12080. private _update;
  12081. /** @hidden */
  12082. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12083. /** @hidden */
  12084. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12085. /** @hidden */
  12086. private _getEffect;
  12087. /**
  12088. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12089. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12090. */
  12091. animate(preWarmOnly?: boolean): void;
  12092. private _appendParticleVertices;
  12093. /**
  12094. * Rebuilds the particle system.
  12095. */
  12096. rebuild(): void;
  12097. /**
  12098. * Is this system ready to be used/rendered
  12099. * @return true if the system is ready
  12100. */
  12101. isReady(): boolean;
  12102. private _render;
  12103. /**
  12104. * Renders the particle system in its current state.
  12105. * @returns the current number of particles
  12106. */
  12107. render(): number;
  12108. /**
  12109. * Disposes the particle system and free the associated resources
  12110. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12111. */
  12112. dispose(disposeTexture?: boolean): void;
  12113. /**
  12114. * Clones the particle system.
  12115. * @param name The name of the cloned object
  12116. * @param newEmitter The new emitter to use
  12117. * @returns the cloned particle system
  12118. */
  12119. clone(name: string, newEmitter: any): ParticleSystem;
  12120. /**
  12121. * Serializes the particle system to a JSON object
  12122. * @param serializeTexture defines if the texture must be serialized as well
  12123. * @returns the JSON object
  12124. */
  12125. serialize(serializeTexture?: boolean): any;
  12126. /** @hidden */
  12127. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12128. /** @hidden */
  12129. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12130. /**
  12131. * Parses a JSON object to create a particle system.
  12132. * @param parsedParticleSystem The JSON object to parse
  12133. * @param scene The scene to create the particle system in
  12134. * @param rootUrl The root url to use to load external dependencies like texture
  12135. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12136. * @returns the Parsed particle system
  12137. */
  12138. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12139. }
  12140. }
  12141. declare module BABYLON {
  12142. /**
  12143. * A particle represents one of the element emitted by a particle system.
  12144. * This is mainly define by its coordinates, direction, velocity and age.
  12145. */
  12146. export class Particle {
  12147. /**
  12148. * The particle system the particle belongs to.
  12149. */
  12150. particleSystem: ParticleSystem;
  12151. private static _Count;
  12152. /**
  12153. * Unique ID of the particle
  12154. */
  12155. id: number;
  12156. /**
  12157. * The world position of the particle in the scene.
  12158. */
  12159. position: Vector3;
  12160. /**
  12161. * The world direction of the particle in the scene.
  12162. */
  12163. direction: Vector3;
  12164. /**
  12165. * The color of the particle.
  12166. */
  12167. color: Color4;
  12168. /**
  12169. * The color change of the particle per step.
  12170. */
  12171. colorStep: Color4;
  12172. /**
  12173. * Defines how long will the life of the particle be.
  12174. */
  12175. lifeTime: number;
  12176. /**
  12177. * The current age of the particle.
  12178. */
  12179. age: number;
  12180. /**
  12181. * The current size of the particle.
  12182. */
  12183. size: number;
  12184. /**
  12185. * The current scale of the particle.
  12186. */
  12187. scale: Vector2;
  12188. /**
  12189. * The current angle of the particle.
  12190. */
  12191. angle: number;
  12192. /**
  12193. * Defines how fast is the angle changing.
  12194. */
  12195. angularSpeed: number;
  12196. /**
  12197. * Defines the cell index used by the particle to be rendered from a sprite.
  12198. */
  12199. cellIndex: number;
  12200. /**
  12201. * The information required to support color remapping
  12202. */
  12203. remapData: Vector4;
  12204. /** @hidden */
  12205. _randomCellOffset?: number;
  12206. /** @hidden */
  12207. _initialDirection: Nullable<Vector3>;
  12208. /** @hidden */
  12209. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12210. /** @hidden */
  12211. _initialStartSpriteCellID: number;
  12212. /** @hidden */
  12213. _initialEndSpriteCellID: number;
  12214. /** @hidden */
  12215. _currentColorGradient: Nullable<ColorGradient>;
  12216. /** @hidden */
  12217. _currentColor1: Color4;
  12218. /** @hidden */
  12219. _currentColor2: Color4;
  12220. /** @hidden */
  12221. _currentSizeGradient: Nullable<FactorGradient>;
  12222. /** @hidden */
  12223. _currentSize1: number;
  12224. /** @hidden */
  12225. _currentSize2: number;
  12226. /** @hidden */
  12227. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12228. /** @hidden */
  12229. _currentAngularSpeed1: number;
  12230. /** @hidden */
  12231. _currentAngularSpeed2: number;
  12232. /** @hidden */
  12233. _currentVelocityGradient: Nullable<FactorGradient>;
  12234. /** @hidden */
  12235. _currentVelocity1: number;
  12236. /** @hidden */
  12237. _currentVelocity2: number;
  12238. /** @hidden */
  12239. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12240. /** @hidden */
  12241. _currentLimitVelocity1: number;
  12242. /** @hidden */
  12243. _currentLimitVelocity2: number;
  12244. /** @hidden */
  12245. _currentDragGradient: Nullable<FactorGradient>;
  12246. /** @hidden */
  12247. _currentDrag1: number;
  12248. /** @hidden */
  12249. _currentDrag2: number;
  12250. /** @hidden */
  12251. _randomNoiseCoordinates1: Vector3;
  12252. /** @hidden */
  12253. _randomNoiseCoordinates2: Vector3;
  12254. /** @hidden */
  12255. _localPosition?: Vector3;
  12256. /**
  12257. * Creates a new instance Particle
  12258. * @param particleSystem the particle system the particle belongs to
  12259. */
  12260. constructor(
  12261. /**
  12262. * The particle system the particle belongs to.
  12263. */
  12264. particleSystem: ParticleSystem);
  12265. private updateCellInfoFromSystem;
  12266. /**
  12267. * Defines how the sprite cell index is updated for the particle
  12268. */
  12269. updateCellIndex(): void;
  12270. /** @hidden */
  12271. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12272. /** @hidden */
  12273. _inheritParticleInfoToSubEmitters(): void;
  12274. /** @hidden */
  12275. _reset(): void;
  12276. /**
  12277. * Copy the properties of particle to another one.
  12278. * @param other the particle to copy the information to.
  12279. */
  12280. copyTo(other: Particle): void;
  12281. }
  12282. }
  12283. declare module BABYLON {
  12284. /**
  12285. * Particle emitter represents a volume emitting particles.
  12286. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12287. */
  12288. export interface IParticleEmitterType {
  12289. /**
  12290. * Called by the particle System when the direction is computed for the created particle.
  12291. * @param worldMatrix is the world matrix of the particle system
  12292. * @param directionToUpdate is the direction vector to update with the result
  12293. * @param particle is the particle we are computed the direction for
  12294. * @param isLocal defines if the direction should be set in local space
  12295. */
  12296. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12297. /**
  12298. * Called by the particle System when the position is computed for the created particle.
  12299. * @param worldMatrix is the world matrix of the particle system
  12300. * @param positionToUpdate is the position vector to update with the result
  12301. * @param particle is the particle we are computed the position for
  12302. * @param isLocal defines if the position should be set in local space
  12303. */
  12304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12305. /**
  12306. * Clones the current emitter and returns a copy of it
  12307. * @returns the new emitter
  12308. */
  12309. clone(): IParticleEmitterType;
  12310. /**
  12311. * Called by the GPUParticleSystem to setup the update shader
  12312. * @param effect defines the update shader
  12313. */
  12314. applyToShader(effect: Effect): void;
  12315. /**
  12316. * Returns a string to use to update the GPU particles update shader
  12317. * @returns the effect defines string
  12318. */
  12319. getEffectDefines(): string;
  12320. /**
  12321. * Returns a string representing the class name
  12322. * @returns a string containing the class name
  12323. */
  12324. getClassName(): string;
  12325. /**
  12326. * Serializes the particle system to a JSON object.
  12327. * @returns the JSON object
  12328. */
  12329. serialize(): any;
  12330. /**
  12331. * Parse properties from a JSON object
  12332. * @param serializationObject defines the JSON object
  12333. * @param scene defines the hosting scene
  12334. */
  12335. parse(serializationObject: any, scene: Scene): void;
  12336. }
  12337. }
  12338. declare module BABYLON {
  12339. /**
  12340. * Particle emitter emitting particles from the inside of a box.
  12341. * It emits the particles randomly between 2 given directions.
  12342. */
  12343. export class BoxParticleEmitter implements IParticleEmitterType {
  12344. /**
  12345. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12346. */
  12347. direction1: Vector3;
  12348. /**
  12349. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12350. */
  12351. direction2: Vector3;
  12352. /**
  12353. * 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.
  12354. */
  12355. minEmitBox: Vector3;
  12356. /**
  12357. * 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.
  12358. */
  12359. maxEmitBox: Vector3;
  12360. /**
  12361. * Creates a new instance BoxParticleEmitter
  12362. */
  12363. constructor();
  12364. /**
  12365. * Called by the particle System when the direction is computed for the created particle.
  12366. * @param worldMatrix is the world matrix of the particle system
  12367. * @param directionToUpdate is the direction vector to update with the result
  12368. * @param particle is the particle we are computed the direction for
  12369. * @param isLocal defines if the direction should be set in local space
  12370. */
  12371. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12372. /**
  12373. * Called by the particle System when the position is computed for the created particle.
  12374. * @param worldMatrix is the world matrix of the particle system
  12375. * @param positionToUpdate is the position vector to update with the result
  12376. * @param particle is the particle we are computed the position for
  12377. * @param isLocal defines if the position should be set in local space
  12378. */
  12379. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12380. /**
  12381. * Clones the current emitter and returns a copy of it
  12382. * @returns the new emitter
  12383. */
  12384. clone(): BoxParticleEmitter;
  12385. /**
  12386. * Called by the GPUParticleSystem to setup the update shader
  12387. * @param effect defines the update shader
  12388. */
  12389. applyToShader(effect: Effect): void;
  12390. /**
  12391. * Returns a string to use to update the GPU particles update shader
  12392. * @returns a string containng the defines string
  12393. */
  12394. getEffectDefines(): string;
  12395. /**
  12396. * Returns the string "BoxParticleEmitter"
  12397. * @returns a string containing the class name
  12398. */
  12399. getClassName(): string;
  12400. /**
  12401. * Serializes the particle system to a JSON object.
  12402. * @returns the JSON object
  12403. */
  12404. serialize(): any;
  12405. /**
  12406. * Parse properties from a JSON object
  12407. * @param serializationObject defines the JSON object
  12408. */
  12409. parse(serializationObject: any): void;
  12410. }
  12411. }
  12412. declare module BABYLON {
  12413. /**
  12414. * Particle emitter emitting particles from the inside of a cone.
  12415. * It emits the particles alongside the cone volume from the base to the particle.
  12416. * The emission direction might be randomized.
  12417. */
  12418. export class ConeParticleEmitter implements IParticleEmitterType {
  12419. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12420. directionRandomizer: number;
  12421. private _radius;
  12422. private _angle;
  12423. private _height;
  12424. /**
  12425. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12426. */
  12427. radiusRange: number;
  12428. /**
  12429. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12430. */
  12431. heightRange: number;
  12432. /**
  12433. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12434. */
  12435. emitFromSpawnPointOnly: boolean;
  12436. /**
  12437. * Gets or sets the radius of the emission cone
  12438. */
  12439. get radius(): number;
  12440. set radius(value: number);
  12441. /**
  12442. * Gets or sets the angle of the emission cone
  12443. */
  12444. get angle(): number;
  12445. set angle(value: number);
  12446. private _buildHeight;
  12447. /**
  12448. * Creates a new instance ConeParticleEmitter
  12449. * @param radius the radius of the emission cone (1 by default)
  12450. * @param angle the cone base angle (PI by default)
  12451. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12452. */
  12453. constructor(radius?: number, angle?: number,
  12454. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12455. directionRandomizer?: number);
  12456. /**
  12457. * Called by the particle System when the direction is computed for the created particle.
  12458. * @param worldMatrix is the world matrix of the particle system
  12459. * @param directionToUpdate is the direction vector to update with the result
  12460. * @param particle is the particle we are computed the direction for
  12461. * @param isLocal defines if the direction should be set in local space
  12462. */
  12463. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12464. /**
  12465. * Called by the particle System when the position is computed for the created particle.
  12466. * @param worldMatrix is the world matrix of the particle system
  12467. * @param positionToUpdate is the position vector to update with the result
  12468. * @param particle is the particle we are computed the position for
  12469. * @param isLocal defines if the position should be set in local space
  12470. */
  12471. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12472. /**
  12473. * Clones the current emitter and returns a copy of it
  12474. * @returns the new emitter
  12475. */
  12476. clone(): ConeParticleEmitter;
  12477. /**
  12478. * Called by the GPUParticleSystem to setup the update shader
  12479. * @param effect defines the update shader
  12480. */
  12481. applyToShader(effect: Effect): void;
  12482. /**
  12483. * Returns a string to use to update the GPU particles update shader
  12484. * @returns a string containng the defines string
  12485. */
  12486. getEffectDefines(): string;
  12487. /**
  12488. * Returns the string "ConeParticleEmitter"
  12489. * @returns a string containing the class name
  12490. */
  12491. getClassName(): string;
  12492. /**
  12493. * Serializes the particle system to a JSON object.
  12494. * @returns the JSON object
  12495. */
  12496. serialize(): any;
  12497. /**
  12498. * Parse properties from a JSON object
  12499. * @param serializationObject defines the JSON object
  12500. */
  12501. parse(serializationObject: any): void;
  12502. }
  12503. }
  12504. declare module BABYLON {
  12505. /**
  12506. * Particle emitter emitting particles from the inside of a cylinder.
  12507. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12508. */
  12509. export class CylinderParticleEmitter implements IParticleEmitterType {
  12510. /**
  12511. * The radius of the emission cylinder.
  12512. */
  12513. radius: number;
  12514. /**
  12515. * The height of the emission cylinder.
  12516. */
  12517. height: number;
  12518. /**
  12519. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12520. */
  12521. radiusRange: number;
  12522. /**
  12523. * How much to randomize the particle direction [0-1].
  12524. */
  12525. directionRandomizer: number;
  12526. /**
  12527. * Creates a new instance CylinderParticleEmitter
  12528. * @param radius the radius of the emission cylinder (1 by default)
  12529. * @param height the height of the emission cylinder (1 by default)
  12530. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12531. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12532. */
  12533. constructor(
  12534. /**
  12535. * The radius of the emission cylinder.
  12536. */
  12537. radius?: number,
  12538. /**
  12539. * The height of the emission cylinder.
  12540. */
  12541. height?: number,
  12542. /**
  12543. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12544. */
  12545. radiusRange?: number,
  12546. /**
  12547. * How much to randomize the particle direction [0-1].
  12548. */
  12549. directionRandomizer?: number);
  12550. /**
  12551. * Called by the particle System when the direction is computed for the created particle.
  12552. * @param worldMatrix is the world matrix of the particle system
  12553. * @param directionToUpdate is the direction vector to update with the result
  12554. * @param particle is the particle we are computed the direction for
  12555. * @param isLocal defines if the direction should be set in local space
  12556. */
  12557. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12558. /**
  12559. * Called by the particle System when the position is computed for the created particle.
  12560. * @param worldMatrix is the world matrix of the particle system
  12561. * @param positionToUpdate is the position vector to update with the result
  12562. * @param particle is the particle we are computed the position for
  12563. * @param isLocal defines if the position should be set in local space
  12564. */
  12565. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12566. /**
  12567. * Clones the current emitter and returns a copy of it
  12568. * @returns the new emitter
  12569. */
  12570. clone(): CylinderParticleEmitter;
  12571. /**
  12572. * Called by the GPUParticleSystem to setup the update shader
  12573. * @param effect defines the update shader
  12574. */
  12575. applyToShader(effect: Effect): void;
  12576. /**
  12577. * Returns a string to use to update the GPU particles update shader
  12578. * @returns a string containng the defines string
  12579. */
  12580. getEffectDefines(): string;
  12581. /**
  12582. * Returns the string "CylinderParticleEmitter"
  12583. * @returns a string containing the class name
  12584. */
  12585. getClassName(): string;
  12586. /**
  12587. * Serializes the particle system to a JSON object.
  12588. * @returns the JSON object
  12589. */
  12590. serialize(): any;
  12591. /**
  12592. * Parse properties from a JSON object
  12593. * @param serializationObject defines the JSON object
  12594. */
  12595. parse(serializationObject: any): void;
  12596. }
  12597. /**
  12598. * Particle emitter emitting particles from the inside of a cylinder.
  12599. * It emits the particles randomly between two vectors.
  12600. */
  12601. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12602. /**
  12603. * The min limit of the emission direction.
  12604. */
  12605. direction1: Vector3;
  12606. /**
  12607. * The max limit of the emission direction.
  12608. */
  12609. direction2: Vector3;
  12610. /**
  12611. * Creates a new instance CylinderDirectedParticleEmitter
  12612. * @param radius the radius of the emission cylinder (1 by default)
  12613. * @param height the height of the emission cylinder (1 by default)
  12614. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12615. * @param direction1 the min limit of the emission direction (up vector by default)
  12616. * @param direction2 the max limit of the emission direction (up vector by default)
  12617. */
  12618. constructor(radius?: number, height?: number, radiusRange?: number,
  12619. /**
  12620. * The min limit of the emission direction.
  12621. */
  12622. direction1?: Vector3,
  12623. /**
  12624. * The max limit of the emission direction.
  12625. */
  12626. direction2?: Vector3);
  12627. /**
  12628. * Called by the particle System when the direction is computed for the created particle.
  12629. * @param worldMatrix is the world matrix of the particle system
  12630. * @param directionToUpdate is the direction vector to update with the result
  12631. * @param particle is the particle we are computed the direction for
  12632. */
  12633. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12634. /**
  12635. * Clones the current emitter and returns a copy of it
  12636. * @returns the new emitter
  12637. */
  12638. clone(): CylinderDirectedParticleEmitter;
  12639. /**
  12640. * Called by the GPUParticleSystem to setup the update shader
  12641. * @param effect defines the update shader
  12642. */
  12643. applyToShader(effect: Effect): void;
  12644. /**
  12645. * Returns a string to use to update the GPU particles update shader
  12646. * @returns a string containng the defines string
  12647. */
  12648. getEffectDefines(): string;
  12649. /**
  12650. * Returns the string "CylinderDirectedParticleEmitter"
  12651. * @returns a string containing the class name
  12652. */
  12653. getClassName(): string;
  12654. /**
  12655. * Serializes the particle system to a JSON object.
  12656. * @returns the JSON object
  12657. */
  12658. serialize(): any;
  12659. /**
  12660. * Parse properties from a JSON object
  12661. * @param serializationObject defines the JSON object
  12662. */
  12663. parse(serializationObject: any): void;
  12664. }
  12665. }
  12666. declare module BABYLON {
  12667. /**
  12668. * Particle emitter emitting particles from the inside of a hemisphere.
  12669. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12670. */
  12671. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12672. /**
  12673. * The radius of the emission hemisphere.
  12674. */
  12675. radius: number;
  12676. /**
  12677. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12678. */
  12679. radiusRange: number;
  12680. /**
  12681. * How much to randomize the particle direction [0-1].
  12682. */
  12683. directionRandomizer: number;
  12684. /**
  12685. * Creates a new instance HemisphericParticleEmitter
  12686. * @param radius the radius of the emission hemisphere (1 by default)
  12687. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12688. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12689. */
  12690. constructor(
  12691. /**
  12692. * The radius of the emission hemisphere.
  12693. */
  12694. radius?: number,
  12695. /**
  12696. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12697. */
  12698. radiusRange?: number,
  12699. /**
  12700. * How much to randomize the particle direction [0-1].
  12701. */
  12702. directionRandomizer?: number);
  12703. /**
  12704. * Called by the particle System when the direction is computed for the created particle.
  12705. * @param worldMatrix is the world matrix of the particle system
  12706. * @param directionToUpdate is the direction vector to update with the result
  12707. * @param particle is the particle we are computed the direction for
  12708. * @param isLocal defines if the direction should be set in local space
  12709. */
  12710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12711. /**
  12712. * Called by the particle System when the position is computed for the created particle.
  12713. * @param worldMatrix is the world matrix of the particle system
  12714. * @param positionToUpdate is the position vector to update with the result
  12715. * @param particle is the particle we are computed the position for
  12716. * @param isLocal defines if the position should be set in local space
  12717. */
  12718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12719. /**
  12720. * Clones the current emitter and returns a copy of it
  12721. * @returns the new emitter
  12722. */
  12723. clone(): HemisphericParticleEmitter;
  12724. /**
  12725. * Called by the GPUParticleSystem to setup the update shader
  12726. * @param effect defines the update shader
  12727. */
  12728. applyToShader(effect: Effect): void;
  12729. /**
  12730. * Returns a string to use to update the GPU particles update shader
  12731. * @returns a string containng the defines string
  12732. */
  12733. getEffectDefines(): string;
  12734. /**
  12735. * Returns the string "HemisphericParticleEmitter"
  12736. * @returns a string containing the class name
  12737. */
  12738. getClassName(): string;
  12739. /**
  12740. * Serializes the particle system to a JSON object.
  12741. * @returns the JSON object
  12742. */
  12743. serialize(): any;
  12744. /**
  12745. * Parse properties from a JSON object
  12746. * @param serializationObject defines the JSON object
  12747. */
  12748. parse(serializationObject: any): void;
  12749. }
  12750. }
  12751. declare module BABYLON {
  12752. /**
  12753. * Particle emitter emitting particles from a point.
  12754. * It emits the particles randomly between 2 given directions.
  12755. */
  12756. export class PointParticleEmitter implements IParticleEmitterType {
  12757. /**
  12758. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12759. */
  12760. direction1: Vector3;
  12761. /**
  12762. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12763. */
  12764. direction2: Vector3;
  12765. /**
  12766. * Creates a new instance PointParticleEmitter
  12767. */
  12768. constructor();
  12769. /**
  12770. * Called by the particle System when the direction is computed for the created particle.
  12771. * @param worldMatrix is the world matrix of the particle system
  12772. * @param directionToUpdate is the direction vector to update with the result
  12773. * @param particle is the particle we are computed the direction for
  12774. * @param isLocal defines if the direction should be set in local space
  12775. */
  12776. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12777. /**
  12778. * Called by the particle System when the position is computed for the created particle.
  12779. * @param worldMatrix is the world matrix of the particle system
  12780. * @param positionToUpdate is the position vector to update with the result
  12781. * @param particle is the particle we are computed the position for
  12782. * @param isLocal defines if the position should be set in local space
  12783. */
  12784. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12785. /**
  12786. * Clones the current emitter and returns a copy of it
  12787. * @returns the new emitter
  12788. */
  12789. clone(): PointParticleEmitter;
  12790. /**
  12791. * Called by the GPUParticleSystem to setup the update shader
  12792. * @param effect defines the update shader
  12793. */
  12794. applyToShader(effect: Effect): void;
  12795. /**
  12796. * Returns a string to use to update the GPU particles update shader
  12797. * @returns a string containng the defines string
  12798. */
  12799. getEffectDefines(): string;
  12800. /**
  12801. * Returns the string "PointParticleEmitter"
  12802. * @returns a string containing the class name
  12803. */
  12804. getClassName(): string;
  12805. /**
  12806. * Serializes the particle system to a JSON object.
  12807. * @returns the JSON object
  12808. */
  12809. serialize(): any;
  12810. /**
  12811. * Parse properties from a JSON object
  12812. * @param serializationObject defines the JSON object
  12813. */
  12814. parse(serializationObject: any): void;
  12815. }
  12816. }
  12817. declare module BABYLON {
  12818. /**
  12819. * Particle emitter emitting particles from the inside of a sphere.
  12820. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12821. */
  12822. export class SphereParticleEmitter implements IParticleEmitterType {
  12823. /**
  12824. * The radius of the emission sphere.
  12825. */
  12826. radius: number;
  12827. /**
  12828. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12829. */
  12830. radiusRange: number;
  12831. /**
  12832. * How much to randomize the particle direction [0-1].
  12833. */
  12834. directionRandomizer: number;
  12835. /**
  12836. * Creates a new instance SphereParticleEmitter
  12837. * @param radius the radius of the emission sphere (1 by default)
  12838. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12839. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12840. */
  12841. constructor(
  12842. /**
  12843. * The radius of the emission sphere.
  12844. */
  12845. radius?: number,
  12846. /**
  12847. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12848. */
  12849. radiusRange?: number,
  12850. /**
  12851. * How much to randomize the particle direction [0-1].
  12852. */
  12853. directionRandomizer?: number);
  12854. /**
  12855. * Called by the particle System when the direction is computed for the created particle.
  12856. * @param worldMatrix is the world matrix of the particle system
  12857. * @param directionToUpdate is the direction vector to update with the result
  12858. * @param particle is the particle we are computed the direction for
  12859. * @param isLocal defines if the direction should be set in local space
  12860. */
  12861. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12862. /**
  12863. * Called by the particle System when the position is computed for the created particle.
  12864. * @param worldMatrix is the world matrix of the particle system
  12865. * @param positionToUpdate is the position vector to update with the result
  12866. * @param particle is the particle we are computed the position for
  12867. * @param isLocal defines if the position should be set in local space
  12868. */
  12869. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12870. /**
  12871. * Clones the current emitter and returns a copy of it
  12872. * @returns the new emitter
  12873. */
  12874. clone(): SphereParticleEmitter;
  12875. /**
  12876. * Called by the GPUParticleSystem to setup the update shader
  12877. * @param effect defines the update shader
  12878. */
  12879. applyToShader(effect: Effect): void;
  12880. /**
  12881. * Returns a string to use to update the GPU particles update shader
  12882. * @returns a string containng the defines string
  12883. */
  12884. getEffectDefines(): string;
  12885. /**
  12886. * Returns the string "SphereParticleEmitter"
  12887. * @returns a string containing the class name
  12888. */
  12889. getClassName(): string;
  12890. /**
  12891. * Serializes the particle system to a JSON object.
  12892. * @returns the JSON object
  12893. */
  12894. serialize(): any;
  12895. /**
  12896. * Parse properties from a JSON object
  12897. * @param serializationObject defines the JSON object
  12898. */
  12899. parse(serializationObject: any): void;
  12900. }
  12901. /**
  12902. * Particle emitter emitting particles from the inside of a sphere.
  12903. * It emits the particles randomly between two vectors.
  12904. */
  12905. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12906. /**
  12907. * The min limit of the emission direction.
  12908. */
  12909. direction1: Vector3;
  12910. /**
  12911. * The max limit of the emission direction.
  12912. */
  12913. direction2: Vector3;
  12914. /**
  12915. * Creates a new instance SphereDirectedParticleEmitter
  12916. * @param radius the radius of the emission sphere (1 by default)
  12917. * @param direction1 the min limit of the emission direction (up vector by default)
  12918. * @param direction2 the max limit of the emission direction (up vector by default)
  12919. */
  12920. constructor(radius?: number,
  12921. /**
  12922. * The min limit of the emission direction.
  12923. */
  12924. direction1?: Vector3,
  12925. /**
  12926. * The max limit of the emission direction.
  12927. */
  12928. direction2?: Vector3);
  12929. /**
  12930. * Called by the particle System when the direction is computed for the created particle.
  12931. * @param worldMatrix is the world matrix of the particle system
  12932. * @param directionToUpdate is the direction vector to update with the result
  12933. * @param particle is the particle we are computed the direction for
  12934. */
  12935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12936. /**
  12937. * Clones the current emitter and returns a copy of it
  12938. * @returns the new emitter
  12939. */
  12940. clone(): SphereDirectedParticleEmitter;
  12941. /**
  12942. * Called by the GPUParticleSystem to setup the update shader
  12943. * @param effect defines the update shader
  12944. */
  12945. applyToShader(effect: Effect): void;
  12946. /**
  12947. * Returns a string to use to update the GPU particles update shader
  12948. * @returns a string containng the defines string
  12949. */
  12950. getEffectDefines(): string;
  12951. /**
  12952. * Returns the string "SphereDirectedParticleEmitter"
  12953. * @returns a string containing the class name
  12954. */
  12955. getClassName(): string;
  12956. /**
  12957. * Serializes the particle system to a JSON object.
  12958. * @returns the JSON object
  12959. */
  12960. serialize(): any;
  12961. /**
  12962. * Parse properties from a JSON object
  12963. * @param serializationObject defines the JSON object
  12964. */
  12965. parse(serializationObject: any): void;
  12966. }
  12967. }
  12968. declare module BABYLON {
  12969. /**
  12970. * Particle emitter emitting particles from a custom list of positions.
  12971. */
  12972. export class CustomParticleEmitter implements IParticleEmitterType {
  12973. /**
  12974. * Gets or sets the position generator that will create the inital position of each particle.
  12975. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12976. */
  12977. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12978. /**
  12979. * Gets or sets the destination generator that will create the final destination of each particle.
  12980. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12981. */
  12982. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12983. /**
  12984. * Creates a new instance CustomParticleEmitter
  12985. */
  12986. constructor();
  12987. /**
  12988. * Called by the particle System when the direction is computed for the created particle.
  12989. * @param worldMatrix is the world matrix of the particle system
  12990. * @param directionToUpdate is the direction vector to update with the result
  12991. * @param particle is the particle we are computed the direction for
  12992. * @param isLocal defines if the direction should be set in local space
  12993. */
  12994. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12995. /**
  12996. * Called by the particle System when the position is computed for the created particle.
  12997. * @param worldMatrix is the world matrix of the particle system
  12998. * @param positionToUpdate is the position vector to update with the result
  12999. * @param particle is the particle we are computed the position for
  13000. * @param isLocal defines if the position should be set in local space
  13001. */
  13002. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13003. /**
  13004. * Clones the current emitter and returns a copy of it
  13005. * @returns the new emitter
  13006. */
  13007. clone(): CustomParticleEmitter;
  13008. /**
  13009. * Called by the GPUParticleSystem to setup the update shader
  13010. * @param effect defines the update shader
  13011. */
  13012. applyToShader(effect: Effect): void;
  13013. /**
  13014. * Returns a string to use to update the GPU particles update shader
  13015. * @returns a string containng the defines string
  13016. */
  13017. getEffectDefines(): string;
  13018. /**
  13019. * Returns the string "PointParticleEmitter"
  13020. * @returns a string containing the class name
  13021. */
  13022. getClassName(): string;
  13023. /**
  13024. * Serializes the particle system to a JSON object.
  13025. * @returns the JSON object
  13026. */
  13027. serialize(): any;
  13028. /**
  13029. * Parse properties from a JSON object
  13030. * @param serializationObject defines the JSON object
  13031. */
  13032. parse(serializationObject: any): void;
  13033. }
  13034. }
  13035. declare module BABYLON {
  13036. /**
  13037. * Particle emitter emitting particles from the inside of a box.
  13038. * It emits the particles randomly between 2 given directions.
  13039. */
  13040. export class MeshParticleEmitter implements IParticleEmitterType {
  13041. private _indices;
  13042. private _positions;
  13043. private _normals;
  13044. private _storedNormal;
  13045. private _mesh;
  13046. /**
  13047. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13048. */
  13049. direction1: Vector3;
  13050. /**
  13051. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13052. */
  13053. direction2: Vector3;
  13054. /**
  13055. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13056. */
  13057. useMeshNormalsForDirection: boolean;
  13058. /** Defines the mesh to use as source */
  13059. get mesh(): Nullable<AbstractMesh>;
  13060. set mesh(value: Nullable<AbstractMesh>);
  13061. /**
  13062. * Creates a new instance MeshParticleEmitter
  13063. * @param mesh defines the mesh to use as source
  13064. */
  13065. constructor(mesh?: Nullable<AbstractMesh>);
  13066. /**
  13067. * Called by the particle System when the direction is computed for the created particle.
  13068. * @param worldMatrix is the world matrix of the particle system
  13069. * @param directionToUpdate is the direction vector to update with the result
  13070. * @param particle is the particle we are computed the direction for
  13071. * @param isLocal defines if the direction should be set in local space
  13072. */
  13073. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13074. /**
  13075. * Called by the particle System when the position is computed for the created particle.
  13076. * @param worldMatrix is the world matrix of the particle system
  13077. * @param positionToUpdate is the position vector to update with the result
  13078. * @param particle is the particle we are computed the position for
  13079. * @param isLocal defines if the position should be set in local space
  13080. */
  13081. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13082. /**
  13083. * Clones the current emitter and returns a copy of it
  13084. * @returns the new emitter
  13085. */
  13086. clone(): MeshParticleEmitter;
  13087. /**
  13088. * Called by the GPUParticleSystem to setup the update shader
  13089. * @param effect defines the update shader
  13090. */
  13091. applyToShader(effect: Effect): void;
  13092. /**
  13093. * Returns a string to use to update the GPU particles update shader
  13094. * @returns a string containng the defines string
  13095. */
  13096. getEffectDefines(): string;
  13097. /**
  13098. * Returns the string "BoxParticleEmitter"
  13099. * @returns a string containing the class name
  13100. */
  13101. getClassName(): string;
  13102. /**
  13103. * Serializes the particle system to a JSON object.
  13104. * @returns the JSON object
  13105. */
  13106. serialize(): any;
  13107. /**
  13108. * Parse properties from a JSON object
  13109. * @param serializationObject defines the JSON object
  13110. * @param scene defines the hosting scene
  13111. */
  13112. parse(serializationObject: any, scene: Scene): void;
  13113. }
  13114. }
  13115. declare module BABYLON {
  13116. /**
  13117. * Interface representing a particle system in Babylon.js.
  13118. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13119. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13120. */
  13121. export interface IParticleSystem {
  13122. /**
  13123. * List of animations used by the particle system.
  13124. */
  13125. animations: Animation[];
  13126. /**
  13127. * The id of the Particle system.
  13128. */
  13129. id: string;
  13130. /**
  13131. * The name of the Particle system.
  13132. */
  13133. name: string;
  13134. /**
  13135. * The emitter represents the Mesh or position we are attaching the particle system to.
  13136. */
  13137. emitter: Nullable<AbstractMesh | Vector3>;
  13138. /**
  13139. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13140. */
  13141. isBillboardBased: boolean;
  13142. /**
  13143. * The rendering group used by the Particle system to chose when to render.
  13144. */
  13145. renderingGroupId: number;
  13146. /**
  13147. * The layer mask we are rendering the particles through.
  13148. */
  13149. layerMask: number;
  13150. /**
  13151. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13152. */
  13153. updateSpeed: number;
  13154. /**
  13155. * The amount of time the particle system is running (depends of the overall update speed).
  13156. */
  13157. targetStopDuration: number;
  13158. /**
  13159. * The texture used to render each particle. (this can be a spritesheet)
  13160. */
  13161. particleTexture: Nullable<Texture>;
  13162. /**
  13163. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13164. */
  13165. blendMode: number;
  13166. /**
  13167. * Minimum life time of emitting particles.
  13168. */
  13169. minLifeTime: number;
  13170. /**
  13171. * Maximum life time of emitting particles.
  13172. */
  13173. maxLifeTime: number;
  13174. /**
  13175. * Minimum Size of emitting particles.
  13176. */
  13177. minSize: number;
  13178. /**
  13179. * Maximum Size of emitting particles.
  13180. */
  13181. maxSize: number;
  13182. /**
  13183. * Minimum scale of emitting particles on X axis.
  13184. */
  13185. minScaleX: number;
  13186. /**
  13187. * Maximum scale of emitting particles on X axis.
  13188. */
  13189. maxScaleX: number;
  13190. /**
  13191. * Minimum scale of emitting particles on Y axis.
  13192. */
  13193. minScaleY: number;
  13194. /**
  13195. * Maximum scale of emitting particles on Y axis.
  13196. */
  13197. maxScaleY: number;
  13198. /**
  13199. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13200. */
  13201. color1: Color4;
  13202. /**
  13203. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13204. */
  13205. color2: Color4;
  13206. /**
  13207. * Color the particle will have at the end of its lifetime.
  13208. */
  13209. colorDead: Color4;
  13210. /**
  13211. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13212. */
  13213. emitRate: number;
  13214. /**
  13215. * You can use gravity if you want to give an orientation to your particles.
  13216. */
  13217. gravity: Vector3;
  13218. /**
  13219. * Minimum power of emitting particles.
  13220. */
  13221. minEmitPower: number;
  13222. /**
  13223. * Maximum power of emitting particles.
  13224. */
  13225. maxEmitPower: number;
  13226. /**
  13227. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13228. */
  13229. minAngularSpeed: number;
  13230. /**
  13231. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13232. */
  13233. maxAngularSpeed: number;
  13234. /**
  13235. * Gets or sets the minimal initial rotation in radians.
  13236. */
  13237. minInitialRotation: number;
  13238. /**
  13239. * Gets or sets the maximal initial rotation in radians.
  13240. */
  13241. maxInitialRotation: number;
  13242. /**
  13243. * The particle emitter type defines the emitter used by the particle system.
  13244. * It can be for example box, sphere, or cone...
  13245. */
  13246. particleEmitterType: Nullable<IParticleEmitterType>;
  13247. /**
  13248. * Defines the delay in milliseconds before starting the system (0 by default)
  13249. */
  13250. startDelay: number;
  13251. /**
  13252. * 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
  13253. */
  13254. preWarmCycles: number;
  13255. /**
  13256. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13257. */
  13258. preWarmStepOffset: number;
  13259. /**
  13260. * 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)
  13261. */
  13262. spriteCellChangeSpeed: number;
  13263. /**
  13264. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13265. */
  13266. startSpriteCellID: number;
  13267. /**
  13268. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13269. */
  13270. endSpriteCellID: number;
  13271. /**
  13272. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13273. */
  13274. spriteCellWidth: number;
  13275. /**
  13276. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13277. */
  13278. spriteCellHeight: number;
  13279. /**
  13280. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13281. */
  13282. spriteRandomStartCell: boolean;
  13283. /**
  13284. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13285. */
  13286. isAnimationSheetEnabled: boolean;
  13287. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13288. translationPivot: Vector2;
  13289. /**
  13290. * Gets or sets a texture used to add random noise to particle positions
  13291. */
  13292. noiseTexture: Nullable<BaseTexture>;
  13293. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13294. noiseStrength: Vector3;
  13295. /**
  13296. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13297. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13298. */
  13299. billboardMode: number;
  13300. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13301. limitVelocityDamping: number;
  13302. /**
  13303. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13304. */
  13305. beginAnimationOnStart: boolean;
  13306. /**
  13307. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13308. */
  13309. beginAnimationFrom: number;
  13310. /**
  13311. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13312. */
  13313. beginAnimationTo: number;
  13314. /**
  13315. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13316. */
  13317. beginAnimationLoop: boolean;
  13318. /**
  13319. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13320. */
  13321. disposeOnStop: boolean;
  13322. /**
  13323. * Specifies if the particles are updated in emitter local space or world space
  13324. */
  13325. isLocal: boolean;
  13326. /** Snippet ID if the particle system was created from the snippet server */
  13327. snippetId: string;
  13328. /**
  13329. * Gets the maximum number of particles active at the same time.
  13330. * @returns The max number of active particles.
  13331. */
  13332. getCapacity(): number;
  13333. /**
  13334. * Gets the number of particles active at the same time.
  13335. * @returns The number of active particles.
  13336. */
  13337. getActiveCount(): number;
  13338. /**
  13339. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13340. * @returns True if it has been started, otherwise false.
  13341. */
  13342. isStarted(): boolean;
  13343. /**
  13344. * Animates the particle system for this frame.
  13345. */
  13346. animate(): void;
  13347. /**
  13348. * Renders the particle system in its current state.
  13349. * @returns the current number of particles
  13350. */
  13351. render(): number;
  13352. /**
  13353. * Dispose the particle system and frees its associated resources.
  13354. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13355. */
  13356. dispose(disposeTexture?: boolean): void;
  13357. /**
  13358. * Clones the particle system.
  13359. * @param name The name of the cloned object
  13360. * @param newEmitter The new emitter to use
  13361. * @returns the cloned particle system
  13362. */
  13363. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13364. /**
  13365. * Serializes the particle system to a JSON object
  13366. * @param serializeTexture defines if the texture must be serialized as well
  13367. * @returns the JSON object
  13368. */
  13369. serialize(serializeTexture: boolean): any;
  13370. /**
  13371. * Rebuild the particle system
  13372. */
  13373. rebuild(): void;
  13374. /** Force the system to rebuild all gradients that need to be resync */
  13375. forceRefreshGradients(): void;
  13376. /**
  13377. * Starts the particle system and begins to emit
  13378. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13379. */
  13380. start(delay?: number): void;
  13381. /**
  13382. * Stops the particle system.
  13383. */
  13384. stop(): void;
  13385. /**
  13386. * Remove all active particles
  13387. */
  13388. reset(): void;
  13389. /**
  13390. * Gets a boolean indicating that the system is stopping
  13391. * @returns true if the system is currently stopping
  13392. */
  13393. isStopping(): boolean;
  13394. /**
  13395. * Is this system ready to be used/rendered
  13396. * @return true if the system is ready
  13397. */
  13398. isReady(): boolean;
  13399. /**
  13400. * Returns the string "ParticleSystem"
  13401. * @returns a string containing the class name
  13402. */
  13403. getClassName(): string;
  13404. /**
  13405. * Adds a new color gradient
  13406. * @param gradient defines the gradient to use (between 0 and 1)
  13407. * @param color1 defines the color to affect to the specified gradient
  13408. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13409. * @returns the current particle system
  13410. */
  13411. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13412. /**
  13413. * Remove a specific color gradient
  13414. * @param gradient defines the gradient to remove
  13415. * @returns the current particle system
  13416. */
  13417. removeColorGradient(gradient: number): IParticleSystem;
  13418. /**
  13419. * Adds a new size gradient
  13420. * @param gradient defines the gradient to use (between 0 and 1)
  13421. * @param factor defines the size factor to affect to the specified gradient
  13422. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13423. * @returns the current particle system
  13424. */
  13425. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13426. /**
  13427. * Remove a specific size gradient
  13428. * @param gradient defines the gradient to remove
  13429. * @returns the current particle system
  13430. */
  13431. removeSizeGradient(gradient: number): IParticleSystem;
  13432. /**
  13433. * Gets the current list of color gradients.
  13434. * You must use addColorGradient and removeColorGradient to udpate this list
  13435. * @returns the list of color gradients
  13436. */
  13437. getColorGradients(): Nullable<Array<ColorGradient>>;
  13438. /**
  13439. * Gets the current list of size gradients.
  13440. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13441. * @returns the list of size gradients
  13442. */
  13443. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13444. /**
  13445. * Gets the current list of angular speed gradients.
  13446. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13447. * @returns the list of angular speed gradients
  13448. */
  13449. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13450. /**
  13451. * Adds a new angular speed gradient
  13452. * @param gradient defines the gradient to use (between 0 and 1)
  13453. * @param factor defines the angular speed to affect to the specified gradient
  13454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13455. * @returns the current particle system
  13456. */
  13457. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13458. /**
  13459. * Remove a specific angular speed gradient
  13460. * @param gradient defines the gradient to remove
  13461. * @returns the current particle system
  13462. */
  13463. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13464. /**
  13465. * Gets the current list of velocity gradients.
  13466. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13467. * @returns the list of velocity gradients
  13468. */
  13469. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13470. /**
  13471. * Adds a new velocity gradient
  13472. * @param gradient defines the gradient to use (between 0 and 1)
  13473. * @param factor defines the velocity to affect to the specified gradient
  13474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13475. * @returns the current particle system
  13476. */
  13477. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13478. /**
  13479. * Remove a specific velocity gradient
  13480. * @param gradient defines the gradient to remove
  13481. * @returns the current particle system
  13482. */
  13483. removeVelocityGradient(gradient: number): IParticleSystem;
  13484. /**
  13485. * Gets the current list of limit velocity gradients.
  13486. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13487. * @returns the list of limit velocity gradients
  13488. */
  13489. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13490. /**
  13491. * Adds a new limit velocity gradient
  13492. * @param gradient defines the gradient to use (between 0 and 1)
  13493. * @param factor defines the limit velocity to affect to the specified gradient
  13494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13495. * @returns the current particle system
  13496. */
  13497. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13498. /**
  13499. * Remove a specific limit velocity gradient
  13500. * @param gradient defines the gradient to remove
  13501. * @returns the current particle system
  13502. */
  13503. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13504. /**
  13505. * Adds a new drag gradient
  13506. * @param gradient defines the gradient to use (between 0 and 1)
  13507. * @param factor defines the drag to affect to the specified gradient
  13508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13509. * @returns the current particle system
  13510. */
  13511. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13512. /**
  13513. * Remove a specific drag gradient
  13514. * @param gradient defines the gradient to remove
  13515. * @returns the current particle system
  13516. */
  13517. removeDragGradient(gradient: number): IParticleSystem;
  13518. /**
  13519. * Gets the current list of drag gradients.
  13520. * You must use addDragGradient and removeDragGradient to udpate this list
  13521. * @returns the list of drag gradients
  13522. */
  13523. getDragGradients(): Nullable<Array<FactorGradient>>;
  13524. /**
  13525. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13526. * @param gradient defines the gradient to use (between 0 and 1)
  13527. * @param factor defines the emit rate to affect to the specified gradient
  13528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13529. * @returns the current particle system
  13530. */
  13531. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13532. /**
  13533. * Remove a specific emit rate gradient
  13534. * @param gradient defines the gradient to remove
  13535. * @returns the current particle system
  13536. */
  13537. removeEmitRateGradient(gradient: number): IParticleSystem;
  13538. /**
  13539. * Gets the current list of emit rate gradients.
  13540. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13541. * @returns the list of emit rate gradients
  13542. */
  13543. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13544. /**
  13545. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13546. * @param gradient defines the gradient to use (between 0 and 1)
  13547. * @param factor defines the start size to affect to the specified gradient
  13548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13549. * @returns the current particle system
  13550. */
  13551. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13552. /**
  13553. * Remove a specific start size gradient
  13554. * @param gradient defines the gradient to remove
  13555. * @returns the current particle system
  13556. */
  13557. removeStartSizeGradient(gradient: number): IParticleSystem;
  13558. /**
  13559. * Gets the current list of start size gradients.
  13560. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13561. * @returns the list of start size gradients
  13562. */
  13563. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13564. /**
  13565. * Adds a new life time gradient
  13566. * @param gradient defines the gradient to use (between 0 and 1)
  13567. * @param factor defines the life time factor to affect to the specified gradient
  13568. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13569. * @returns the current particle system
  13570. */
  13571. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13572. /**
  13573. * Remove a specific life time gradient
  13574. * @param gradient defines the gradient to remove
  13575. * @returns the current particle system
  13576. */
  13577. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13578. /**
  13579. * Gets the current list of life time gradients.
  13580. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13581. * @returns the list of life time gradients
  13582. */
  13583. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13584. /**
  13585. * Gets the current list of color gradients.
  13586. * You must use addColorGradient and removeColorGradient to udpate this list
  13587. * @returns the list of color gradients
  13588. */
  13589. getColorGradients(): Nullable<Array<ColorGradient>>;
  13590. /**
  13591. * Adds a new ramp gradient used to remap particle colors
  13592. * @param gradient defines the gradient to use (between 0 and 1)
  13593. * @param color defines the color to affect to the specified gradient
  13594. * @returns the current particle system
  13595. */
  13596. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13597. /**
  13598. * Gets the current list of ramp gradients.
  13599. * You must use addRampGradient and removeRampGradient to udpate this list
  13600. * @returns the list of ramp gradients
  13601. */
  13602. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13603. /** Gets or sets a boolean indicating that ramp gradients must be used
  13604. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13605. */
  13606. useRampGradients: boolean;
  13607. /**
  13608. * Adds a new color remap gradient
  13609. * @param gradient defines the gradient to use (between 0 and 1)
  13610. * @param min defines the color remap minimal range
  13611. * @param max defines the color remap maximal range
  13612. * @returns the current particle system
  13613. */
  13614. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13615. /**
  13616. * Gets the current list of color remap gradients.
  13617. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13618. * @returns the list of color remap gradients
  13619. */
  13620. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13621. /**
  13622. * Adds a new alpha remap gradient
  13623. * @param gradient defines the gradient to use (between 0 and 1)
  13624. * @param min defines the alpha remap minimal range
  13625. * @param max defines the alpha remap maximal range
  13626. * @returns the current particle system
  13627. */
  13628. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13629. /**
  13630. * Gets the current list of alpha remap gradients.
  13631. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13632. * @returns the list of alpha remap gradients
  13633. */
  13634. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13635. /**
  13636. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13637. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13638. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13639. * @returns the emitter
  13640. */
  13641. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13642. /**
  13643. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13644. * @param radius The radius of the hemisphere to emit from
  13645. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13646. * @returns the emitter
  13647. */
  13648. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13649. /**
  13650. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13651. * @param radius The radius of the sphere to emit from
  13652. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13653. * @returns the emitter
  13654. */
  13655. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13656. /**
  13657. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13658. * @param radius The radius of the sphere to emit from
  13659. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13660. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13661. * @returns the emitter
  13662. */
  13663. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13664. /**
  13665. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13666. * @param radius The radius of the emission cylinder
  13667. * @param height The height of the emission cylinder
  13668. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13669. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13670. * @returns the emitter
  13671. */
  13672. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13673. /**
  13674. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13675. * @param radius The radius of the cylinder to emit from
  13676. * @param height The height of the emission cylinder
  13677. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13678. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13679. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13680. * @returns the emitter
  13681. */
  13682. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13683. /**
  13684. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13685. * @param radius The radius of the cone to emit from
  13686. * @param angle The base angle of the cone
  13687. * @returns the emitter
  13688. */
  13689. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13690. /**
  13691. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13692. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13693. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13694. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13695. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13696. * @returns the emitter
  13697. */
  13698. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13699. /**
  13700. * Get hosting scene
  13701. * @returns the scene
  13702. */
  13703. getScene(): Scene;
  13704. }
  13705. }
  13706. declare module BABYLON {
  13707. /**
  13708. * 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.
  13709. * @see https://doc.babylonjs.com/how_to/transformnode
  13710. */
  13711. export class TransformNode extends Node {
  13712. /**
  13713. * Object will not rotate to face the camera
  13714. */
  13715. static BILLBOARDMODE_NONE: number;
  13716. /**
  13717. * Object will rotate to face the camera but only on the x axis
  13718. */
  13719. static BILLBOARDMODE_X: number;
  13720. /**
  13721. * Object will rotate to face the camera but only on the y axis
  13722. */
  13723. static BILLBOARDMODE_Y: number;
  13724. /**
  13725. * Object will rotate to face the camera but only on the z axis
  13726. */
  13727. static BILLBOARDMODE_Z: number;
  13728. /**
  13729. * Object will rotate to face the camera
  13730. */
  13731. static BILLBOARDMODE_ALL: number;
  13732. /**
  13733. * Object will rotate to face the camera's position instead of orientation
  13734. */
  13735. static BILLBOARDMODE_USE_POSITION: number;
  13736. private _forward;
  13737. private _forwardInverted;
  13738. private _up;
  13739. private _right;
  13740. private _rightInverted;
  13741. private _position;
  13742. private _rotation;
  13743. private _rotationQuaternion;
  13744. protected _scaling: Vector3;
  13745. protected _isDirty: boolean;
  13746. private _transformToBoneReferal;
  13747. private _isAbsoluteSynced;
  13748. private _billboardMode;
  13749. /**
  13750. * Gets or sets the billboard mode. Default is 0.
  13751. *
  13752. * | Value | Type | Description |
  13753. * | --- | --- | --- |
  13754. * | 0 | BILLBOARDMODE_NONE | |
  13755. * | 1 | BILLBOARDMODE_X | |
  13756. * | 2 | BILLBOARDMODE_Y | |
  13757. * | 4 | BILLBOARDMODE_Z | |
  13758. * | 7 | BILLBOARDMODE_ALL | |
  13759. *
  13760. */
  13761. get billboardMode(): number;
  13762. set billboardMode(value: number);
  13763. private _preserveParentRotationForBillboard;
  13764. /**
  13765. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13766. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13767. */
  13768. get preserveParentRotationForBillboard(): boolean;
  13769. set preserveParentRotationForBillboard(value: boolean);
  13770. /**
  13771. * 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
  13772. */
  13773. scalingDeterminant: number;
  13774. private _infiniteDistance;
  13775. /**
  13776. * Gets or sets the distance of the object to max, often used by skybox
  13777. */
  13778. get infiniteDistance(): boolean;
  13779. set infiniteDistance(value: boolean);
  13780. /**
  13781. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13782. * By default the system will update normals to compensate
  13783. */
  13784. ignoreNonUniformScaling: boolean;
  13785. /**
  13786. * 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
  13787. */
  13788. reIntegrateRotationIntoRotationQuaternion: boolean;
  13789. /** @hidden */
  13790. _poseMatrix: Nullable<Matrix>;
  13791. /** @hidden */
  13792. _localMatrix: Matrix;
  13793. private _usePivotMatrix;
  13794. private _absolutePosition;
  13795. private _absoluteScaling;
  13796. private _absoluteRotationQuaternion;
  13797. private _pivotMatrix;
  13798. private _pivotMatrixInverse;
  13799. protected _postMultiplyPivotMatrix: boolean;
  13800. protected _isWorldMatrixFrozen: boolean;
  13801. /** @hidden */
  13802. _indexInSceneTransformNodesArray: number;
  13803. /**
  13804. * An event triggered after the world matrix is updated
  13805. */
  13806. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13807. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13808. /**
  13809. * Gets a string identifying the name of the class
  13810. * @returns "TransformNode" string
  13811. */
  13812. getClassName(): string;
  13813. /**
  13814. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13815. */
  13816. get position(): Vector3;
  13817. set position(newPosition: Vector3);
  13818. /**
  13819. * 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)).
  13820. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13821. */
  13822. get rotation(): Vector3;
  13823. set rotation(newRotation: Vector3);
  13824. /**
  13825. * 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)).
  13826. */
  13827. get scaling(): Vector3;
  13828. set scaling(newScaling: Vector3);
  13829. /**
  13830. * 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).
  13831. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13832. */
  13833. get rotationQuaternion(): Nullable<Quaternion>;
  13834. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13835. /**
  13836. * The forward direction of that transform in world space.
  13837. */
  13838. get forward(): Vector3;
  13839. /**
  13840. * The up direction of that transform in world space.
  13841. */
  13842. get up(): Vector3;
  13843. /**
  13844. * The right direction of that transform in world space.
  13845. */
  13846. get right(): Vector3;
  13847. /**
  13848. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13849. * @param matrix the matrix to copy the pose from
  13850. * @returns this TransformNode.
  13851. */
  13852. updatePoseMatrix(matrix: Matrix): TransformNode;
  13853. /**
  13854. * Returns the mesh Pose matrix.
  13855. * @returns the pose matrix
  13856. */
  13857. getPoseMatrix(): Matrix;
  13858. /** @hidden */
  13859. _isSynchronized(): boolean;
  13860. /** @hidden */
  13861. _initCache(): void;
  13862. /**
  13863. * Flag the transform node as dirty (Forcing it to update everything)
  13864. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13865. * @returns this transform node
  13866. */
  13867. markAsDirty(property: string): TransformNode;
  13868. /**
  13869. * Returns the current mesh absolute position.
  13870. * Returns a Vector3.
  13871. */
  13872. get absolutePosition(): Vector3;
  13873. /**
  13874. * Returns the current mesh absolute scaling.
  13875. * Returns a Vector3.
  13876. */
  13877. get absoluteScaling(): Vector3;
  13878. /**
  13879. * Returns the current mesh absolute rotation.
  13880. * Returns a Quaternion.
  13881. */
  13882. get absoluteRotationQuaternion(): Quaternion;
  13883. /**
  13884. * Sets a new matrix to apply before all other transformation
  13885. * @param matrix defines the transform matrix
  13886. * @returns the current TransformNode
  13887. */
  13888. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13889. /**
  13890. * Sets a new pivot matrix to the current node
  13891. * @param matrix defines the new pivot matrix to use
  13892. * @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
  13893. * @returns the current TransformNode
  13894. */
  13895. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13896. /**
  13897. * Returns the mesh pivot matrix.
  13898. * Default : Identity.
  13899. * @returns the matrix
  13900. */
  13901. getPivotMatrix(): Matrix;
  13902. /**
  13903. * Instantiate (when possible) or clone that node with its hierarchy
  13904. * @param newParent defines the new parent to use for the instance (or clone)
  13905. * @param options defines options to configure how copy is done
  13906. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13907. * @returns an instance (or a clone) of the current node with its hiearchy
  13908. */
  13909. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13910. doNotInstantiate: boolean;
  13911. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13912. /**
  13913. * Prevents the World matrix to be computed any longer
  13914. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13915. * @returns the TransformNode.
  13916. */
  13917. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13918. /**
  13919. * Allows back the World matrix computation.
  13920. * @returns the TransformNode.
  13921. */
  13922. unfreezeWorldMatrix(): this;
  13923. /**
  13924. * True if the World matrix has been frozen.
  13925. */
  13926. get isWorldMatrixFrozen(): boolean;
  13927. /**
  13928. * Retuns the mesh absolute position in the World.
  13929. * @returns a Vector3.
  13930. */
  13931. getAbsolutePosition(): Vector3;
  13932. /**
  13933. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13934. * @param absolutePosition the absolute position to set
  13935. * @returns the TransformNode.
  13936. */
  13937. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13938. /**
  13939. * Sets the mesh position in its local space.
  13940. * @param vector3 the position to set in localspace
  13941. * @returns the TransformNode.
  13942. */
  13943. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13944. /**
  13945. * Returns the mesh position in the local space from the current World matrix values.
  13946. * @returns a new Vector3.
  13947. */
  13948. getPositionExpressedInLocalSpace(): Vector3;
  13949. /**
  13950. * Translates the mesh along the passed Vector3 in its local space.
  13951. * @param vector3 the distance to translate in localspace
  13952. * @returns the TransformNode.
  13953. */
  13954. locallyTranslate(vector3: Vector3): TransformNode;
  13955. private static _lookAtVectorCache;
  13956. /**
  13957. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13958. * @param targetPoint the position (must be in same space as current mesh) to look at
  13959. * @param yawCor optional yaw (y-axis) correction in radians
  13960. * @param pitchCor optional pitch (x-axis) correction in radians
  13961. * @param rollCor optional roll (z-axis) correction in radians
  13962. * @param space the choosen space of the target
  13963. * @returns the TransformNode.
  13964. */
  13965. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13966. /**
  13967. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13968. * This Vector3 is expressed in the World space.
  13969. * @param localAxis axis to rotate
  13970. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13971. */
  13972. getDirection(localAxis: Vector3): Vector3;
  13973. /**
  13974. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13975. * localAxis is expressed in the mesh local space.
  13976. * result is computed in the Wordl space from the mesh World matrix.
  13977. * @param localAxis axis to rotate
  13978. * @param result the resulting transformnode
  13979. * @returns this TransformNode.
  13980. */
  13981. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13982. /**
  13983. * Sets this transform node rotation to the given local axis.
  13984. * @param localAxis the axis in local space
  13985. * @param yawCor optional yaw (y-axis) correction in radians
  13986. * @param pitchCor optional pitch (x-axis) correction in radians
  13987. * @param rollCor optional roll (z-axis) correction in radians
  13988. * @returns this TransformNode
  13989. */
  13990. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13991. /**
  13992. * Sets a new pivot point to the current node
  13993. * @param point defines the new pivot point to use
  13994. * @param space defines if the point is in world or local space (local by default)
  13995. * @returns the current TransformNode
  13996. */
  13997. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13998. /**
  13999. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14000. * @returns the pivot point
  14001. */
  14002. getPivotPoint(): Vector3;
  14003. /**
  14004. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14005. * @param result the vector3 to store the result
  14006. * @returns this TransformNode.
  14007. */
  14008. getPivotPointToRef(result: Vector3): TransformNode;
  14009. /**
  14010. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14011. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14012. */
  14013. getAbsolutePivotPoint(): Vector3;
  14014. /**
  14015. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14016. * @param result vector3 to store the result
  14017. * @returns this TransformNode.
  14018. */
  14019. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14020. /**
  14021. * Defines the passed node as the parent of the current node.
  14022. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14023. * @see https://doc.babylonjs.com/how_to/parenting
  14024. * @param node the node ot set as the parent
  14025. * @returns this TransformNode.
  14026. */
  14027. setParent(node: Nullable<Node>): TransformNode;
  14028. private _nonUniformScaling;
  14029. /**
  14030. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14031. */
  14032. get nonUniformScaling(): boolean;
  14033. /** @hidden */
  14034. _updateNonUniformScalingState(value: boolean): boolean;
  14035. /**
  14036. * Attach the current TransformNode to another TransformNode associated with a bone
  14037. * @param bone Bone affecting the TransformNode
  14038. * @param affectedTransformNode TransformNode associated with the bone
  14039. * @returns this object
  14040. */
  14041. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14042. /**
  14043. * Detach the transform node if its associated with a bone
  14044. * @returns this object
  14045. */
  14046. detachFromBone(): TransformNode;
  14047. private static _rotationAxisCache;
  14048. /**
  14049. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14050. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14051. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14052. * The passed axis is also normalized.
  14053. * @param axis the axis to rotate around
  14054. * @param amount the amount to rotate in radians
  14055. * @param space Space to rotate in (Default: local)
  14056. * @returns the TransformNode.
  14057. */
  14058. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14059. /**
  14060. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14061. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14062. * The passed axis is also normalized. .
  14063. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14064. * @param point the point to rotate around
  14065. * @param axis the axis to rotate around
  14066. * @param amount the amount to rotate in radians
  14067. * @returns the TransformNode
  14068. */
  14069. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14070. /**
  14071. * Translates the mesh along the axis vector for the passed distance in the given space.
  14072. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14073. * @param axis the axis to translate in
  14074. * @param distance the distance to translate
  14075. * @param space Space to rotate in (Default: local)
  14076. * @returns the TransformNode.
  14077. */
  14078. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14079. /**
  14080. * Adds a rotation step to the mesh current rotation.
  14081. * x, y, z are Euler angles expressed in radians.
  14082. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14083. * This means this rotation is made in the mesh local space only.
  14084. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14085. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14086. * ```javascript
  14087. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14088. * ```
  14089. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14090. * 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.
  14091. * @param x Rotation to add
  14092. * @param y Rotation to add
  14093. * @param z Rotation to add
  14094. * @returns the TransformNode.
  14095. */
  14096. addRotation(x: number, y: number, z: number): TransformNode;
  14097. /**
  14098. * @hidden
  14099. */
  14100. protected _getEffectiveParent(): Nullable<Node>;
  14101. /**
  14102. * Computes the world matrix of the node
  14103. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14104. * @returns the world matrix
  14105. */
  14106. computeWorldMatrix(force?: boolean): Matrix;
  14107. /**
  14108. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14109. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14110. */
  14111. resetLocalMatrix(independentOfChildren?: boolean): void;
  14112. protected _afterComputeWorldMatrix(): void;
  14113. /**
  14114. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14115. * @param func callback function to add
  14116. *
  14117. * @returns the TransformNode.
  14118. */
  14119. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14120. /**
  14121. * Removes a registered callback function.
  14122. * @param func callback function to remove
  14123. * @returns the TransformNode.
  14124. */
  14125. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14126. /**
  14127. * Gets the position of the current mesh in camera space
  14128. * @param camera defines the camera to use
  14129. * @returns a position
  14130. */
  14131. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14132. /**
  14133. * Returns the distance from the mesh to the active camera
  14134. * @param camera defines the camera to use
  14135. * @returns the distance
  14136. */
  14137. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14138. /**
  14139. * Clone the current transform node
  14140. * @param name Name of the new clone
  14141. * @param newParent New parent for the clone
  14142. * @param doNotCloneChildren Do not clone children hierarchy
  14143. * @returns the new transform node
  14144. */
  14145. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14146. /**
  14147. * Serializes the objects information.
  14148. * @param currentSerializationObject defines the object to serialize in
  14149. * @returns the serialized object
  14150. */
  14151. serialize(currentSerializationObject?: any): any;
  14152. /**
  14153. * Returns a new TransformNode object parsed from the source provided.
  14154. * @param parsedTransformNode is the source.
  14155. * @param scene the scne the object belongs to
  14156. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14157. * @returns a new TransformNode object parsed from the source provided.
  14158. */
  14159. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14160. /**
  14161. * Get all child-transformNodes of this node
  14162. * @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
  14163. * @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
  14164. * @returns an array of TransformNode
  14165. */
  14166. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14167. /**
  14168. * Releases resources associated with this transform node.
  14169. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14170. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14171. */
  14172. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14173. /**
  14174. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14175. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14176. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14177. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14178. * @returns the current mesh
  14179. */
  14180. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14181. private _syncAbsoluteScalingAndRotation;
  14182. }
  14183. }
  14184. declare module BABYLON {
  14185. /**
  14186. * Class used to override all child animations of a given target
  14187. */
  14188. export class AnimationPropertiesOverride {
  14189. /**
  14190. * Gets or sets a value indicating if animation blending must be used
  14191. */
  14192. enableBlending: boolean;
  14193. /**
  14194. * Gets or sets the blending speed to use when enableBlending is true
  14195. */
  14196. blendingSpeed: number;
  14197. /**
  14198. * Gets or sets the default loop mode to use
  14199. */
  14200. loopMode: number;
  14201. }
  14202. }
  14203. declare module BABYLON {
  14204. /**
  14205. * Class used to store bone information
  14206. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14207. */
  14208. export class Bone extends Node {
  14209. /**
  14210. * defines the bone name
  14211. */
  14212. name: string;
  14213. private static _tmpVecs;
  14214. private static _tmpQuat;
  14215. private static _tmpMats;
  14216. /**
  14217. * Gets the list of child bones
  14218. */
  14219. children: Bone[];
  14220. /** Gets the animations associated with this bone */
  14221. animations: Animation[];
  14222. /**
  14223. * Gets or sets bone length
  14224. */
  14225. length: number;
  14226. /**
  14227. * @hidden Internal only
  14228. * Set this value to map this bone to a different index in the transform matrices
  14229. * Set this value to -1 to exclude the bone from the transform matrices
  14230. */
  14231. _index: Nullable<number>;
  14232. private _skeleton;
  14233. private _localMatrix;
  14234. private _restPose;
  14235. private _baseMatrix;
  14236. private _absoluteTransform;
  14237. private _invertedAbsoluteTransform;
  14238. private _parent;
  14239. private _scalingDeterminant;
  14240. private _worldTransform;
  14241. private _localScaling;
  14242. private _localRotation;
  14243. private _localPosition;
  14244. private _needToDecompose;
  14245. private _needToCompose;
  14246. /** @hidden */
  14247. _linkedTransformNode: Nullable<TransformNode>;
  14248. /** @hidden */
  14249. _waitingTransformNodeId: Nullable<string>;
  14250. /** @hidden */
  14251. get _matrix(): Matrix;
  14252. /** @hidden */
  14253. set _matrix(value: Matrix);
  14254. /**
  14255. * Create a new bone
  14256. * @param name defines the bone name
  14257. * @param skeleton defines the parent skeleton
  14258. * @param parentBone defines the parent (can be null if the bone is the root)
  14259. * @param localMatrix defines the local matrix
  14260. * @param restPose defines the rest pose matrix
  14261. * @param baseMatrix defines the base matrix
  14262. * @param index defines index of the bone in the hiearchy
  14263. */
  14264. constructor(
  14265. /**
  14266. * defines the bone name
  14267. */
  14268. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14269. /**
  14270. * Gets the current object class name.
  14271. * @return the class name
  14272. */
  14273. getClassName(): string;
  14274. /**
  14275. * Gets the parent skeleton
  14276. * @returns a skeleton
  14277. */
  14278. getSkeleton(): Skeleton;
  14279. /**
  14280. * Gets parent bone
  14281. * @returns a bone or null if the bone is the root of the bone hierarchy
  14282. */
  14283. getParent(): Nullable<Bone>;
  14284. /**
  14285. * Returns an array containing the root bones
  14286. * @returns an array containing the root bones
  14287. */
  14288. getChildren(): Array<Bone>;
  14289. /**
  14290. * Gets the node index in matrix array generated for rendering
  14291. * @returns the node index
  14292. */
  14293. getIndex(): number;
  14294. /**
  14295. * Sets the parent bone
  14296. * @param parent defines the parent (can be null if the bone is the root)
  14297. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14298. */
  14299. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14300. /**
  14301. * Gets the local matrix
  14302. * @returns a matrix
  14303. */
  14304. getLocalMatrix(): Matrix;
  14305. /**
  14306. * Gets the base matrix (initial matrix which remains unchanged)
  14307. * @returns a matrix
  14308. */
  14309. getBaseMatrix(): Matrix;
  14310. /**
  14311. * Gets the rest pose matrix
  14312. * @returns a matrix
  14313. */
  14314. getRestPose(): Matrix;
  14315. /**
  14316. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14317. */
  14318. getWorldMatrix(): Matrix;
  14319. /**
  14320. * Sets the local matrix to rest pose matrix
  14321. */
  14322. returnToRest(): void;
  14323. /**
  14324. * Gets the inverse of the absolute transform matrix.
  14325. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14326. * @returns a matrix
  14327. */
  14328. getInvertedAbsoluteTransform(): Matrix;
  14329. /**
  14330. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14331. * @returns a matrix
  14332. */
  14333. getAbsoluteTransform(): Matrix;
  14334. /**
  14335. * Links with the given transform node.
  14336. * The local matrix of this bone is copied from the transform node every frame.
  14337. * @param transformNode defines the transform node to link to
  14338. */
  14339. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14340. /**
  14341. * Gets the node used to drive the bone's transformation
  14342. * @returns a transform node or null
  14343. */
  14344. getTransformNode(): Nullable<TransformNode>;
  14345. /** Gets or sets current position (in local space) */
  14346. get position(): Vector3;
  14347. set position(newPosition: Vector3);
  14348. /** Gets or sets current rotation (in local space) */
  14349. get rotation(): Vector3;
  14350. set rotation(newRotation: Vector3);
  14351. /** Gets or sets current rotation quaternion (in local space) */
  14352. get rotationQuaternion(): Quaternion;
  14353. set rotationQuaternion(newRotation: Quaternion);
  14354. /** Gets or sets current scaling (in local space) */
  14355. get scaling(): Vector3;
  14356. set scaling(newScaling: Vector3);
  14357. /**
  14358. * Gets the animation properties override
  14359. */
  14360. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14361. private _decompose;
  14362. private _compose;
  14363. /**
  14364. * Update the base and local matrices
  14365. * @param matrix defines the new base or local matrix
  14366. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14367. * @param updateLocalMatrix defines if the local matrix should be updated
  14368. */
  14369. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14370. /** @hidden */
  14371. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14372. /**
  14373. * Flag the bone as dirty (Forcing it to update everything)
  14374. */
  14375. markAsDirty(): void;
  14376. /** @hidden */
  14377. _markAsDirtyAndCompose(): void;
  14378. private _markAsDirtyAndDecompose;
  14379. /**
  14380. * Translate the bone in local or world space
  14381. * @param vec The amount to translate the bone
  14382. * @param space The space that the translation is in
  14383. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14384. */
  14385. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14386. /**
  14387. * Set the postion of the bone in local or world space
  14388. * @param position The position to set the bone
  14389. * @param space The space that the position is in
  14390. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14391. */
  14392. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14393. /**
  14394. * Set the absolute position of the bone (world space)
  14395. * @param position The position to set the bone
  14396. * @param mesh The mesh that this bone is attached to
  14397. */
  14398. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14399. /**
  14400. * Scale the bone on the x, y and z axes (in local space)
  14401. * @param x The amount to scale the bone on the x axis
  14402. * @param y The amount to scale the bone on the y axis
  14403. * @param z The amount to scale the bone on the z axis
  14404. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14405. */
  14406. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14407. /**
  14408. * Set the bone scaling in local space
  14409. * @param scale defines the scaling vector
  14410. */
  14411. setScale(scale: Vector3): void;
  14412. /**
  14413. * Gets the current scaling in local space
  14414. * @returns the current scaling vector
  14415. */
  14416. getScale(): Vector3;
  14417. /**
  14418. * Gets the current scaling in local space and stores it in a target vector
  14419. * @param result defines the target vector
  14420. */
  14421. getScaleToRef(result: Vector3): void;
  14422. /**
  14423. * Set the yaw, pitch, and roll of the bone in local or world space
  14424. * @param yaw The rotation of the bone on the y axis
  14425. * @param pitch The rotation of the bone on the x axis
  14426. * @param roll The rotation of the bone on the z axis
  14427. * @param space The space that the axes of rotation are in
  14428. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14429. */
  14430. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14431. /**
  14432. * Add a rotation to the bone on an axis in local or world space
  14433. * @param axis The axis to rotate the bone on
  14434. * @param amount The amount to rotate the bone
  14435. * @param space The space that the axis is in
  14436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14437. */
  14438. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14439. /**
  14440. * Set the rotation of the bone to a particular axis angle in local or world space
  14441. * @param axis The axis to rotate the bone on
  14442. * @param angle The angle that the bone should be rotated to
  14443. * @param space The space that the axis is in
  14444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14445. */
  14446. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14447. /**
  14448. * Set the euler rotation of the bone in local of world space
  14449. * @param rotation The euler rotation that the bone should be set to
  14450. * @param space The space that the rotation is in
  14451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14452. */
  14453. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14454. /**
  14455. * Set the quaternion rotation of the bone in local of world space
  14456. * @param quat The quaternion rotation that the bone should be set to
  14457. * @param space The space that the rotation is in
  14458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14459. */
  14460. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14461. /**
  14462. * Set the rotation matrix of the bone in local of world space
  14463. * @param rotMat The rotation matrix that the bone should be set to
  14464. * @param space The space that the rotation is in
  14465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14466. */
  14467. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14468. private _rotateWithMatrix;
  14469. private _getNegativeRotationToRef;
  14470. /**
  14471. * Get the position of the bone in local or world space
  14472. * @param space The space that the returned position is in
  14473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14474. * @returns The position of the bone
  14475. */
  14476. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14477. /**
  14478. * Copy the position of the bone to a vector3 in local or world space
  14479. * @param space The space that the returned position is in
  14480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14481. * @param result The vector3 to copy the position to
  14482. */
  14483. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14484. /**
  14485. * Get the absolute position of the bone (world space)
  14486. * @param mesh The mesh that this bone is attached to
  14487. * @returns The absolute position of the bone
  14488. */
  14489. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14490. /**
  14491. * Copy the absolute position of the bone (world space) to the result param
  14492. * @param mesh The mesh that this bone is attached to
  14493. * @param result The vector3 to copy the absolute position to
  14494. */
  14495. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14496. /**
  14497. * Compute the absolute transforms of this bone and its children
  14498. */
  14499. computeAbsoluteTransforms(): void;
  14500. /**
  14501. * Get the world direction from an axis that is in the local space of the bone
  14502. * @param localAxis The local direction that is used to compute the world direction
  14503. * @param mesh The mesh that this bone is attached to
  14504. * @returns The world direction
  14505. */
  14506. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14507. /**
  14508. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14509. * @param localAxis The local direction that is used to compute the world direction
  14510. * @param mesh The mesh that this bone is attached to
  14511. * @param result The vector3 that the world direction will be copied to
  14512. */
  14513. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14514. /**
  14515. * Get the euler rotation of the bone in local or world space
  14516. * @param space The space that the rotation should be in
  14517. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14518. * @returns The euler rotation
  14519. */
  14520. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14521. /**
  14522. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14523. * @param space The space that the rotation should be in
  14524. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14525. * @param result The vector3 that the rotation should be copied to
  14526. */
  14527. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14528. /**
  14529. * Get the quaternion rotation of the bone in either local or world space
  14530. * @param space The space that the rotation should be in
  14531. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14532. * @returns The quaternion rotation
  14533. */
  14534. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14535. /**
  14536. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14537. * @param space The space that the rotation should be in
  14538. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14539. * @param result The quaternion that the rotation should be copied to
  14540. */
  14541. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14542. /**
  14543. * Get the rotation matrix of the bone in local or world space
  14544. * @param space The space that the rotation should be in
  14545. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14546. * @returns The rotation matrix
  14547. */
  14548. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14549. /**
  14550. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14551. * @param space The space that the rotation should be in
  14552. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14553. * @param result The quaternion that the rotation should be copied to
  14554. */
  14555. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14556. /**
  14557. * Get the world position of a point that is in the local space of the bone
  14558. * @param position The local position
  14559. * @param mesh The mesh that this bone is attached to
  14560. * @returns The world position
  14561. */
  14562. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14563. /**
  14564. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14565. * @param position The local position
  14566. * @param mesh The mesh that this bone is attached to
  14567. * @param result The vector3 that the world position should be copied to
  14568. */
  14569. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14570. /**
  14571. * Get the local position of a point that is in world space
  14572. * @param position The world position
  14573. * @param mesh The mesh that this bone is attached to
  14574. * @returns The local position
  14575. */
  14576. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14577. /**
  14578. * Get the local position of a point that is in world space and copy it to the result param
  14579. * @param position The world position
  14580. * @param mesh The mesh that this bone is attached to
  14581. * @param result The vector3 that the local position should be copied to
  14582. */
  14583. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14584. }
  14585. }
  14586. declare module BABYLON {
  14587. /**
  14588. * Defines a runtime animation
  14589. */
  14590. export class RuntimeAnimation {
  14591. private _events;
  14592. /**
  14593. * The current frame of the runtime animation
  14594. */
  14595. private _currentFrame;
  14596. /**
  14597. * The animation used by the runtime animation
  14598. */
  14599. private _animation;
  14600. /**
  14601. * The target of the runtime animation
  14602. */
  14603. private _target;
  14604. /**
  14605. * The initiating animatable
  14606. */
  14607. private _host;
  14608. /**
  14609. * The original value of the runtime animation
  14610. */
  14611. private _originalValue;
  14612. /**
  14613. * The original blend value of the runtime animation
  14614. */
  14615. private _originalBlendValue;
  14616. /**
  14617. * The offsets cache of the runtime animation
  14618. */
  14619. private _offsetsCache;
  14620. /**
  14621. * The high limits cache of the runtime animation
  14622. */
  14623. private _highLimitsCache;
  14624. /**
  14625. * Specifies if the runtime animation has been stopped
  14626. */
  14627. private _stopped;
  14628. /**
  14629. * The blending factor of the runtime animation
  14630. */
  14631. private _blendingFactor;
  14632. /**
  14633. * The BabylonJS scene
  14634. */
  14635. private _scene;
  14636. /**
  14637. * The current value of the runtime animation
  14638. */
  14639. private _currentValue;
  14640. /** @hidden */
  14641. _animationState: _IAnimationState;
  14642. /**
  14643. * The active target of the runtime animation
  14644. */
  14645. private _activeTargets;
  14646. private _currentActiveTarget;
  14647. private _directTarget;
  14648. /**
  14649. * The target path of the runtime animation
  14650. */
  14651. private _targetPath;
  14652. /**
  14653. * The weight of the runtime animation
  14654. */
  14655. private _weight;
  14656. /**
  14657. * The ratio offset of the runtime animation
  14658. */
  14659. private _ratioOffset;
  14660. /**
  14661. * The previous delay of the runtime animation
  14662. */
  14663. private _previousDelay;
  14664. /**
  14665. * The previous ratio of the runtime animation
  14666. */
  14667. private _previousRatio;
  14668. private _enableBlending;
  14669. private _keys;
  14670. private _minFrame;
  14671. private _maxFrame;
  14672. private _minValue;
  14673. private _maxValue;
  14674. private _targetIsArray;
  14675. /**
  14676. * Gets the current frame of the runtime animation
  14677. */
  14678. get currentFrame(): number;
  14679. /**
  14680. * Gets the weight of the runtime animation
  14681. */
  14682. get weight(): number;
  14683. /**
  14684. * Gets the current value of the runtime animation
  14685. */
  14686. get currentValue(): any;
  14687. /**
  14688. * Gets the target path of the runtime animation
  14689. */
  14690. get targetPath(): string;
  14691. /**
  14692. * Gets the actual target of the runtime animation
  14693. */
  14694. get target(): any;
  14695. /**
  14696. * Gets the additive state of the runtime animation
  14697. */
  14698. get isAdditive(): boolean;
  14699. /** @hidden */
  14700. _onLoop: () => void;
  14701. /**
  14702. * Create a new RuntimeAnimation object
  14703. * @param target defines the target of the animation
  14704. * @param animation defines the source animation object
  14705. * @param scene defines the hosting scene
  14706. * @param host defines the initiating Animatable
  14707. */
  14708. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14709. private _preparePath;
  14710. /**
  14711. * Gets the animation from the runtime animation
  14712. */
  14713. get animation(): Animation;
  14714. /**
  14715. * Resets the runtime animation to the beginning
  14716. * @param restoreOriginal defines whether to restore the target property to the original value
  14717. */
  14718. reset(restoreOriginal?: boolean): void;
  14719. /**
  14720. * Specifies if the runtime animation is stopped
  14721. * @returns Boolean specifying if the runtime animation is stopped
  14722. */
  14723. isStopped(): boolean;
  14724. /**
  14725. * Disposes of the runtime animation
  14726. */
  14727. dispose(): void;
  14728. /**
  14729. * Apply the interpolated value to the target
  14730. * @param currentValue defines the value computed by the animation
  14731. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14732. */
  14733. setValue(currentValue: any, weight: number): void;
  14734. private _getOriginalValues;
  14735. private _setValue;
  14736. /**
  14737. * Gets the loop pmode of the runtime animation
  14738. * @returns Loop Mode
  14739. */
  14740. private _getCorrectLoopMode;
  14741. /**
  14742. * Move the current animation to a given frame
  14743. * @param frame defines the frame to move to
  14744. */
  14745. goToFrame(frame: number): void;
  14746. /**
  14747. * @hidden Internal use only
  14748. */
  14749. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14750. /**
  14751. * Execute the current animation
  14752. * @param delay defines the delay to add to the current frame
  14753. * @param from defines the lower bound of the animation range
  14754. * @param to defines the upper bound of the animation range
  14755. * @param loop defines if the current animation must loop
  14756. * @param speedRatio defines the current speed ratio
  14757. * @param weight defines the weight of the animation (default is -1 so no weight)
  14758. * @param onLoop optional callback called when animation loops
  14759. * @returns a boolean indicating if the animation is running
  14760. */
  14761. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14762. }
  14763. }
  14764. declare module BABYLON {
  14765. /**
  14766. * Class used to store an actual running animation
  14767. */
  14768. export class Animatable {
  14769. /** defines the target object */
  14770. target: any;
  14771. /** defines the starting frame number (default is 0) */
  14772. fromFrame: number;
  14773. /** defines the ending frame number (default is 100) */
  14774. toFrame: number;
  14775. /** defines if the animation must loop (default is false) */
  14776. loopAnimation: boolean;
  14777. /** defines a callback to call when animation ends if it is not looping */
  14778. onAnimationEnd?: (() => void) | null | undefined;
  14779. /** defines a callback to call when animation loops */
  14780. onAnimationLoop?: (() => void) | null | undefined;
  14781. /** defines whether the animation should be evaluated additively */
  14782. isAdditive: boolean;
  14783. private _localDelayOffset;
  14784. private _pausedDelay;
  14785. private _runtimeAnimations;
  14786. private _paused;
  14787. private _scene;
  14788. private _speedRatio;
  14789. private _weight;
  14790. private _syncRoot;
  14791. /**
  14792. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14793. * This will only apply for non looping animation (default is true)
  14794. */
  14795. disposeOnEnd: boolean;
  14796. /**
  14797. * Gets a boolean indicating if the animation has started
  14798. */
  14799. animationStarted: boolean;
  14800. /**
  14801. * Observer raised when the animation ends
  14802. */
  14803. onAnimationEndObservable: Observable<Animatable>;
  14804. /**
  14805. * Observer raised when the animation loops
  14806. */
  14807. onAnimationLoopObservable: Observable<Animatable>;
  14808. /**
  14809. * Gets the root Animatable used to synchronize and normalize animations
  14810. */
  14811. get syncRoot(): Nullable<Animatable>;
  14812. /**
  14813. * Gets the current frame of the first RuntimeAnimation
  14814. * Used to synchronize Animatables
  14815. */
  14816. get masterFrame(): number;
  14817. /**
  14818. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14819. */
  14820. get weight(): number;
  14821. set weight(value: number);
  14822. /**
  14823. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14824. */
  14825. get speedRatio(): number;
  14826. set speedRatio(value: number);
  14827. /**
  14828. * Creates a new Animatable
  14829. * @param scene defines the hosting scene
  14830. * @param target defines the target object
  14831. * @param fromFrame defines the starting frame number (default is 0)
  14832. * @param toFrame defines the ending frame number (default is 100)
  14833. * @param loopAnimation defines if the animation must loop (default is false)
  14834. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14835. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14836. * @param animations defines a group of animation to add to the new Animatable
  14837. * @param onAnimationLoop defines a callback to call when animation loops
  14838. * @param isAdditive defines whether the animation should be evaluated additively
  14839. */
  14840. constructor(scene: Scene,
  14841. /** defines the target object */
  14842. target: any,
  14843. /** defines the starting frame number (default is 0) */
  14844. fromFrame?: number,
  14845. /** defines the ending frame number (default is 100) */
  14846. toFrame?: number,
  14847. /** defines if the animation must loop (default is false) */
  14848. loopAnimation?: boolean, speedRatio?: number,
  14849. /** defines a callback to call when animation ends if it is not looping */
  14850. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14851. /** defines a callback to call when animation loops */
  14852. onAnimationLoop?: (() => void) | null | undefined,
  14853. /** defines whether the animation should be evaluated additively */
  14854. isAdditive?: boolean);
  14855. /**
  14856. * Synchronize and normalize current Animatable with a source Animatable
  14857. * This is useful when using animation weights and when animations are not of the same length
  14858. * @param root defines the root Animatable to synchronize with
  14859. * @returns the current Animatable
  14860. */
  14861. syncWith(root: Animatable): Animatable;
  14862. /**
  14863. * Gets the list of runtime animations
  14864. * @returns an array of RuntimeAnimation
  14865. */
  14866. getAnimations(): RuntimeAnimation[];
  14867. /**
  14868. * Adds more animations to the current animatable
  14869. * @param target defines the target of the animations
  14870. * @param animations defines the new animations to add
  14871. */
  14872. appendAnimations(target: any, animations: Animation[]): void;
  14873. /**
  14874. * Gets the source animation for a specific property
  14875. * @param property defines the propertyu to look for
  14876. * @returns null or the source animation for the given property
  14877. */
  14878. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14879. /**
  14880. * Gets the runtime animation for a specific property
  14881. * @param property defines the propertyu to look for
  14882. * @returns null or the runtime animation for the given property
  14883. */
  14884. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14885. /**
  14886. * Resets the animatable to its original state
  14887. */
  14888. reset(): void;
  14889. /**
  14890. * Allows the animatable to blend with current running animations
  14891. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14892. * @param blendingSpeed defines the blending speed to use
  14893. */
  14894. enableBlending(blendingSpeed: number): void;
  14895. /**
  14896. * Disable animation blending
  14897. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14898. */
  14899. disableBlending(): void;
  14900. /**
  14901. * Jump directly to a given frame
  14902. * @param frame defines the frame to jump to
  14903. */
  14904. goToFrame(frame: number): void;
  14905. /**
  14906. * Pause the animation
  14907. */
  14908. pause(): void;
  14909. /**
  14910. * Restart the animation
  14911. */
  14912. restart(): void;
  14913. private _raiseOnAnimationEnd;
  14914. /**
  14915. * Stop and delete the current animation
  14916. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14917. * @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)
  14918. */
  14919. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14920. /**
  14921. * Wait asynchronously for the animation to end
  14922. * @returns a promise which will be fullfilled when the animation ends
  14923. */
  14924. waitAsync(): Promise<Animatable>;
  14925. /** @hidden */
  14926. _animate(delay: number): boolean;
  14927. }
  14928. interface Scene {
  14929. /** @hidden */
  14930. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14931. /** @hidden */
  14932. _processLateAnimationBindingsForMatrices(holder: {
  14933. totalWeight: number;
  14934. totalAdditiveWeight: number;
  14935. animations: RuntimeAnimation[];
  14936. additiveAnimations: RuntimeAnimation[];
  14937. originalValue: Matrix;
  14938. }): any;
  14939. /** @hidden */
  14940. _processLateAnimationBindingsForQuaternions(holder: {
  14941. totalWeight: number;
  14942. totalAdditiveWeight: number;
  14943. animations: RuntimeAnimation[];
  14944. additiveAnimations: RuntimeAnimation[];
  14945. originalValue: Quaternion;
  14946. }, refQuaternion: Quaternion): Quaternion;
  14947. /** @hidden */
  14948. _processLateAnimationBindings(): void;
  14949. /**
  14950. * Will start the animation sequence of a given target
  14951. * @param target defines the target
  14952. * @param from defines from which frame should animation start
  14953. * @param to defines until which frame should animation run.
  14954. * @param weight defines the weight to apply to the animation (1.0 by default)
  14955. * @param loop defines if the animation loops
  14956. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14957. * @param onAnimationEnd defines the function to be executed when the animation ends
  14958. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14959. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14960. * @param onAnimationLoop defines the callback to call when an animation loops
  14961. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14962. * @returns the animatable object created for this animation
  14963. */
  14964. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14965. /**
  14966. * Will start the animation sequence of a given target
  14967. * @param target defines the target
  14968. * @param from defines from which frame should animation start
  14969. * @param to defines until which frame should animation run.
  14970. * @param loop defines if the animation loops
  14971. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14972. * @param onAnimationEnd defines the function to be executed when the animation ends
  14973. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14974. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14975. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14976. * @param onAnimationLoop defines the callback to call when an animation loops
  14977. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14978. * @returns the animatable object created for this animation
  14979. */
  14980. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14981. /**
  14982. * Will start the animation sequence of a given target and its hierarchy
  14983. * @param target defines the target
  14984. * @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.
  14985. * @param from defines from which frame should animation start
  14986. * @param to defines until which frame should animation run.
  14987. * @param loop defines if the animation loops
  14988. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14989. * @param onAnimationEnd defines the function to be executed when the animation ends
  14990. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14991. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14992. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14993. * @param onAnimationLoop defines the callback to call when an animation loops
  14994. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14995. * @returns the list of created animatables
  14996. */
  14997. 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, isAdditive?: boolean): Animatable[];
  14998. /**
  14999. * Begin a new animation on a given node
  15000. * @param target defines the target where the animation will take place
  15001. * @param animations defines the list of animations to start
  15002. * @param from defines the initial value
  15003. * @param to defines the final value
  15004. * @param loop defines if you want animation to loop (off by default)
  15005. * @param speedRatio defines the speed ratio to apply to all animations
  15006. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15007. * @param onAnimationLoop defines the callback to call when an animation loops
  15008. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15009. * @returns the list of created animatables
  15010. */
  15011. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15012. /**
  15013. * Begin a new animation on a given node and its hierarchy
  15014. * @param target defines the root node where the animation will take place
  15015. * @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.
  15016. * @param animations defines the list of animations to start
  15017. * @param from defines the initial value
  15018. * @param to defines the final value
  15019. * @param loop defines if you want animation to loop (off by default)
  15020. * @param speedRatio defines the speed ratio to apply to all animations
  15021. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15022. * @param onAnimationLoop defines the callback to call when an animation loops
  15023. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15024. * @returns the list of animatables created for all nodes
  15025. */
  15026. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15027. /**
  15028. * Gets the animatable associated with a specific target
  15029. * @param target defines the target of the animatable
  15030. * @returns the required animatable if found
  15031. */
  15032. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15033. /**
  15034. * Gets all animatables associated with a given target
  15035. * @param target defines the target to look animatables for
  15036. * @returns an array of Animatables
  15037. */
  15038. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15039. /**
  15040. * Stops and removes all animations that have been applied to the scene
  15041. */
  15042. stopAllAnimations(): void;
  15043. /**
  15044. * Gets the current delta time used by animation engine
  15045. */
  15046. deltaTime: number;
  15047. }
  15048. interface Bone {
  15049. /**
  15050. * Copy an animation range from another bone
  15051. * @param source defines the source bone
  15052. * @param rangeName defines the range name to copy
  15053. * @param frameOffset defines the frame offset
  15054. * @param rescaleAsRequired defines if rescaling must be applied if required
  15055. * @param skelDimensionsRatio defines the scaling ratio
  15056. * @returns true if operation was successful
  15057. */
  15058. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15059. }
  15060. }
  15061. declare module BABYLON {
  15062. /**
  15063. * Class used to handle skinning animations
  15064. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15065. */
  15066. export class Skeleton implements IAnimatable {
  15067. /** defines the skeleton name */
  15068. name: string;
  15069. /** defines the skeleton Id */
  15070. id: string;
  15071. /**
  15072. * Defines the list of child bones
  15073. */
  15074. bones: Bone[];
  15075. /**
  15076. * Defines an estimate of the dimension of the skeleton at rest
  15077. */
  15078. dimensionsAtRest: Vector3;
  15079. /**
  15080. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15081. */
  15082. needInitialSkinMatrix: boolean;
  15083. /**
  15084. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15085. */
  15086. overrideMesh: Nullable<AbstractMesh>;
  15087. /**
  15088. * Gets the list of animations attached to this skeleton
  15089. */
  15090. animations: Array<Animation>;
  15091. private _scene;
  15092. private _isDirty;
  15093. private _transformMatrices;
  15094. private _transformMatrixTexture;
  15095. private _meshesWithPoseMatrix;
  15096. private _animatables;
  15097. private _identity;
  15098. private _synchronizedWithMesh;
  15099. private _ranges;
  15100. private _lastAbsoluteTransformsUpdateId;
  15101. private _canUseTextureForBones;
  15102. private _uniqueId;
  15103. /** @hidden */
  15104. _numBonesWithLinkedTransformNode: number;
  15105. /** @hidden */
  15106. _hasWaitingData: Nullable<boolean>;
  15107. /**
  15108. * Specifies if the skeleton should be serialized
  15109. */
  15110. doNotSerialize: boolean;
  15111. private _useTextureToStoreBoneMatrices;
  15112. /**
  15113. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15114. * Please note that this option is not available if the hardware does not support it
  15115. */
  15116. get useTextureToStoreBoneMatrices(): boolean;
  15117. set useTextureToStoreBoneMatrices(value: boolean);
  15118. private _animationPropertiesOverride;
  15119. /**
  15120. * Gets or sets the animation properties override
  15121. */
  15122. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15123. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15124. /**
  15125. * List of inspectable custom properties (used by the Inspector)
  15126. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15127. */
  15128. inspectableCustomProperties: IInspectable[];
  15129. /**
  15130. * An observable triggered before computing the skeleton's matrices
  15131. */
  15132. onBeforeComputeObservable: Observable<Skeleton>;
  15133. /**
  15134. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15135. */
  15136. get isUsingTextureForMatrices(): boolean;
  15137. /**
  15138. * Gets the unique ID of this skeleton
  15139. */
  15140. get uniqueId(): number;
  15141. /**
  15142. * Creates a new skeleton
  15143. * @param name defines the skeleton name
  15144. * @param id defines the skeleton Id
  15145. * @param scene defines the hosting scene
  15146. */
  15147. constructor(
  15148. /** defines the skeleton name */
  15149. name: string,
  15150. /** defines the skeleton Id */
  15151. id: string, scene: Scene);
  15152. /**
  15153. * Gets the current object class name.
  15154. * @return the class name
  15155. */
  15156. getClassName(): string;
  15157. /**
  15158. * Returns an array containing the root bones
  15159. * @returns an array containing the root bones
  15160. */
  15161. getChildren(): Array<Bone>;
  15162. /**
  15163. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15164. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15165. * @returns a Float32Array containing matrices data
  15166. */
  15167. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15168. /**
  15169. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15170. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15171. * @returns a raw texture containing the data
  15172. */
  15173. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15174. /**
  15175. * Gets the current hosting scene
  15176. * @returns a scene object
  15177. */
  15178. getScene(): Scene;
  15179. /**
  15180. * Gets a string representing the current skeleton data
  15181. * @param fullDetails defines a boolean indicating if we want a verbose version
  15182. * @returns a string representing the current skeleton data
  15183. */
  15184. toString(fullDetails?: boolean): string;
  15185. /**
  15186. * Get bone's index searching by name
  15187. * @param name defines bone's name to search for
  15188. * @return the indice of the bone. Returns -1 if not found
  15189. */
  15190. getBoneIndexByName(name: string): number;
  15191. /**
  15192. * Creater a new animation range
  15193. * @param name defines the name of the range
  15194. * @param from defines the start key
  15195. * @param to defines the end key
  15196. */
  15197. createAnimationRange(name: string, from: number, to: number): void;
  15198. /**
  15199. * Delete a specific animation range
  15200. * @param name defines the name of the range
  15201. * @param deleteFrames defines if frames must be removed as well
  15202. */
  15203. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15204. /**
  15205. * Gets a specific animation range
  15206. * @param name defines the name of the range to look for
  15207. * @returns the requested animation range or null if not found
  15208. */
  15209. getAnimationRange(name: string): Nullable<AnimationRange>;
  15210. /**
  15211. * Gets the list of all animation ranges defined on this skeleton
  15212. * @returns an array
  15213. */
  15214. getAnimationRanges(): Nullable<AnimationRange>[];
  15215. /**
  15216. * Copy animation range from a source skeleton.
  15217. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15218. * @param source defines the source skeleton
  15219. * @param name defines the name of the range to copy
  15220. * @param rescaleAsRequired defines if rescaling must be applied if required
  15221. * @returns true if operation was successful
  15222. */
  15223. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15224. /**
  15225. * Forces the skeleton to go to rest pose
  15226. */
  15227. returnToRest(): void;
  15228. private _getHighestAnimationFrame;
  15229. /**
  15230. * Begin a specific animation range
  15231. * @param name defines the name of the range to start
  15232. * @param loop defines if looping must be turned on (false by default)
  15233. * @param speedRatio defines the speed ratio to apply (1 by default)
  15234. * @param onAnimationEnd defines a callback which will be called when animation will end
  15235. * @returns a new animatable
  15236. */
  15237. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15238. /**
  15239. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15240. * @param skeleton defines the Skeleton containing the animation range to convert
  15241. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15242. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15243. * @returns the original skeleton
  15244. */
  15245. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15246. /** @hidden */
  15247. _markAsDirty(): void;
  15248. /** @hidden */
  15249. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15250. /** @hidden */
  15251. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15252. private _computeTransformMatrices;
  15253. /**
  15254. * Build all resources required to render a skeleton
  15255. */
  15256. prepare(): void;
  15257. /**
  15258. * Gets the list of animatables currently running for this skeleton
  15259. * @returns an array of animatables
  15260. */
  15261. getAnimatables(): IAnimatable[];
  15262. /**
  15263. * Clone the current skeleton
  15264. * @param name defines the name of the new skeleton
  15265. * @param id defines the id of the new skeleton
  15266. * @returns the new skeleton
  15267. */
  15268. clone(name: string, id?: string): Skeleton;
  15269. /**
  15270. * Enable animation blending for this skeleton
  15271. * @param blendingSpeed defines the blending speed to apply
  15272. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15273. */
  15274. enableBlending(blendingSpeed?: number): void;
  15275. /**
  15276. * Releases all resources associated with the current skeleton
  15277. */
  15278. dispose(): void;
  15279. /**
  15280. * Serialize the skeleton in a JSON object
  15281. * @returns a JSON object
  15282. */
  15283. serialize(): any;
  15284. /**
  15285. * Creates a new skeleton from serialized data
  15286. * @param parsedSkeleton defines the serialized data
  15287. * @param scene defines the hosting scene
  15288. * @returns a new skeleton
  15289. */
  15290. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15291. /**
  15292. * Compute all node absolute transforms
  15293. * @param forceUpdate defines if computation must be done even if cache is up to date
  15294. */
  15295. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15296. /**
  15297. * Gets the root pose matrix
  15298. * @returns a matrix
  15299. */
  15300. getPoseMatrix(): Nullable<Matrix>;
  15301. /**
  15302. * Sorts bones per internal index
  15303. */
  15304. sortBones(): void;
  15305. private _sortBones;
  15306. }
  15307. }
  15308. declare module BABYLON {
  15309. /**
  15310. * Creates an instance based on a source mesh.
  15311. */
  15312. export class InstancedMesh extends AbstractMesh {
  15313. private _sourceMesh;
  15314. private _currentLOD;
  15315. /** @hidden */
  15316. _indexInSourceMeshInstanceArray: number;
  15317. constructor(name: string, source: Mesh);
  15318. /**
  15319. * Returns the string "InstancedMesh".
  15320. */
  15321. getClassName(): string;
  15322. /** Gets the list of lights affecting that mesh */
  15323. get lightSources(): Light[];
  15324. _resyncLightSources(): void;
  15325. _resyncLightSource(light: Light): void;
  15326. _removeLightSource(light: Light, dispose: boolean): void;
  15327. /**
  15328. * If the source mesh receives shadows
  15329. */
  15330. get receiveShadows(): boolean;
  15331. /**
  15332. * The material of the source mesh
  15333. */
  15334. get material(): Nullable<Material>;
  15335. /**
  15336. * Visibility of the source mesh
  15337. */
  15338. get visibility(): number;
  15339. /**
  15340. * Skeleton of the source mesh
  15341. */
  15342. get skeleton(): Nullable<Skeleton>;
  15343. /**
  15344. * Rendering ground id of the source mesh
  15345. */
  15346. get renderingGroupId(): number;
  15347. set renderingGroupId(value: number);
  15348. /**
  15349. * Returns the total number of vertices (integer).
  15350. */
  15351. getTotalVertices(): number;
  15352. /**
  15353. * Returns a positive integer : the total number of indices in this mesh geometry.
  15354. * @returns the numner of indices or zero if the mesh has no geometry.
  15355. */
  15356. getTotalIndices(): number;
  15357. /**
  15358. * The source mesh of the instance
  15359. */
  15360. get sourceMesh(): Mesh;
  15361. /**
  15362. * Is this node ready to be used/rendered
  15363. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15364. * @return {boolean} is it ready
  15365. */
  15366. isReady(completeCheck?: boolean): boolean;
  15367. /**
  15368. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15369. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15370. * @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.
  15371. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15372. */
  15373. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15374. /**
  15375. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15376. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15377. * The `data` are either a numeric array either a Float32Array.
  15378. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15379. * 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).
  15380. * Note that a new underlying VertexBuffer object is created each call.
  15381. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15382. *
  15383. * Possible `kind` values :
  15384. * - VertexBuffer.PositionKind
  15385. * - VertexBuffer.UVKind
  15386. * - VertexBuffer.UV2Kind
  15387. * - VertexBuffer.UV3Kind
  15388. * - VertexBuffer.UV4Kind
  15389. * - VertexBuffer.UV5Kind
  15390. * - VertexBuffer.UV6Kind
  15391. * - VertexBuffer.ColorKind
  15392. * - VertexBuffer.MatricesIndicesKind
  15393. * - VertexBuffer.MatricesIndicesExtraKind
  15394. * - VertexBuffer.MatricesWeightsKind
  15395. * - VertexBuffer.MatricesWeightsExtraKind
  15396. *
  15397. * Returns the Mesh.
  15398. */
  15399. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15400. /**
  15401. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15402. * If the mesh has no geometry, it is simply returned as it is.
  15403. * The `data` are either a numeric array either a Float32Array.
  15404. * No new underlying VertexBuffer object is created.
  15405. * 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.
  15406. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15407. *
  15408. * Possible `kind` values :
  15409. * - VertexBuffer.PositionKind
  15410. * - VertexBuffer.UVKind
  15411. * - VertexBuffer.UV2Kind
  15412. * - VertexBuffer.UV3Kind
  15413. * - VertexBuffer.UV4Kind
  15414. * - VertexBuffer.UV5Kind
  15415. * - VertexBuffer.UV6Kind
  15416. * - VertexBuffer.ColorKind
  15417. * - VertexBuffer.MatricesIndicesKind
  15418. * - VertexBuffer.MatricesIndicesExtraKind
  15419. * - VertexBuffer.MatricesWeightsKind
  15420. * - VertexBuffer.MatricesWeightsExtraKind
  15421. *
  15422. * Returns the Mesh.
  15423. */
  15424. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15425. /**
  15426. * Sets the mesh indices.
  15427. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15428. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15429. * This method creates a new index buffer each call.
  15430. * Returns the Mesh.
  15431. */
  15432. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15433. /**
  15434. * Boolean : True if the mesh owns the requested kind of data.
  15435. */
  15436. isVerticesDataPresent(kind: string): boolean;
  15437. /**
  15438. * Returns an array of indices (IndicesArray).
  15439. */
  15440. getIndices(): Nullable<IndicesArray>;
  15441. get _positions(): Nullable<Vector3[]>;
  15442. /**
  15443. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15444. * This means the mesh underlying bounding box and sphere are recomputed.
  15445. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15446. * @returns the current mesh
  15447. */
  15448. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15449. /** @hidden */
  15450. _preActivate(): InstancedMesh;
  15451. /** @hidden */
  15452. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15453. /** @hidden */
  15454. _postActivate(): void;
  15455. getWorldMatrix(): Matrix;
  15456. get isAnInstance(): boolean;
  15457. /**
  15458. * Returns the current associated LOD AbstractMesh.
  15459. */
  15460. getLOD(camera: Camera): AbstractMesh;
  15461. /** @hidden */
  15462. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15463. /** @hidden */
  15464. _syncSubMeshes(): InstancedMesh;
  15465. /** @hidden */
  15466. _generatePointsArray(): boolean;
  15467. /**
  15468. * Creates a new InstancedMesh from the current mesh.
  15469. * - name (string) : the cloned mesh name
  15470. * - newParent (optional Node) : the optional Node to parent the clone to.
  15471. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15472. *
  15473. * Returns the clone.
  15474. */
  15475. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15476. /**
  15477. * Disposes the InstancedMesh.
  15478. * Returns nothing.
  15479. */
  15480. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15481. }
  15482. interface Mesh {
  15483. /**
  15484. * Register a custom buffer that will be instanced
  15485. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15486. * @param kind defines the buffer kind
  15487. * @param stride defines the stride in floats
  15488. */
  15489. registerInstancedBuffer(kind: string, stride: number): void;
  15490. /** @hidden */
  15491. _userInstancedBuffersStorage: {
  15492. data: {
  15493. [key: string]: Float32Array;
  15494. };
  15495. sizes: {
  15496. [key: string]: number;
  15497. };
  15498. vertexBuffers: {
  15499. [key: string]: Nullable<VertexBuffer>;
  15500. };
  15501. strides: {
  15502. [key: string]: number;
  15503. };
  15504. };
  15505. }
  15506. interface AbstractMesh {
  15507. /**
  15508. * Object used to store instanced buffers defined by user
  15509. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15510. */
  15511. instancedBuffers: {
  15512. [key: string]: any;
  15513. };
  15514. }
  15515. }
  15516. declare module BABYLON {
  15517. /**
  15518. * Defines the options associated with the creation of a shader material.
  15519. */
  15520. export interface IShaderMaterialOptions {
  15521. /**
  15522. * Does the material work in alpha blend mode
  15523. */
  15524. needAlphaBlending: boolean;
  15525. /**
  15526. * Does the material work in alpha test mode
  15527. */
  15528. needAlphaTesting: boolean;
  15529. /**
  15530. * The list of attribute names used in the shader
  15531. */
  15532. attributes: string[];
  15533. /**
  15534. * The list of unifrom names used in the shader
  15535. */
  15536. uniforms: string[];
  15537. /**
  15538. * The list of UBO names used in the shader
  15539. */
  15540. uniformBuffers: string[];
  15541. /**
  15542. * The list of sampler names used in the shader
  15543. */
  15544. samplers: string[];
  15545. /**
  15546. * The list of defines used in the shader
  15547. */
  15548. defines: string[];
  15549. }
  15550. /**
  15551. * 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.
  15552. *
  15553. * This returned material effects how the mesh will look based on the code in the shaders.
  15554. *
  15555. * @see http://doc.babylonjs.com/how_to/shader_material
  15556. */
  15557. export class ShaderMaterial extends Material {
  15558. private _shaderPath;
  15559. private _options;
  15560. private _textures;
  15561. private _textureArrays;
  15562. private _floats;
  15563. private _ints;
  15564. private _floatsArrays;
  15565. private _colors3;
  15566. private _colors3Arrays;
  15567. private _colors4;
  15568. private _colors4Arrays;
  15569. private _vectors2;
  15570. private _vectors3;
  15571. private _vectors4;
  15572. private _matrices;
  15573. private _matrixArrays;
  15574. private _matrices3x3;
  15575. private _matrices2x2;
  15576. private _vectors2Arrays;
  15577. private _vectors3Arrays;
  15578. private _vectors4Arrays;
  15579. private _cachedWorldViewMatrix;
  15580. private _cachedWorldViewProjectionMatrix;
  15581. private _renderId;
  15582. private _multiview;
  15583. private _cachedDefines;
  15584. /**
  15585. * Instantiate a new shader material.
  15586. * 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.
  15587. * This returned material effects how the mesh will look based on the code in the shaders.
  15588. * @see http://doc.babylonjs.com/how_to/shader_material
  15589. * @param name Define the name of the material in the scene
  15590. * @param scene Define the scene the material belongs to
  15591. * @param shaderPath Defines the route to the shader code in one of three ways:
  15592. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15593. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15594. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15595. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15596. * @param options Define the options used to create the shader
  15597. */
  15598. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15599. /**
  15600. * Gets the shader path used to define the shader code
  15601. * It can be modified to trigger a new compilation
  15602. */
  15603. get shaderPath(): any;
  15604. /**
  15605. * Sets the shader path used to define the shader code
  15606. * It can be modified to trigger a new compilation
  15607. */
  15608. set shaderPath(shaderPath: any);
  15609. /**
  15610. * Gets the options used to compile the shader.
  15611. * They can be modified to trigger a new compilation
  15612. */
  15613. get options(): IShaderMaterialOptions;
  15614. /**
  15615. * Gets the current class name of the material e.g. "ShaderMaterial"
  15616. * Mainly use in serialization.
  15617. * @returns the class name
  15618. */
  15619. getClassName(): string;
  15620. /**
  15621. * Specifies if the material will require alpha blending
  15622. * @returns a boolean specifying if alpha blending is needed
  15623. */
  15624. needAlphaBlending(): boolean;
  15625. /**
  15626. * Specifies if this material should be rendered in alpha test mode
  15627. * @returns a boolean specifying if an alpha test is needed.
  15628. */
  15629. needAlphaTesting(): boolean;
  15630. private _checkUniform;
  15631. /**
  15632. * Set a texture in the shader.
  15633. * @param name Define the name of the uniform samplers as defined in the shader
  15634. * @param texture Define the texture to bind to this sampler
  15635. * @return the material itself allowing "fluent" like uniform updates
  15636. */
  15637. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15638. /**
  15639. * Set a texture array in the shader.
  15640. * @param name Define the name of the uniform sampler array as defined in the shader
  15641. * @param textures Define the list of textures to bind to this sampler
  15642. * @return the material itself allowing "fluent" like uniform updates
  15643. */
  15644. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15645. /**
  15646. * Set a float in the shader.
  15647. * @param name Define the name of the uniform as defined in the shader
  15648. * @param value Define the value to give to the uniform
  15649. * @return the material itself allowing "fluent" like uniform updates
  15650. */
  15651. setFloat(name: string, value: number): ShaderMaterial;
  15652. /**
  15653. * Set a int in the shader.
  15654. * @param name Define the name of the uniform as defined in the shader
  15655. * @param value Define the value to give to the uniform
  15656. * @return the material itself allowing "fluent" like uniform updates
  15657. */
  15658. setInt(name: string, value: number): ShaderMaterial;
  15659. /**
  15660. * Set an array of floats in the shader.
  15661. * @param name Define the name of the uniform as defined in the shader
  15662. * @param value Define the value to give to the uniform
  15663. * @return the material itself allowing "fluent" like uniform updates
  15664. */
  15665. setFloats(name: string, value: number[]): ShaderMaterial;
  15666. /**
  15667. * Set a vec3 in the shader from a Color3.
  15668. * @param name Define the name of the uniform as defined in the shader
  15669. * @param value Define the value to give to the uniform
  15670. * @return the material itself allowing "fluent" like uniform updates
  15671. */
  15672. setColor3(name: string, value: Color3): ShaderMaterial;
  15673. /**
  15674. * Set a vec3 array in the shader from a Color3 array.
  15675. * @param name Define the name of the uniform as defined in the shader
  15676. * @param value Define the value to give to the uniform
  15677. * @return the material itself allowing "fluent" like uniform updates
  15678. */
  15679. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15680. /**
  15681. * Set a vec4 in the shader from a Color4.
  15682. * @param name Define the name of the uniform as defined in the shader
  15683. * @param value Define the value to give to the uniform
  15684. * @return the material itself allowing "fluent" like uniform updates
  15685. */
  15686. setColor4(name: string, value: Color4): ShaderMaterial;
  15687. /**
  15688. * Set a vec4 array in the shader from a Color4 array.
  15689. * @param name Define the name of the uniform as defined in the shader
  15690. * @param value Define the value to give to the uniform
  15691. * @return the material itself allowing "fluent" like uniform updates
  15692. */
  15693. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15694. /**
  15695. * Set a vec2 in the shader from a Vector2.
  15696. * @param name Define the name of the uniform as defined in the shader
  15697. * @param value Define the value to give to the uniform
  15698. * @return the material itself allowing "fluent" like uniform updates
  15699. */
  15700. setVector2(name: string, value: Vector2): ShaderMaterial;
  15701. /**
  15702. * Set a vec3 in the shader from a Vector3.
  15703. * @param name Define the name of the uniform as defined in the shader
  15704. * @param value Define the value to give to the uniform
  15705. * @return the material itself allowing "fluent" like uniform updates
  15706. */
  15707. setVector3(name: string, value: Vector3): ShaderMaterial;
  15708. /**
  15709. * Set a vec4 in the shader from a Vector4.
  15710. * @param name Define the name of the uniform as defined in the shader
  15711. * @param value Define the value to give to the uniform
  15712. * @return the material itself allowing "fluent" like uniform updates
  15713. */
  15714. setVector4(name: string, value: Vector4): ShaderMaterial;
  15715. /**
  15716. * Set a mat4 in the shader from a Matrix.
  15717. * @param name Define the name of the uniform as defined in the shader
  15718. * @param value Define the value to give to the uniform
  15719. * @return the material itself allowing "fluent" like uniform updates
  15720. */
  15721. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15722. /**
  15723. * Set a float32Array in the shader from a matrix array.
  15724. * @param name Define the name of the uniform as defined in the shader
  15725. * @param value Define the value to give to the uniform
  15726. * @return the material itself allowing "fluent" like uniform updates
  15727. */
  15728. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15729. /**
  15730. * Set a mat3 in the shader from a Float32Array.
  15731. * @param name Define the name of the uniform as defined in the shader
  15732. * @param value Define the value to give to the uniform
  15733. * @return the material itself allowing "fluent" like uniform updates
  15734. */
  15735. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15736. /**
  15737. * Set a mat2 in the shader from a Float32Array.
  15738. * @param name Define the name of the uniform as defined in the shader
  15739. * @param value Define the value to give to the uniform
  15740. * @return the material itself allowing "fluent" like uniform updates
  15741. */
  15742. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15743. /**
  15744. * Set a vec2 array in the shader from a number array.
  15745. * @param name Define the name of the uniform as defined in the shader
  15746. * @param value Define the value to give to the uniform
  15747. * @return the material itself allowing "fluent" like uniform updates
  15748. */
  15749. setArray2(name: string, value: number[]): ShaderMaterial;
  15750. /**
  15751. * Set a vec3 array in the shader from a number array.
  15752. * @param name Define the name of the uniform as defined in the shader
  15753. * @param value Define the value to give to the uniform
  15754. * @return the material itself allowing "fluent" like uniform updates
  15755. */
  15756. setArray3(name: string, value: number[]): ShaderMaterial;
  15757. /**
  15758. * Set a vec4 array in the shader from a number array.
  15759. * @param name Define the name of the uniform as defined in the shader
  15760. * @param value Define the value to give to the uniform
  15761. * @return the material itself allowing "fluent" like uniform updates
  15762. */
  15763. setArray4(name: string, value: number[]): ShaderMaterial;
  15764. private _checkCache;
  15765. /**
  15766. * Specifies that the submesh is ready to be used
  15767. * @param mesh defines the mesh to check
  15768. * @param subMesh defines which submesh to check
  15769. * @param useInstances specifies that instances should be used
  15770. * @returns a boolean indicating that the submesh is ready or not
  15771. */
  15772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15773. /**
  15774. * Checks if the material is ready to render the requested mesh
  15775. * @param mesh Define the mesh to render
  15776. * @param useInstances Define whether or not the material is used with instances
  15777. * @returns true if ready, otherwise false
  15778. */
  15779. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15780. /**
  15781. * Binds the world matrix to the material
  15782. * @param world defines the world transformation matrix
  15783. * @param effectOverride - If provided, use this effect instead of internal effect
  15784. */
  15785. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  15786. /**
  15787. * Binds the submesh to this material by preparing the effect and shader to draw
  15788. * @param world defines the world transformation matrix
  15789. * @param mesh defines the mesh containing the submesh
  15790. * @param subMesh defines the submesh to bind the material to
  15791. */
  15792. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  15793. /**
  15794. * Binds the material to the mesh
  15795. * @param world defines the world transformation matrix
  15796. * @param mesh defines the mesh to bind the material to
  15797. * @param effectOverride - If provided, use this effect instead of internal effect
  15798. */
  15799. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  15800. protected _afterBind(mesh?: Mesh): void;
  15801. /**
  15802. * Gets the active textures from the material
  15803. * @returns an array of textures
  15804. */
  15805. getActiveTextures(): BaseTexture[];
  15806. /**
  15807. * Specifies if the material uses a texture
  15808. * @param texture defines the texture to check against the material
  15809. * @returns a boolean specifying if the material uses the texture
  15810. */
  15811. hasTexture(texture: BaseTexture): boolean;
  15812. /**
  15813. * Makes a duplicate of the material, and gives it a new name
  15814. * @param name defines the new name for the duplicated material
  15815. * @returns the cloned material
  15816. */
  15817. clone(name: string): ShaderMaterial;
  15818. /**
  15819. * Disposes the material
  15820. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15821. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15822. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15823. */
  15824. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15825. /**
  15826. * Serializes this material in a JSON representation
  15827. * @returns the serialized material object
  15828. */
  15829. serialize(): any;
  15830. /**
  15831. * Creates a shader material from parsed shader material data
  15832. * @param source defines the JSON represnetation of the material
  15833. * @param scene defines the hosting scene
  15834. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15835. * @returns a new material
  15836. */
  15837. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15838. }
  15839. }
  15840. declare module BABYLON {
  15841. /** @hidden */
  15842. export var colorPixelShader: {
  15843. name: string;
  15844. shader: string;
  15845. };
  15846. }
  15847. declare module BABYLON {
  15848. /** @hidden */
  15849. export var colorVertexShader: {
  15850. name: string;
  15851. shader: string;
  15852. };
  15853. }
  15854. declare module BABYLON {
  15855. /**
  15856. * Line mesh
  15857. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15858. */
  15859. export class LinesMesh extends Mesh {
  15860. /**
  15861. * If vertex color should be applied to the mesh
  15862. */
  15863. readonly useVertexColor?: boolean | undefined;
  15864. /**
  15865. * If vertex alpha should be applied to the mesh
  15866. */
  15867. readonly useVertexAlpha?: boolean | undefined;
  15868. /**
  15869. * Color of the line (Default: White)
  15870. */
  15871. color: Color3;
  15872. /**
  15873. * Alpha of the line (Default: 1)
  15874. */
  15875. alpha: number;
  15876. /**
  15877. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15878. * This margin is expressed in world space coordinates, so its value may vary.
  15879. * Default value is 0.1
  15880. */
  15881. intersectionThreshold: number;
  15882. private _colorShader;
  15883. private color4;
  15884. /**
  15885. * Creates a new LinesMesh
  15886. * @param name defines the name
  15887. * @param scene defines the hosting scene
  15888. * @param parent defines the parent mesh if any
  15889. * @param source defines the optional source LinesMesh used to clone data from
  15890. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15891. * When false, achieved by calling a clone(), also passing False.
  15892. * This will make creation of children, recursive.
  15893. * @param useVertexColor defines if this LinesMesh supports vertex color
  15894. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15895. */
  15896. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15897. /**
  15898. * If vertex color should be applied to the mesh
  15899. */
  15900. useVertexColor?: boolean | undefined,
  15901. /**
  15902. * If vertex alpha should be applied to the mesh
  15903. */
  15904. useVertexAlpha?: boolean | undefined);
  15905. private _addClipPlaneDefine;
  15906. private _removeClipPlaneDefine;
  15907. isReady(): boolean;
  15908. /**
  15909. * Returns the string "LineMesh"
  15910. */
  15911. getClassName(): string;
  15912. /**
  15913. * @hidden
  15914. */
  15915. get material(): Material;
  15916. /**
  15917. * @hidden
  15918. */
  15919. set material(value: Material);
  15920. /**
  15921. * @hidden
  15922. */
  15923. get checkCollisions(): boolean;
  15924. /** @hidden */
  15925. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15926. /** @hidden */
  15927. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15928. /**
  15929. * Disposes of the line mesh
  15930. * @param doNotRecurse If children should be disposed
  15931. */
  15932. dispose(doNotRecurse?: boolean): void;
  15933. /**
  15934. * Returns a new LineMesh object cloned from the current one.
  15935. */
  15936. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15937. /**
  15938. * Creates a new InstancedLinesMesh object from the mesh model.
  15939. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15940. * @param name defines the name of the new instance
  15941. * @returns a new InstancedLinesMesh
  15942. */
  15943. createInstance(name: string): InstancedLinesMesh;
  15944. }
  15945. /**
  15946. * Creates an instance based on a source LinesMesh
  15947. */
  15948. export class InstancedLinesMesh extends InstancedMesh {
  15949. /**
  15950. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15951. * This margin is expressed in world space coordinates, so its value may vary.
  15952. * Initilized with the intersectionThreshold value of the source LinesMesh
  15953. */
  15954. intersectionThreshold: number;
  15955. constructor(name: string, source: LinesMesh);
  15956. /**
  15957. * Returns the string "InstancedLinesMesh".
  15958. */
  15959. getClassName(): string;
  15960. }
  15961. }
  15962. declare module BABYLON {
  15963. /** @hidden */
  15964. export var linePixelShader: {
  15965. name: string;
  15966. shader: string;
  15967. };
  15968. }
  15969. declare module BABYLON {
  15970. /** @hidden */
  15971. export var lineVertexShader: {
  15972. name: string;
  15973. shader: string;
  15974. };
  15975. }
  15976. declare module BABYLON {
  15977. interface AbstractMesh {
  15978. /**
  15979. * Gets the edgesRenderer associated with the mesh
  15980. */
  15981. edgesRenderer: Nullable<EdgesRenderer>;
  15982. }
  15983. interface LinesMesh {
  15984. /**
  15985. * Enables the edge rendering mode on the mesh.
  15986. * This mode makes the mesh edges visible
  15987. * @param epsilon defines the maximal distance between two angles to detect a face
  15988. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15989. * @returns the currentAbstractMesh
  15990. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15991. */
  15992. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15993. }
  15994. interface InstancedLinesMesh {
  15995. /**
  15996. * Enables the edge rendering mode on the mesh.
  15997. * This mode makes the mesh edges visible
  15998. * @param epsilon defines the maximal distance between two angles to detect a face
  15999. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16000. * @returns the current InstancedLinesMesh
  16001. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16002. */
  16003. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16004. }
  16005. /**
  16006. * Defines the minimum contract an Edges renderer should follow.
  16007. */
  16008. export interface IEdgesRenderer extends IDisposable {
  16009. /**
  16010. * Gets or sets a boolean indicating if the edgesRenderer is active
  16011. */
  16012. isEnabled: boolean;
  16013. /**
  16014. * Renders the edges of the attached mesh,
  16015. */
  16016. render(): void;
  16017. /**
  16018. * Checks wether or not the edges renderer is ready to render.
  16019. * @return true if ready, otherwise false.
  16020. */
  16021. isReady(): boolean;
  16022. }
  16023. /**
  16024. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16025. */
  16026. export class EdgesRenderer implements IEdgesRenderer {
  16027. /**
  16028. * Define the size of the edges with an orthographic camera
  16029. */
  16030. edgesWidthScalerForOrthographic: number;
  16031. /**
  16032. * Define the size of the edges with a perspective camera
  16033. */
  16034. edgesWidthScalerForPerspective: number;
  16035. protected _source: AbstractMesh;
  16036. protected _linesPositions: number[];
  16037. protected _linesNormals: number[];
  16038. protected _linesIndices: number[];
  16039. protected _epsilon: number;
  16040. protected _indicesCount: number;
  16041. protected _lineShader: ShaderMaterial;
  16042. protected _ib: DataBuffer;
  16043. protected _buffers: {
  16044. [key: string]: Nullable<VertexBuffer>;
  16045. };
  16046. protected _checkVerticesInsteadOfIndices: boolean;
  16047. private _meshRebuildObserver;
  16048. private _meshDisposeObserver;
  16049. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16050. isEnabled: boolean;
  16051. /**
  16052. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16053. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16054. * @param source Mesh used to create edges
  16055. * @param epsilon sum of angles in adjacency to check for edge
  16056. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16057. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16058. */
  16059. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16060. protected _prepareRessources(): void;
  16061. /** @hidden */
  16062. _rebuild(): void;
  16063. /**
  16064. * Releases the required resources for the edges renderer
  16065. */
  16066. dispose(): void;
  16067. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16068. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16069. /**
  16070. * Checks if the pair of p0 and p1 is en edge
  16071. * @param faceIndex
  16072. * @param edge
  16073. * @param faceNormals
  16074. * @param p0
  16075. * @param p1
  16076. * @private
  16077. */
  16078. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16079. /**
  16080. * push line into the position, normal and index buffer
  16081. * @protected
  16082. */
  16083. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16084. /**
  16085. * Generates lines edges from adjacencjes
  16086. * @private
  16087. */
  16088. _generateEdgesLines(): void;
  16089. /**
  16090. * Checks wether or not the edges renderer is ready to render.
  16091. * @return true if ready, otherwise false.
  16092. */
  16093. isReady(): boolean;
  16094. /**
  16095. * Renders the edges of the attached mesh,
  16096. */
  16097. render(): void;
  16098. }
  16099. /**
  16100. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16101. */
  16102. export class LineEdgesRenderer extends EdgesRenderer {
  16103. /**
  16104. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16105. * @param source LineMesh used to generate edges
  16106. * @param epsilon not important (specified angle for edge detection)
  16107. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16108. */
  16109. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16110. /**
  16111. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16112. */
  16113. _generateEdgesLines(): void;
  16114. }
  16115. }
  16116. declare module BABYLON {
  16117. /**
  16118. * This represents the object necessary to create a rendering group.
  16119. * This is exclusively used and created by the rendering manager.
  16120. * To modify the behavior, you use the available helpers in your scene or meshes.
  16121. * @hidden
  16122. */
  16123. export class RenderingGroup {
  16124. index: number;
  16125. private static _zeroVector;
  16126. private _scene;
  16127. private _opaqueSubMeshes;
  16128. private _transparentSubMeshes;
  16129. private _alphaTestSubMeshes;
  16130. private _depthOnlySubMeshes;
  16131. private _particleSystems;
  16132. private _spriteManagers;
  16133. private _opaqueSortCompareFn;
  16134. private _alphaTestSortCompareFn;
  16135. private _transparentSortCompareFn;
  16136. private _renderOpaque;
  16137. private _renderAlphaTest;
  16138. private _renderTransparent;
  16139. /** @hidden */
  16140. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16141. onBeforeTransparentRendering: () => void;
  16142. /**
  16143. * Set the opaque sort comparison function.
  16144. * If null the sub meshes will be render in the order they were created
  16145. */
  16146. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16147. /**
  16148. * Set the alpha test sort comparison function.
  16149. * If null the sub meshes will be render in the order they were created
  16150. */
  16151. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16152. /**
  16153. * Set the transparent sort comparison function.
  16154. * If null the sub meshes will be render in the order they were created
  16155. */
  16156. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16157. /**
  16158. * Creates a new rendering group.
  16159. * @param index The rendering group index
  16160. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16161. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16162. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16163. */
  16164. 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>);
  16165. /**
  16166. * Render all the sub meshes contained in the group.
  16167. * @param customRenderFunction Used to override the default render behaviour of the group.
  16168. * @returns true if rendered some submeshes.
  16169. */
  16170. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16171. /**
  16172. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16173. * @param subMeshes The submeshes to render
  16174. */
  16175. private renderOpaqueSorted;
  16176. /**
  16177. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16178. * @param subMeshes The submeshes to render
  16179. */
  16180. private renderAlphaTestSorted;
  16181. /**
  16182. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16183. * @param subMeshes The submeshes to render
  16184. */
  16185. private renderTransparentSorted;
  16186. /**
  16187. * Renders the submeshes in a specified order.
  16188. * @param subMeshes The submeshes to sort before render
  16189. * @param sortCompareFn The comparison function use to sort
  16190. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16191. * @param transparent Specifies to activate blending if true
  16192. */
  16193. private static renderSorted;
  16194. /**
  16195. * Renders the submeshes in the order they were dispatched (no sort applied).
  16196. * @param subMeshes The submeshes to render
  16197. */
  16198. private static renderUnsorted;
  16199. /**
  16200. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16201. * are rendered back to front if in the same alpha index.
  16202. *
  16203. * @param a The first submesh
  16204. * @param b The second submesh
  16205. * @returns The result of the comparison
  16206. */
  16207. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16208. /**
  16209. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16210. * are rendered back to front.
  16211. *
  16212. * @param a The first submesh
  16213. * @param b The second submesh
  16214. * @returns The result of the comparison
  16215. */
  16216. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16217. /**
  16218. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16219. * are rendered front to back (prevent overdraw).
  16220. *
  16221. * @param a The first submesh
  16222. * @param b The second submesh
  16223. * @returns The result of the comparison
  16224. */
  16225. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16226. /**
  16227. * Resets the different lists of submeshes to prepare a new frame.
  16228. */
  16229. prepare(): void;
  16230. dispose(): void;
  16231. /**
  16232. * Inserts the submesh in its correct queue depending on its material.
  16233. * @param subMesh The submesh to dispatch
  16234. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16235. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16236. */
  16237. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16238. dispatchSprites(spriteManager: ISpriteManager): void;
  16239. dispatchParticles(particleSystem: IParticleSystem): void;
  16240. private _renderParticles;
  16241. private _renderSprites;
  16242. }
  16243. }
  16244. declare module BABYLON {
  16245. /**
  16246. * Interface describing the different options available in the rendering manager
  16247. * regarding Auto Clear between groups.
  16248. */
  16249. export interface IRenderingManagerAutoClearSetup {
  16250. /**
  16251. * Defines whether or not autoclear is enable.
  16252. */
  16253. autoClear: boolean;
  16254. /**
  16255. * Defines whether or not to autoclear the depth buffer.
  16256. */
  16257. depth: boolean;
  16258. /**
  16259. * Defines whether or not to autoclear the stencil buffer.
  16260. */
  16261. stencil: boolean;
  16262. }
  16263. /**
  16264. * This class is used by the onRenderingGroupObservable
  16265. */
  16266. export class RenderingGroupInfo {
  16267. /**
  16268. * The Scene that being rendered
  16269. */
  16270. scene: Scene;
  16271. /**
  16272. * The camera currently used for the rendering pass
  16273. */
  16274. camera: Nullable<Camera>;
  16275. /**
  16276. * The ID of the renderingGroup being processed
  16277. */
  16278. renderingGroupId: number;
  16279. }
  16280. /**
  16281. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16282. * It is enable to manage the different groups as well as the different necessary sort functions.
  16283. * This should not be used directly aside of the few static configurations
  16284. */
  16285. export class RenderingManager {
  16286. /**
  16287. * The max id used for rendering groups (not included)
  16288. */
  16289. static MAX_RENDERINGGROUPS: number;
  16290. /**
  16291. * The min id used for rendering groups (included)
  16292. */
  16293. static MIN_RENDERINGGROUPS: number;
  16294. /**
  16295. * Used to globally prevent autoclearing scenes.
  16296. */
  16297. static AUTOCLEAR: boolean;
  16298. /**
  16299. * @hidden
  16300. */
  16301. _useSceneAutoClearSetup: boolean;
  16302. private _scene;
  16303. private _renderingGroups;
  16304. private _depthStencilBufferAlreadyCleaned;
  16305. private _autoClearDepthStencil;
  16306. private _customOpaqueSortCompareFn;
  16307. private _customAlphaTestSortCompareFn;
  16308. private _customTransparentSortCompareFn;
  16309. private _renderingGroupInfo;
  16310. /**
  16311. * Instantiates a new rendering group for a particular scene
  16312. * @param scene Defines the scene the groups belongs to
  16313. */
  16314. constructor(scene: Scene);
  16315. private _clearDepthStencilBuffer;
  16316. /**
  16317. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16318. * @hidden
  16319. */
  16320. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16321. /**
  16322. * Resets the different information of the group to prepare a new frame
  16323. * @hidden
  16324. */
  16325. reset(): void;
  16326. /**
  16327. * Dispose and release the group and its associated resources.
  16328. * @hidden
  16329. */
  16330. dispose(): void;
  16331. /**
  16332. * Clear the info related to rendering groups preventing retention points during dispose.
  16333. */
  16334. freeRenderingGroups(): void;
  16335. private _prepareRenderingGroup;
  16336. /**
  16337. * Add a sprite manager to the rendering manager in order to render it this frame.
  16338. * @param spriteManager Define the sprite manager to render
  16339. */
  16340. dispatchSprites(spriteManager: ISpriteManager): void;
  16341. /**
  16342. * Add a particle system to the rendering manager in order to render it this frame.
  16343. * @param particleSystem Define the particle system to render
  16344. */
  16345. dispatchParticles(particleSystem: IParticleSystem): void;
  16346. /**
  16347. * Add a submesh to the manager in order to render it this frame
  16348. * @param subMesh The submesh to dispatch
  16349. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16350. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16351. */
  16352. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16353. /**
  16354. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16355. * This allowed control for front to back rendering or reversly depending of the special needs.
  16356. *
  16357. * @param renderingGroupId The rendering group id corresponding to its index
  16358. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16359. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16360. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16361. */
  16362. 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;
  16363. /**
  16364. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16365. *
  16366. * @param renderingGroupId The rendering group id corresponding to its index
  16367. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16368. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16369. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16370. */
  16371. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16372. /**
  16373. * Gets the current auto clear configuration for one rendering group of the rendering
  16374. * manager.
  16375. * @param index the rendering group index to get the information for
  16376. * @returns The auto clear setup for the requested rendering group
  16377. */
  16378. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16379. }
  16380. }
  16381. declare module BABYLON {
  16382. /**
  16383. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16384. */
  16385. export interface ICustomShaderOptions {
  16386. /**
  16387. * Gets or sets the custom shader name to use
  16388. */
  16389. shaderName: string;
  16390. /**
  16391. * The list of attribute names used in the shader
  16392. */
  16393. attributes?: string[];
  16394. /**
  16395. * The list of unifrom names used in the shader
  16396. */
  16397. uniforms?: string[];
  16398. /**
  16399. * The list of sampler names used in the shader
  16400. */
  16401. samplers?: string[];
  16402. /**
  16403. * The list of defines used in the shader
  16404. */
  16405. defines?: string[];
  16406. }
  16407. /**
  16408. * Interface to implement to create a shadow generator compatible with BJS.
  16409. */
  16410. export interface IShadowGenerator {
  16411. /**
  16412. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16413. * @returns The render target texture if present otherwise, null
  16414. */
  16415. getShadowMap(): Nullable<RenderTargetTexture>;
  16416. /**
  16417. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16418. * @param subMesh The submesh we want to render in the shadow map
  16419. * @param useInstances Defines wether will draw in the map using instances
  16420. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16421. * @returns true if ready otherwise, false
  16422. */
  16423. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16424. /**
  16425. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16426. * @param defines Defines of the material we want to update
  16427. * @param lightIndex Index of the light in the enabled light list of the material
  16428. */
  16429. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16430. /**
  16431. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16432. * defined in the generator but impacting the effect).
  16433. * It implies the unifroms available on the materials are the standard BJS ones.
  16434. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16435. * @param effect The effect we are binfing the information for
  16436. */
  16437. bindShadowLight(lightIndex: string, effect: Effect): void;
  16438. /**
  16439. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16440. * (eq to shadow prjection matrix * light transform matrix)
  16441. * @returns The transform matrix used to create the shadow map
  16442. */
  16443. getTransformMatrix(): Matrix;
  16444. /**
  16445. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16446. * Cube and 2D textures for instance.
  16447. */
  16448. recreateShadowMap(): void;
  16449. /**
  16450. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16451. * @param onCompiled Callback triggered at the and of the effects compilation
  16452. * @param options Sets of optional options forcing the compilation with different modes
  16453. */
  16454. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16455. useInstances: boolean;
  16456. }>): void;
  16457. /**
  16458. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16459. * @param options Sets of optional options forcing the compilation with different modes
  16460. * @returns A promise that resolves when the compilation completes
  16461. */
  16462. forceCompilationAsync(options?: Partial<{
  16463. useInstances: boolean;
  16464. }>): Promise<void>;
  16465. /**
  16466. * Serializes the shadow generator setup to a json object.
  16467. * @returns The serialized JSON object
  16468. */
  16469. serialize(): any;
  16470. /**
  16471. * Disposes the Shadow map and related Textures and effects.
  16472. */
  16473. dispose(): void;
  16474. }
  16475. /**
  16476. * Default implementation IShadowGenerator.
  16477. * This is the main object responsible of generating shadows in the framework.
  16478. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16479. */
  16480. export class ShadowGenerator implements IShadowGenerator {
  16481. /**
  16482. * Name of the shadow generator class
  16483. */
  16484. static CLASSNAME: string;
  16485. /**
  16486. * Shadow generator mode None: no filtering applied.
  16487. */
  16488. static readonly FILTER_NONE: number;
  16489. /**
  16490. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16491. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16492. */
  16493. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16494. /**
  16495. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16496. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16497. */
  16498. static readonly FILTER_POISSONSAMPLING: number;
  16499. /**
  16500. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16501. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16502. */
  16503. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16504. /**
  16505. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16506. * edge artifacts on steep falloff.
  16507. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16508. */
  16509. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16510. /**
  16511. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16512. * edge artifacts on steep falloff.
  16513. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16514. */
  16515. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16516. /**
  16517. * Shadow generator mode PCF: Percentage Closer Filtering
  16518. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16519. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16520. */
  16521. static readonly FILTER_PCF: number;
  16522. /**
  16523. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16524. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16525. * Contact Hardening
  16526. */
  16527. static readonly FILTER_PCSS: number;
  16528. /**
  16529. * Reserved for PCF and PCSS
  16530. * Highest Quality.
  16531. *
  16532. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16533. *
  16534. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16535. */
  16536. static readonly QUALITY_HIGH: number;
  16537. /**
  16538. * Reserved for PCF and PCSS
  16539. * Good tradeoff for quality/perf cross devices
  16540. *
  16541. * Execute PCF on a 3*3 kernel.
  16542. *
  16543. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16544. */
  16545. static readonly QUALITY_MEDIUM: number;
  16546. /**
  16547. * Reserved for PCF and PCSS
  16548. * The lowest quality but the fastest.
  16549. *
  16550. * Execute PCF on a 1*1 kernel.
  16551. *
  16552. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16553. */
  16554. static readonly QUALITY_LOW: number;
  16555. /** Gets or sets the custom shader name to use */
  16556. customShaderOptions: ICustomShaderOptions;
  16557. /**
  16558. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16559. */
  16560. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16561. /**
  16562. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16563. */
  16564. onAfterShadowMapRenderObservable: Observable<Effect>;
  16565. /**
  16566. * Observable triggered before a mesh is rendered in the shadow map.
  16567. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16568. */
  16569. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16570. /**
  16571. * Observable triggered after a mesh is rendered in the shadow map.
  16572. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16573. */
  16574. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16575. protected _bias: number;
  16576. /**
  16577. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16578. */
  16579. get bias(): number;
  16580. /**
  16581. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16582. */
  16583. set bias(bias: number);
  16584. protected _normalBias: number;
  16585. /**
  16586. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16587. */
  16588. get normalBias(): number;
  16589. /**
  16590. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16591. */
  16592. set normalBias(normalBias: number);
  16593. protected _blurBoxOffset: number;
  16594. /**
  16595. * Gets the blur box offset: offset applied during the blur pass.
  16596. * Only useful if useKernelBlur = false
  16597. */
  16598. get blurBoxOffset(): number;
  16599. /**
  16600. * Sets the blur box offset: offset applied during the blur pass.
  16601. * Only useful if useKernelBlur = false
  16602. */
  16603. set blurBoxOffset(value: number);
  16604. protected _blurScale: number;
  16605. /**
  16606. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16607. * 2 means half of the size.
  16608. */
  16609. get blurScale(): number;
  16610. /**
  16611. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16612. * 2 means half of the size.
  16613. */
  16614. set blurScale(value: number);
  16615. protected _blurKernel: number;
  16616. /**
  16617. * Gets the blur kernel: kernel size of the blur pass.
  16618. * Only useful if useKernelBlur = true
  16619. */
  16620. get blurKernel(): number;
  16621. /**
  16622. * Sets the blur kernel: kernel size of the blur pass.
  16623. * Only useful if useKernelBlur = true
  16624. */
  16625. set blurKernel(value: number);
  16626. protected _useKernelBlur: boolean;
  16627. /**
  16628. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16629. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16630. */
  16631. get useKernelBlur(): boolean;
  16632. /**
  16633. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16634. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16635. */
  16636. set useKernelBlur(value: boolean);
  16637. protected _depthScale: number;
  16638. /**
  16639. * Gets the depth scale used in ESM mode.
  16640. */
  16641. get depthScale(): number;
  16642. /**
  16643. * Sets the depth scale used in ESM mode.
  16644. * This can override the scale stored on the light.
  16645. */
  16646. set depthScale(value: number);
  16647. protected _validateFilter(filter: number): number;
  16648. protected _filter: number;
  16649. /**
  16650. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16651. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16652. */
  16653. get filter(): number;
  16654. /**
  16655. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16656. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16657. */
  16658. set filter(value: number);
  16659. /**
  16660. * Gets if the current filter is set to Poisson Sampling.
  16661. */
  16662. get usePoissonSampling(): boolean;
  16663. /**
  16664. * Sets the current filter to Poisson Sampling.
  16665. */
  16666. set usePoissonSampling(value: boolean);
  16667. /**
  16668. * Gets if the current filter is set to ESM.
  16669. */
  16670. get useExponentialShadowMap(): boolean;
  16671. /**
  16672. * Sets the current filter is to ESM.
  16673. */
  16674. set useExponentialShadowMap(value: boolean);
  16675. /**
  16676. * Gets if the current filter is set to filtered ESM.
  16677. */
  16678. get useBlurExponentialShadowMap(): boolean;
  16679. /**
  16680. * Gets if the current filter is set to filtered ESM.
  16681. */
  16682. set useBlurExponentialShadowMap(value: boolean);
  16683. /**
  16684. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16685. * exponential to prevent steep falloff artifacts).
  16686. */
  16687. get useCloseExponentialShadowMap(): boolean;
  16688. /**
  16689. * Sets the current filter to "close ESM" (using the inverse of the
  16690. * exponential to prevent steep falloff artifacts).
  16691. */
  16692. set useCloseExponentialShadowMap(value: boolean);
  16693. /**
  16694. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16695. * exponential to prevent steep falloff artifacts).
  16696. */
  16697. get useBlurCloseExponentialShadowMap(): boolean;
  16698. /**
  16699. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16700. * exponential to prevent steep falloff artifacts).
  16701. */
  16702. set useBlurCloseExponentialShadowMap(value: boolean);
  16703. /**
  16704. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16705. */
  16706. get usePercentageCloserFiltering(): boolean;
  16707. /**
  16708. * Sets the current filter to "PCF" (percentage closer filtering).
  16709. */
  16710. set usePercentageCloserFiltering(value: boolean);
  16711. protected _filteringQuality: number;
  16712. /**
  16713. * Gets the PCF or PCSS Quality.
  16714. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16715. */
  16716. get filteringQuality(): number;
  16717. /**
  16718. * Sets the PCF or PCSS Quality.
  16719. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16720. */
  16721. set filteringQuality(filteringQuality: number);
  16722. /**
  16723. * Gets if the current filter is set to "PCSS" (contact hardening).
  16724. */
  16725. get useContactHardeningShadow(): boolean;
  16726. /**
  16727. * Sets the current filter to "PCSS" (contact hardening).
  16728. */
  16729. set useContactHardeningShadow(value: boolean);
  16730. protected _contactHardeningLightSizeUVRatio: number;
  16731. /**
  16732. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16733. * Using a ratio helps keeping shape stability independently of the map size.
  16734. *
  16735. * It does not account for the light projection as it was having too much
  16736. * instability during the light setup or during light position changes.
  16737. *
  16738. * Only valid if useContactHardeningShadow is true.
  16739. */
  16740. get contactHardeningLightSizeUVRatio(): number;
  16741. /**
  16742. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16743. * Using a ratio helps keeping shape stability independently of the map size.
  16744. *
  16745. * It does not account for the light projection as it was having too much
  16746. * instability during the light setup or during light position changes.
  16747. *
  16748. * Only valid if useContactHardeningShadow is true.
  16749. */
  16750. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16751. protected _darkness: number;
  16752. /** Gets or sets the actual darkness of a shadow */
  16753. get darkness(): number;
  16754. set darkness(value: number);
  16755. /**
  16756. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16757. * 0 means strongest and 1 would means no shadow.
  16758. * @returns the darkness.
  16759. */
  16760. getDarkness(): number;
  16761. /**
  16762. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16763. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16764. * @returns the shadow generator allowing fluent coding.
  16765. */
  16766. setDarkness(darkness: number): ShadowGenerator;
  16767. protected _transparencyShadow: boolean;
  16768. /** Gets or sets the ability to have transparent shadow */
  16769. get transparencyShadow(): boolean;
  16770. set transparencyShadow(value: boolean);
  16771. /**
  16772. * Sets the ability to have transparent shadow (boolean).
  16773. * @param transparent True if transparent else False
  16774. * @returns the shadow generator allowing fluent coding
  16775. */
  16776. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16777. /**
  16778. * Enables or disables shadows with varying strength based on the transparency
  16779. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  16780. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  16781. * mesh.visibility * alphaTexture.a
  16782. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  16783. */
  16784. enableSoftTransparentShadow: boolean;
  16785. protected _shadowMap: Nullable<RenderTargetTexture>;
  16786. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16787. /**
  16788. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16789. * @returns The render target texture if present otherwise, null
  16790. */
  16791. getShadowMap(): Nullable<RenderTargetTexture>;
  16792. /**
  16793. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16794. * @returns The render target texture if the shadow map is present otherwise, null
  16795. */
  16796. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16797. /**
  16798. * Gets the class name of that object
  16799. * @returns "ShadowGenerator"
  16800. */
  16801. getClassName(): string;
  16802. /**
  16803. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16804. * @param mesh Mesh to add
  16805. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16806. * @returns the Shadow Generator itself
  16807. */
  16808. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16809. /**
  16810. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16811. * @param mesh Mesh to remove
  16812. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16813. * @returns the Shadow Generator itself
  16814. */
  16815. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16816. /**
  16817. * Controls the extent to which the shadows fade out at the edge of the frustum
  16818. */
  16819. frustumEdgeFalloff: number;
  16820. protected _light: IShadowLight;
  16821. /**
  16822. * Returns the associated light object.
  16823. * @returns the light generating the shadow
  16824. */
  16825. getLight(): IShadowLight;
  16826. /**
  16827. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16828. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16829. * It might on the other hand introduce peter panning.
  16830. */
  16831. forceBackFacesOnly: boolean;
  16832. protected _scene: Scene;
  16833. protected _lightDirection: Vector3;
  16834. protected _effect: Effect;
  16835. protected _viewMatrix: Matrix;
  16836. protected _projectionMatrix: Matrix;
  16837. protected _transformMatrix: Matrix;
  16838. protected _cachedPosition: Vector3;
  16839. protected _cachedDirection: Vector3;
  16840. protected _cachedDefines: string;
  16841. protected _currentRenderID: number;
  16842. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16843. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16844. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16845. protected _blurPostProcesses: PostProcess[];
  16846. protected _mapSize: number;
  16847. protected _currentFaceIndex: number;
  16848. protected _currentFaceIndexCache: number;
  16849. protected _textureType: number;
  16850. protected _defaultTextureMatrix: Matrix;
  16851. protected _storedUniqueId: Nullable<number>;
  16852. /** @hidden */
  16853. static _SceneComponentInitialization: (scene: Scene) => void;
  16854. /**
  16855. * Creates a ShadowGenerator object.
  16856. * A ShadowGenerator is the required tool to use the shadows.
  16857. * Each light casting shadows needs to use its own ShadowGenerator.
  16858. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16859. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16860. * @param light The light object generating the shadows.
  16861. * @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.
  16862. */
  16863. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16864. protected _initializeGenerator(): void;
  16865. protected _createTargetRenderTexture(): void;
  16866. protected _initializeShadowMap(): void;
  16867. protected _initializeBlurRTTAndPostProcesses(): void;
  16868. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16869. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  16870. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  16871. protected _applyFilterValues(): void;
  16872. /**
  16873. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16874. * @param onCompiled Callback triggered at the and of the effects compilation
  16875. * @param options Sets of optional options forcing the compilation with different modes
  16876. */
  16877. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16878. useInstances: boolean;
  16879. }>): void;
  16880. /**
  16881. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16882. * @param options Sets of optional options forcing the compilation with different modes
  16883. * @returns A promise that resolves when the compilation completes
  16884. */
  16885. forceCompilationAsync(options?: Partial<{
  16886. useInstances: boolean;
  16887. }>): Promise<void>;
  16888. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16889. private _prepareShadowDefines;
  16890. /**
  16891. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16892. * @param subMesh The submesh we want to render in the shadow map
  16893. * @param useInstances Defines wether will draw in the map using instances
  16894. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  16895. * @returns true if ready otherwise, false
  16896. */
  16897. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  16898. /**
  16899. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16900. * @param defines Defines of the material we want to update
  16901. * @param lightIndex Index of the light in the enabled light list of the material
  16902. */
  16903. prepareDefines(defines: any, lightIndex: number): void;
  16904. /**
  16905. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16906. * defined in the generator but impacting the effect).
  16907. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16908. * @param effect The effect we are binfing the information for
  16909. */
  16910. bindShadowLight(lightIndex: string, effect: Effect): void;
  16911. /**
  16912. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16913. * (eq to shadow prjection matrix * light transform matrix)
  16914. * @returns The transform matrix used to create the shadow map
  16915. */
  16916. getTransformMatrix(): Matrix;
  16917. /**
  16918. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16919. * Cube and 2D textures for instance.
  16920. */
  16921. recreateShadowMap(): void;
  16922. protected _disposeBlurPostProcesses(): void;
  16923. protected _disposeRTTandPostProcesses(): void;
  16924. /**
  16925. * Disposes the ShadowGenerator.
  16926. * Returns nothing.
  16927. */
  16928. dispose(): void;
  16929. /**
  16930. * Serializes the shadow generator setup to a json object.
  16931. * @returns The serialized JSON object
  16932. */
  16933. serialize(): any;
  16934. /**
  16935. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16936. * @param parsedShadowGenerator The JSON object to parse
  16937. * @param scene The scene to create the shadow map for
  16938. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16939. * @returns The parsed shadow generator
  16940. */
  16941. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16942. }
  16943. }
  16944. declare module BABYLON {
  16945. /**
  16946. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16947. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16948. * 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.
  16949. */
  16950. export abstract class Light extends Node {
  16951. /**
  16952. * Falloff Default: light is falling off following the material specification:
  16953. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16954. */
  16955. static readonly FALLOFF_DEFAULT: number;
  16956. /**
  16957. * Falloff Physical: light is falling off following the inverse squared distance law.
  16958. */
  16959. static readonly FALLOFF_PHYSICAL: number;
  16960. /**
  16961. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16962. * to enhance interoperability with other engines.
  16963. */
  16964. static readonly FALLOFF_GLTF: number;
  16965. /**
  16966. * Falloff Standard: light is falling off like in the standard material
  16967. * to enhance interoperability with other materials.
  16968. */
  16969. static readonly FALLOFF_STANDARD: number;
  16970. /**
  16971. * If every light affecting the material is in this lightmapMode,
  16972. * material.lightmapTexture adds or multiplies
  16973. * (depends on material.useLightmapAsShadowmap)
  16974. * after every other light calculations.
  16975. */
  16976. static readonly LIGHTMAP_DEFAULT: number;
  16977. /**
  16978. * material.lightmapTexture as only diffuse lighting from this light
  16979. * adds only specular lighting from this light
  16980. * adds dynamic shadows
  16981. */
  16982. static readonly LIGHTMAP_SPECULAR: number;
  16983. /**
  16984. * material.lightmapTexture as only lighting
  16985. * no light calculation from this light
  16986. * only adds dynamic shadows from this light
  16987. */
  16988. static readonly LIGHTMAP_SHADOWSONLY: number;
  16989. /**
  16990. * Each light type uses the default quantity according to its type:
  16991. * point/spot lights use luminous intensity
  16992. * directional lights use illuminance
  16993. */
  16994. static readonly INTENSITYMODE_AUTOMATIC: number;
  16995. /**
  16996. * lumen (lm)
  16997. */
  16998. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16999. /**
  17000. * candela (lm/sr)
  17001. */
  17002. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17003. /**
  17004. * lux (lm/m^2)
  17005. */
  17006. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17007. /**
  17008. * nit (cd/m^2)
  17009. */
  17010. static readonly INTENSITYMODE_LUMINANCE: number;
  17011. /**
  17012. * Light type const id of the point light.
  17013. */
  17014. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17015. /**
  17016. * Light type const id of the directional light.
  17017. */
  17018. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17019. /**
  17020. * Light type const id of the spot light.
  17021. */
  17022. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17023. /**
  17024. * Light type const id of the hemispheric light.
  17025. */
  17026. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17027. /**
  17028. * Diffuse gives the basic color to an object.
  17029. */
  17030. diffuse: Color3;
  17031. /**
  17032. * Specular produces a highlight color on an object.
  17033. * Note: This is note affecting PBR materials.
  17034. */
  17035. specular: Color3;
  17036. /**
  17037. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17038. * falling off base on range or angle.
  17039. * This can be set to any values in Light.FALLOFF_x.
  17040. *
  17041. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17042. * other types of materials.
  17043. */
  17044. falloffType: number;
  17045. /**
  17046. * Strength of the light.
  17047. * Note: By default it is define in the framework own unit.
  17048. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17049. */
  17050. intensity: number;
  17051. private _range;
  17052. protected _inverseSquaredRange: number;
  17053. /**
  17054. * Defines how far from the source the light is impacting in scene units.
  17055. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17056. */
  17057. get range(): number;
  17058. /**
  17059. * Defines how far from the source the light is impacting in scene units.
  17060. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17061. */
  17062. set range(value: number);
  17063. /**
  17064. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17065. * of light.
  17066. */
  17067. private _photometricScale;
  17068. private _intensityMode;
  17069. /**
  17070. * Gets the photometric scale used to interpret the intensity.
  17071. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17072. */
  17073. get intensityMode(): number;
  17074. /**
  17075. * Sets the photometric scale used to interpret the intensity.
  17076. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17077. */
  17078. set intensityMode(value: number);
  17079. private _radius;
  17080. /**
  17081. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17082. */
  17083. get radius(): number;
  17084. /**
  17085. * sets the light radius used by PBR Materials to simulate soft area lights.
  17086. */
  17087. set radius(value: number);
  17088. private _renderPriority;
  17089. /**
  17090. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17091. * exceeding the number allowed of the materials.
  17092. */
  17093. renderPriority: number;
  17094. private _shadowEnabled;
  17095. /**
  17096. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17097. * the current shadow generator.
  17098. */
  17099. get shadowEnabled(): boolean;
  17100. /**
  17101. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17102. * the current shadow generator.
  17103. */
  17104. set shadowEnabled(value: boolean);
  17105. private _includedOnlyMeshes;
  17106. /**
  17107. * Gets the only meshes impacted by this light.
  17108. */
  17109. get includedOnlyMeshes(): AbstractMesh[];
  17110. /**
  17111. * Sets the only meshes impacted by this light.
  17112. */
  17113. set includedOnlyMeshes(value: AbstractMesh[]);
  17114. private _excludedMeshes;
  17115. /**
  17116. * Gets the meshes not impacted by this light.
  17117. */
  17118. get excludedMeshes(): AbstractMesh[];
  17119. /**
  17120. * Sets the meshes not impacted by this light.
  17121. */
  17122. set excludedMeshes(value: AbstractMesh[]);
  17123. private _excludeWithLayerMask;
  17124. /**
  17125. * Gets the layer id use to find what meshes are not impacted by the light.
  17126. * Inactive if 0
  17127. */
  17128. get excludeWithLayerMask(): number;
  17129. /**
  17130. * Sets the layer id use to find what meshes are not impacted by the light.
  17131. * Inactive if 0
  17132. */
  17133. set excludeWithLayerMask(value: number);
  17134. private _includeOnlyWithLayerMask;
  17135. /**
  17136. * Gets the layer id use to find what meshes are impacted by the light.
  17137. * Inactive if 0
  17138. */
  17139. get includeOnlyWithLayerMask(): number;
  17140. /**
  17141. * Sets the layer id use to find what meshes are impacted by the light.
  17142. * Inactive if 0
  17143. */
  17144. set includeOnlyWithLayerMask(value: number);
  17145. private _lightmapMode;
  17146. /**
  17147. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17148. */
  17149. get lightmapMode(): number;
  17150. /**
  17151. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17152. */
  17153. set lightmapMode(value: number);
  17154. /**
  17155. * Shadow generator associted to the light.
  17156. * @hidden Internal use only.
  17157. */
  17158. _shadowGenerator: Nullable<IShadowGenerator>;
  17159. /**
  17160. * @hidden Internal use only.
  17161. */
  17162. _excludedMeshesIds: string[];
  17163. /**
  17164. * @hidden Internal use only.
  17165. */
  17166. _includedOnlyMeshesIds: string[];
  17167. /**
  17168. * The current light unifom buffer.
  17169. * @hidden Internal use only.
  17170. */
  17171. _uniformBuffer: UniformBuffer;
  17172. /** @hidden */
  17173. _renderId: number;
  17174. /**
  17175. * Creates a Light object in the scene.
  17176. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17177. * @param name The firendly name of the light
  17178. * @param scene The scene the light belongs too
  17179. */
  17180. constructor(name: string, scene: Scene);
  17181. protected abstract _buildUniformLayout(): void;
  17182. /**
  17183. * Sets the passed Effect "effect" with the Light information.
  17184. * @param effect The effect to update
  17185. * @param lightIndex The index of the light in the effect to update
  17186. * @returns The light
  17187. */
  17188. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17189. /**
  17190. * Sets the passed Effect "effect" with the Light textures.
  17191. * @param effect The effect to update
  17192. * @param lightIndex The index of the light in the effect to update
  17193. * @returns The light
  17194. */
  17195. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17196. /**
  17197. * Binds the lights information from the scene to the effect for the given mesh.
  17198. * @param lightIndex Light index
  17199. * @param scene The scene where the light belongs to
  17200. * @param effect The effect we are binding the data to
  17201. * @param useSpecular Defines if specular is supported
  17202. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17203. */
  17204. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17205. /**
  17206. * Sets the passed Effect "effect" with the Light information.
  17207. * @param effect The effect to update
  17208. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17209. * @returns The light
  17210. */
  17211. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17212. /**
  17213. * Returns the string "Light".
  17214. * @returns the class name
  17215. */
  17216. getClassName(): string;
  17217. /** @hidden */
  17218. readonly _isLight: boolean;
  17219. /**
  17220. * Converts the light information to a readable string for debug purpose.
  17221. * @param fullDetails Supports for multiple levels of logging within scene loading
  17222. * @returns the human readable light info
  17223. */
  17224. toString(fullDetails?: boolean): string;
  17225. /** @hidden */
  17226. protected _syncParentEnabledState(): void;
  17227. /**
  17228. * Set the enabled state of this node.
  17229. * @param value - the new enabled state
  17230. */
  17231. setEnabled(value: boolean): void;
  17232. /**
  17233. * Returns the Light associated shadow generator if any.
  17234. * @return the associated shadow generator.
  17235. */
  17236. getShadowGenerator(): Nullable<IShadowGenerator>;
  17237. /**
  17238. * Returns a Vector3, the absolute light position in the World.
  17239. * @returns the world space position of the light
  17240. */
  17241. getAbsolutePosition(): Vector3;
  17242. /**
  17243. * Specifies if the light will affect the passed mesh.
  17244. * @param mesh The mesh to test against the light
  17245. * @return true the mesh is affected otherwise, false.
  17246. */
  17247. canAffectMesh(mesh: AbstractMesh): boolean;
  17248. /**
  17249. * Sort function to order lights for rendering.
  17250. * @param a First Light object to compare to second.
  17251. * @param b Second Light object to compare first.
  17252. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17253. */
  17254. static CompareLightsPriority(a: Light, b: Light): number;
  17255. /**
  17256. * Releases resources associated with this node.
  17257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17259. */
  17260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17261. /**
  17262. * Returns the light type ID (integer).
  17263. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17264. */
  17265. getTypeID(): number;
  17266. /**
  17267. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17268. * @returns the scaled intensity in intensity mode unit
  17269. */
  17270. getScaledIntensity(): number;
  17271. /**
  17272. * Returns a new Light object, named "name", from the current one.
  17273. * @param name The name of the cloned light
  17274. * @param newParent The parent of this light, if it has one
  17275. * @returns the new created light
  17276. */
  17277. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  17278. /**
  17279. * Serializes the current light into a Serialization object.
  17280. * @returns the serialized object.
  17281. */
  17282. serialize(): any;
  17283. /**
  17284. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17285. * This new light is named "name" and added to the passed scene.
  17286. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17287. * @param name The friendly name of the light
  17288. * @param scene The scene the new light will belong to
  17289. * @returns the constructor function
  17290. */
  17291. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17292. /**
  17293. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17294. * @param parsedLight The JSON representation of the light
  17295. * @param scene The scene to create the parsed light in
  17296. * @returns the created light after parsing
  17297. */
  17298. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17299. private _hookArrayForExcluded;
  17300. private _hookArrayForIncludedOnly;
  17301. private _resyncMeshes;
  17302. /**
  17303. * Forces the meshes to update their light related information in their rendering used effects
  17304. * @hidden Internal Use Only
  17305. */
  17306. _markMeshesAsLightDirty(): void;
  17307. /**
  17308. * Recomputes the cached photometric scale if needed.
  17309. */
  17310. private _computePhotometricScale;
  17311. /**
  17312. * Returns the Photometric Scale according to the light type and intensity mode.
  17313. */
  17314. private _getPhotometricScale;
  17315. /**
  17316. * Reorder the light in the scene according to their defined priority.
  17317. * @hidden Internal Use Only
  17318. */
  17319. _reorderLightsInScene(): void;
  17320. /**
  17321. * Prepares the list of defines specific to the light type.
  17322. * @param defines the list of defines
  17323. * @param lightIndex defines the index of the light for the effect
  17324. */
  17325. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17326. }
  17327. }
  17328. declare module BABYLON {
  17329. /**
  17330. * Interface used to define Action
  17331. */
  17332. export interface IAction {
  17333. /**
  17334. * Trigger for the action
  17335. */
  17336. trigger: number;
  17337. /** Options of the trigger */
  17338. triggerOptions: any;
  17339. /**
  17340. * Gets the trigger parameters
  17341. * @returns the trigger parameters
  17342. */
  17343. getTriggerParameter(): any;
  17344. /**
  17345. * Internal only - executes current action event
  17346. * @hidden
  17347. */
  17348. _executeCurrent(evt?: ActionEvent): void;
  17349. /**
  17350. * Serialize placeholder for child classes
  17351. * @param parent of child
  17352. * @returns the serialized object
  17353. */
  17354. serialize(parent: any): any;
  17355. /**
  17356. * Internal only
  17357. * @hidden
  17358. */
  17359. _prepare(): void;
  17360. /**
  17361. * Internal only - manager for action
  17362. * @hidden
  17363. */
  17364. _actionManager: AbstractActionManager;
  17365. /**
  17366. * Adds action to chain of actions, may be a DoNothingAction
  17367. * @param action defines the next action to execute
  17368. * @returns The action passed in
  17369. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17370. */
  17371. then(action: IAction): IAction;
  17372. }
  17373. /**
  17374. * The action to be carried out following a trigger
  17375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17376. */
  17377. export class Action implements IAction {
  17378. /** the trigger, with or without parameters, for the action */
  17379. triggerOptions: any;
  17380. /**
  17381. * Trigger for the action
  17382. */
  17383. trigger: number;
  17384. /**
  17385. * Internal only - manager for action
  17386. * @hidden
  17387. */
  17388. _actionManager: ActionManager;
  17389. private _nextActiveAction;
  17390. private _child;
  17391. private _condition?;
  17392. private _triggerParameter;
  17393. /**
  17394. * An event triggered prior to action being executed.
  17395. */
  17396. onBeforeExecuteObservable: Observable<Action>;
  17397. /**
  17398. * Creates a new Action
  17399. * @param triggerOptions the trigger, with or without parameters, for the action
  17400. * @param condition an optional determinant of action
  17401. */
  17402. constructor(
  17403. /** the trigger, with or without parameters, for the action */
  17404. triggerOptions: any, condition?: Condition);
  17405. /**
  17406. * Internal only
  17407. * @hidden
  17408. */
  17409. _prepare(): void;
  17410. /**
  17411. * Gets the trigger parameters
  17412. * @returns the trigger parameters
  17413. */
  17414. getTriggerParameter(): any;
  17415. /**
  17416. * Internal only - executes current action event
  17417. * @hidden
  17418. */
  17419. _executeCurrent(evt?: ActionEvent): void;
  17420. /**
  17421. * Execute placeholder for child classes
  17422. * @param evt optional action event
  17423. */
  17424. execute(evt?: ActionEvent): void;
  17425. /**
  17426. * Skips to next active action
  17427. */
  17428. skipToNextActiveAction(): void;
  17429. /**
  17430. * Adds action to chain of actions, may be a DoNothingAction
  17431. * @param action defines the next action to execute
  17432. * @returns The action passed in
  17433. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17434. */
  17435. then(action: Action): Action;
  17436. /**
  17437. * Internal only
  17438. * @hidden
  17439. */
  17440. _getProperty(propertyPath: string): string;
  17441. /**
  17442. * Internal only
  17443. * @hidden
  17444. */
  17445. _getEffectiveTarget(target: any, propertyPath: string): any;
  17446. /**
  17447. * Serialize placeholder for child classes
  17448. * @param parent of child
  17449. * @returns the serialized object
  17450. */
  17451. serialize(parent: any): any;
  17452. /**
  17453. * Internal only called by serialize
  17454. * @hidden
  17455. */
  17456. protected _serialize(serializedAction: any, parent?: any): any;
  17457. /**
  17458. * Internal only
  17459. * @hidden
  17460. */
  17461. static _SerializeValueAsString: (value: any) => string;
  17462. /**
  17463. * Internal only
  17464. * @hidden
  17465. */
  17466. static _GetTargetProperty: (target: Node | Scene) => {
  17467. name: string;
  17468. targetType: string;
  17469. value: string;
  17470. };
  17471. }
  17472. }
  17473. declare module BABYLON {
  17474. /**
  17475. * A Condition applied to an Action
  17476. */
  17477. export class Condition {
  17478. /**
  17479. * Internal only - manager for action
  17480. * @hidden
  17481. */
  17482. _actionManager: ActionManager;
  17483. /**
  17484. * Internal only
  17485. * @hidden
  17486. */
  17487. _evaluationId: number;
  17488. /**
  17489. * Internal only
  17490. * @hidden
  17491. */
  17492. _currentResult: boolean;
  17493. /**
  17494. * Creates a new Condition
  17495. * @param actionManager the manager of the action the condition is applied to
  17496. */
  17497. constructor(actionManager: ActionManager);
  17498. /**
  17499. * Check if the current condition is valid
  17500. * @returns a boolean
  17501. */
  17502. isValid(): boolean;
  17503. /**
  17504. * Internal only
  17505. * @hidden
  17506. */
  17507. _getProperty(propertyPath: string): string;
  17508. /**
  17509. * Internal only
  17510. * @hidden
  17511. */
  17512. _getEffectiveTarget(target: any, propertyPath: string): any;
  17513. /**
  17514. * Serialize placeholder for child classes
  17515. * @returns the serialized object
  17516. */
  17517. serialize(): any;
  17518. /**
  17519. * Internal only
  17520. * @hidden
  17521. */
  17522. protected _serialize(serializedCondition: any): any;
  17523. }
  17524. /**
  17525. * Defines specific conditional operators as extensions of Condition
  17526. */
  17527. export class ValueCondition extends Condition {
  17528. /** path to specify the property of the target the conditional operator uses */
  17529. propertyPath: string;
  17530. /** the value compared by the conditional operator against the current value of the property */
  17531. value: any;
  17532. /** the conditional operator, default ValueCondition.IsEqual */
  17533. operator: number;
  17534. /**
  17535. * Internal only
  17536. * @hidden
  17537. */
  17538. private static _IsEqual;
  17539. /**
  17540. * Internal only
  17541. * @hidden
  17542. */
  17543. private static _IsDifferent;
  17544. /**
  17545. * Internal only
  17546. * @hidden
  17547. */
  17548. private static _IsGreater;
  17549. /**
  17550. * Internal only
  17551. * @hidden
  17552. */
  17553. private static _IsLesser;
  17554. /**
  17555. * returns the number for IsEqual
  17556. */
  17557. static get IsEqual(): number;
  17558. /**
  17559. * Returns the number for IsDifferent
  17560. */
  17561. static get IsDifferent(): number;
  17562. /**
  17563. * Returns the number for IsGreater
  17564. */
  17565. static get IsGreater(): number;
  17566. /**
  17567. * Returns the number for IsLesser
  17568. */
  17569. static get IsLesser(): number;
  17570. /**
  17571. * Internal only The action manager for the condition
  17572. * @hidden
  17573. */
  17574. _actionManager: ActionManager;
  17575. /**
  17576. * Internal only
  17577. * @hidden
  17578. */
  17579. private _target;
  17580. /**
  17581. * Internal only
  17582. * @hidden
  17583. */
  17584. private _effectiveTarget;
  17585. /**
  17586. * Internal only
  17587. * @hidden
  17588. */
  17589. private _property;
  17590. /**
  17591. * Creates a new ValueCondition
  17592. * @param actionManager manager for the action the condition applies to
  17593. * @param target for the action
  17594. * @param propertyPath path to specify the property of the target the conditional operator uses
  17595. * @param value the value compared by the conditional operator against the current value of the property
  17596. * @param operator the conditional operator, default ValueCondition.IsEqual
  17597. */
  17598. constructor(actionManager: ActionManager, target: any,
  17599. /** path to specify the property of the target the conditional operator uses */
  17600. propertyPath: string,
  17601. /** the value compared by the conditional operator against the current value of the property */
  17602. value: any,
  17603. /** the conditional operator, default ValueCondition.IsEqual */
  17604. operator?: number);
  17605. /**
  17606. * Compares the given value with the property value for the specified conditional operator
  17607. * @returns the result of the comparison
  17608. */
  17609. isValid(): boolean;
  17610. /**
  17611. * Serialize the ValueCondition into a JSON compatible object
  17612. * @returns serialization object
  17613. */
  17614. serialize(): any;
  17615. /**
  17616. * Gets the name of the conditional operator for the ValueCondition
  17617. * @param operator the conditional operator
  17618. * @returns the name
  17619. */
  17620. static GetOperatorName(operator: number): string;
  17621. }
  17622. /**
  17623. * Defines a predicate condition as an extension of Condition
  17624. */
  17625. export class PredicateCondition extends Condition {
  17626. /** defines the predicate function used to validate the condition */
  17627. predicate: () => boolean;
  17628. /**
  17629. * Internal only - manager for action
  17630. * @hidden
  17631. */
  17632. _actionManager: ActionManager;
  17633. /**
  17634. * Creates a new PredicateCondition
  17635. * @param actionManager manager for the action the condition applies to
  17636. * @param predicate defines the predicate function used to validate the condition
  17637. */
  17638. constructor(actionManager: ActionManager,
  17639. /** defines the predicate function used to validate the condition */
  17640. predicate: () => boolean);
  17641. /**
  17642. * @returns the validity of the predicate condition
  17643. */
  17644. isValid(): boolean;
  17645. }
  17646. /**
  17647. * Defines a state condition as an extension of Condition
  17648. */
  17649. export class StateCondition extends Condition {
  17650. /** Value to compare with target state */
  17651. value: string;
  17652. /**
  17653. * Internal only - manager for action
  17654. * @hidden
  17655. */
  17656. _actionManager: ActionManager;
  17657. /**
  17658. * Internal only
  17659. * @hidden
  17660. */
  17661. private _target;
  17662. /**
  17663. * Creates a new StateCondition
  17664. * @param actionManager manager for the action the condition applies to
  17665. * @param target of the condition
  17666. * @param value to compare with target state
  17667. */
  17668. constructor(actionManager: ActionManager, target: any,
  17669. /** Value to compare with target state */
  17670. value: string);
  17671. /**
  17672. * Gets a boolean indicating if the current condition is met
  17673. * @returns the validity of the state
  17674. */
  17675. isValid(): boolean;
  17676. /**
  17677. * Serialize the StateCondition into a JSON compatible object
  17678. * @returns serialization object
  17679. */
  17680. serialize(): any;
  17681. }
  17682. }
  17683. declare module BABYLON {
  17684. /**
  17685. * This defines an action responsible to toggle a boolean once triggered.
  17686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17687. */
  17688. export class SwitchBooleanAction extends Action {
  17689. /**
  17690. * The path to the boolean property in the target object
  17691. */
  17692. propertyPath: string;
  17693. private _target;
  17694. private _effectiveTarget;
  17695. private _property;
  17696. /**
  17697. * Instantiate the action
  17698. * @param triggerOptions defines the trigger options
  17699. * @param target defines the object containing the boolean
  17700. * @param propertyPath defines the path to the boolean property in the target object
  17701. * @param condition defines the trigger related conditions
  17702. */
  17703. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17704. /** @hidden */
  17705. _prepare(): void;
  17706. /**
  17707. * Execute the action toggle the boolean value.
  17708. */
  17709. execute(): void;
  17710. /**
  17711. * Serializes the actions and its related information.
  17712. * @param parent defines the object to serialize in
  17713. * @returns the serialized object
  17714. */
  17715. serialize(parent: any): any;
  17716. }
  17717. /**
  17718. * This defines an action responsible to set a the state field of the target
  17719. * to a desired value once triggered.
  17720. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17721. */
  17722. export class SetStateAction extends Action {
  17723. /**
  17724. * The value to store in the state field.
  17725. */
  17726. value: string;
  17727. private _target;
  17728. /**
  17729. * Instantiate the action
  17730. * @param triggerOptions defines the trigger options
  17731. * @param target defines the object containing the state property
  17732. * @param value defines the value to store in the state field
  17733. * @param condition defines the trigger related conditions
  17734. */
  17735. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17736. /**
  17737. * Execute the action and store the value on the target state property.
  17738. */
  17739. execute(): void;
  17740. /**
  17741. * Serializes the actions and its related information.
  17742. * @param parent defines the object to serialize in
  17743. * @returns the serialized object
  17744. */
  17745. serialize(parent: any): any;
  17746. }
  17747. /**
  17748. * This defines an action responsible to set a property of the target
  17749. * to a desired value once triggered.
  17750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17751. */
  17752. export class SetValueAction extends Action {
  17753. /**
  17754. * The path of the property to set in the target.
  17755. */
  17756. propertyPath: string;
  17757. /**
  17758. * The value to set in the property
  17759. */
  17760. value: any;
  17761. private _target;
  17762. private _effectiveTarget;
  17763. private _property;
  17764. /**
  17765. * Instantiate the action
  17766. * @param triggerOptions defines the trigger options
  17767. * @param target defines the object containing the property
  17768. * @param propertyPath defines the path of the property to set in the target
  17769. * @param value defines the value to set in the property
  17770. * @param condition defines the trigger related conditions
  17771. */
  17772. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17773. /** @hidden */
  17774. _prepare(): void;
  17775. /**
  17776. * Execute the action and set the targetted property to the desired value.
  17777. */
  17778. execute(): void;
  17779. /**
  17780. * Serializes the actions and its related information.
  17781. * @param parent defines the object to serialize in
  17782. * @returns the serialized object
  17783. */
  17784. serialize(parent: any): any;
  17785. }
  17786. /**
  17787. * This defines an action responsible to increment the target value
  17788. * to a desired value once triggered.
  17789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17790. */
  17791. export class IncrementValueAction extends Action {
  17792. /**
  17793. * The path of the property to increment in the target.
  17794. */
  17795. propertyPath: string;
  17796. /**
  17797. * The value we should increment the property by.
  17798. */
  17799. value: any;
  17800. private _target;
  17801. private _effectiveTarget;
  17802. private _property;
  17803. /**
  17804. * Instantiate the action
  17805. * @param triggerOptions defines the trigger options
  17806. * @param target defines the object containing the property
  17807. * @param propertyPath defines the path of the property to increment in the target
  17808. * @param value defines the value value we should increment the property by
  17809. * @param condition defines the trigger related conditions
  17810. */
  17811. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17812. /** @hidden */
  17813. _prepare(): void;
  17814. /**
  17815. * Execute the action and increment the target of the value amount.
  17816. */
  17817. execute(): void;
  17818. /**
  17819. * Serializes the actions and its related information.
  17820. * @param parent defines the object to serialize in
  17821. * @returns the serialized object
  17822. */
  17823. serialize(parent: any): any;
  17824. }
  17825. /**
  17826. * This defines an action responsible to start an animation once triggered.
  17827. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17828. */
  17829. export class PlayAnimationAction extends Action {
  17830. /**
  17831. * Where the animation should start (animation frame)
  17832. */
  17833. from: number;
  17834. /**
  17835. * Where the animation should stop (animation frame)
  17836. */
  17837. to: number;
  17838. /**
  17839. * Define if the animation should loop or stop after the first play.
  17840. */
  17841. loop?: boolean;
  17842. private _target;
  17843. /**
  17844. * Instantiate the action
  17845. * @param triggerOptions defines the trigger options
  17846. * @param target defines the target animation or animation name
  17847. * @param from defines from where the animation should start (animation frame)
  17848. * @param end defines where the animation should stop (animation frame)
  17849. * @param loop defines if the animation should loop or stop after the first play
  17850. * @param condition defines the trigger related conditions
  17851. */
  17852. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17853. /** @hidden */
  17854. _prepare(): void;
  17855. /**
  17856. * Execute the action and play the animation.
  17857. */
  17858. execute(): void;
  17859. /**
  17860. * Serializes the actions and its related information.
  17861. * @param parent defines the object to serialize in
  17862. * @returns the serialized object
  17863. */
  17864. serialize(parent: any): any;
  17865. }
  17866. /**
  17867. * This defines an action responsible to stop an animation once triggered.
  17868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17869. */
  17870. export class StopAnimationAction extends Action {
  17871. private _target;
  17872. /**
  17873. * Instantiate the action
  17874. * @param triggerOptions defines the trigger options
  17875. * @param target defines the target animation or animation name
  17876. * @param condition defines the trigger related conditions
  17877. */
  17878. constructor(triggerOptions: any, target: any, condition?: Condition);
  17879. /** @hidden */
  17880. _prepare(): void;
  17881. /**
  17882. * Execute the action and stop the animation.
  17883. */
  17884. execute(): void;
  17885. /**
  17886. * Serializes the actions and its related information.
  17887. * @param parent defines the object to serialize in
  17888. * @returns the serialized object
  17889. */
  17890. serialize(parent: any): any;
  17891. }
  17892. /**
  17893. * This defines an action responsible that does nothing once triggered.
  17894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17895. */
  17896. export class DoNothingAction extends Action {
  17897. /**
  17898. * Instantiate the action
  17899. * @param triggerOptions defines the trigger options
  17900. * @param condition defines the trigger related conditions
  17901. */
  17902. constructor(triggerOptions?: any, condition?: Condition);
  17903. /**
  17904. * Execute the action and do nothing.
  17905. */
  17906. execute(): void;
  17907. /**
  17908. * Serializes the actions and its related information.
  17909. * @param parent defines the object to serialize in
  17910. * @returns the serialized object
  17911. */
  17912. serialize(parent: any): any;
  17913. }
  17914. /**
  17915. * This defines an action responsible to trigger several actions once triggered.
  17916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17917. */
  17918. export class CombineAction extends Action {
  17919. /**
  17920. * The list of aggregated animations to run.
  17921. */
  17922. children: Action[];
  17923. /**
  17924. * Instantiate the action
  17925. * @param triggerOptions defines the trigger options
  17926. * @param children defines the list of aggregated animations to run
  17927. * @param condition defines the trigger related conditions
  17928. */
  17929. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17930. /** @hidden */
  17931. _prepare(): void;
  17932. /**
  17933. * Execute the action and executes all the aggregated actions.
  17934. */
  17935. execute(evt: ActionEvent): void;
  17936. /**
  17937. * Serializes the actions and its related information.
  17938. * @param parent defines the object to serialize in
  17939. * @returns the serialized object
  17940. */
  17941. serialize(parent: any): any;
  17942. }
  17943. /**
  17944. * This defines an action responsible to run code (external event) once triggered.
  17945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17946. */
  17947. export class ExecuteCodeAction extends Action {
  17948. /**
  17949. * The callback function to run.
  17950. */
  17951. func: (evt: ActionEvent) => void;
  17952. /**
  17953. * Instantiate the action
  17954. * @param triggerOptions defines the trigger options
  17955. * @param func defines the callback function to run
  17956. * @param condition defines the trigger related conditions
  17957. */
  17958. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17959. /**
  17960. * Execute the action and run the attached code.
  17961. */
  17962. execute(evt: ActionEvent): void;
  17963. }
  17964. /**
  17965. * This defines an action responsible to set the parent property of the target once triggered.
  17966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17967. */
  17968. export class SetParentAction extends Action {
  17969. private _parent;
  17970. private _target;
  17971. /**
  17972. * Instantiate the action
  17973. * @param triggerOptions defines the trigger options
  17974. * @param target defines the target containing the parent property
  17975. * @param parent defines from where the animation should start (animation frame)
  17976. * @param condition defines the trigger related conditions
  17977. */
  17978. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17979. /** @hidden */
  17980. _prepare(): void;
  17981. /**
  17982. * Execute the action and set the parent property.
  17983. */
  17984. execute(): void;
  17985. /**
  17986. * Serializes the actions and its related information.
  17987. * @param parent defines the object to serialize in
  17988. * @returns the serialized object
  17989. */
  17990. serialize(parent: any): any;
  17991. }
  17992. }
  17993. declare module BABYLON {
  17994. /**
  17995. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17996. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17998. */
  17999. export class ActionManager extends AbstractActionManager {
  18000. /**
  18001. * Nothing
  18002. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18003. */
  18004. static readonly NothingTrigger: number;
  18005. /**
  18006. * On pick
  18007. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18008. */
  18009. static readonly OnPickTrigger: number;
  18010. /**
  18011. * On left pick
  18012. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18013. */
  18014. static readonly OnLeftPickTrigger: number;
  18015. /**
  18016. * On right pick
  18017. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18018. */
  18019. static readonly OnRightPickTrigger: number;
  18020. /**
  18021. * On center pick
  18022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18023. */
  18024. static readonly OnCenterPickTrigger: number;
  18025. /**
  18026. * On pick down
  18027. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18028. */
  18029. static readonly OnPickDownTrigger: number;
  18030. /**
  18031. * On double pick
  18032. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18033. */
  18034. static readonly OnDoublePickTrigger: number;
  18035. /**
  18036. * On pick up
  18037. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18038. */
  18039. static readonly OnPickUpTrigger: number;
  18040. /**
  18041. * On pick out.
  18042. * This trigger will only be raised if you also declared a OnPickDown
  18043. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18044. */
  18045. static readonly OnPickOutTrigger: number;
  18046. /**
  18047. * On long press
  18048. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18049. */
  18050. static readonly OnLongPressTrigger: number;
  18051. /**
  18052. * On pointer over
  18053. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18054. */
  18055. static readonly OnPointerOverTrigger: number;
  18056. /**
  18057. * On pointer out
  18058. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18059. */
  18060. static readonly OnPointerOutTrigger: number;
  18061. /**
  18062. * On every frame
  18063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18064. */
  18065. static readonly OnEveryFrameTrigger: number;
  18066. /**
  18067. * On intersection enter
  18068. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18069. */
  18070. static readonly OnIntersectionEnterTrigger: number;
  18071. /**
  18072. * On intersection exit
  18073. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18074. */
  18075. static readonly OnIntersectionExitTrigger: number;
  18076. /**
  18077. * On key down
  18078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18079. */
  18080. static readonly OnKeyDownTrigger: number;
  18081. /**
  18082. * On key up
  18083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18084. */
  18085. static readonly OnKeyUpTrigger: number;
  18086. private _scene;
  18087. /**
  18088. * Creates a new action manager
  18089. * @param scene defines the hosting scene
  18090. */
  18091. constructor(scene: Scene);
  18092. /**
  18093. * Releases all associated resources
  18094. */
  18095. dispose(): void;
  18096. /**
  18097. * Gets hosting scene
  18098. * @returns the hosting scene
  18099. */
  18100. getScene(): Scene;
  18101. /**
  18102. * Does this action manager handles actions of any of the given triggers
  18103. * @param triggers defines the triggers to be tested
  18104. * @return a boolean indicating whether one (or more) of the triggers is handled
  18105. */
  18106. hasSpecificTriggers(triggers: number[]): boolean;
  18107. /**
  18108. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18109. * speed.
  18110. * @param triggerA defines the trigger to be tested
  18111. * @param triggerB defines the trigger to be tested
  18112. * @return a boolean indicating whether one (or more) of the triggers is handled
  18113. */
  18114. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18115. /**
  18116. * Does this action manager handles actions of a given trigger
  18117. * @param trigger defines the trigger to be tested
  18118. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18119. * @return whether the trigger is handled
  18120. */
  18121. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18122. /**
  18123. * Does this action manager has pointer triggers
  18124. */
  18125. get hasPointerTriggers(): boolean;
  18126. /**
  18127. * Does this action manager has pick triggers
  18128. */
  18129. get hasPickTriggers(): boolean;
  18130. /**
  18131. * Registers an action to this action manager
  18132. * @param action defines the action to be registered
  18133. * @return the action amended (prepared) after registration
  18134. */
  18135. registerAction(action: IAction): Nullable<IAction>;
  18136. /**
  18137. * Unregisters an action to this action manager
  18138. * @param action defines the action to be unregistered
  18139. * @return a boolean indicating whether the action has been unregistered
  18140. */
  18141. unregisterAction(action: IAction): Boolean;
  18142. /**
  18143. * Process a specific trigger
  18144. * @param trigger defines the trigger to process
  18145. * @param evt defines the event details to be processed
  18146. */
  18147. processTrigger(trigger: number, evt?: IActionEvent): void;
  18148. /** @hidden */
  18149. _getEffectiveTarget(target: any, propertyPath: string): any;
  18150. /** @hidden */
  18151. _getProperty(propertyPath: string): string;
  18152. /**
  18153. * Serialize this manager to a JSON object
  18154. * @param name defines the property name to store this manager
  18155. * @returns a JSON representation of this manager
  18156. */
  18157. serialize(name: string): any;
  18158. /**
  18159. * Creates a new ActionManager from a JSON data
  18160. * @param parsedActions defines the JSON data to read from
  18161. * @param object defines the hosting mesh
  18162. * @param scene defines the hosting scene
  18163. */
  18164. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18165. /**
  18166. * Get a trigger name by index
  18167. * @param trigger defines the trigger index
  18168. * @returns a trigger name
  18169. */
  18170. static GetTriggerName(trigger: number): string;
  18171. }
  18172. }
  18173. declare module BABYLON {
  18174. /**
  18175. * Class used to represent a sprite
  18176. * @see http://doc.babylonjs.com/babylon101/sprites
  18177. */
  18178. export class Sprite implements IAnimatable {
  18179. /** defines the name */
  18180. name: string;
  18181. /** Gets or sets the current world position */
  18182. position: Vector3;
  18183. /** Gets or sets the main color */
  18184. color: Color4;
  18185. /** Gets or sets the width */
  18186. width: number;
  18187. /** Gets or sets the height */
  18188. height: number;
  18189. /** Gets or sets rotation angle */
  18190. angle: number;
  18191. /** Gets or sets the cell index in the sprite sheet */
  18192. cellIndex: number;
  18193. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18194. cellRef: string;
  18195. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18196. invertU: boolean;
  18197. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18198. invertV: boolean;
  18199. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18200. disposeWhenFinishedAnimating: boolean;
  18201. /** Gets the list of attached animations */
  18202. animations: Nullable<Array<Animation>>;
  18203. /** Gets or sets a boolean indicating if the sprite can be picked */
  18204. isPickable: boolean;
  18205. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  18206. useAlphaForPicking: boolean;
  18207. /** @hidden */
  18208. _xOffset: number;
  18209. /** @hidden */
  18210. _yOffset: number;
  18211. /** @hidden */
  18212. _xSize: number;
  18213. /** @hidden */
  18214. _ySize: number;
  18215. /**
  18216. * Gets or sets the associated action manager
  18217. */
  18218. actionManager: Nullable<ActionManager>;
  18219. /**
  18220. * An event triggered when the control has been disposed
  18221. */
  18222. onDisposeObservable: Observable<Sprite>;
  18223. private _animationStarted;
  18224. private _loopAnimation;
  18225. private _fromIndex;
  18226. private _toIndex;
  18227. private _delay;
  18228. private _direction;
  18229. private _manager;
  18230. private _time;
  18231. private _onAnimationEnd;
  18232. /**
  18233. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18234. */
  18235. isVisible: boolean;
  18236. /**
  18237. * Gets or sets the sprite size
  18238. */
  18239. get size(): number;
  18240. set size(value: number);
  18241. /**
  18242. * Gets or sets the unique id of the sprite
  18243. */
  18244. uniqueId: number;
  18245. /**
  18246. * Gets the manager of this sprite
  18247. */
  18248. get manager(): ISpriteManager;
  18249. /**
  18250. * Creates a new Sprite
  18251. * @param name defines the name
  18252. * @param manager defines the manager
  18253. */
  18254. constructor(
  18255. /** defines the name */
  18256. name: string, manager: ISpriteManager);
  18257. /**
  18258. * Returns the string "Sprite"
  18259. * @returns "Sprite"
  18260. */
  18261. getClassName(): string;
  18262. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  18263. get fromIndex(): number;
  18264. set fromIndex(value: number);
  18265. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  18266. get toIndex(): number;
  18267. set toIndex(value: number);
  18268. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  18269. get loopAnimation(): boolean;
  18270. set loopAnimation(value: boolean);
  18271. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  18272. get delay(): number;
  18273. set delay(value: number);
  18274. /**
  18275. * Starts an animation
  18276. * @param from defines the initial key
  18277. * @param to defines the end key
  18278. * @param loop defines if the animation must loop
  18279. * @param delay defines the start delay (in ms)
  18280. * @param onAnimationEnd defines a callback to call when animation ends
  18281. */
  18282. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18283. /** Stops current animation (if any) */
  18284. stopAnimation(): void;
  18285. /** @hidden */
  18286. _animate(deltaTime: number): void;
  18287. /** Release associated resources */
  18288. dispose(): void;
  18289. }
  18290. }
  18291. declare module BABYLON {
  18292. /**
  18293. * Information about the result of picking within a scene
  18294. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18295. */
  18296. export class PickingInfo {
  18297. /** @hidden */
  18298. _pickingUnavailable: boolean;
  18299. /**
  18300. * If the pick collided with an object
  18301. */
  18302. hit: boolean;
  18303. /**
  18304. * Distance away where the pick collided
  18305. */
  18306. distance: number;
  18307. /**
  18308. * The location of pick collision
  18309. */
  18310. pickedPoint: Nullable<Vector3>;
  18311. /**
  18312. * The mesh corresponding the the pick collision
  18313. */
  18314. pickedMesh: Nullable<AbstractMesh>;
  18315. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18316. bu: number;
  18317. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18318. bv: number;
  18319. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18320. faceId: number;
  18321. /** Id of the the submesh that was picked */
  18322. subMeshId: number;
  18323. /** If a sprite was picked, this will be the sprite the pick collided with */
  18324. pickedSprite: Nullable<Sprite>;
  18325. /**
  18326. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18327. */
  18328. originMesh: Nullable<AbstractMesh>;
  18329. /**
  18330. * The ray that was used to perform the picking.
  18331. */
  18332. ray: Nullable<Ray>;
  18333. /**
  18334. * Gets the normal correspodning to the face the pick collided with
  18335. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18336. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18337. * @returns The normal correspodning to the face the pick collided with
  18338. */
  18339. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18340. /**
  18341. * Gets the texture coordinates of where the pick occured
  18342. * @returns the vector containing the coordnates of the texture
  18343. */
  18344. getTextureCoordinates(): Nullable<Vector2>;
  18345. }
  18346. }
  18347. declare module BABYLON {
  18348. /**
  18349. * Gather the list of pointer event types as constants.
  18350. */
  18351. export class PointerEventTypes {
  18352. /**
  18353. * 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.
  18354. */
  18355. static readonly POINTERDOWN: number;
  18356. /**
  18357. * The pointerup event is fired when a pointer is no longer active.
  18358. */
  18359. static readonly POINTERUP: number;
  18360. /**
  18361. * The pointermove event is fired when a pointer changes coordinates.
  18362. */
  18363. static readonly POINTERMOVE: number;
  18364. /**
  18365. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18366. */
  18367. static readonly POINTERWHEEL: number;
  18368. /**
  18369. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18370. */
  18371. static readonly POINTERPICK: number;
  18372. /**
  18373. * The pointertap event is fired when a the object has been touched and released without drag.
  18374. */
  18375. static readonly POINTERTAP: number;
  18376. /**
  18377. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18378. */
  18379. static readonly POINTERDOUBLETAP: number;
  18380. }
  18381. /**
  18382. * Base class of pointer info types.
  18383. */
  18384. export class PointerInfoBase {
  18385. /**
  18386. * Defines the type of event (PointerEventTypes)
  18387. */
  18388. type: number;
  18389. /**
  18390. * Defines the related dom event
  18391. */
  18392. event: PointerEvent | MouseWheelEvent;
  18393. /**
  18394. * Instantiates the base class of pointers info.
  18395. * @param type Defines the type of event (PointerEventTypes)
  18396. * @param event Defines the related dom event
  18397. */
  18398. constructor(
  18399. /**
  18400. * Defines the type of event (PointerEventTypes)
  18401. */
  18402. type: number,
  18403. /**
  18404. * Defines the related dom event
  18405. */
  18406. event: PointerEvent | MouseWheelEvent);
  18407. }
  18408. /**
  18409. * This class is used to store pointer related info for the onPrePointerObservable event.
  18410. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18411. */
  18412. export class PointerInfoPre extends PointerInfoBase {
  18413. /**
  18414. * Ray from a pointer if availible (eg. 6dof controller)
  18415. */
  18416. ray: Nullable<Ray>;
  18417. /**
  18418. * Defines the local position of the pointer on the canvas.
  18419. */
  18420. localPosition: Vector2;
  18421. /**
  18422. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18423. */
  18424. skipOnPointerObservable: boolean;
  18425. /**
  18426. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18427. * @param type Defines the type of event (PointerEventTypes)
  18428. * @param event Defines the related dom event
  18429. * @param localX Defines the local x coordinates of the pointer when the event occured
  18430. * @param localY Defines the local y coordinates of the pointer when the event occured
  18431. */
  18432. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18433. }
  18434. /**
  18435. * This type contains all the data related to a pointer event in Babylon.js.
  18436. * 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.
  18437. */
  18438. export class PointerInfo extends PointerInfoBase {
  18439. /**
  18440. * Defines the picking info associated to the info (if any)\
  18441. */
  18442. pickInfo: Nullable<PickingInfo>;
  18443. /**
  18444. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18445. * @param type Defines the type of event (PointerEventTypes)
  18446. * @param event Defines the related dom event
  18447. * @param pickInfo Defines the picking info associated to the info (if any)\
  18448. */
  18449. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18450. /**
  18451. * Defines the picking info associated to the info (if any)\
  18452. */
  18453. pickInfo: Nullable<PickingInfo>);
  18454. }
  18455. /**
  18456. * Data relating to a touch event on the screen.
  18457. */
  18458. export interface PointerTouch {
  18459. /**
  18460. * X coordinate of touch.
  18461. */
  18462. x: number;
  18463. /**
  18464. * Y coordinate of touch.
  18465. */
  18466. y: number;
  18467. /**
  18468. * Id of touch. Unique for each finger.
  18469. */
  18470. pointerId: number;
  18471. /**
  18472. * Event type passed from DOM.
  18473. */
  18474. type: any;
  18475. }
  18476. }
  18477. declare module BABYLON {
  18478. /**
  18479. * Manage the mouse inputs to control the movement of a free camera.
  18480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18481. */
  18482. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18483. /**
  18484. * Define if touch is enabled in the mouse input
  18485. */
  18486. touchEnabled: boolean;
  18487. /**
  18488. * Defines the camera the input is attached to.
  18489. */
  18490. camera: FreeCamera;
  18491. /**
  18492. * Defines the buttons associated with the input to handle camera move.
  18493. */
  18494. buttons: number[];
  18495. /**
  18496. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18497. */
  18498. angularSensibility: number;
  18499. private _pointerInput;
  18500. private _onMouseMove;
  18501. private _observer;
  18502. private previousPosition;
  18503. /**
  18504. * Observable for when a pointer move event occurs containing the move offset
  18505. */
  18506. onPointerMovedObservable: Observable<{
  18507. offsetX: number;
  18508. offsetY: number;
  18509. }>;
  18510. /**
  18511. * @hidden
  18512. * If the camera should be rotated automatically based on pointer movement
  18513. */
  18514. _allowCameraRotation: boolean;
  18515. /**
  18516. * Manage the mouse inputs to control the movement of a free camera.
  18517. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18518. * @param touchEnabled Defines if touch is enabled or not
  18519. */
  18520. constructor(
  18521. /**
  18522. * Define if touch is enabled in the mouse input
  18523. */
  18524. touchEnabled?: boolean);
  18525. /**
  18526. * Attach the input controls to a specific dom element to get the input from.
  18527. * @param element Defines the element the controls should be listened from
  18528. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18529. */
  18530. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18531. /**
  18532. * Called on JS contextmenu event.
  18533. * Override this method to provide functionality.
  18534. */
  18535. protected onContextMenu(evt: PointerEvent): void;
  18536. /**
  18537. * Detach the current controls from the specified dom element.
  18538. * @param element Defines the element to stop listening the inputs from
  18539. */
  18540. detachControl(element: Nullable<HTMLElement>): void;
  18541. /**
  18542. * Gets the class name of the current intput.
  18543. * @returns the class name
  18544. */
  18545. getClassName(): string;
  18546. /**
  18547. * Get the friendly name associated with the input class.
  18548. * @returns the input friendly name
  18549. */
  18550. getSimpleName(): string;
  18551. }
  18552. }
  18553. declare module BABYLON {
  18554. /**
  18555. * Manage the touch inputs to control the movement of a free camera.
  18556. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18557. */
  18558. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18559. /**
  18560. * Defines the camera the input is attached to.
  18561. */
  18562. camera: FreeCamera;
  18563. /**
  18564. * Defines the touch sensibility for rotation.
  18565. * The higher the faster.
  18566. */
  18567. touchAngularSensibility: number;
  18568. /**
  18569. * Defines the touch sensibility for move.
  18570. * The higher the faster.
  18571. */
  18572. touchMoveSensibility: number;
  18573. private _offsetX;
  18574. private _offsetY;
  18575. private _pointerPressed;
  18576. private _pointerInput;
  18577. private _observer;
  18578. private _onLostFocus;
  18579. /**
  18580. * Attach the input controls to a specific dom element to get the input from.
  18581. * @param element Defines the element the controls should be listened from
  18582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18583. */
  18584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18585. /**
  18586. * Detach the current controls from the specified dom element.
  18587. * @param element Defines the element to stop listening the inputs from
  18588. */
  18589. detachControl(element: Nullable<HTMLElement>): void;
  18590. /**
  18591. * Update the current camera state depending on the inputs that have been used this frame.
  18592. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18593. */
  18594. checkInputs(): void;
  18595. /**
  18596. * Gets the class name of the current intput.
  18597. * @returns the class name
  18598. */
  18599. getClassName(): string;
  18600. /**
  18601. * Get the friendly name associated with the input class.
  18602. * @returns the input friendly name
  18603. */
  18604. getSimpleName(): string;
  18605. }
  18606. }
  18607. declare module BABYLON {
  18608. /**
  18609. * Default Inputs manager for the FreeCamera.
  18610. * It groups all the default supported inputs for ease of use.
  18611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18612. */
  18613. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18614. /**
  18615. * @hidden
  18616. */
  18617. _mouseInput: Nullable<FreeCameraMouseInput>;
  18618. /**
  18619. * Instantiates a new FreeCameraInputsManager.
  18620. * @param camera Defines the camera the inputs belong to
  18621. */
  18622. constructor(camera: FreeCamera);
  18623. /**
  18624. * Add keyboard input support to the input manager.
  18625. * @returns the current input manager
  18626. */
  18627. addKeyboard(): FreeCameraInputsManager;
  18628. /**
  18629. * Add mouse input support to the input manager.
  18630. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18631. * @returns the current input manager
  18632. */
  18633. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18634. /**
  18635. * Removes the mouse input support from the manager
  18636. * @returns the current input manager
  18637. */
  18638. removeMouse(): FreeCameraInputsManager;
  18639. /**
  18640. * Add touch input support to the input manager.
  18641. * @returns the current input manager
  18642. */
  18643. addTouch(): FreeCameraInputsManager;
  18644. /**
  18645. * Remove all attached input methods from a camera
  18646. */
  18647. clear(): void;
  18648. }
  18649. }
  18650. declare module BABYLON {
  18651. /**
  18652. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18653. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18654. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18655. */
  18656. export class FreeCamera extends TargetCamera {
  18657. /**
  18658. * Define the collision ellipsoid of the camera.
  18659. * This is helpful to simulate a camera body like the player body around the camera
  18660. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18661. */
  18662. ellipsoid: Vector3;
  18663. /**
  18664. * Define an offset for the position of the ellipsoid around the camera.
  18665. * This can be helpful to determine the center of the body near the gravity center of the body
  18666. * instead of its head.
  18667. */
  18668. ellipsoidOffset: Vector3;
  18669. /**
  18670. * Enable or disable collisions of the camera with the rest of the scene objects.
  18671. */
  18672. checkCollisions: boolean;
  18673. /**
  18674. * Enable or disable gravity on the camera.
  18675. */
  18676. applyGravity: boolean;
  18677. /**
  18678. * Define the input manager associated to the camera.
  18679. */
  18680. inputs: FreeCameraInputsManager;
  18681. /**
  18682. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18683. * Higher values reduce sensitivity.
  18684. */
  18685. get angularSensibility(): number;
  18686. /**
  18687. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18688. * Higher values reduce sensitivity.
  18689. */
  18690. set angularSensibility(value: number);
  18691. /**
  18692. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18693. */
  18694. get keysUp(): number[];
  18695. set keysUp(value: number[]);
  18696. /**
  18697. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18698. */
  18699. get keysUpward(): number[];
  18700. set keysUpward(value: number[]);
  18701. /**
  18702. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18703. */
  18704. get keysDown(): number[];
  18705. set keysDown(value: number[]);
  18706. /**
  18707. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18708. */
  18709. get keysDownward(): number[];
  18710. set keysDownward(value: number[]);
  18711. /**
  18712. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18713. */
  18714. get keysLeft(): number[];
  18715. set keysLeft(value: number[]);
  18716. /**
  18717. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18718. */
  18719. get keysRight(): number[];
  18720. set keysRight(value: number[]);
  18721. /**
  18722. * Event raised when the camera collide with a mesh in the scene.
  18723. */
  18724. onCollide: (collidedMesh: AbstractMesh) => void;
  18725. private _collider;
  18726. private _needMoveForGravity;
  18727. private _oldPosition;
  18728. private _diffPosition;
  18729. private _newPosition;
  18730. /** @hidden */
  18731. _localDirection: Vector3;
  18732. /** @hidden */
  18733. _transformedDirection: Vector3;
  18734. /**
  18735. * Instantiates a Free Camera.
  18736. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18737. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18738. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18739. * @param name Define the name of the camera in the scene
  18740. * @param position Define the start position of the camera in the scene
  18741. * @param scene Define the scene the camera belongs to
  18742. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18743. */
  18744. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18745. /**
  18746. * Attached controls to the current camera.
  18747. * @param element Defines the element the controls should be listened from
  18748. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18749. */
  18750. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18751. /**
  18752. * Detach the current controls from the camera.
  18753. * The camera will stop reacting to inputs.
  18754. * @param element Defines the element to stop listening the inputs from
  18755. */
  18756. detachControl(element: HTMLElement): void;
  18757. private _collisionMask;
  18758. /**
  18759. * Define a collision mask to limit the list of object the camera can collide with
  18760. */
  18761. get collisionMask(): number;
  18762. set collisionMask(mask: number);
  18763. /** @hidden */
  18764. _collideWithWorld(displacement: Vector3): void;
  18765. private _onCollisionPositionChange;
  18766. /** @hidden */
  18767. _checkInputs(): void;
  18768. /** @hidden */
  18769. _decideIfNeedsToMove(): boolean;
  18770. /** @hidden */
  18771. _updatePosition(): void;
  18772. /**
  18773. * Destroy the camera and release the current resources hold by it.
  18774. */
  18775. dispose(): void;
  18776. /**
  18777. * Gets the current object class name.
  18778. * @return the class name
  18779. */
  18780. getClassName(): string;
  18781. }
  18782. }
  18783. declare module BABYLON {
  18784. /**
  18785. * Represents a gamepad control stick position
  18786. */
  18787. export class StickValues {
  18788. /**
  18789. * The x component of the control stick
  18790. */
  18791. x: number;
  18792. /**
  18793. * The y component of the control stick
  18794. */
  18795. y: number;
  18796. /**
  18797. * Initializes the gamepad x and y control stick values
  18798. * @param x The x component of the gamepad control stick value
  18799. * @param y The y component of the gamepad control stick value
  18800. */
  18801. constructor(
  18802. /**
  18803. * The x component of the control stick
  18804. */
  18805. x: number,
  18806. /**
  18807. * The y component of the control stick
  18808. */
  18809. y: number);
  18810. }
  18811. /**
  18812. * An interface which manages callbacks for gamepad button changes
  18813. */
  18814. export interface GamepadButtonChanges {
  18815. /**
  18816. * Called when a gamepad has been changed
  18817. */
  18818. changed: boolean;
  18819. /**
  18820. * Called when a gamepad press event has been triggered
  18821. */
  18822. pressChanged: boolean;
  18823. /**
  18824. * Called when a touch event has been triggered
  18825. */
  18826. touchChanged: boolean;
  18827. /**
  18828. * Called when a value has changed
  18829. */
  18830. valueChanged: boolean;
  18831. }
  18832. /**
  18833. * Represents a gamepad
  18834. */
  18835. export class Gamepad {
  18836. /**
  18837. * The id of the gamepad
  18838. */
  18839. id: string;
  18840. /**
  18841. * The index of the gamepad
  18842. */
  18843. index: number;
  18844. /**
  18845. * The browser gamepad
  18846. */
  18847. browserGamepad: any;
  18848. /**
  18849. * Specifies what type of gamepad this represents
  18850. */
  18851. type: number;
  18852. private _leftStick;
  18853. private _rightStick;
  18854. /** @hidden */
  18855. _isConnected: boolean;
  18856. private _leftStickAxisX;
  18857. private _leftStickAxisY;
  18858. private _rightStickAxisX;
  18859. private _rightStickAxisY;
  18860. /**
  18861. * Triggered when the left control stick has been changed
  18862. */
  18863. private _onleftstickchanged;
  18864. /**
  18865. * Triggered when the right control stick has been changed
  18866. */
  18867. private _onrightstickchanged;
  18868. /**
  18869. * Represents a gamepad controller
  18870. */
  18871. static GAMEPAD: number;
  18872. /**
  18873. * Represents a generic controller
  18874. */
  18875. static GENERIC: number;
  18876. /**
  18877. * Represents an XBox controller
  18878. */
  18879. static XBOX: number;
  18880. /**
  18881. * Represents a pose-enabled controller
  18882. */
  18883. static POSE_ENABLED: number;
  18884. /**
  18885. * Represents an Dual Shock controller
  18886. */
  18887. static DUALSHOCK: number;
  18888. /**
  18889. * Specifies whether the left control stick should be Y-inverted
  18890. */
  18891. protected _invertLeftStickY: boolean;
  18892. /**
  18893. * Specifies if the gamepad has been connected
  18894. */
  18895. get isConnected(): boolean;
  18896. /**
  18897. * Initializes the gamepad
  18898. * @param id The id of the gamepad
  18899. * @param index The index of the gamepad
  18900. * @param browserGamepad The browser gamepad
  18901. * @param leftStickX The x component of the left joystick
  18902. * @param leftStickY The y component of the left joystick
  18903. * @param rightStickX The x component of the right joystick
  18904. * @param rightStickY The y component of the right joystick
  18905. */
  18906. constructor(
  18907. /**
  18908. * The id of the gamepad
  18909. */
  18910. id: string,
  18911. /**
  18912. * The index of the gamepad
  18913. */
  18914. index: number,
  18915. /**
  18916. * The browser gamepad
  18917. */
  18918. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18919. /**
  18920. * Callback triggered when the left joystick has changed
  18921. * @param callback
  18922. */
  18923. onleftstickchanged(callback: (values: StickValues) => void): void;
  18924. /**
  18925. * Callback triggered when the right joystick has changed
  18926. * @param callback
  18927. */
  18928. onrightstickchanged(callback: (values: StickValues) => void): void;
  18929. /**
  18930. * Gets the left joystick
  18931. */
  18932. get leftStick(): StickValues;
  18933. /**
  18934. * Sets the left joystick values
  18935. */
  18936. set leftStick(newValues: StickValues);
  18937. /**
  18938. * Gets the right joystick
  18939. */
  18940. get rightStick(): StickValues;
  18941. /**
  18942. * Sets the right joystick value
  18943. */
  18944. set rightStick(newValues: StickValues);
  18945. /**
  18946. * Updates the gamepad joystick positions
  18947. */
  18948. update(): void;
  18949. /**
  18950. * Disposes the gamepad
  18951. */
  18952. dispose(): void;
  18953. }
  18954. /**
  18955. * Represents a generic gamepad
  18956. */
  18957. export class GenericPad extends Gamepad {
  18958. private _buttons;
  18959. private _onbuttondown;
  18960. private _onbuttonup;
  18961. /**
  18962. * Observable triggered when a button has been pressed
  18963. */
  18964. onButtonDownObservable: Observable<number>;
  18965. /**
  18966. * Observable triggered when a button has been released
  18967. */
  18968. onButtonUpObservable: Observable<number>;
  18969. /**
  18970. * Callback triggered when a button has been pressed
  18971. * @param callback Called when a button has been pressed
  18972. */
  18973. onbuttondown(callback: (buttonPressed: number) => void): void;
  18974. /**
  18975. * Callback triggered when a button has been released
  18976. * @param callback Called when a button has been released
  18977. */
  18978. onbuttonup(callback: (buttonReleased: number) => void): void;
  18979. /**
  18980. * Initializes the generic gamepad
  18981. * @param id The id of the generic gamepad
  18982. * @param index The index of the generic gamepad
  18983. * @param browserGamepad The browser gamepad
  18984. */
  18985. constructor(id: string, index: number, browserGamepad: any);
  18986. private _setButtonValue;
  18987. /**
  18988. * Updates the generic gamepad
  18989. */
  18990. update(): void;
  18991. /**
  18992. * Disposes the generic gamepad
  18993. */
  18994. dispose(): void;
  18995. }
  18996. }
  18997. declare module BABYLON {
  18998. /**
  18999. * Defines the types of pose enabled controllers that are supported
  19000. */
  19001. export enum PoseEnabledControllerType {
  19002. /**
  19003. * HTC Vive
  19004. */
  19005. VIVE = 0,
  19006. /**
  19007. * Oculus Rift
  19008. */
  19009. OCULUS = 1,
  19010. /**
  19011. * Windows mixed reality
  19012. */
  19013. WINDOWS = 2,
  19014. /**
  19015. * Samsung gear VR
  19016. */
  19017. GEAR_VR = 3,
  19018. /**
  19019. * Google Daydream
  19020. */
  19021. DAYDREAM = 4,
  19022. /**
  19023. * Generic
  19024. */
  19025. GENERIC = 5
  19026. }
  19027. /**
  19028. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19029. */
  19030. export interface MutableGamepadButton {
  19031. /**
  19032. * Value of the button/trigger
  19033. */
  19034. value: number;
  19035. /**
  19036. * If the button/trigger is currently touched
  19037. */
  19038. touched: boolean;
  19039. /**
  19040. * If the button/trigger is currently pressed
  19041. */
  19042. pressed: boolean;
  19043. }
  19044. /**
  19045. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19046. * @hidden
  19047. */
  19048. export interface ExtendedGamepadButton extends GamepadButton {
  19049. /**
  19050. * If the button/trigger is currently pressed
  19051. */
  19052. readonly pressed: boolean;
  19053. /**
  19054. * If the button/trigger is currently touched
  19055. */
  19056. readonly touched: boolean;
  19057. /**
  19058. * Value of the button/trigger
  19059. */
  19060. readonly value: number;
  19061. }
  19062. /** @hidden */
  19063. export interface _GamePadFactory {
  19064. /**
  19065. * Returns whether or not the current gamepad can be created for this type of controller.
  19066. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19067. * @returns true if it can be created, otherwise false
  19068. */
  19069. canCreate(gamepadInfo: any): boolean;
  19070. /**
  19071. * Creates a new instance of the Gamepad.
  19072. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19073. * @returns the new gamepad instance
  19074. */
  19075. create(gamepadInfo: any): Gamepad;
  19076. }
  19077. /**
  19078. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19079. */
  19080. export class PoseEnabledControllerHelper {
  19081. /** @hidden */
  19082. static _ControllerFactories: _GamePadFactory[];
  19083. /** @hidden */
  19084. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19085. /**
  19086. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19087. * @param vrGamepad the gamepad to initialized
  19088. * @returns a vr controller of the type the gamepad identified as
  19089. */
  19090. static InitiateController(vrGamepad: any): Gamepad;
  19091. }
  19092. /**
  19093. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19094. */
  19095. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19096. /**
  19097. * If the controller is used in a webXR session
  19098. */
  19099. isXR: boolean;
  19100. private _deviceRoomPosition;
  19101. private _deviceRoomRotationQuaternion;
  19102. /**
  19103. * The device position in babylon space
  19104. */
  19105. devicePosition: Vector3;
  19106. /**
  19107. * The device rotation in babylon space
  19108. */
  19109. deviceRotationQuaternion: Quaternion;
  19110. /**
  19111. * The scale factor of the device in babylon space
  19112. */
  19113. deviceScaleFactor: number;
  19114. /**
  19115. * (Likely devicePosition should be used instead) The device position in its room space
  19116. */
  19117. position: Vector3;
  19118. /**
  19119. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19120. */
  19121. rotationQuaternion: Quaternion;
  19122. /**
  19123. * The type of controller (Eg. Windows mixed reality)
  19124. */
  19125. controllerType: PoseEnabledControllerType;
  19126. protected _calculatedPosition: Vector3;
  19127. private _calculatedRotation;
  19128. /**
  19129. * The raw pose from the device
  19130. */
  19131. rawPose: DevicePose;
  19132. private _trackPosition;
  19133. private _maxRotationDistFromHeadset;
  19134. private _draggedRoomRotation;
  19135. /**
  19136. * @hidden
  19137. */
  19138. _disableTrackPosition(fixedPosition: Vector3): void;
  19139. /**
  19140. * Internal, the mesh attached to the controller
  19141. * @hidden
  19142. */
  19143. _mesh: Nullable<AbstractMesh>;
  19144. private _poseControlledCamera;
  19145. private _leftHandSystemQuaternion;
  19146. /**
  19147. * Internal, matrix used to convert room space to babylon space
  19148. * @hidden
  19149. */
  19150. _deviceToWorld: Matrix;
  19151. /**
  19152. * Node to be used when casting a ray from the controller
  19153. * @hidden
  19154. */
  19155. _pointingPoseNode: Nullable<TransformNode>;
  19156. /**
  19157. * Name of the child mesh that can be used to cast a ray from the controller
  19158. */
  19159. static readonly POINTING_POSE: string;
  19160. /**
  19161. * Creates a new PoseEnabledController from a gamepad
  19162. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19163. */
  19164. constructor(browserGamepad: any);
  19165. private _workingMatrix;
  19166. /**
  19167. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19168. */
  19169. update(): void;
  19170. /**
  19171. * Updates only the pose device and mesh without doing any button event checking
  19172. */
  19173. protected _updatePoseAndMesh(): void;
  19174. /**
  19175. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19176. * @param poseData raw pose fromthe device
  19177. */
  19178. updateFromDevice(poseData: DevicePose): void;
  19179. /**
  19180. * @hidden
  19181. */
  19182. _meshAttachedObservable: Observable<AbstractMesh>;
  19183. /**
  19184. * Attaches a mesh to the controller
  19185. * @param mesh the mesh to be attached
  19186. */
  19187. attachToMesh(mesh: AbstractMesh): void;
  19188. /**
  19189. * Attaches the controllers mesh to a camera
  19190. * @param camera the camera the mesh should be attached to
  19191. */
  19192. attachToPoseControlledCamera(camera: TargetCamera): void;
  19193. /**
  19194. * Disposes of the controller
  19195. */
  19196. dispose(): void;
  19197. /**
  19198. * The mesh that is attached to the controller
  19199. */
  19200. get mesh(): Nullable<AbstractMesh>;
  19201. /**
  19202. * Gets the ray of the controller in the direction the controller is pointing
  19203. * @param length the length the resulting ray should be
  19204. * @returns a ray in the direction the controller is pointing
  19205. */
  19206. getForwardRay(length?: number): Ray;
  19207. }
  19208. }
  19209. declare module BABYLON {
  19210. /**
  19211. * Defines the WebVRController object that represents controllers tracked in 3D space
  19212. */
  19213. export abstract class WebVRController extends PoseEnabledController {
  19214. /**
  19215. * Internal, the default controller model for the controller
  19216. */
  19217. protected _defaultModel: Nullable<AbstractMesh>;
  19218. /**
  19219. * Fired when the trigger state has changed
  19220. */
  19221. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19222. /**
  19223. * Fired when the main button state has changed
  19224. */
  19225. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19226. /**
  19227. * Fired when the secondary button state has changed
  19228. */
  19229. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19230. /**
  19231. * Fired when the pad state has changed
  19232. */
  19233. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19234. /**
  19235. * Fired when controllers stick values have changed
  19236. */
  19237. onPadValuesChangedObservable: Observable<StickValues>;
  19238. /**
  19239. * Array of button availible on the controller
  19240. */
  19241. protected _buttons: Array<MutableGamepadButton>;
  19242. private _onButtonStateChange;
  19243. /**
  19244. * Fired when a controller button's state has changed
  19245. * @param callback the callback containing the button that was modified
  19246. */
  19247. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19248. /**
  19249. * X and Y axis corresponding to the controllers joystick
  19250. */
  19251. pad: StickValues;
  19252. /**
  19253. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19254. */
  19255. hand: string;
  19256. /**
  19257. * The default controller model for the controller
  19258. */
  19259. get defaultModel(): Nullable<AbstractMesh>;
  19260. /**
  19261. * Creates a new WebVRController from a gamepad
  19262. * @param vrGamepad the gamepad that the WebVRController should be created from
  19263. */
  19264. constructor(vrGamepad: any);
  19265. /**
  19266. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19267. */
  19268. update(): void;
  19269. /**
  19270. * Function to be called when a button is modified
  19271. */
  19272. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19273. /**
  19274. * Loads a mesh and attaches it to the controller
  19275. * @param scene the scene the mesh should be added to
  19276. * @param meshLoaded callback for when the mesh has been loaded
  19277. */
  19278. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19279. private _setButtonValue;
  19280. private _changes;
  19281. private _checkChanges;
  19282. /**
  19283. * Disposes of th webVRCOntroller
  19284. */
  19285. dispose(): void;
  19286. }
  19287. }
  19288. declare module BABYLON {
  19289. /**
  19290. * The HemisphericLight simulates the ambient environment light,
  19291. * so the passed direction is the light reflection direction, not the incoming direction.
  19292. */
  19293. export class HemisphericLight extends Light {
  19294. /**
  19295. * The groundColor is the light in the opposite direction to the one specified during creation.
  19296. * 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.
  19297. */
  19298. groundColor: Color3;
  19299. /**
  19300. * The light reflection direction, not the incoming direction.
  19301. */
  19302. direction: Vector3;
  19303. /**
  19304. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19305. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19306. * The HemisphericLight can't cast shadows.
  19307. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19308. * @param name The friendly name of the light
  19309. * @param direction The direction of the light reflection
  19310. * @param scene The scene the light belongs to
  19311. */
  19312. constructor(name: string, direction: Vector3, scene: Scene);
  19313. protected _buildUniformLayout(): void;
  19314. /**
  19315. * Returns the string "HemisphericLight".
  19316. * @return The class name
  19317. */
  19318. getClassName(): string;
  19319. /**
  19320. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19321. * Returns the updated direction.
  19322. * @param target The target the direction should point to
  19323. * @return The computed direction
  19324. */
  19325. setDirectionToTarget(target: Vector3): Vector3;
  19326. /**
  19327. * Returns the shadow generator associated to the light.
  19328. * @returns Always null for hemispheric lights because it does not support shadows.
  19329. */
  19330. getShadowGenerator(): Nullable<IShadowGenerator>;
  19331. /**
  19332. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19333. * @param effect The effect to update
  19334. * @param lightIndex The index of the light in the effect to update
  19335. * @returns The hemispheric light
  19336. */
  19337. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19338. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19339. /**
  19340. * Computes the world matrix of the node
  19341. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19342. * @param useWasUpdatedFlag defines a reserved property
  19343. * @returns the world matrix
  19344. */
  19345. computeWorldMatrix(): Matrix;
  19346. /**
  19347. * Returns the integer 3.
  19348. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19349. */
  19350. getTypeID(): number;
  19351. /**
  19352. * Prepares the list of defines specific to the light type.
  19353. * @param defines the list of defines
  19354. * @param lightIndex defines the index of the light for the effect
  19355. */
  19356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19357. }
  19358. }
  19359. declare module BABYLON {
  19360. /** @hidden */
  19361. export var vrMultiviewToSingleviewPixelShader: {
  19362. name: string;
  19363. shader: string;
  19364. };
  19365. }
  19366. declare module BABYLON {
  19367. /**
  19368. * Renders to multiple views with a single draw call
  19369. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19370. */
  19371. export class MultiviewRenderTarget extends RenderTargetTexture {
  19372. /**
  19373. * Creates a multiview render target
  19374. * @param scene scene used with the render target
  19375. * @param size the size of the render target (used for each view)
  19376. */
  19377. constructor(scene: Scene, size?: number | {
  19378. width: number;
  19379. height: number;
  19380. } | {
  19381. ratio: number;
  19382. });
  19383. /**
  19384. * @hidden
  19385. * @param faceIndex the face index, if its a cube texture
  19386. */
  19387. _bindFrameBuffer(faceIndex?: number): void;
  19388. /**
  19389. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19390. * @returns the view count
  19391. */
  19392. getViewCount(): number;
  19393. }
  19394. }
  19395. declare module BABYLON {
  19396. /**
  19397. * Represents a camera frustum
  19398. */
  19399. export class Frustum {
  19400. /**
  19401. * Gets the planes representing the frustum
  19402. * @param transform matrix to be applied to the returned planes
  19403. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19404. */
  19405. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19406. /**
  19407. * Gets the near frustum plane transformed by the transform matrix
  19408. * @param transform transformation matrix to be applied to the resulting frustum plane
  19409. * @param frustumPlane the resuling frustum plane
  19410. */
  19411. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19412. /**
  19413. * Gets the far frustum plane transformed by the transform matrix
  19414. * @param transform transformation matrix to be applied to the resulting frustum plane
  19415. * @param frustumPlane the resuling frustum plane
  19416. */
  19417. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19418. /**
  19419. * Gets the left frustum plane transformed by the transform matrix
  19420. * @param transform transformation matrix to be applied to the resulting frustum plane
  19421. * @param frustumPlane the resuling frustum plane
  19422. */
  19423. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19424. /**
  19425. * Gets the right frustum plane transformed by the transform matrix
  19426. * @param transform transformation matrix to be applied to the resulting frustum plane
  19427. * @param frustumPlane the resuling frustum plane
  19428. */
  19429. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19430. /**
  19431. * Gets the top frustum plane transformed by the transform matrix
  19432. * @param transform transformation matrix to be applied to the resulting frustum plane
  19433. * @param frustumPlane the resuling frustum plane
  19434. */
  19435. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19436. /**
  19437. * Gets the bottom frustum plane transformed by the transform matrix
  19438. * @param transform transformation matrix to be applied to the resulting frustum plane
  19439. * @param frustumPlane the resuling frustum plane
  19440. */
  19441. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19442. /**
  19443. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19444. * @param transform transformation matrix to be applied to the resulting frustum planes
  19445. * @param frustumPlanes the resuling frustum planes
  19446. */
  19447. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19448. }
  19449. }
  19450. declare module BABYLON {
  19451. interface Engine {
  19452. /**
  19453. * Creates a new multiview render target
  19454. * @param width defines the width of the texture
  19455. * @param height defines the height of the texture
  19456. * @returns the created multiview texture
  19457. */
  19458. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19459. /**
  19460. * Binds a multiview framebuffer to be drawn to
  19461. * @param multiviewTexture texture to bind
  19462. */
  19463. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19464. }
  19465. interface Camera {
  19466. /**
  19467. * @hidden
  19468. * 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)
  19469. */
  19470. _useMultiviewToSingleView: boolean;
  19471. /**
  19472. * @hidden
  19473. * 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)
  19474. */
  19475. _multiviewTexture: Nullable<RenderTargetTexture>;
  19476. /**
  19477. * @hidden
  19478. * ensures the multiview texture of the camera exists and has the specified width/height
  19479. * @param width height to set on the multiview texture
  19480. * @param height width to set on the multiview texture
  19481. */
  19482. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19483. }
  19484. interface Scene {
  19485. /** @hidden */
  19486. _transformMatrixR: Matrix;
  19487. /** @hidden */
  19488. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19489. /** @hidden */
  19490. _createMultiviewUbo(): void;
  19491. /** @hidden */
  19492. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19493. /** @hidden */
  19494. _renderMultiviewToSingleView(camera: Camera): void;
  19495. }
  19496. }
  19497. declare module BABYLON {
  19498. /**
  19499. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19500. * This will not be used for webXR as it supports displaying texture arrays directly
  19501. */
  19502. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19503. /**
  19504. * Initializes a VRMultiviewToSingleview
  19505. * @param name name of the post process
  19506. * @param camera camera to be applied to
  19507. * @param scaleFactor scaling factor to the size of the output texture
  19508. */
  19509. constructor(name: string, camera: Camera, scaleFactor: number);
  19510. }
  19511. }
  19512. declare module BABYLON {
  19513. /**
  19514. * Interface used to define additional presentation attributes
  19515. */
  19516. export interface IVRPresentationAttributes {
  19517. /**
  19518. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19519. */
  19520. highRefreshRate: boolean;
  19521. /**
  19522. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19523. */
  19524. foveationLevel: number;
  19525. }
  19526. interface Engine {
  19527. /** @hidden */
  19528. _vrDisplay: any;
  19529. /** @hidden */
  19530. _vrSupported: boolean;
  19531. /** @hidden */
  19532. _oldSize: Size;
  19533. /** @hidden */
  19534. _oldHardwareScaleFactor: number;
  19535. /** @hidden */
  19536. _vrExclusivePointerMode: boolean;
  19537. /** @hidden */
  19538. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19539. /** @hidden */
  19540. _onVRDisplayPointerRestricted: () => void;
  19541. /** @hidden */
  19542. _onVRDisplayPointerUnrestricted: () => void;
  19543. /** @hidden */
  19544. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19545. /** @hidden */
  19546. _onVrDisplayDisconnect: Nullable<() => void>;
  19547. /** @hidden */
  19548. _onVrDisplayPresentChange: Nullable<() => void>;
  19549. /**
  19550. * Observable signaled when VR display mode changes
  19551. */
  19552. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19553. /**
  19554. * Observable signaled when VR request present is complete
  19555. */
  19556. onVRRequestPresentComplete: Observable<boolean>;
  19557. /**
  19558. * Observable signaled when VR request present starts
  19559. */
  19560. onVRRequestPresentStart: Observable<Engine>;
  19561. /**
  19562. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19563. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19564. */
  19565. isInVRExclusivePointerMode: boolean;
  19566. /**
  19567. * Gets a boolean indicating if a webVR device was detected
  19568. * @returns true if a webVR device was detected
  19569. */
  19570. isVRDevicePresent(): boolean;
  19571. /**
  19572. * Gets the current webVR device
  19573. * @returns the current webVR device (or null)
  19574. */
  19575. getVRDevice(): any;
  19576. /**
  19577. * Initializes a webVR display and starts listening to display change events
  19578. * The onVRDisplayChangedObservable will be notified upon these changes
  19579. * @returns A promise containing a VRDisplay and if vr is supported
  19580. */
  19581. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19582. /** @hidden */
  19583. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19584. /**
  19585. * Gets or sets the presentation attributes used to configure VR rendering
  19586. */
  19587. vrPresentationAttributes?: IVRPresentationAttributes;
  19588. /**
  19589. * Call this function to switch to webVR mode
  19590. * Will do nothing if webVR is not supported or if there is no webVR device
  19591. * @param options the webvr options provided to the camera. mainly used for multiview
  19592. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19593. */
  19594. enableVR(options: WebVROptions): void;
  19595. /** @hidden */
  19596. _onVRFullScreenTriggered(): void;
  19597. }
  19598. }
  19599. declare module BABYLON {
  19600. /**
  19601. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19602. * IMPORTANT!! The data is right-hand data.
  19603. * @export
  19604. * @interface DevicePose
  19605. */
  19606. export interface DevicePose {
  19607. /**
  19608. * The position of the device, values in array are [x,y,z].
  19609. */
  19610. readonly position: Nullable<Float32Array>;
  19611. /**
  19612. * The linearVelocity of the device, values in array are [x,y,z].
  19613. */
  19614. readonly linearVelocity: Nullable<Float32Array>;
  19615. /**
  19616. * The linearAcceleration of the device, values in array are [x,y,z].
  19617. */
  19618. readonly linearAcceleration: Nullable<Float32Array>;
  19619. /**
  19620. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19621. */
  19622. readonly orientation: Nullable<Float32Array>;
  19623. /**
  19624. * The angularVelocity of the device, values in array are [x,y,z].
  19625. */
  19626. readonly angularVelocity: Nullable<Float32Array>;
  19627. /**
  19628. * The angularAcceleration of the device, values in array are [x,y,z].
  19629. */
  19630. readonly angularAcceleration: Nullable<Float32Array>;
  19631. }
  19632. /**
  19633. * Interface representing a pose controlled object in Babylon.
  19634. * A pose controlled object has both regular pose values as well as pose values
  19635. * from an external device such as a VR head mounted display
  19636. */
  19637. export interface PoseControlled {
  19638. /**
  19639. * The position of the object in babylon space.
  19640. */
  19641. position: Vector3;
  19642. /**
  19643. * The rotation quaternion of the object in babylon space.
  19644. */
  19645. rotationQuaternion: Quaternion;
  19646. /**
  19647. * The position of the device in babylon space.
  19648. */
  19649. devicePosition?: Vector3;
  19650. /**
  19651. * The rotation quaternion of the device in babylon space.
  19652. */
  19653. deviceRotationQuaternion: Quaternion;
  19654. /**
  19655. * The raw pose coming from the device.
  19656. */
  19657. rawPose: Nullable<DevicePose>;
  19658. /**
  19659. * The scale of the device to be used when translating from device space to babylon space.
  19660. */
  19661. deviceScaleFactor: number;
  19662. /**
  19663. * Updates the poseControlled values based on the input device pose.
  19664. * @param poseData the pose data to update the object with
  19665. */
  19666. updateFromDevice(poseData: DevicePose): void;
  19667. }
  19668. /**
  19669. * Set of options to customize the webVRCamera
  19670. */
  19671. export interface WebVROptions {
  19672. /**
  19673. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19674. */
  19675. trackPosition?: boolean;
  19676. /**
  19677. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19678. */
  19679. positionScale?: number;
  19680. /**
  19681. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19682. */
  19683. displayName?: string;
  19684. /**
  19685. * Should the native controller meshes be initialized. (default: true)
  19686. */
  19687. controllerMeshes?: boolean;
  19688. /**
  19689. * Creating a default HemiLight only on controllers. (default: true)
  19690. */
  19691. defaultLightingOnControllers?: boolean;
  19692. /**
  19693. * If you don't want to use the default VR button of the helper. (default: false)
  19694. */
  19695. useCustomVRButton?: boolean;
  19696. /**
  19697. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19698. */
  19699. customVRButton?: HTMLButtonElement;
  19700. /**
  19701. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19702. */
  19703. rayLength?: number;
  19704. /**
  19705. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19706. */
  19707. defaultHeight?: number;
  19708. /**
  19709. * If multiview should be used if availible (default: false)
  19710. */
  19711. useMultiview?: boolean;
  19712. }
  19713. /**
  19714. * This represents a WebVR camera.
  19715. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19716. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19717. */
  19718. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19719. private webVROptions;
  19720. /**
  19721. * @hidden
  19722. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19723. */
  19724. _vrDevice: any;
  19725. /**
  19726. * The rawPose of the vrDevice.
  19727. */
  19728. rawPose: Nullable<DevicePose>;
  19729. private _onVREnabled;
  19730. private _specsVersion;
  19731. private _attached;
  19732. private _frameData;
  19733. protected _descendants: Array<Node>;
  19734. private _deviceRoomPosition;
  19735. /** @hidden */
  19736. _deviceRoomRotationQuaternion: Quaternion;
  19737. private _standingMatrix;
  19738. /**
  19739. * Represents device position in babylon space.
  19740. */
  19741. devicePosition: Vector3;
  19742. /**
  19743. * Represents device rotation in babylon space.
  19744. */
  19745. deviceRotationQuaternion: Quaternion;
  19746. /**
  19747. * The scale of the device to be used when translating from device space to babylon space.
  19748. */
  19749. deviceScaleFactor: number;
  19750. private _deviceToWorld;
  19751. private _worldToDevice;
  19752. /**
  19753. * References to the webVR controllers for the vrDevice.
  19754. */
  19755. controllers: Array<WebVRController>;
  19756. /**
  19757. * Emits an event when a controller is attached.
  19758. */
  19759. onControllersAttachedObservable: Observable<WebVRController[]>;
  19760. /**
  19761. * Emits an event when a controller's mesh has been loaded;
  19762. */
  19763. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19764. /**
  19765. * Emits an event when the HMD's pose has been updated.
  19766. */
  19767. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19768. private _poseSet;
  19769. /**
  19770. * If the rig cameras be used as parent instead of this camera.
  19771. */
  19772. rigParenting: boolean;
  19773. private _lightOnControllers;
  19774. private _defaultHeight?;
  19775. /**
  19776. * Instantiates a WebVRFreeCamera.
  19777. * @param name The name of the WebVRFreeCamera
  19778. * @param position The starting anchor position for the camera
  19779. * @param scene The scene the camera belongs to
  19780. * @param webVROptions a set of customizable options for the webVRCamera
  19781. */
  19782. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19783. /**
  19784. * Gets the device distance from the ground in meters.
  19785. * @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.
  19786. */
  19787. deviceDistanceToRoomGround(): number;
  19788. /**
  19789. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19790. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19791. */
  19792. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19793. /**
  19794. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19795. * @returns A promise with a boolean set to if the standing matrix is supported.
  19796. */
  19797. useStandingMatrixAsync(): Promise<boolean>;
  19798. /**
  19799. * Disposes the camera
  19800. */
  19801. dispose(): void;
  19802. /**
  19803. * Gets a vrController by name.
  19804. * @param name The name of the controller to retreive
  19805. * @returns the controller matching the name specified or null if not found
  19806. */
  19807. getControllerByName(name: string): Nullable<WebVRController>;
  19808. private _leftController;
  19809. /**
  19810. * The controller corresponding to the users left hand.
  19811. */
  19812. get leftController(): Nullable<WebVRController>;
  19813. private _rightController;
  19814. /**
  19815. * The controller corresponding to the users right hand.
  19816. */
  19817. get rightController(): Nullable<WebVRController>;
  19818. /**
  19819. * Casts a ray forward from the vrCamera's gaze.
  19820. * @param length Length of the ray (default: 100)
  19821. * @returns the ray corresponding to the gaze
  19822. */
  19823. getForwardRay(length?: number): Ray;
  19824. /**
  19825. * @hidden
  19826. * Updates the camera based on device's frame data
  19827. */
  19828. _checkInputs(): void;
  19829. /**
  19830. * Updates the poseControlled values based on the input device pose.
  19831. * @param poseData Pose coming from the device
  19832. */
  19833. updateFromDevice(poseData: DevicePose): void;
  19834. private _htmlElementAttached;
  19835. private _detachIfAttached;
  19836. /**
  19837. * WebVR's attach control will start broadcasting frames to the device.
  19838. * Note that in certain browsers (chrome for example) this function must be called
  19839. * within a user-interaction callback. Example:
  19840. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19841. *
  19842. * @param element html element to attach the vrDevice to
  19843. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19844. */
  19845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19846. /**
  19847. * Detaches the camera from the html element and disables VR
  19848. *
  19849. * @param element html element to detach from
  19850. */
  19851. detachControl(element: HTMLElement): void;
  19852. /**
  19853. * @returns the name of this class
  19854. */
  19855. getClassName(): string;
  19856. /**
  19857. * Calls resetPose on the vrDisplay
  19858. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19859. */
  19860. resetToCurrentRotation(): void;
  19861. /**
  19862. * @hidden
  19863. * Updates the rig cameras (left and right eye)
  19864. */
  19865. _updateRigCameras(): void;
  19866. private _workingVector;
  19867. private _oneVector;
  19868. private _workingMatrix;
  19869. private updateCacheCalled;
  19870. private _correctPositionIfNotTrackPosition;
  19871. /**
  19872. * @hidden
  19873. * Updates the cached values of the camera
  19874. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19875. */
  19876. _updateCache(ignoreParentClass?: boolean): void;
  19877. /**
  19878. * @hidden
  19879. * Get current device position in babylon world
  19880. */
  19881. _computeDevicePosition(): void;
  19882. /**
  19883. * Updates the current device position and rotation in the babylon world
  19884. */
  19885. update(): void;
  19886. /**
  19887. * @hidden
  19888. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19889. * @returns an identity matrix
  19890. */
  19891. _getViewMatrix(): Matrix;
  19892. private _tmpMatrix;
  19893. /**
  19894. * This function is called by the two RIG cameras.
  19895. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19896. * @hidden
  19897. */
  19898. _getWebVRViewMatrix(): Matrix;
  19899. /** @hidden */
  19900. _getWebVRProjectionMatrix(): Matrix;
  19901. private _onGamepadConnectedObserver;
  19902. private _onGamepadDisconnectedObserver;
  19903. private _updateCacheWhenTrackingDisabledObserver;
  19904. /**
  19905. * Initializes the controllers and their meshes
  19906. */
  19907. initControllers(): void;
  19908. }
  19909. }
  19910. declare module BABYLON {
  19911. /**
  19912. * Size options for a post process
  19913. */
  19914. export type PostProcessOptions = {
  19915. width: number;
  19916. height: number;
  19917. };
  19918. /**
  19919. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19920. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19921. */
  19922. export class PostProcess {
  19923. /** Name of the PostProcess. */
  19924. name: string;
  19925. /**
  19926. * Gets or sets the unique id of the post process
  19927. */
  19928. uniqueId: number;
  19929. /**
  19930. * Width of the texture to apply the post process on
  19931. */
  19932. width: number;
  19933. /**
  19934. * Height of the texture to apply the post process on
  19935. */
  19936. height: number;
  19937. /**
  19938. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19939. * @hidden
  19940. */
  19941. _outputTexture: Nullable<InternalTexture>;
  19942. /**
  19943. * Sampling mode used by the shader
  19944. * See https://doc.babylonjs.com/classes/3.1/texture
  19945. */
  19946. renderTargetSamplingMode: number;
  19947. /**
  19948. * Clear color to use when screen clearing
  19949. */
  19950. clearColor: Color4;
  19951. /**
  19952. * If the buffer needs to be cleared before applying the post process. (default: true)
  19953. * Should be set to false if shader will overwrite all previous pixels.
  19954. */
  19955. autoClear: boolean;
  19956. /**
  19957. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19958. */
  19959. alphaMode: number;
  19960. /**
  19961. * Sets the setAlphaBlendConstants of the babylon engine
  19962. */
  19963. alphaConstants: Color4;
  19964. /**
  19965. * Animations to be used for the post processing
  19966. */
  19967. animations: Animation[];
  19968. /**
  19969. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19970. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19971. */
  19972. enablePixelPerfectMode: boolean;
  19973. /**
  19974. * Force the postprocess to be applied without taking in account viewport
  19975. */
  19976. forceFullscreenViewport: boolean;
  19977. /**
  19978. * List of inspectable custom properties (used by the Inspector)
  19979. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19980. */
  19981. inspectableCustomProperties: IInspectable[];
  19982. /**
  19983. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19984. *
  19985. * | Value | Type | Description |
  19986. * | ----- | ----------------------------------- | ----------- |
  19987. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19988. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19989. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19990. *
  19991. */
  19992. scaleMode: number;
  19993. /**
  19994. * Force textures to be a power of two (default: false)
  19995. */
  19996. alwaysForcePOT: boolean;
  19997. private _samples;
  19998. /**
  19999. * Number of sample textures (default: 1)
  20000. */
  20001. get samples(): number;
  20002. set samples(n: number);
  20003. /**
  20004. * Modify the scale of the post process to be the same as the viewport (default: false)
  20005. */
  20006. adaptScaleToCurrentViewport: boolean;
  20007. private _camera;
  20008. private _scene;
  20009. private _engine;
  20010. private _options;
  20011. private _reusable;
  20012. private _textureType;
  20013. private _textureFormat;
  20014. /**
  20015. * Smart array of input and output textures for the post process.
  20016. * @hidden
  20017. */
  20018. _textures: SmartArray<InternalTexture>;
  20019. /**
  20020. * The index in _textures that corresponds to the output texture.
  20021. * @hidden
  20022. */
  20023. _currentRenderTextureInd: number;
  20024. private _effect;
  20025. private _samplers;
  20026. private _fragmentUrl;
  20027. private _vertexUrl;
  20028. private _parameters;
  20029. private _scaleRatio;
  20030. protected _indexParameters: any;
  20031. private _shareOutputWithPostProcess;
  20032. private _texelSize;
  20033. private _forcedOutputTexture;
  20034. /**
  20035. * Returns the fragment url or shader name used in the post process.
  20036. * @returns the fragment url or name in the shader store.
  20037. */
  20038. getEffectName(): string;
  20039. /**
  20040. * An event triggered when the postprocess is activated.
  20041. */
  20042. onActivateObservable: Observable<Camera>;
  20043. private _onActivateObserver;
  20044. /**
  20045. * A function that is added to the onActivateObservable
  20046. */
  20047. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20048. /**
  20049. * An event triggered when the postprocess changes its size.
  20050. */
  20051. onSizeChangedObservable: Observable<PostProcess>;
  20052. private _onSizeChangedObserver;
  20053. /**
  20054. * A function that is added to the onSizeChangedObservable
  20055. */
  20056. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20057. /**
  20058. * An event triggered when the postprocess applies its effect.
  20059. */
  20060. onApplyObservable: Observable<Effect>;
  20061. private _onApplyObserver;
  20062. /**
  20063. * A function that is added to the onApplyObservable
  20064. */
  20065. set onApply(callback: (effect: Effect) => void);
  20066. /**
  20067. * An event triggered before rendering the postprocess
  20068. */
  20069. onBeforeRenderObservable: Observable<Effect>;
  20070. private _onBeforeRenderObserver;
  20071. /**
  20072. * A function that is added to the onBeforeRenderObservable
  20073. */
  20074. set onBeforeRender(callback: (effect: Effect) => void);
  20075. /**
  20076. * An event triggered after rendering the postprocess
  20077. */
  20078. onAfterRenderObservable: Observable<Effect>;
  20079. private _onAfterRenderObserver;
  20080. /**
  20081. * A function that is added to the onAfterRenderObservable
  20082. */
  20083. set onAfterRender(callback: (efect: Effect) => void);
  20084. /**
  20085. * 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
  20086. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20087. */
  20088. get inputTexture(): InternalTexture;
  20089. set inputTexture(value: InternalTexture);
  20090. /**
  20091. * Gets the camera which post process is applied to.
  20092. * @returns The camera the post process is applied to.
  20093. */
  20094. getCamera(): Camera;
  20095. /**
  20096. * Gets the texel size of the postprocess.
  20097. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20098. */
  20099. get texelSize(): Vector2;
  20100. /**
  20101. * Creates a new instance PostProcess
  20102. * @param name The name of the PostProcess.
  20103. * @param fragmentUrl The url of the fragment shader to be used.
  20104. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20105. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20106. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20107. * @param camera The camera to apply the render pass to.
  20108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20109. * @param engine The engine which the post process will be applied. (default: current engine)
  20110. * @param reusable If the post process can be reused on the same frame. (default: false)
  20111. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20112. * @param textureType Type of textures used when performing the post process. (default: 0)
  20113. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20114. * @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
  20115. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20116. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20117. */
  20118. constructor(
  20119. /** Name of the PostProcess. */
  20120. 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);
  20121. /**
  20122. * Gets a string idenfifying the name of the class
  20123. * @returns "PostProcess" string
  20124. */
  20125. getClassName(): string;
  20126. /**
  20127. * Gets the engine which this post process belongs to.
  20128. * @returns The engine the post process was enabled with.
  20129. */
  20130. getEngine(): Engine;
  20131. /**
  20132. * The effect that is created when initializing the post process.
  20133. * @returns The created effect corresponding the the postprocess.
  20134. */
  20135. getEffect(): Effect;
  20136. /**
  20137. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20138. * @param postProcess The post process to share the output with.
  20139. * @returns This post process.
  20140. */
  20141. shareOutputWith(postProcess: PostProcess): PostProcess;
  20142. /**
  20143. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20144. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20145. */
  20146. useOwnOutput(): void;
  20147. /**
  20148. * Updates the effect with the current post process compile time values and recompiles the shader.
  20149. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20150. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20151. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20152. * @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
  20153. * @param onCompiled Called when the shader has been compiled.
  20154. * @param onError Called if there is an error when compiling a shader.
  20155. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  20156. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  20157. */
  20158. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, vertexUrl?: string, fragmentUrl?: string): void;
  20159. /**
  20160. * The post process is reusable if it can be used multiple times within one frame.
  20161. * @returns If the post process is reusable
  20162. */
  20163. isReusable(): boolean;
  20164. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20165. markTextureDirty(): void;
  20166. /**
  20167. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20168. * 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.
  20169. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20170. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20171. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20172. * @returns The target texture that was bound to be written to.
  20173. */
  20174. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20175. /**
  20176. * If the post process is supported.
  20177. */
  20178. get isSupported(): boolean;
  20179. /**
  20180. * The aspect ratio of the output texture.
  20181. */
  20182. get aspectRatio(): number;
  20183. /**
  20184. * Get a value indicating if the post-process is ready to be used
  20185. * @returns true if the post-process is ready (shader is compiled)
  20186. */
  20187. isReady(): boolean;
  20188. /**
  20189. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20190. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20191. */
  20192. apply(): Nullable<Effect>;
  20193. private _disposeTextures;
  20194. /**
  20195. * Disposes the post process.
  20196. * @param camera The camera to dispose the post process on.
  20197. */
  20198. dispose(camera?: Camera): void;
  20199. }
  20200. }
  20201. declare module BABYLON {
  20202. /** @hidden */
  20203. export var kernelBlurVaryingDeclaration: {
  20204. name: string;
  20205. shader: string;
  20206. };
  20207. }
  20208. declare module BABYLON {
  20209. /** @hidden */
  20210. export var kernelBlurFragment: {
  20211. name: string;
  20212. shader: string;
  20213. };
  20214. }
  20215. declare module BABYLON {
  20216. /** @hidden */
  20217. export var kernelBlurFragment2: {
  20218. name: string;
  20219. shader: string;
  20220. };
  20221. }
  20222. declare module BABYLON {
  20223. /** @hidden */
  20224. export var kernelBlurPixelShader: {
  20225. name: string;
  20226. shader: string;
  20227. };
  20228. }
  20229. declare module BABYLON {
  20230. /** @hidden */
  20231. export var kernelBlurVertex: {
  20232. name: string;
  20233. shader: string;
  20234. };
  20235. }
  20236. declare module BABYLON {
  20237. /** @hidden */
  20238. export var kernelBlurVertexShader: {
  20239. name: string;
  20240. shader: string;
  20241. };
  20242. }
  20243. declare module BABYLON {
  20244. /**
  20245. * The Blur Post Process which blurs an image based on a kernel and direction.
  20246. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20247. */
  20248. export class BlurPostProcess extends PostProcess {
  20249. /** The direction in which to blur the image. */
  20250. direction: Vector2;
  20251. private blockCompilation;
  20252. protected _kernel: number;
  20253. protected _idealKernel: number;
  20254. protected _packedFloat: boolean;
  20255. private _staticDefines;
  20256. /**
  20257. * Sets the length in pixels of the blur sample region
  20258. */
  20259. set kernel(v: number);
  20260. /**
  20261. * Gets the length in pixels of the blur sample region
  20262. */
  20263. get kernel(): number;
  20264. /**
  20265. * Sets wether or not the blur needs to unpack/repack floats
  20266. */
  20267. set packedFloat(v: boolean);
  20268. /**
  20269. * Gets wether or not the blur is unpacking/repacking floats
  20270. */
  20271. get packedFloat(): boolean;
  20272. /**
  20273. * Creates a new instance BlurPostProcess
  20274. * @param name The name of the effect.
  20275. * @param direction The direction in which to blur the image.
  20276. * @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.
  20277. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20278. * @param camera The camera to apply the render pass to.
  20279. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20280. * @param engine The engine which the post process will be applied. (default: current engine)
  20281. * @param reusable If the post process can be reused on the same frame. (default: false)
  20282. * @param textureType Type of textures used when performing the post process. (default: 0)
  20283. * @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)
  20284. */
  20285. constructor(name: string,
  20286. /** The direction in which to blur the image. */
  20287. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20288. /**
  20289. * Updates the effect with the current post process compile time values and recompiles the shader.
  20290. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20291. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20292. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20293. * @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
  20294. * @param onCompiled Called when the shader has been compiled.
  20295. * @param onError Called if there is an error when compiling a shader.
  20296. */
  20297. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20298. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20299. /**
  20300. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20301. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20302. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20303. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20304. * The gaps between physical kernels are compensated for in the weighting of the samples
  20305. * @param idealKernel Ideal blur kernel.
  20306. * @return Nearest best kernel.
  20307. */
  20308. protected _nearestBestKernel(idealKernel: number): number;
  20309. /**
  20310. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20311. * @param x The point on the Gaussian distribution to sample.
  20312. * @return the value of the Gaussian function at x.
  20313. */
  20314. protected _gaussianWeight(x: number): number;
  20315. /**
  20316. * Generates a string that can be used as a floating point number in GLSL.
  20317. * @param x Value to print.
  20318. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20319. * @return GLSL float string.
  20320. */
  20321. protected _glslFloat(x: number, decimalFigures?: number): string;
  20322. }
  20323. }
  20324. declare module BABYLON {
  20325. /**
  20326. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20327. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20328. * You can then easily use it as a reflectionTexture on a flat surface.
  20329. * In case the surface is not a plane, please consider relying on reflection probes.
  20330. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20331. */
  20332. export class MirrorTexture extends RenderTargetTexture {
  20333. private scene;
  20334. /**
  20335. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20336. * 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.
  20337. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20338. */
  20339. mirrorPlane: Plane;
  20340. /**
  20341. * Define the blur ratio used to blur the reflection if needed.
  20342. */
  20343. set blurRatio(value: number);
  20344. get blurRatio(): number;
  20345. /**
  20346. * Define the adaptive blur kernel used to blur the reflection if needed.
  20347. * This will autocompute the closest best match for the `blurKernel`
  20348. */
  20349. set adaptiveBlurKernel(value: number);
  20350. /**
  20351. * Define the blur kernel used to blur the reflection if needed.
  20352. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20353. */
  20354. set blurKernel(value: number);
  20355. /**
  20356. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20357. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20358. */
  20359. set blurKernelX(value: number);
  20360. get blurKernelX(): number;
  20361. /**
  20362. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20363. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20364. */
  20365. set blurKernelY(value: number);
  20366. get blurKernelY(): number;
  20367. private _autoComputeBlurKernel;
  20368. protected _onRatioRescale(): void;
  20369. private _updateGammaSpace;
  20370. private _imageProcessingConfigChangeObserver;
  20371. private _transformMatrix;
  20372. private _mirrorMatrix;
  20373. private _savedViewMatrix;
  20374. private _blurX;
  20375. private _blurY;
  20376. private _adaptiveBlurKernel;
  20377. private _blurKernelX;
  20378. private _blurKernelY;
  20379. private _blurRatio;
  20380. /**
  20381. * Instantiates a Mirror Texture.
  20382. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20383. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20384. * You can then easily use it as a reflectionTexture on a flat surface.
  20385. * In case the surface is not a plane, please consider relying on reflection probes.
  20386. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20387. * @param name
  20388. * @param size
  20389. * @param scene
  20390. * @param generateMipMaps
  20391. * @param type
  20392. * @param samplingMode
  20393. * @param generateDepthBuffer
  20394. */
  20395. constructor(name: string, size: number | {
  20396. width: number;
  20397. height: number;
  20398. } | {
  20399. ratio: number;
  20400. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20401. private _preparePostProcesses;
  20402. /**
  20403. * Clone the mirror texture.
  20404. * @returns the cloned texture
  20405. */
  20406. clone(): MirrorTexture;
  20407. /**
  20408. * Serialize the texture to a JSON representation you could use in Parse later on
  20409. * @returns the serialized JSON representation
  20410. */
  20411. serialize(): any;
  20412. /**
  20413. * Dispose the texture and release its associated resources.
  20414. */
  20415. dispose(): void;
  20416. }
  20417. }
  20418. declare module BABYLON {
  20419. /**
  20420. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20421. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20422. */
  20423. export class Texture extends BaseTexture {
  20424. /**
  20425. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20426. */
  20427. static SerializeBuffers: boolean;
  20428. /** @hidden */
  20429. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20430. /** @hidden */
  20431. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20432. /** @hidden */
  20433. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20434. /** nearest is mag = nearest and min = nearest and mip = linear */
  20435. static readonly NEAREST_SAMPLINGMODE: number;
  20436. /** nearest is mag = nearest and min = nearest and mip = linear */
  20437. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20438. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20439. static readonly BILINEAR_SAMPLINGMODE: number;
  20440. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20441. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20442. /** Trilinear is mag = linear and min = linear and mip = linear */
  20443. static readonly TRILINEAR_SAMPLINGMODE: number;
  20444. /** Trilinear is mag = linear and min = linear and mip = linear */
  20445. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20446. /** mag = nearest and min = nearest and mip = nearest */
  20447. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20448. /** mag = nearest and min = linear and mip = nearest */
  20449. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20450. /** mag = nearest and min = linear and mip = linear */
  20451. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20452. /** mag = nearest and min = linear and mip = none */
  20453. static readonly NEAREST_LINEAR: number;
  20454. /** mag = nearest and min = nearest and mip = none */
  20455. static readonly NEAREST_NEAREST: number;
  20456. /** mag = linear and min = nearest and mip = nearest */
  20457. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20458. /** mag = linear and min = nearest and mip = linear */
  20459. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20460. /** mag = linear and min = linear and mip = none */
  20461. static readonly LINEAR_LINEAR: number;
  20462. /** mag = linear and min = nearest and mip = none */
  20463. static readonly LINEAR_NEAREST: number;
  20464. /** Explicit coordinates mode */
  20465. static readonly EXPLICIT_MODE: number;
  20466. /** Spherical coordinates mode */
  20467. static readonly SPHERICAL_MODE: number;
  20468. /** Planar coordinates mode */
  20469. static readonly PLANAR_MODE: number;
  20470. /** Cubic coordinates mode */
  20471. static readonly CUBIC_MODE: number;
  20472. /** Projection coordinates mode */
  20473. static readonly PROJECTION_MODE: number;
  20474. /** Inverse Cubic coordinates mode */
  20475. static readonly SKYBOX_MODE: number;
  20476. /** Inverse Cubic coordinates mode */
  20477. static readonly INVCUBIC_MODE: number;
  20478. /** Equirectangular coordinates mode */
  20479. static readonly EQUIRECTANGULAR_MODE: number;
  20480. /** Equirectangular Fixed coordinates mode */
  20481. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20482. /** Equirectangular Fixed Mirrored coordinates mode */
  20483. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20484. /** Texture is not repeating outside of 0..1 UVs */
  20485. static readonly CLAMP_ADDRESSMODE: number;
  20486. /** Texture is repeating outside of 0..1 UVs */
  20487. static readonly WRAP_ADDRESSMODE: number;
  20488. /** Texture is repeating and mirrored */
  20489. static readonly MIRROR_ADDRESSMODE: number;
  20490. /**
  20491. * 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
  20492. */
  20493. static UseSerializedUrlIfAny: boolean;
  20494. /**
  20495. * Define the url of the texture.
  20496. */
  20497. url: Nullable<string>;
  20498. /**
  20499. * Define an offset on the texture to offset the u coordinates of the UVs
  20500. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20501. */
  20502. uOffset: number;
  20503. /**
  20504. * Define an offset on the texture to offset the v coordinates of the UVs
  20505. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20506. */
  20507. vOffset: number;
  20508. /**
  20509. * Define an offset on the texture to scale the u coordinates of the UVs
  20510. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20511. */
  20512. uScale: number;
  20513. /**
  20514. * Define an offset on the texture to scale the v coordinates of the UVs
  20515. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20516. */
  20517. vScale: number;
  20518. /**
  20519. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20520. * @see http://doc.babylonjs.com/how_to/more_materials
  20521. */
  20522. uAng: number;
  20523. /**
  20524. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20525. * @see http://doc.babylonjs.com/how_to/more_materials
  20526. */
  20527. vAng: number;
  20528. /**
  20529. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20530. * @see http://doc.babylonjs.com/how_to/more_materials
  20531. */
  20532. wAng: number;
  20533. /**
  20534. * Defines the center of rotation (U)
  20535. */
  20536. uRotationCenter: number;
  20537. /**
  20538. * Defines the center of rotation (V)
  20539. */
  20540. vRotationCenter: number;
  20541. /**
  20542. * Defines the center of rotation (W)
  20543. */
  20544. wRotationCenter: number;
  20545. /**
  20546. * Are mip maps generated for this texture or not.
  20547. */
  20548. get noMipmap(): boolean;
  20549. /**
  20550. * List of inspectable custom properties (used by the Inspector)
  20551. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20552. */
  20553. inspectableCustomProperties: Nullable<IInspectable[]>;
  20554. private _noMipmap;
  20555. /** @hidden */
  20556. _invertY: boolean;
  20557. private _rowGenerationMatrix;
  20558. private _cachedTextureMatrix;
  20559. private _projectionModeMatrix;
  20560. private _t0;
  20561. private _t1;
  20562. private _t2;
  20563. private _cachedUOffset;
  20564. private _cachedVOffset;
  20565. private _cachedUScale;
  20566. private _cachedVScale;
  20567. private _cachedUAng;
  20568. private _cachedVAng;
  20569. private _cachedWAng;
  20570. private _cachedProjectionMatrixId;
  20571. private _cachedCoordinatesMode;
  20572. /** @hidden */
  20573. protected _initialSamplingMode: number;
  20574. /** @hidden */
  20575. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20576. private _deleteBuffer;
  20577. protected _format: Nullable<number>;
  20578. private _delayedOnLoad;
  20579. private _delayedOnError;
  20580. private _mimeType?;
  20581. /**
  20582. * Observable triggered once the texture has been loaded.
  20583. */
  20584. onLoadObservable: Observable<Texture>;
  20585. protected _isBlocking: boolean;
  20586. /**
  20587. * Is the texture preventing material to render while loading.
  20588. * If false, a default texture will be used instead of the loading one during the preparation step.
  20589. */
  20590. set isBlocking(value: boolean);
  20591. get isBlocking(): boolean;
  20592. /**
  20593. * Get the current sampling mode associated with the texture.
  20594. */
  20595. get samplingMode(): number;
  20596. /**
  20597. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20598. */
  20599. get invertY(): boolean;
  20600. /**
  20601. * Instantiates a new texture.
  20602. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20603. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20604. * @param url defines the url of the picture to load as a texture
  20605. * @param sceneOrEngine defines the scene or engine the texture will belong to
  20606. * @param noMipmap defines if the texture will require mip maps or not
  20607. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20608. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20609. * @param onLoad defines a callback triggered when the texture has been loaded
  20610. * @param onError defines a callback triggered when an error occurred during the loading session
  20611. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20612. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20613. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20614. * @param mimeType defines an optional mime type information
  20615. */
  20616. 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);
  20617. /**
  20618. * Update the url (and optional buffer) of this texture if url was null during construction.
  20619. * @param url the url of the texture
  20620. * @param buffer the buffer of the texture (defaults to null)
  20621. * @param onLoad callback called when the texture is loaded (defaults to null)
  20622. */
  20623. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20624. /**
  20625. * Finish the loading sequence of a texture flagged as delayed load.
  20626. * @hidden
  20627. */
  20628. delayLoad(): void;
  20629. private _prepareRowForTextureGeneration;
  20630. /**
  20631. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20632. * @returns the transform matrix of the texture.
  20633. */
  20634. getTextureMatrix(uBase?: number): Matrix;
  20635. /**
  20636. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20637. * @returns The reflection texture transform
  20638. */
  20639. getReflectionTextureMatrix(): Matrix;
  20640. /**
  20641. * Clones the texture.
  20642. * @returns the cloned texture
  20643. */
  20644. clone(): Texture;
  20645. /**
  20646. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20647. * @returns The JSON representation of the texture
  20648. */
  20649. serialize(): any;
  20650. /**
  20651. * Get the current class name of the texture useful for serialization or dynamic coding.
  20652. * @returns "Texture"
  20653. */
  20654. getClassName(): string;
  20655. /**
  20656. * Dispose the texture and release its associated resources.
  20657. */
  20658. dispose(): void;
  20659. /**
  20660. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20661. * @param parsedTexture Define the JSON representation of the texture
  20662. * @param scene Define the scene the parsed texture should be instantiated in
  20663. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20664. * @returns The parsed texture if successful
  20665. */
  20666. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20667. /**
  20668. * Creates a texture from its base 64 representation.
  20669. * @param data Define the base64 payload without the data: prefix
  20670. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20671. * @param scene Define the scene the texture should belong to
  20672. * @param noMipmap Forces the texture to not create mip map information if true
  20673. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20674. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20675. * @param onLoad define a callback triggered when the texture has been loaded
  20676. * @param onError define a callback triggered when an error occurred during the loading session
  20677. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20678. * @returns the created texture
  20679. */
  20680. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20681. /**
  20682. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20683. * @param data Define the base64 payload without the data: prefix
  20684. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20685. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20686. * @param scene Define the scene the texture should belong to
  20687. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20688. * @param noMipmap Forces the texture to not create mip map information if true
  20689. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20690. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20691. * @param onLoad define a callback triggered when the texture has been loaded
  20692. * @param onError define a callback triggered when an error occurred during the loading session
  20693. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20694. * @returns the created texture
  20695. */
  20696. 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;
  20697. }
  20698. }
  20699. declare module BABYLON {
  20700. /**
  20701. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20702. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20703. */
  20704. export class PostProcessManager {
  20705. private _scene;
  20706. private _indexBuffer;
  20707. private _vertexBuffers;
  20708. /**
  20709. * Creates a new instance PostProcess
  20710. * @param scene The scene that the post process is associated with.
  20711. */
  20712. constructor(scene: Scene);
  20713. private _prepareBuffers;
  20714. private _buildIndexBuffer;
  20715. /**
  20716. * Rebuilds the vertex buffers of the manager.
  20717. * @hidden
  20718. */
  20719. _rebuild(): void;
  20720. /**
  20721. * Prepares a frame to be run through a post process.
  20722. * @param sourceTexture The input texture to the post procesess. (default: null)
  20723. * @param postProcesses An array of post processes to be run. (default: null)
  20724. * @returns True if the post processes were able to be run.
  20725. * @hidden
  20726. */
  20727. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20728. /**
  20729. * Manually render a set of post processes to a texture.
  20730. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  20731. * @param postProcesses An array of post processes to be run.
  20732. * @param targetTexture The target texture to render to.
  20733. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20734. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20735. * @param lodLevel defines which lod of the texture to render to
  20736. */
  20737. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20738. /**
  20739. * Finalize the result of the output of the postprocesses.
  20740. * @param doNotPresent If true the result will not be displayed to the screen.
  20741. * @param targetTexture The target texture to render to.
  20742. * @param faceIndex The index of the face to bind the target texture to.
  20743. * @param postProcesses The array of post processes to render.
  20744. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20745. * @hidden
  20746. */
  20747. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20748. /**
  20749. * Disposes of the post process manager.
  20750. */
  20751. dispose(): void;
  20752. }
  20753. }
  20754. declare module BABYLON {
  20755. /**
  20756. * This Helps creating a texture that will be created from a camera in your scene.
  20757. * It is basically a dynamic texture that could be used to create special effects for instance.
  20758. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20759. */
  20760. export class RenderTargetTexture extends Texture {
  20761. isCube: boolean;
  20762. /**
  20763. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20764. */
  20765. static readonly REFRESHRATE_RENDER_ONCE: number;
  20766. /**
  20767. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20768. */
  20769. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20770. /**
  20771. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20772. * the central point of your effect and can save a lot of performances.
  20773. */
  20774. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20775. /**
  20776. * Use this predicate to dynamically define the list of mesh you want to render.
  20777. * If set, the renderList property will be overwritten.
  20778. */
  20779. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20780. private _renderList;
  20781. /**
  20782. * Use this list to define the list of mesh you want to render.
  20783. */
  20784. get renderList(): Nullable<Array<AbstractMesh>>;
  20785. set renderList(value: Nullable<Array<AbstractMesh>>);
  20786. /**
  20787. * Use this function to overload the renderList array at rendering time.
  20788. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20789. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20790. * the cube (if the RTT is a cube, else layerOrFace=0).
  20791. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20792. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20793. * hold dummy elements!
  20794. */
  20795. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20796. private _hookArray;
  20797. /**
  20798. * Define if particles should be rendered in your texture.
  20799. */
  20800. renderParticles: boolean;
  20801. /**
  20802. * Define if sprites should be rendered in your texture.
  20803. */
  20804. renderSprites: boolean;
  20805. /**
  20806. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20807. */
  20808. coordinatesMode: number;
  20809. /**
  20810. * Define the camera used to render the texture.
  20811. */
  20812. activeCamera: Nullable<Camera>;
  20813. /**
  20814. * Override the mesh isReady function with your own one.
  20815. */
  20816. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20817. /**
  20818. * Override the render function of the texture with your own one.
  20819. */
  20820. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20821. /**
  20822. * Define if camera post processes should be use while rendering the texture.
  20823. */
  20824. useCameraPostProcesses: boolean;
  20825. /**
  20826. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20827. */
  20828. ignoreCameraViewport: boolean;
  20829. private _postProcessManager;
  20830. private _postProcesses;
  20831. private _resizeObserver;
  20832. /**
  20833. * An event triggered when the texture is unbind.
  20834. */
  20835. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20836. /**
  20837. * An event triggered when the texture is unbind.
  20838. */
  20839. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20840. private _onAfterUnbindObserver;
  20841. /**
  20842. * Set a after unbind callback in the texture.
  20843. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20844. */
  20845. set onAfterUnbind(callback: () => void);
  20846. /**
  20847. * An event triggered before rendering the texture
  20848. */
  20849. onBeforeRenderObservable: Observable<number>;
  20850. private _onBeforeRenderObserver;
  20851. /**
  20852. * Set a before render callback in the texture.
  20853. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20854. */
  20855. set onBeforeRender(callback: (faceIndex: number) => void);
  20856. /**
  20857. * An event triggered after rendering the texture
  20858. */
  20859. onAfterRenderObservable: Observable<number>;
  20860. private _onAfterRenderObserver;
  20861. /**
  20862. * Set a after render callback in the texture.
  20863. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20864. */
  20865. set onAfterRender(callback: (faceIndex: number) => void);
  20866. /**
  20867. * An event triggered after the texture clear
  20868. */
  20869. onClearObservable: Observable<Engine>;
  20870. private _onClearObserver;
  20871. /**
  20872. * Set a clear callback in the texture.
  20873. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20874. */
  20875. set onClear(callback: (Engine: Engine) => void);
  20876. /**
  20877. * An event triggered when the texture is resized.
  20878. */
  20879. onResizeObservable: Observable<RenderTargetTexture>;
  20880. /**
  20881. * Define the clear color of the Render Target if it should be different from the scene.
  20882. */
  20883. clearColor: Color4;
  20884. protected _size: number | {
  20885. width: number;
  20886. height: number;
  20887. layers?: number;
  20888. };
  20889. protected _initialSizeParameter: number | {
  20890. width: number;
  20891. height: number;
  20892. } | {
  20893. ratio: number;
  20894. };
  20895. protected _sizeRatio: Nullable<number>;
  20896. /** @hidden */
  20897. _generateMipMaps: boolean;
  20898. protected _renderingManager: RenderingManager;
  20899. /** @hidden */
  20900. _waitingRenderList: string[];
  20901. protected _doNotChangeAspectRatio: boolean;
  20902. protected _currentRefreshId: number;
  20903. protected _refreshRate: number;
  20904. protected _textureMatrix: Matrix;
  20905. protected _samples: number;
  20906. protected _renderTargetOptions: RenderTargetCreationOptions;
  20907. /**
  20908. * Gets render target creation options that were used.
  20909. */
  20910. get renderTargetOptions(): RenderTargetCreationOptions;
  20911. protected _onRatioRescale(): void;
  20912. /**
  20913. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20914. * It must define where the camera used to render the texture is set
  20915. */
  20916. boundingBoxPosition: Vector3;
  20917. private _boundingBoxSize;
  20918. /**
  20919. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20920. * When defined, the cubemap will switch to local mode
  20921. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20922. * @example https://www.babylonjs-playground.com/#RNASML
  20923. */
  20924. set boundingBoxSize(value: Vector3);
  20925. get boundingBoxSize(): Vector3;
  20926. /**
  20927. * In case the RTT has been created with a depth texture, get the associated
  20928. * depth texture.
  20929. * Otherwise, return null.
  20930. */
  20931. get depthStencilTexture(): Nullable<InternalTexture>;
  20932. /**
  20933. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20934. * or used a shadow, depth texture...
  20935. * @param name The friendly name of the texture
  20936. * @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)
  20937. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20938. * @param generateMipMaps True if mip maps need to be generated after render.
  20939. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20940. * @param type The type of the buffer in the RTT (int, half float, float...)
  20941. * @param isCube True if a cube texture needs to be created
  20942. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20943. * @param generateDepthBuffer True to generate a depth buffer
  20944. * @param generateStencilBuffer True to generate a stencil buffer
  20945. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20946. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20947. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20948. */
  20949. constructor(name: string, size: number | {
  20950. width: number;
  20951. height: number;
  20952. layers?: number;
  20953. } | {
  20954. ratio: number;
  20955. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20956. /**
  20957. * Creates a depth stencil texture.
  20958. * This is only available in WebGL 2 or with the depth texture extension available.
  20959. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20960. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20961. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20962. */
  20963. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20964. private _processSizeParameter;
  20965. /**
  20966. * Define the number of samples to use in case of MSAA.
  20967. * It defaults to one meaning no MSAA has been enabled.
  20968. */
  20969. get samples(): number;
  20970. set samples(value: number);
  20971. /**
  20972. * Resets the refresh counter of the texture and start bak from scratch.
  20973. * Could be useful to regenerate the texture if it is setup to render only once.
  20974. */
  20975. resetRefreshCounter(): void;
  20976. /**
  20977. * Define the refresh rate of the texture or the rendering frequency.
  20978. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20979. */
  20980. get refreshRate(): number;
  20981. set refreshRate(value: number);
  20982. /**
  20983. * Adds a post process to the render target rendering passes.
  20984. * @param postProcess define the post process to add
  20985. */
  20986. addPostProcess(postProcess: PostProcess): void;
  20987. /**
  20988. * Clear all the post processes attached to the render target
  20989. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20990. */
  20991. clearPostProcesses(dispose?: boolean): void;
  20992. /**
  20993. * Remove one of the post process from the list of attached post processes to the texture
  20994. * @param postProcess define the post process to remove from the list
  20995. */
  20996. removePostProcess(postProcess: PostProcess): void;
  20997. /** @hidden */
  20998. _shouldRender(): boolean;
  20999. /**
  21000. * Gets the actual render size of the texture.
  21001. * @returns the width of the render size
  21002. */
  21003. getRenderSize(): number;
  21004. /**
  21005. * Gets the actual render width of the texture.
  21006. * @returns the width of the render size
  21007. */
  21008. getRenderWidth(): number;
  21009. /**
  21010. * Gets the actual render height of the texture.
  21011. * @returns the height of the render size
  21012. */
  21013. getRenderHeight(): number;
  21014. /**
  21015. * Gets the actual number of layers of the texture.
  21016. * @returns the number of layers
  21017. */
  21018. getRenderLayers(): number;
  21019. /**
  21020. * Get if the texture can be rescaled or not.
  21021. */
  21022. get canRescale(): boolean;
  21023. /**
  21024. * Resize the texture using a ratio.
  21025. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21026. */
  21027. scale(ratio: number): void;
  21028. /**
  21029. * Get the texture reflection matrix used to rotate/transform the reflection.
  21030. * @returns the reflection matrix
  21031. */
  21032. getReflectionTextureMatrix(): Matrix;
  21033. /**
  21034. * Resize the texture to a new desired size.
  21035. * Be carrefull as it will recreate all the data in the new texture.
  21036. * @param size Define the new size. It can be:
  21037. * - a number for squared texture,
  21038. * - an object containing { width: number, height: number }
  21039. * - or an object containing a ratio { ratio: number }
  21040. */
  21041. resize(size: number | {
  21042. width: number;
  21043. height: number;
  21044. } | {
  21045. ratio: number;
  21046. }): void;
  21047. private _defaultRenderListPrepared;
  21048. /**
  21049. * Renders all the objects from the render list into the texture.
  21050. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21051. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21052. */
  21053. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21054. private _bestReflectionRenderTargetDimension;
  21055. private _prepareRenderingManager;
  21056. /**
  21057. * @hidden
  21058. * @param faceIndex face index to bind to if this is a cubetexture
  21059. * @param layer defines the index of the texture to bind in the array
  21060. */
  21061. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21062. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21063. private renderToTarget;
  21064. /**
  21065. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21066. * This allowed control for front to back rendering or reversly depending of the special needs.
  21067. *
  21068. * @param renderingGroupId The rendering group id corresponding to its index
  21069. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21070. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21071. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21072. */
  21073. 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;
  21074. /**
  21075. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21076. *
  21077. * @param renderingGroupId The rendering group id corresponding to its index
  21078. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21079. */
  21080. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21081. /**
  21082. * Clones the texture.
  21083. * @returns the cloned texture
  21084. */
  21085. clone(): RenderTargetTexture;
  21086. /**
  21087. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21088. * @returns The JSON representation of the texture
  21089. */
  21090. serialize(): any;
  21091. /**
  21092. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21093. */
  21094. disposeFramebufferObjects(): void;
  21095. /**
  21096. * Dispose the texture and release its associated resources.
  21097. */
  21098. dispose(): void;
  21099. /** @hidden */
  21100. _rebuild(): void;
  21101. /**
  21102. * Clear the info related to rendering groups preventing retention point in material dispose.
  21103. */
  21104. freeRenderingGroups(): void;
  21105. /**
  21106. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21107. * @returns the view count
  21108. */
  21109. getViewCount(): number;
  21110. }
  21111. }
  21112. declare module BABYLON {
  21113. /**
  21114. * Class used to manipulate GUIDs
  21115. */
  21116. export class GUID {
  21117. /**
  21118. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21119. * Be aware Math.random() could cause collisions, but:
  21120. * "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"
  21121. * @returns a pseudo random id
  21122. */
  21123. static RandomId(): string;
  21124. }
  21125. }
  21126. declare module BABYLON {
  21127. /**
  21128. * Options to be used when creating a shadow depth material
  21129. */
  21130. export interface IIOptionShadowDepthMaterial {
  21131. /** Variables in the vertex shader code that need to have their names remapped.
  21132. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  21133. * "var_name" should be either: worldPos or vNormalW
  21134. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  21135. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  21136. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  21137. */
  21138. remappedVariables?: string[];
  21139. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  21140. standalone?: boolean;
  21141. }
  21142. /**
  21143. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  21144. */
  21145. export class ShadowDepthWrapper {
  21146. private _scene;
  21147. private _options?;
  21148. private _baseMaterial;
  21149. private _onEffectCreatedObserver;
  21150. private _subMeshToEffect;
  21151. private _subMeshToDepthEffect;
  21152. private _meshes;
  21153. /** @hidden */
  21154. _matriceNames: any;
  21155. /** Gets the standalone status of the wrapper */
  21156. get standalone(): boolean;
  21157. /** Gets the base material the wrapper is built upon */
  21158. get baseMaterial(): Material;
  21159. /**
  21160. * Instantiate a new shadow depth wrapper.
  21161. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  21162. * generate the shadow depth map. For more information, please refer to the documentation:
  21163. * https://doc.babylonjs.com/babylon101/shadows
  21164. * @param baseMaterial Material to wrap
  21165. * @param scene Define the scene the material belongs to
  21166. * @param options Options used to create the wrapper
  21167. */
  21168. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  21169. /**
  21170. * Gets the effect to use to generate the depth map
  21171. * @param subMesh subMesh to get the effect for
  21172. * @param shadowGenerator shadow generator to get the effect for
  21173. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  21174. */
  21175. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  21176. /**
  21177. * Specifies that the submesh is ready to be used for depth rendering
  21178. * @param subMesh submesh to check
  21179. * @param defines the list of defines to take into account when checking the effect
  21180. * @param shadowGenerator combined with subMesh, it defines the effect to check
  21181. * @param useInstances specifies that instances should be used
  21182. * @returns a boolean indicating that the submesh is ready or not
  21183. */
  21184. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  21185. /**
  21186. * Disposes the resources
  21187. */
  21188. dispose(): void;
  21189. private _makeEffect;
  21190. }
  21191. }
  21192. declare module BABYLON {
  21193. /**
  21194. * Options for compiling materials.
  21195. */
  21196. export interface IMaterialCompilationOptions {
  21197. /**
  21198. * Defines whether clip planes are enabled.
  21199. */
  21200. clipPlane: boolean;
  21201. /**
  21202. * Defines whether instances are enabled.
  21203. */
  21204. useInstances: boolean;
  21205. }
  21206. /**
  21207. * Base class for the main features of a material in Babylon.js
  21208. */
  21209. export class Material implements IAnimatable {
  21210. /**
  21211. * Returns the triangle fill mode
  21212. */
  21213. static readonly TriangleFillMode: number;
  21214. /**
  21215. * Returns the wireframe mode
  21216. */
  21217. static readonly WireFrameFillMode: number;
  21218. /**
  21219. * Returns the point fill mode
  21220. */
  21221. static readonly PointFillMode: number;
  21222. /**
  21223. * Returns the point list draw mode
  21224. */
  21225. static readonly PointListDrawMode: number;
  21226. /**
  21227. * Returns the line list draw mode
  21228. */
  21229. static readonly LineListDrawMode: number;
  21230. /**
  21231. * Returns the line loop draw mode
  21232. */
  21233. static readonly LineLoopDrawMode: number;
  21234. /**
  21235. * Returns the line strip draw mode
  21236. */
  21237. static readonly LineStripDrawMode: number;
  21238. /**
  21239. * Returns the triangle strip draw mode
  21240. */
  21241. static readonly TriangleStripDrawMode: number;
  21242. /**
  21243. * Returns the triangle fan draw mode
  21244. */
  21245. static readonly TriangleFanDrawMode: number;
  21246. /**
  21247. * Stores the clock-wise side orientation
  21248. */
  21249. static readonly ClockWiseSideOrientation: number;
  21250. /**
  21251. * Stores the counter clock-wise side orientation
  21252. */
  21253. static readonly CounterClockWiseSideOrientation: number;
  21254. /**
  21255. * The dirty texture flag value
  21256. */
  21257. static readonly TextureDirtyFlag: number;
  21258. /**
  21259. * The dirty light flag value
  21260. */
  21261. static readonly LightDirtyFlag: number;
  21262. /**
  21263. * The dirty fresnel flag value
  21264. */
  21265. static readonly FresnelDirtyFlag: number;
  21266. /**
  21267. * The dirty attribute flag value
  21268. */
  21269. static readonly AttributesDirtyFlag: number;
  21270. /**
  21271. * The dirty misc flag value
  21272. */
  21273. static readonly MiscDirtyFlag: number;
  21274. /**
  21275. * The all dirty flag value
  21276. */
  21277. static readonly AllDirtyFlag: number;
  21278. /**
  21279. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21280. */
  21281. static readonly MATERIAL_OPAQUE: number;
  21282. /**
  21283. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21284. */
  21285. static readonly MATERIAL_ALPHATEST: number;
  21286. /**
  21287. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21288. */
  21289. static readonly MATERIAL_ALPHABLEND: number;
  21290. /**
  21291. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21292. * They are also discarded below the alpha cutoff threshold to improve performances.
  21293. */
  21294. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21295. /**
  21296. * Custom callback helping to override the default shader used in the material.
  21297. */
  21298. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[]) => string;
  21299. /**
  21300. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  21301. */
  21302. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  21303. /**
  21304. * The ID of the material
  21305. */
  21306. id: string;
  21307. /**
  21308. * Gets or sets the unique id of the material
  21309. */
  21310. uniqueId: number;
  21311. /**
  21312. * The name of the material
  21313. */
  21314. name: string;
  21315. /**
  21316. * Gets or sets user defined metadata
  21317. */
  21318. metadata: any;
  21319. /**
  21320. * For internal use only. Please do not use.
  21321. */
  21322. reservedDataStore: any;
  21323. /**
  21324. * Specifies if the ready state should be checked on each call
  21325. */
  21326. checkReadyOnEveryCall: boolean;
  21327. /**
  21328. * Specifies if the ready state should be checked once
  21329. */
  21330. checkReadyOnlyOnce: boolean;
  21331. /**
  21332. * The state of the material
  21333. */
  21334. state: string;
  21335. /**
  21336. * The alpha value of the material
  21337. */
  21338. protected _alpha: number;
  21339. /**
  21340. * List of inspectable custom properties (used by the Inspector)
  21341. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21342. */
  21343. inspectableCustomProperties: IInspectable[];
  21344. /**
  21345. * Sets the alpha value of the material
  21346. */
  21347. set alpha(value: number);
  21348. /**
  21349. * Gets the alpha value of the material
  21350. */
  21351. get alpha(): number;
  21352. /**
  21353. * Specifies if back face culling is enabled
  21354. */
  21355. protected _backFaceCulling: boolean;
  21356. /**
  21357. * Sets the back-face culling state
  21358. */
  21359. set backFaceCulling(value: boolean);
  21360. /**
  21361. * Gets the back-face culling state
  21362. */
  21363. get backFaceCulling(): boolean;
  21364. /**
  21365. * Stores the value for side orientation
  21366. */
  21367. sideOrientation: number;
  21368. /**
  21369. * Callback triggered when the material is compiled
  21370. */
  21371. onCompiled: Nullable<(effect: Effect) => void>;
  21372. /**
  21373. * Callback triggered when an error occurs
  21374. */
  21375. onError: Nullable<(effect: Effect, errors: string) => void>;
  21376. /**
  21377. * Callback triggered to get the render target textures
  21378. */
  21379. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21380. /**
  21381. * Gets a boolean indicating that current material needs to register RTT
  21382. */
  21383. get hasRenderTargetTextures(): boolean;
  21384. /**
  21385. * Specifies if the material should be serialized
  21386. */
  21387. doNotSerialize: boolean;
  21388. /**
  21389. * @hidden
  21390. */
  21391. _storeEffectOnSubMeshes: boolean;
  21392. /**
  21393. * Stores the animations for the material
  21394. */
  21395. animations: Nullable<Array<Animation>>;
  21396. /**
  21397. * An event triggered when the material is disposed
  21398. */
  21399. onDisposeObservable: Observable<Material>;
  21400. /**
  21401. * An observer which watches for dispose events
  21402. */
  21403. private _onDisposeObserver;
  21404. private _onUnBindObservable;
  21405. /**
  21406. * Called during a dispose event
  21407. */
  21408. set onDispose(callback: () => void);
  21409. private _onBindObservable;
  21410. /**
  21411. * An event triggered when the material is bound
  21412. */
  21413. get onBindObservable(): Observable<AbstractMesh>;
  21414. /**
  21415. * An observer which watches for bind events
  21416. */
  21417. private _onBindObserver;
  21418. /**
  21419. * Called during a bind event
  21420. */
  21421. set onBind(callback: (Mesh: AbstractMesh) => void);
  21422. /**
  21423. * An event triggered when the material is unbound
  21424. */
  21425. get onUnBindObservable(): Observable<Material>;
  21426. protected _onEffectCreatedObservable: Nullable<Observable<{
  21427. effect: Effect;
  21428. subMesh: Nullable<SubMesh>;
  21429. }>>;
  21430. /**
  21431. * An event triggered when the effect is (re)created
  21432. */
  21433. get onEffectCreatedObservable(): Observable<{
  21434. effect: Effect;
  21435. subMesh: Nullable<SubMesh>;
  21436. }>;
  21437. /**
  21438. * Stores the value of the alpha mode
  21439. */
  21440. private _alphaMode;
  21441. /**
  21442. * Sets the value of the alpha mode.
  21443. *
  21444. * | Value | Type | Description |
  21445. * | --- | --- | --- |
  21446. * | 0 | ALPHA_DISABLE | |
  21447. * | 1 | ALPHA_ADD | |
  21448. * | 2 | ALPHA_COMBINE | |
  21449. * | 3 | ALPHA_SUBTRACT | |
  21450. * | 4 | ALPHA_MULTIPLY | |
  21451. * | 5 | ALPHA_MAXIMIZED | |
  21452. * | 6 | ALPHA_ONEONE | |
  21453. * | 7 | ALPHA_PREMULTIPLIED | |
  21454. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21455. * | 9 | ALPHA_INTERPOLATE | |
  21456. * | 10 | ALPHA_SCREENMODE | |
  21457. *
  21458. */
  21459. set alphaMode(value: number);
  21460. /**
  21461. * Gets the value of the alpha mode
  21462. */
  21463. get alphaMode(): number;
  21464. /**
  21465. * Stores the state of the need depth pre-pass value
  21466. */
  21467. private _needDepthPrePass;
  21468. /**
  21469. * Sets the need depth pre-pass value
  21470. */
  21471. set needDepthPrePass(value: boolean);
  21472. /**
  21473. * Gets the depth pre-pass value
  21474. */
  21475. get needDepthPrePass(): boolean;
  21476. /**
  21477. * Specifies if depth writing should be disabled
  21478. */
  21479. disableDepthWrite: boolean;
  21480. /**
  21481. * Specifies if color writing should be disabled
  21482. */
  21483. disableColorWrite: boolean;
  21484. /**
  21485. * Specifies if depth writing should be forced
  21486. */
  21487. forceDepthWrite: boolean;
  21488. /**
  21489. * Specifies the depth function that should be used. 0 means the default engine function
  21490. */
  21491. depthFunction: number;
  21492. /**
  21493. * Specifies if there should be a separate pass for culling
  21494. */
  21495. separateCullingPass: boolean;
  21496. /**
  21497. * Stores the state specifing if fog should be enabled
  21498. */
  21499. private _fogEnabled;
  21500. /**
  21501. * Sets the state for enabling fog
  21502. */
  21503. set fogEnabled(value: boolean);
  21504. /**
  21505. * Gets the value of the fog enabled state
  21506. */
  21507. get fogEnabled(): boolean;
  21508. /**
  21509. * Stores the size of points
  21510. */
  21511. pointSize: number;
  21512. /**
  21513. * Stores the z offset value
  21514. */
  21515. zOffset: number;
  21516. get wireframe(): boolean;
  21517. /**
  21518. * Sets the state of wireframe mode
  21519. */
  21520. set wireframe(value: boolean);
  21521. /**
  21522. * Gets the value specifying if point clouds are enabled
  21523. */
  21524. get pointsCloud(): boolean;
  21525. /**
  21526. * Sets the state of point cloud mode
  21527. */
  21528. set pointsCloud(value: boolean);
  21529. /**
  21530. * Gets the material fill mode
  21531. */
  21532. get fillMode(): number;
  21533. /**
  21534. * Sets the material fill mode
  21535. */
  21536. set fillMode(value: number);
  21537. /**
  21538. * @hidden
  21539. * Stores the effects for the material
  21540. */
  21541. _effect: Nullable<Effect>;
  21542. /**
  21543. * Specifies if uniform buffers should be used
  21544. */
  21545. private _useUBO;
  21546. /**
  21547. * Stores a reference to the scene
  21548. */
  21549. private _scene;
  21550. /**
  21551. * Stores the fill mode state
  21552. */
  21553. private _fillMode;
  21554. /**
  21555. * Specifies if the depth write state should be cached
  21556. */
  21557. private _cachedDepthWriteState;
  21558. /**
  21559. * Specifies if the color write state should be cached
  21560. */
  21561. private _cachedColorWriteState;
  21562. /**
  21563. * Specifies if the depth function state should be cached
  21564. */
  21565. private _cachedDepthFunctionState;
  21566. /**
  21567. * Stores the uniform buffer
  21568. */
  21569. protected _uniformBuffer: UniformBuffer;
  21570. /** @hidden */
  21571. _indexInSceneMaterialArray: number;
  21572. /** @hidden */
  21573. meshMap: Nullable<{
  21574. [id: string]: AbstractMesh | undefined;
  21575. }>;
  21576. /**
  21577. * Creates a material instance
  21578. * @param name defines the name of the material
  21579. * @param scene defines the scene to reference
  21580. * @param doNotAdd specifies if the material should be added to the scene
  21581. */
  21582. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21583. /**
  21584. * Returns a string representation of the current material
  21585. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21586. * @returns a string with material information
  21587. */
  21588. toString(fullDetails?: boolean): string;
  21589. /**
  21590. * Gets the class name of the material
  21591. * @returns a string with the class name of the material
  21592. */
  21593. getClassName(): string;
  21594. /**
  21595. * Specifies if updates for the material been locked
  21596. */
  21597. get isFrozen(): boolean;
  21598. /**
  21599. * Locks updates for the material
  21600. */
  21601. freeze(): void;
  21602. /**
  21603. * Unlocks updates for the material
  21604. */
  21605. unfreeze(): void;
  21606. /**
  21607. * Specifies if the material is ready to be used
  21608. * @param mesh defines the mesh to check
  21609. * @param useInstances specifies if instances should be used
  21610. * @returns a boolean indicating if the material is ready to be used
  21611. */
  21612. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21613. /**
  21614. * Specifies that the submesh is ready to be used
  21615. * @param mesh defines the mesh to check
  21616. * @param subMesh defines which submesh to check
  21617. * @param useInstances specifies that instances should be used
  21618. * @returns a boolean indicating that the submesh is ready or not
  21619. */
  21620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21621. /**
  21622. * Returns the material effect
  21623. * @returns the effect associated with the material
  21624. */
  21625. getEffect(): Nullable<Effect>;
  21626. /**
  21627. * Returns the current scene
  21628. * @returns a Scene
  21629. */
  21630. getScene(): Scene;
  21631. /**
  21632. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21633. */
  21634. protected _forceAlphaTest: boolean;
  21635. /**
  21636. * The transparency mode of the material.
  21637. */
  21638. protected _transparencyMode: Nullable<number>;
  21639. /**
  21640. * Gets the current transparency mode.
  21641. */
  21642. get transparencyMode(): Nullable<number>;
  21643. /**
  21644. * Sets the transparency mode of the material.
  21645. *
  21646. * | Value | Type | Description |
  21647. * | ----- | ----------------------------------- | ----------- |
  21648. * | 0 | OPAQUE | |
  21649. * | 1 | ALPHATEST | |
  21650. * | 2 | ALPHABLEND | |
  21651. * | 3 | ALPHATESTANDBLEND | |
  21652. *
  21653. */
  21654. set transparencyMode(value: Nullable<number>);
  21655. /**
  21656. * Returns true if alpha blending should be disabled.
  21657. */
  21658. protected get _disableAlphaBlending(): boolean;
  21659. /**
  21660. * Specifies whether or not this material should be rendered in alpha blend mode.
  21661. * @returns a boolean specifying if alpha blending is needed
  21662. */
  21663. needAlphaBlending(): boolean;
  21664. /**
  21665. * Specifies if the mesh will require alpha blending
  21666. * @param mesh defines the mesh to check
  21667. * @returns a boolean specifying if alpha blending is needed for the mesh
  21668. */
  21669. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21670. /**
  21671. * Specifies whether or not this material should be rendered in alpha test mode.
  21672. * @returns a boolean specifying if an alpha test is needed.
  21673. */
  21674. needAlphaTesting(): boolean;
  21675. /**
  21676. * Specifies if material alpha testing should be turned on for the mesh
  21677. * @param mesh defines the mesh to check
  21678. */
  21679. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21680. /**
  21681. * Gets the texture used for the alpha test
  21682. * @returns the texture to use for alpha testing
  21683. */
  21684. getAlphaTestTexture(): Nullable<BaseTexture>;
  21685. /**
  21686. * Marks the material to indicate that it needs to be re-calculated
  21687. */
  21688. markDirty(): void;
  21689. /** @hidden */
  21690. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21691. /**
  21692. * Binds the material to the mesh
  21693. * @param world defines the world transformation matrix
  21694. * @param mesh defines the mesh to bind the material to
  21695. */
  21696. bind(world: Matrix, mesh?: Mesh): void;
  21697. /**
  21698. * Binds the submesh to the material
  21699. * @param world defines the world transformation matrix
  21700. * @param mesh defines the mesh containing the submesh
  21701. * @param subMesh defines the submesh to bind the material to
  21702. */
  21703. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21704. /**
  21705. * Binds the world matrix to the material
  21706. * @param world defines the world transformation matrix
  21707. */
  21708. bindOnlyWorldMatrix(world: Matrix): void;
  21709. /**
  21710. * Binds the scene's uniform buffer to the effect.
  21711. * @param effect defines the effect to bind to the scene uniform buffer
  21712. * @param sceneUbo defines the uniform buffer storing scene data
  21713. */
  21714. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21715. /**
  21716. * Binds the view matrix to the effect
  21717. * @param effect defines the effect to bind the view matrix to
  21718. */
  21719. bindView(effect: Effect): void;
  21720. /**
  21721. * Binds the view projection matrix to the effect
  21722. * @param effect defines the effect to bind the view projection matrix to
  21723. */
  21724. bindViewProjection(effect: Effect): void;
  21725. /**
  21726. * Processes to execute after binding the material to a mesh
  21727. * @param mesh defines the rendered mesh
  21728. */
  21729. protected _afterBind(mesh?: Mesh): void;
  21730. /**
  21731. * Unbinds the material from the mesh
  21732. */
  21733. unbind(): void;
  21734. /**
  21735. * Gets the active textures from the material
  21736. * @returns an array of textures
  21737. */
  21738. getActiveTextures(): BaseTexture[];
  21739. /**
  21740. * Specifies if the material uses a texture
  21741. * @param texture defines the texture to check against the material
  21742. * @returns a boolean specifying if the material uses the texture
  21743. */
  21744. hasTexture(texture: BaseTexture): boolean;
  21745. /**
  21746. * Makes a duplicate of the material, and gives it a new name
  21747. * @param name defines the new name for the duplicated material
  21748. * @returns the cloned material
  21749. */
  21750. clone(name: string): Nullable<Material>;
  21751. /**
  21752. * Gets the meshes bound to the material
  21753. * @returns an array of meshes bound to the material
  21754. */
  21755. getBindedMeshes(): AbstractMesh[];
  21756. /**
  21757. * Force shader compilation
  21758. * @param mesh defines the mesh associated with this material
  21759. * @param onCompiled defines a function to execute once the material is compiled
  21760. * @param options defines the options to configure the compilation
  21761. * @param onError defines a function to execute if the material fails compiling
  21762. */
  21763. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21764. /**
  21765. * Force shader compilation
  21766. * @param mesh defines the mesh that will use this material
  21767. * @param options defines additional options for compiling the shaders
  21768. * @returns a promise that resolves when the compilation completes
  21769. */
  21770. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21771. private static readonly _AllDirtyCallBack;
  21772. private static readonly _ImageProcessingDirtyCallBack;
  21773. private static readonly _TextureDirtyCallBack;
  21774. private static readonly _FresnelDirtyCallBack;
  21775. private static readonly _MiscDirtyCallBack;
  21776. private static readonly _LightsDirtyCallBack;
  21777. private static readonly _AttributeDirtyCallBack;
  21778. private static _FresnelAndMiscDirtyCallBack;
  21779. private static _TextureAndMiscDirtyCallBack;
  21780. private static readonly _DirtyCallbackArray;
  21781. private static readonly _RunDirtyCallBacks;
  21782. /**
  21783. * Marks a define in the material to indicate that it needs to be re-computed
  21784. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21785. */
  21786. markAsDirty(flag: number): void;
  21787. /**
  21788. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21789. * @param func defines a function which checks material defines against the submeshes
  21790. */
  21791. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21792. /**
  21793. * Indicates that we need to re-calculated for all submeshes
  21794. */
  21795. protected _markAllSubMeshesAsAllDirty(): void;
  21796. /**
  21797. * Indicates that image processing needs to be re-calculated for all submeshes
  21798. */
  21799. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21800. /**
  21801. * Indicates that textures need to be re-calculated for all submeshes
  21802. */
  21803. protected _markAllSubMeshesAsTexturesDirty(): void;
  21804. /**
  21805. * Indicates that fresnel needs to be re-calculated for all submeshes
  21806. */
  21807. protected _markAllSubMeshesAsFresnelDirty(): void;
  21808. /**
  21809. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21810. */
  21811. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21812. /**
  21813. * Indicates that lights need to be re-calculated for all submeshes
  21814. */
  21815. protected _markAllSubMeshesAsLightsDirty(): void;
  21816. /**
  21817. * Indicates that attributes need to be re-calculated for all submeshes
  21818. */
  21819. protected _markAllSubMeshesAsAttributesDirty(): void;
  21820. /**
  21821. * Indicates that misc needs to be re-calculated for all submeshes
  21822. */
  21823. protected _markAllSubMeshesAsMiscDirty(): void;
  21824. /**
  21825. * Indicates that textures and misc need to be re-calculated for all submeshes
  21826. */
  21827. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21828. /**
  21829. * Disposes the material
  21830. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21831. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21832. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21833. */
  21834. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21835. /** @hidden */
  21836. private releaseVertexArrayObject;
  21837. /**
  21838. * Serializes this material
  21839. * @returns the serialized material object
  21840. */
  21841. serialize(): any;
  21842. /**
  21843. * Creates a material from parsed material data
  21844. * @param parsedMaterial defines parsed material data
  21845. * @param scene defines the hosting scene
  21846. * @param rootUrl defines the root URL to use to load textures
  21847. * @returns a new material
  21848. */
  21849. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21850. }
  21851. }
  21852. declare module BABYLON {
  21853. /**
  21854. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21855. * separate meshes. This can be use to improve performances.
  21856. * @see http://doc.babylonjs.com/how_to/multi_materials
  21857. */
  21858. export class MultiMaterial extends Material {
  21859. private _subMaterials;
  21860. /**
  21861. * Gets or Sets the list of Materials used within the multi material.
  21862. * They need to be ordered according to the submeshes order in the associated mesh
  21863. */
  21864. get subMaterials(): Nullable<Material>[];
  21865. set subMaterials(value: Nullable<Material>[]);
  21866. /**
  21867. * Function used to align with Node.getChildren()
  21868. * @returns the list of Materials used within the multi material
  21869. */
  21870. getChildren(): Nullable<Material>[];
  21871. /**
  21872. * Instantiates a new Multi Material
  21873. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21874. * separate meshes. This can be use to improve performances.
  21875. * @see http://doc.babylonjs.com/how_to/multi_materials
  21876. * @param name Define the name in the scene
  21877. * @param scene Define the scene the material belongs to
  21878. */
  21879. constructor(name: string, scene: Scene);
  21880. private _hookArray;
  21881. /**
  21882. * Get one of the submaterial by its index in the submaterials array
  21883. * @param index The index to look the sub material at
  21884. * @returns The Material if the index has been defined
  21885. */
  21886. getSubMaterial(index: number): Nullable<Material>;
  21887. /**
  21888. * Get the list of active textures for the whole sub materials list.
  21889. * @returns All the textures that will be used during the rendering
  21890. */
  21891. getActiveTextures(): BaseTexture[];
  21892. /**
  21893. * Gets the current class name of the material e.g. "MultiMaterial"
  21894. * Mainly use in serialization.
  21895. * @returns the class name
  21896. */
  21897. getClassName(): string;
  21898. /**
  21899. * Checks if the material is ready to render the requested sub mesh
  21900. * @param mesh Define the mesh the submesh belongs to
  21901. * @param subMesh Define the sub mesh to look readyness for
  21902. * @param useInstances Define whether or not the material is used with instances
  21903. * @returns true if ready, otherwise false
  21904. */
  21905. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21906. /**
  21907. * Clones the current material and its related sub materials
  21908. * @param name Define the name of the newly cloned material
  21909. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21910. * @returns the cloned material
  21911. */
  21912. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21913. /**
  21914. * Serializes the materials into a JSON representation.
  21915. * @returns the JSON representation
  21916. */
  21917. serialize(): any;
  21918. /**
  21919. * Dispose the material and release its associated resources
  21920. * @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)
  21921. * @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)
  21922. * @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)
  21923. */
  21924. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21925. /**
  21926. * Creates a MultiMaterial from parsed MultiMaterial data.
  21927. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21928. * @param scene defines the hosting scene
  21929. * @returns a new MultiMaterial
  21930. */
  21931. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21932. }
  21933. }
  21934. declare module BABYLON {
  21935. /**
  21936. * Base class for submeshes
  21937. */
  21938. export class BaseSubMesh {
  21939. /** @hidden */
  21940. _materialDefines: Nullable<MaterialDefines>;
  21941. /** @hidden */
  21942. _materialEffect: Nullable<Effect>;
  21943. /** @hidden */
  21944. _effectOverride: Nullable<Effect>;
  21945. /**
  21946. * Gets material defines used by the effect associated to the sub mesh
  21947. */
  21948. get materialDefines(): Nullable<MaterialDefines>;
  21949. /**
  21950. * Sets material defines used by the effect associated to the sub mesh
  21951. */
  21952. set materialDefines(defines: Nullable<MaterialDefines>);
  21953. /**
  21954. * Gets associated effect
  21955. */
  21956. get effect(): Nullable<Effect>;
  21957. /**
  21958. * Sets associated effect (effect used to render this submesh)
  21959. * @param effect defines the effect to associate with
  21960. * @param defines defines the set of defines used to compile this effect
  21961. */
  21962. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21963. }
  21964. /**
  21965. * Defines a subdivision inside a mesh
  21966. */
  21967. export class SubMesh extends BaseSubMesh implements ICullable {
  21968. /** the material index to use */
  21969. materialIndex: number;
  21970. /** vertex index start */
  21971. verticesStart: number;
  21972. /** vertices count */
  21973. verticesCount: number;
  21974. /** index start */
  21975. indexStart: number;
  21976. /** indices count */
  21977. indexCount: number;
  21978. /** @hidden */
  21979. _linesIndexCount: number;
  21980. private _mesh;
  21981. private _renderingMesh;
  21982. private _boundingInfo;
  21983. private _linesIndexBuffer;
  21984. /** @hidden */
  21985. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21986. /** @hidden */
  21987. _trianglePlanes: Plane[];
  21988. /** @hidden */
  21989. _lastColliderTransformMatrix: Nullable<Matrix>;
  21990. /** @hidden */
  21991. _renderId: number;
  21992. /** @hidden */
  21993. _alphaIndex: number;
  21994. /** @hidden */
  21995. _distanceToCamera: number;
  21996. /** @hidden */
  21997. _id: number;
  21998. private _currentMaterial;
  21999. /**
  22000. * Add a new submesh to a mesh
  22001. * @param materialIndex defines the material index to use
  22002. * @param verticesStart defines vertex index start
  22003. * @param verticesCount defines vertices count
  22004. * @param indexStart defines index start
  22005. * @param indexCount defines indices count
  22006. * @param mesh defines the parent mesh
  22007. * @param renderingMesh defines an optional rendering mesh
  22008. * @param createBoundingBox defines if bounding box should be created for this submesh
  22009. * @returns the new submesh
  22010. */
  22011. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22012. /**
  22013. * Creates a new submesh
  22014. * @param materialIndex defines the material index to use
  22015. * @param verticesStart defines vertex index start
  22016. * @param verticesCount defines vertices count
  22017. * @param indexStart defines index start
  22018. * @param indexCount defines indices count
  22019. * @param mesh defines the parent mesh
  22020. * @param renderingMesh defines an optional rendering mesh
  22021. * @param createBoundingBox defines if bounding box should be created for this submesh
  22022. */
  22023. constructor(
  22024. /** the material index to use */
  22025. materialIndex: number,
  22026. /** vertex index start */
  22027. verticesStart: number,
  22028. /** vertices count */
  22029. verticesCount: number,
  22030. /** index start */
  22031. indexStart: number,
  22032. /** indices count */
  22033. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22034. /**
  22035. * Returns true if this submesh covers the entire parent mesh
  22036. * @ignorenaming
  22037. */
  22038. get IsGlobal(): boolean;
  22039. /**
  22040. * Returns the submesh BoudingInfo object
  22041. * @returns current bounding info (or mesh's one if the submesh is global)
  22042. */
  22043. getBoundingInfo(): BoundingInfo;
  22044. /**
  22045. * Sets the submesh BoundingInfo
  22046. * @param boundingInfo defines the new bounding info to use
  22047. * @returns the SubMesh
  22048. */
  22049. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22050. /**
  22051. * Returns the mesh of the current submesh
  22052. * @return the parent mesh
  22053. */
  22054. getMesh(): AbstractMesh;
  22055. /**
  22056. * Returns the rendering mesh of the submesh
  22057. * @returns the rendering mesh (could be different from parent mesh)
  22058. */
  22059. getRenderingMesh(): Mesh;
  22060. /**
  22061. * Returns the submesh material
  22062. * @returns null or the current material
  22063. */
  22064. getMaterial(): Nullable<Material>;
  22065. /**
  22066. * Sets a new updated BoundingInfo object to the submesh
  22067. * @param data defines an optional position array to use to determine the bounding info
  22068. * @returns the SubMesh
  22069. */
  22070. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22071. /** @hidden */
  22072. _checkCollision(collider: Collider): boolean;
  22073. /**
  22074. * Updates the submesh BoundingInfo
  22075. * @param world defines the world matrix to use to update the bounding info
  22076. * @returns the submesh
  22077. */
  22078. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22079. /**
  22080. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22081. * @param frustumPlanes defines the frustum planes
  22082. * @returns true if the submesh is intersecting with the frustum
  22083. */
  22084. isInFrustum(frustumPlanes: Plane[]): boolean;
  22085. /**
  22086. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22087. * @param frustumPlanes defines the frustum planes
  22088. * @returns true if the submesh is inside the frustum
  22089. */
  22090. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22091. /**
  22092. * Renders the submesh
  22093. * @param enableAlphaMode defines if alpha needs to be used
  22094. * @returns the submesh
  22095. */
  22096. render(enableAlphaMode: boolean): SubMesh;
  22097. /**
  22098. * @hidden
  22099. */
  22100. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22101. /**
  22102. * Checks if the submesh intersects with a ray
  22103. * @param ray defines the ray to test
  22104. * @returns true is the passed ray intersects the submesh bounding box
  22105. */
  22106. canIntersects(ray: Ray): boolean;
  22107. /**
  22108. * Intersects current submesh with a ray
  22109. * @param ray defines the ray to test
  22110. * @param positions defines mesh's positions array
  22111. * @param indices defines mesh's indices array
  22112. * @param fastCheck defines if the first intersection will be used (and not the closest)
  22113. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22114. * @returns intersection info or null if no intersection
  22115. */
  22116. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22117. /** @hidden */
  22118. private _intersectLines;
  22119. /** @hidden */
  22120. private _intersectUnIndexedLines;
  22121. /** @hidden */
  22122. private _intersectTriangles;
  22123. /** @hidden */
  22124. private _intersectUnIndexedTriangles;
  22125. /** @hidden */
  22126. _rebuild(): void;
  22127. /**
  22128. * Creates a new submesh from the passed mesh
  22129. * @param newMesh defines the new hosting mesh
  22130. * @param newRenderingMesh defines an optional rendering mesh
  22131. * @returns the new submesh
  22132. */
  22133. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22134. /**
  22135. * Release associated resources
  22136. */
  22137. dispose(): void;
  22138. /**
  22139. * Gets the class name
  22140. * @returns the string "SubMesh".
  22141. */
  22142. getClassName(): string;
  22143. /**
  22144. * Creates a new submesh from indices data
  22145. * @param materialIndex the index of the main mesh material
  22146. * @param startIndex the index where to start the copy in the mesh indices array
  22147. * @param indexCount the number of indices to copy then from the startIndex
  22148. * @param mesh the main mesh to create the submesh from
  22149. * @param renderingMesh the optional rendering mesh
  22150. * @returns a new submesh
  22151. */
  22152. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22153. }
  22154. }
  22155. declare module BABYLON {
  22156. /**
  22157. * Class used to represent data loading progression
  22158. */
  22159. export class SceneLoaderFlags {
  22160. private static _ForceFullSceneLoadingForIncremental;
  22161. private static _ShowLoadingScreen;
  22162. private static _CleanBoneMatrixWeights;
  22163. private static _loggingLevel;
  22164. /**
  22165. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22166. */
  22167. static get ForceFullSceneLoadingForIncremental(): boolean;
  22168. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22169. /**
  22170. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22171. */
  22172. static get ShowLoadingScreen(): boolean;
  22173. static set ShowLoadingScreen(value: boolean);
  22174. /**
  22175. * Defines the current logging level (while loading the scene)
  22176. * @ignorenaming
  22177. */
  22178. static get loggingLevel(): number;
  22179. static set loggingLevel(value: number);
  22180. /**
  22181. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22182. */
  22183. static get CleanBoneMatrixWeights(): boolean;
  22184. static set CleanBoneMatrixWeights(value: boolean);
  22185. }
  22186. }
  22187. declare module BABYLON {
  22188. /**
  22189. * Class used to store geometry data (vertex buffers + index buffer)
  22190. */
  22191. export class Geometry implements IGetSetVerticesData {
  22192. /**
  22193. * Gets or sets the ID of the geometry
  22194. */
  22195. id: string;
  22196. /**
  22197. * Gets or sets the unique ID of the geometry
  22198. */
  22199. uniqueId: number;
  22200. /**
  22201. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22202. */
  22203. delayLoadState: number;
  22204. /**
  22205. * Gets the file containing the data to load when running in delay load state
  22206. */
  22207. delayLoadingFile: Nullable<string>;
  22208. /**
  22209. * Callback called when the geometry is updated
  22210. */
  22211. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22212. private _scene;
  22213. private _engine;
  22214. private _meshes;
  22215. private _totalVertices;
  22216. /** @hidden */
  22217. _indices: IndicesArray;
  22218. /** @hidden */
  22219. _vertexBuffers: {
  22220. [key: string]: VertexBuffer;
  22221. };
  22222. private _isDisposed;
  22223. private _extend;
  22224. private _boundingBias;
  22225. /** @hidden */
  22226. _delayInfo: Array<string>;
  22227. private _indexBuffer;
  22228. private _indexBufferIsUpdatable;
  22229. /** @hidden */
  22230. _boundingInfo: Nullable<BoundingInfo>;
  22231. /** @hidden */
  22232. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22233. /** @hidden */
  22234. _softwareSkinningFrameId: number;
  22235. private _vertexArrayObjects;
  22236. private _updatable;
  22237. /** @hidden */
  22238. _positions: Nullable<Vector3[]>;
  22239. /**
  22240. * 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
  22241. */
  22242. get boundingBias(): Vector2;
  22243. /**
  22244. * 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
  22245. */
  22246. set boundingBias(value: Vector2);
  22247. /**
  22248. * Static function used to attach a new empty geometry to a mesh
  22249. * @param mesh defines the mesh to attach the geometry to
  22250. * @returns the new Geometry
  22251. */
  22252. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22253. /** Get the list of meshes using this geometry */
  22254. get meshes(): Mesh[];
  22255. /**
  22256. * Creates a new geometry
  22257. * @param id defines the unique ID
  22258. * @param scene defines the hosting scene
  22259. * @param vertexData defines the VertexData used to get geometry data
  22260. * @param updatable defines if geometry must be updatable (false by default)
  22261. * @param mesh defines the mesh that will be associated with the geometry
  22262. */
  22263. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22264. /**
  22265. * Gets the current extend of the geometry
  22266. */
  22267. get extend(): {
  22268. minimum: Vector3;
  22269. maximum: Vector3;
  22270. };
  22271. /**
  22272. * Gets the hosting scene
  22273. * @returns the hosting Scene
  22274. */
  22275. getScene(): Scene;
  22276. /**
  22277. * Gets the hosting engine
  22278. * @returns the hosting Engine
  22279. */
  22280. getEngine(): Engine;
  22281. /**
  22282. * Defines if the geometry is ready to use
  22283. * @returns true if the geometry is ready to be used
  22284. */
  22285. isReady(): boolean;
  22286. /**
  22287. * Gets a value indicating that the geometry should not be serialized
  22288. */
  22289. get doNotSerialize(): boolean;
  22290. /** @hidden */
  22291. _rebuild(): void;
  22292. /**
  22293. * Affects all geometry data in one call
  22294. * @param vertexData defines the geometry data
  22295. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22296. */
  22297. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22298. /**
  22299. * Set specific vertex data
  22300. * @param kind defines the data kind (Position, normal, etc...)
  22301. * @param data defines the vertex data to use
  22302. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22303. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22304. */
  22305. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22306. /**
  22307. * Removes a specific vertex data
  22308. * @param kind defines the data kind (Position, normal, etc...)
  22309. */
  22310. removeVerticesData(kind: string): void;
  22311. /**
  22312. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22313. * @param buffer defines the vertex buffer to use
  22314. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22315. */
  22316. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22317. /**
  22318. * Update a specific vertex buffer
  22319. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22320. * It will do nothing if the buffer is not updatable
  22321. * @param kind defines the data kind (Position, normal, etc...)
  22322. * @param data defines the data to use
  22323. * @param offset defines the offset in the target buffer where to store the data
  22324. * @param useBytes set to true if the offset is in bytes
  22325. */
  22326. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22327. /**
  22328. * Update a specific vertex buffer
  22329. * This function will create a new buffer if the current one is not updatable
  22330. * @param kind defines the data kind (Position, normal, etc...)
  22331. * @param data defines the data to use
  22332. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22333. */
  22334. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22335. private _updateBoundingInfo;
  22336. /** @hidden */
  22337. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22338. /**
  22339. * Gets total number of vertices
  22340. * @returns the total number of vertices
  22341. */
  22342. getTotalVertices(): number;
  22343. /**
  22344. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22345. * @param kind defines the data kind (Position, normal, etc...)
  22346. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22347. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22348. * @returns a float array containing vertex data
  22349. */
  22350. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22351. /**
  22352. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22353. * @param kind defines the data kind (Position, normal, etc...)
  22354. * @returns true if the vertex buffer with the specified kind is updatable
  22355. */
  22356. isVertexBufferUpdatable(kind: string): boolean;
  22357. /**
  22358. * Gets a specific vertex buffer
  22359. * @param kind defines the data kind (Position, normal, etc...)
  22360. * @returns a VertexBuffer
  22361. */
  22362. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22363. /**
  22364. * Returns all vertex buffers
  22365. * @return an object holding all vertex buffers indexed by kind
  22366. */
  22367. getVertexBuffers(): Nullable<{
  22368. [key: string]: VertexBuffer;
  22369. }>;
  22370. /**
  22371. * Gets a boolean indicating if specific vertex buffer is present
  22372. * @param kind defines the data kind (Position, normal, etc...)
  22373. * @returns true if data is present
  22374. */
  22375. isVerticesDataPresent(kind: string): boolean;
  22376. /**
  22377. * Gets a list of all attached data kinds (Position, normal, etc...)
  22378. * @returns a list of string containing all kinds
  22379. */
  22380. getVerticesDataKinds(): string[];
  22381. /**
  22382. * Update index buffer
  22383. * @param indices defines the indices to store in the index buffer
  22384. * @param offset defines the offset in the target buffer where to store the data
  22385. * @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)
  22386. */
  22387. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22388. /**
  22389. * Creates a new index buffer
  22390. * @param indices defines the indices to store in the index buffer
  22391. * @param totalVertices defines the total number of vertices (could be null)
  22392. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22393. */
  22394. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22395. /**
  22396. * Return the total number of indices
  22397. * @returns the total number of indices
  22398. */
  22399. getTotalIndices(): number;
  22400. /**
  22401. * Gets the index buffer array
  22402. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22403. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22404. * @returns the index buffer array
  22405. */
  22406. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22407. /**
  22408. * Gets the index buffer
  22409. * @return the index buffer
  22410. */
  22411. getIndexBuffer(): Nullable<DataBuffer>;
  22412. /** @hidden */
  22413. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22414. /**
  22415. * Release the associated resources for a specific mesh
  22416. * @param mesh defines the source mesh
  22417. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22418. */
  22419. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22420. /**
  22421. * Apply current geometry to a given mesh
  22422. * @param mesh defines the mesh to apply geometry to
  22423. */
  22424. applyToMesh(mesh: Mesh): void;
  22425. private _updateExtend;
  22426. private _applyToMesh;
  22427. private notifyUpdate;
  22428. /**
  22429. * Load the geometry if it was flagged as delay loaded
  22430. * @param scene defines the hosting scene
  22431. * @param onLoaded defines a callback called when the geometry is loaded
  22432. */
  22433. load(scene: Scene, onLoaded?: () => void): void;
  22434. private _queueLoad;
  22435. /**
  22436. * Invert the geometry to move from a right handed system to a left handed one.
  22437. */
  22438. toLeftHanded(): void;
  22439. /** @hidden */
  22440. _resetPointsArrayCache(): void;
  22441. /** @hidden */
  22442. _generatePointsArray(): boolean;
  22443. /**
  22444. * Gets a value indicating if the geometry is disposed
  22445. * @returns true if the geometry was disposed
  22446. */
  22447. isDisposed(): boolean;
  22448. private _disposeVertexArrayObjects;
  22449. /**
  22450. * Free all associated resources
  22451. */
  22452. dispose(): void;
  22453. /**
  22454. * Clone the current geometry into a new geometry
  22455. * @param id defines the unique ID of the new geometry
  22456. * @returns a new geometry object
  22457. */
  22458. copy(id: string): Geometry;
  22459. /**
  22460. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22461. * @return a JSON representation of the current geometry data (without the vertices data)
  22462. */
  22463. serialize(): any;
  22464. private toNumberArray;
  22465. /**
  22466. * Serialize all vertices data into a JSON oject
  22467. * @returns a JSON representation of the current geometry data
  22468. */
  22469. serializeVerticeData(): any;
  22470. /**
  22471. * Extracts a clone of a mesh geometry
  22472. * @param mesh defines the source mesh
  22473. * @param id defines the unique ID of the new geometry object
  22474. * @returns the new geometry object
  22475. */
  22476. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22477. /**
  22478. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22479. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22480. * Be aware Math.random() could cause collisions, but:
  22481. * "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"
  22482. * @returns a string containing a new GUID
  22483. */
  22484. static RandomId(): string;
  22485. /** @hidden */
  22486. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22487. private static _CleanMatricesWeights;
  22488. /**
  22489. * Create a new geometry from persisted data (Using .babylon file format)
  22490. * @param parsedVertexData defines the persisted data
  22491. * @param scene defines the hosting scene
  22492. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22493. * @returns the new geometry object
  22494. */
  22495. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22496. }
  22497. }
  22498. declare module BABYLON {
  22499. /**
  22500. * Define an interface for all classes that will get and set the data on vertices
  22501. */
  22502. export interface IGetSetVerticesData {
  22503. /**
  22504. * Gets a boolean indicating if specific vertex data is present
  22505. * @param kind defines the vertex data kind to use
  22506. * @returns true is data kind is present
  22507. */
  22508. isVerticesDataPresent(kind: string): boolean;
  22509. /**
  22510. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22511. * @param kind defines the data kind (Position, normal, etc...)
  22512. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22513. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22514. * @returns a float array containing vertex data
  22515. */
  22516. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22517. /**
  22518. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22519. * @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.
  22520. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22521. * @returns the indices array or an empty array if the mesh has no geometry
  22522. */
  22523. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22524. /**
  22525. * Set specific vertex data
  22526. * @param kind defines the data kind (Position, normal, etc...)
  22527. * @param data defines the vertex data to use
  22528. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22529. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22530. */
  22531. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22532. /**
  22533. * Update a specific associated vertex buffer
  22534. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22535. * - VertexBuffer.PositionKind
  22536. * - VertexBuffer.UVKind
  22537. * - VertexBuffer.UV2Kind
  22538. * - VertexBuffer.UV3Kind
  22539. * - VertexBuffer.UV4Kind
  22540. * - VertexBuffer.UV5Kind
  22541. * - VertexBuffer.UV6Kind
  22542. * - VertexBuffer.ColorKind
  22543. * - VertexBuffer.MatricesIndicesKind
  22544. * - VertexBuffer.MatricesIndicesExtraKind
  22545. * - VertexBuffer.MatricesWeightsKind
  22546. * - VertexBuffer.MatricesWeightsExtraKind
  22547. * @param data defines the data source
  22548. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22549. * @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)
  22550. */
  22551. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22552. /**
  22553. * Creates a new index buffer
  22554. * @param indices defines the indices to store in the index buffer
  22555. * @param totalVertices defines the total number of vertices (could be null)
  22556. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22557. */
  22558. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22559. }
  22560. /**
  22561. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22562. */
  22563. export class VertexData {
  22564. /**
  22565. * Mesh side orientation : usually the external or front surface
  22566. */
  22567. static readonly FRONTSIDE: number;
  22568. /**
  22569. * Mesh side orientation : usually the internal or back surface
  22570. */
  22571. static readonly BACKSIDE: number;
  22572. /**
  22573. * Mesh side orientation : both internal and external or front and back surfaces
  22574. */
  22575. static readonly DOUBLESIDE: number;
  22576. /**
  22577. * Mesh side orientation : by default, `FRONTSIDE`
  22578. */
  22579. static readonly DEFAULTSIDE: number;
  22580. /**
  22581. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22582. */
  22583. positions: Nullable<FloatArray>;
  22584. /**
  22585. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22586. */
  22587. normals: Nullable<FloatArray>;
  22588. /**
  22589. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22590. */
  22591. tangents: Nullable<FloatArray>;
  22592. /**
  22593. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22594. */
  22595. uvs: Nullable<FloatArray>;
  22596. /**
  22597. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22598. */
  22599. uvs2: Nullable<FloatArray>;
  22600. /**
  22601. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22602. */
  22603. uvs3: Nullable<FloatArray>;
  22604. /**
  22605. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22606. */
  22607. uvs4: Nullable<FloatArray>;
  22608. /**
  22609. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22610. */
  22611. uvs5: Nullable<FloatArray>;
  22612. /**
  22613. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22614. */
  22615. uvs6: Nullable<FloatArray>;
  22616. /**
  22617. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22618. */
  22619. colors: Nullable<FloatArray>;
  22620. /**
  22621. * 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).
  22622. */
  22623. matricesIndices: Nullable<FloatArray>;
  22624. /**
  22625. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22626. */
  22627. matricesWeights: Nullable<FloatArray>;
  22628. /**
  22629. * An array extending the number of possible indices
  22630. */
  22631. matricesIndicesExtra: Nullable<FloatArray>;
  22632. /**
  22633. * An array extending the number of possible weights when the number of indices is extended
  22634. */
  22635. matricesWeightsExtra: Nullable<FloatArray>;
  22636. /**
  22637. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22638. */
  22639. indices: Nullable<IndicesArray>;
  22640. /**
  22641. * Uses the passed data array to set the set the values for the specified kind of data
  22642. * @param data a linear array of floating numbers
  22643. * @param kind the type of data that is being set, eg positions, colors etc
  22644. */
  22645. set(data: FloatArray, kind: string): void;
  22646. /**
  22647. * Associates the vertexData to the passed Mesh.
  22648. * Sets it as updatable or not (default `false`)
  22649. * @param mesh the mesh the vertexData is applied to
  22650. * @param updatable when used and having the value true allows new data to update the vertexData
  22651. * @returns the VertexData
  22652. */
  22653. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22654. /**
  22655. * Associates the vertexData to the passed Geometry.
  22656. * Sets it as updatable or not (default `false`)
  22657. * @param geometry the geometry the vertexData is applied to
  22658. * @param updatable when used and having the value true allows new data to update the vertexData
  22659. * @returns VertexData
  22660. */
  22661. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22662. /**
  22663. * Updates the associated mesh
  22664. * @param mesh the mesh to be updated
  22665. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22666. * @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
  22667. * @returns VertexData
  22668. */
  22669. updateMesh(mesh: Mesh): VertexData;
  22670. /**
  22671. * Updates the associated geometry
  22672. * @param geometry the geometry to be updated
  22673. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22674. * @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
  22675. * @returns VertexData.
  22676. */
  22677. updateGeometry(geometry: Geometry): VertexData;
  22678. private _applyTo;
  22679. private _update;
  22680. /**
  22681. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22682. * @param matrix the transforming matrix
  22683. * @returns the VertexData
  22684. */
  22685. transform(matrix: Matrix): VertexData;
  22686. /**
  22687. * Merges the passed VertexData into the current one
  22688. * @param other the VertexData to be merged into the current one
  22689. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22690. * @returns the modified VertexData
  22691. */
  22692. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22693. private _mergeElement;
  22694. private _validate;
  22695. /**
  22696. * Serializes the VertexData
  22697. * @returns a serialized object
  22698. */
  22699. serialize(): any;
  22700. /**
  22701. * Extracts the vertexData from a mesh
  22702. * @param mesh the mesh from which to extract the VertexData
  22703. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22704. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22705. * @returns the object VertexData associated to the passed mesh
  22706. */
  22707. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22708. /**
  22709. * Extracts the vertexData from the geometry
  22710. * @param geometry the geometry from which to extract the VertexData
  22711. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22712. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22713. * @returns the object VertexData associated to the passed mesh
  22714. */
  22715. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22716. private static _ExtractFrom;
  22717. /**
  22718. * Creates the VertexData for a Ribbon
  22719. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22720. * * pathArray array of paths, each of which an array of successive Vector3
  22721. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22722. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22723. * * 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
  22724. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22725. * * 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)
  22726. * * 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)
  22727. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22728. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22729. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22730. * @returns the VertexData of the ribbon
  22731. */
  22732. static CreateRibbon(options: {
  22733. pathArray: Vector3[][];
  22734. closeArray?: boolean;
  22735. closePath?: boolean;
  22736. offset?: number;
  22737. sideOrientation?: number;
  22738. frontUVs?: Vector4;
  22739. backUVs?: Vector4;
  22740. invertUV?: boolean;
  22741. uvs?: Vector2[];
  22742. colors?: Color4[];
  22743. }): VertexData;
  22744. /**
  22745. * Creates the VertexData for a box
  22746. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22747. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22748. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22749. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22750. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22751. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22752. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22753. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22754. * * 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)
  22755. * * 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)
  22756. * @returns the VertexData of the box
  22757. */
  22758. static CreateBox(options: {
  22759. size?: number;
  22760. width?: number;
  22761. height?: number;
  22762. depth?: number;
  22763. faceUV?: Vector4[];
  22764. faceColors?: Color4[];
  22765. sideOrientation?: number;
  22766. frontUVs?: Vector4;
  22767. backUVs?: Vector4;
  22768. }): VertexData;
  22769. /**
  22770. * Creates the VertexData for a tiled box
  22771. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22772. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22773. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22774. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22775. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22776. * @returns the VertexData of the box
  22777. */
  22778. static CreateTiledBox(options: {
  22779. pattern?: number;
  22780. width?: number;
  22781. height?: number;
  22782. depth?: number;
  22783. tileSize?: number;
  22784. tileWidth?: number;
  22785. tileHeight?: number;
  22786. alignHorizontal?: number;
  22787. alignVertical?: number;
  22788. faceUV?: Vector4[];
  22789. faceColors?: Color4[];
  22790. sideOrientation?: number;
  22791. }): VertexData;
  22792. /**
  22793. * Creates the VertexData for a tiled plane
  22794. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22795. * * pattern a limited pattern arrangement depending on the number
  22796. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22797. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22798. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22800. * * 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)
  22801. * * 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)
  22802. * @returns the VertexData of the tiled plane
  22803. */
  22804. static CreateTiledPlane(options: {
  22805. pattern?: number;
  22806. tileSize?: number;
  22807. tileWidth?: number;
  22808. tileHeight?: number;
  22809. size?: number;
  22810. width?: number;
  22811. height?: number;
  22812. alignHorizontal?: number;
  22813. alignVertical?: number;
  22814. sideOrientation?: number;
  22815. frontUVs?: Vector4;
  22816. backUVs?: Vector4;
  22817. }): VertexData;
  22818. /**
  22819. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22820. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22821. * * segments sets the number of horizontal strips optional, default 32
  22822. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22823. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22824. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22825. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22826. * * 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
  22827. * * 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
  22828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22829. * * 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)
  22830. * * 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)
  22831. * @returns the VertexData of the ellipsoid
  22832. */
  22833. static CreateSphere(options: {
  22834. segments?: number;
  22835. diameter?: number;
  22836. diameterX?: number;
  22837. diameterY?: number;
  22838. diameterZ?: number;
  22839. arc?: number;
  22840. slice?: number;
  22841. sideOrientation?: number;
  22842. frontUVs?: Vector4;
  22843. backUVs?: Vector4;
  22844. }): VertexData;
  22845. /**
  22846. * Creates the VertexData for a cylinder, cone or prism
  22847. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22848. * * height sets the height (y direction) of the cylinder, optional, default 2
  22849. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22850. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22851. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22852. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22853. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22854. * * 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
  22855. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22856. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22857. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22858. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22859. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22860. * * 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)
  22861. * * 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)
  22862. * @returns the VertexData of the cylinder, cone or prism
  22863. */
  22864. static CreateCylinder(options: {
  22865. height?: number;
  22866. diameterTop?: number;
  22867. diameterBottom?: number;
  22868. diameter?: number;
  22869. tessellation?: number;
  22870. subdivisions?: number;
  22871. arc?: number;
  22872. faceColors?: Color4[];
  22873. faceUV?: Vector4[];
  22874. hasRings?: boolean;
  22875. enclose?: boolean;
  22876. sideOrientation?: number;
  22877. frontUVs?: Vector4;
  22878. backUVs?: Vector4;
  22879. }): VertexData;
  22880. /**
  22881. * Creates the VertexData for a torus
  22882. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22883. * * diameter the diameter of the torus, optional default 1
  22884. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22885. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22886. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22887. * * 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)
  22888. * * 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)
  22889. * @returns the VertexData of the torus
  22890. */
  22891. static CreateTorus(options: {
  22892. diameter?: number;
  22893. thickness?: number;
  22894. tessellation?: number;
  22895. sideOrientation?: number;
  22896. frontUVs?: Vector4;
  22897. backUVs?: Vector4;
  22898. }): VertexData;
  22899. /**
  22900. * Creates the VertexData of the LineSystem
  22901. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22902. * - lines an array of lines, each line being an array of successive Vector3
  22903. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22904. * @returns the VertexData of the LineSystem
  22905. */
  22906. static CreateLineSystem(options: {
  22907. lines: Vector3[][];
  22908. colors?: Nullable<Color4[][]>;
  22909. }): VertexData;
  22910. /**
  22911. * Create the VertexData for a DashedLines
  22912. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22913. * - points an array successive Vector3
  22914. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22915. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22916. * - dashNb the intended total number of dashes, optional, default 200
  22917. * @returns the VertexData for the DashedLines
  22918. */
  22919. static CreateDashedLines(options: {
  22920. points: Vector3[];
  22921. dashSize?: number;
  22922. gapSize?: number;
  22923. dashNb?: number;
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for a Ground
  22927. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22928. * - width the width (x direction) of the ground, optional, default 1
  22929. * - height the height (z direction) of the ground, optional, default 1
  22930. * - subdivisions the number of subdivisions per side, optional, default 1
  22931. * @returns the VertexData of the Ground
  22932. */
  22933. static CreateGround(options: {
  22934. width?: number;
  22935. height?: number;
  22936. subdivisions?: number;
  22937. subdivisionsX?: number;
  22938. subdivisionsY?: number;
  22939. }): VertexData;
  22940. /**
  22941. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22942. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22943. * * xmin the ground minimum X coordinate, optional, default -1
  22944. * * zmin the ground minimum Z coordinate, optional, default -1
  22945. * * xmax the ground maximum X coordinate, optional, default 1
  22946. * * zmax the ground maximum Z coordinate, optional, default 1
  22947. * * 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}
  22948. * * 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}
  22949. * @returns the VertexData of the TiledGround
  22950. */
  22951. static CreateTiledGround(options: {
  22952. xmin: number;
  22953. zmin: number;
  22954. xmax: number;
  22955. zmax: number;
  22956. subdivisions?: {
  22957. w: number;
  22958. h: number;
  22959. };
  22960. precision?: {
  22961. w: number;
  22962. h: number;
  22963. };
  22964. }): VertexData;
  22965. /**
  22966. * Creates the VertexData of the Ground designed from a heightmap
  22967. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22968. * * width the width (x direction) of the ground
  22969. * * height the height (z direction) of the ground
  22970. * * subdivisions the number of subdivisions per side
  22971. * * minHeight the minimum altitude on the ground, optional, default 0
  22972. * * maxHeight the maximum altitude on the ground, optional default 1
  22973. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22974. * * buffer the array holding the image color data
  22975. * * bufferWidth the width of image
  22976. * * bufferHeight the height of image
  22977. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22978. * @returns the VertexData of the Ground designed from a heightmap
  22979. */
  22980. static CreateGroundFromHeightMap(options: {
  22981. width: number;
  22982. height: number;
  22983. subdivisions: number;
  22984. minHeight: number;
  22985. maxHeight: number;
  22986. colorFilter: Color3;
  22987. buffer: Uint8Array;
  22988. bufferWidth: number;
  22989. bufferHeight: number;
  22990. alphaFilter: number;
  22991. }): VertexData;
  22992. /**
  22993. * Creates the VertexData for a Plane
  22994. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22995. * * size sets the width and height of the plane to the value of size, optional default 1
  22996. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22997. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22998. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22999. * * 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)
  23000. * * 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)
  23001. * @returns the VertexData of the box
  23002. */
  23003. static CreatePlane(options: {
  23004. size?: number;
  23005. width?: number;
  23006. height?: number;
  23007. sideOrientation?: number;
  23008. frontUVs?: Vector4;
  23009. backUVs?: Vector4;
  23010. }): VertexData;
  23011. /**
  23012. * Creates the VertexData of the Disc or regular Polygon
  23013. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23014. * * radius the radius of the disc, optional default 0.5
  23015. * * tessellation the number of polygon sides, optional, default 64
  23016. * * 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
  23017. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23018. * * 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)
  23019. * * 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)
  23020. * @returns the VertexData of the box
  23021. */
  23022. static CreateDisc(options: {
  23023. radius?: number;
  23024. tessellation?: number;
  23025. arc?: number;
  23026. sideOrientation?: number;
  23027. frontUVs?: Vector4;
  23028. backUVs?: Vector4;
  23029. }): VertexData;
  23030. /**
  23031. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23032. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23033. * @param polygon a mesh built from polygonTriangulation.build()
  23034. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23035. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23036. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23037. * @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)
  23038. * @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)
  23039. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  23040. * @returns the VertexData of the Polygon
  23041. */
  23042. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  23043. /**
  23044. * Creates the VertexData of the IcoSphere
  23045. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23046. * * radius the radius of the IcoSphere, optional default 1
  23047. * * radiusX allows stretching in the x direction, optional, default radius
  23048. * * radiusY allows stretching in the y direction, optional, default radius
  23049. * * radiusZ allows stretching in the z direction, optional, default radius
  23050. * * flat when true creates a flat shaded mesh, optional, default true
  23051. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23052. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23053. * * 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)
  23054. * * 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)
  23055. * @returns the VertexData of the IcoSphere
  23056. */
  23057. static CreateIcoSphere(options: {
  23058. radius?: number;
  23059. radiusX?: number;
  23060. radiusY?: number;
  23061. radiusZ?: number;
  23062. flat?: boolean;
  23063. subdivisions?: number;
  23064. sideOrientation?: number;
  23065. frontUVs?: Vector4;
  23066. backUVs?: Vector4;
  23067. }): VertexData;
  23068. /**
  23069. * Creates the VertexData for a Polyhedron
  23070. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23071. * * type provided types are:
  23072. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23073. * * 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)
  23074. * * size the size of the IcoSphere, optional default 1
  23075. * * sizeX allows stretching in the x direction, optional, default size
  23076. * * sizeY allows stretching in the y direction, optional, default size
  23077. * * sizeZ allows stretching in the z direction, optional, default size
  23078. * * 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
  23079. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23080. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23081. * * flat when true creates a flat shaded mesh, optional, default true
  23082. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23084. * * 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)
  23085. * * 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)
  23086. * @returns the VertexData of the Polyhedron
  23087. */
  23088. static CreatePolyhedron(options: {
  23089. type?: number;
  23090. size?: number;
  23091. sizeX?: number;
  23092. sizeY?: number;
  23093. sizeZ?: number;
  23094. custom?: any;
  23095. faceUV?: Vector4[];
  23096. faceColors?: Color4[];
  23097. flat?: boolean;
  23098. sideOrientation?: number;
  23099. frontUVs?: Vector4;
  23100. backUVs?: Vector4;
  23101. }): VertexData;
  23102. /**
  23103. * Creates the VertexData for a TorusKnot
  23104. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23105. * * radius the radius of the torus knot, optional, default 2
  23106. * * tube the thickness of the tube, optional, default 0.5
  23107. * * radialSegments the number of sides on each tube segments, optional, default 32
  23108. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23109. * * p the number of windings around the z axis, optional, default 2
  23110. * * q the number of windings around the x axis, optional, default 3
  23111. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23112. * * 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)
  23113. * * 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)
  23114. * @returns the VertexData of the Torus Knot
  23115. */
  23116. static CreateTorusKnot(options: {
  23117. radius?: number;
  23118. tube?: number;
  23119. radialSegments?: number;
  23120. tubularSegments?: number;
  23121. p?: number;
  23122. q?: number;
  23123. sideOrientation?: number;
  23124. frontUVs?: Vector4;
  23125. backUVs?: Vector4;
  23126. }): VertexData;
  23127. /**
  23128. * Compute normals for given positions and indices
  23129. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23130. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23131. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23132. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23133. * * facetNormals : optional array of facet normals (vector3)
  23134. * * facetPositions : optional array of facet positions (vector3)
  23135. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23136. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23137. * * bInfo : optional bounding info, required for facetPartitioning computation
  23138. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23139. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23140. * * useRightHandedSystem: optional boolean to for right handed system computation
  23141. * * depthSort : optional boolean to enable the facet depth sort computation
  23142. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23143. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23144. */
  23145. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23146. facetNormals?: any;
  23147. facetPositions?: any;
  23148. facetPartitioning?: any;
  23149. ratio?: number;
  23150. bInfo?: any;
  23151. bbSize?: Vector3;
  23152. subDiv?: any;
  23153. useRightHandedSystem?: boolean;
  23154. depthSort?: boolean;
  23155. distanceTo?: Vector3;
  23156. depthSortedFacets?: any;
  23157. }): void;
  23158. /** @hidden */
  23159. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23160. /**
  23161. * Applies VertexData created from the imported parameters to the geometry
  23162. * @param parsedVertexData the parsed data from an imported file
  23163. * @param geometry the geometry to apply the VertexData to
  23164. */
  23165. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23166. }
  23167. }
  23168. declare module BABYLON {
  23169. /**
  23170. * Defines a target to use with MorphTargetManager
  23171. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23172. */
  23173. export class MorphTarget implements IAnimatable {
  23174. /** defines the name of the target */
  23175. name: string;
  23176. /**
  23177. * Gets or sets the list of animations
  23178. */
  23179. animations: Animation[];
  23180. private _scene;
  23181. private _positions;
  23182. private _normals;
  23183. private _tangents;
  23184. private _uvs;
  23185. private _influence;
  23186. private _uniqueId;
  23187. /**
  23188. * Observable raised when the influence changes
  23189. */
  23190. onInfluenceChanged: Observable<boolean>;
  23191. /** @hidden */
  23192. _onDataLayoutChanged: Observable<void>;
  23193. /**
  23194. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23195. */
  23196. get influence(): number;
  23197. set influence(influence: number);
  23198. /**
  23199. * Gets or sets the id of the morph Target
  23200. */
  23201. id: string;
  23202. private _animationPropertiesOverride;
  23203. /**
  23204. * Gets or sets the animation properties override
  23205. */
  23206. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23207. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23208. /**
  23209. * Creates a new MorphTarget
  23210. * @param name defines the name of the target
  23211. * @param influence defines the influence to use
  23212. * @param scene defines the scene the morphtarget belongs to
  23213. */
  23214. constructor(
  23215. /** defines the name of the target */
  23216. name: string, influence?: number, scene?: Nullable<Scene>);
  23217. /**
  23218. * Gets the unique ID of this manager
  23219. */
  23220. get uniqueId(): number;
  23221. /**
  23222. * Gets a boolean defining if the target contains position data
  23223. */
  23224. get hasPositions(): boolean;
  23225. /**
  23226. * Gets a boolean defining if the target contains normal data
  23227. */
  23228. get hasNormals(): boolean;
  23229. /**
  23230. * Gets a boolean defining if the target contains tangent data
  23231. */
  23232. get hasTangents(): boolean;
  23233. /**
  23234. * Gets a boolean defining if the target contains texture coordinates data
  23235. */
  23236. get hasUVs(): boolean;
  23237. /**
  23238. * Affects position data to this target
  23239. * @param data defines the position data to use
  23240. */
  23241. setPositions(data: Nullable<FloatArray>): void;
  23242. /**
  23243. * Gets the position data stored in this target
  23244. * @returns a FloatArray containing the position data (or null if not present)
  23245. */
  23246. getPositions(): Nullable<FloatArray>;
  23247. /**
  23248. * Affects normal data to this target
  23249. * @param data defines the normal data to use
  23250. */
  23251. setNormals(data: Nullable<FloatArray>): void;
  23252. /**
  23253. * Gets the normal data stored in this target
  23254. * @returns a FloatArray containing the normal data (or null if not present)
  23255. */
  23256. getNormals(): Nullable<FloatArray>;
  23257. /**
  23258. * Affects tangent data to this target
  23259. * @param data defines the tangent data to use
  23260. */
  23261. setTangents(data: Nullable<FloatArray>): void;
  23262. /**
  23263. * Gets the tangent data stored in this target
  23264. * @returns a FloatArray containing the tangent data (or null if not present)
  23265. */
  23266. getTangents(): Nullable<FloatArray>;
  23267. /**
  23268. * Affects texture coordinates data to this target
  23269. * @param data defines the texture coordinates data to use
  23270. */
  23271. setUVs(data: Nullable<FloatArray>): void;
  23272. /**
  23273. * Gets the texture coordinates data stored in this target
  23274. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23275. */
  23276. getUVs(): Nullable<FloatArray>;
  23277. /**
  23278. * Clone the current target
  23279. * @returns a new MorphTarget
  23280. */
  23281. clone(): MorphTarget;
  23282. /**
  23283. * Serializes the current target into a Serialization object
  23284. * @returns the serialized object
  23285. */
  23286. serialize(): any;
  23287. /**
  23288. * Returns the string "MorphTarget"
  23289. * @returns "MorphTarget"
  23290. */
  23291. getClassName(): string;
  23292. /**
  23293. * Creates a new target from serialized data
  23294. * @param serializationObject defines the serialized data to use
  23295. * @returns a new MorphTarget
  23296. */
  23297. static Parse(serializationObject: any): MorphTarget;
  23298. /**
  23299. * Creates a MorphTarget from mesh data
  23300. * @param mesh defines the source mesh
  23301. * @param name defines the name to use for the new target
  23302. * @param influence defines the influence to attach to the target
  23303. * @returns a new MorphTarget
  23304. */
  23305. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23306. }
  23307. }
  23308. declare module BABYLON {
  23309. /**
  23310. * This class is used to deform meshes using morphing between different targets
  23311. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23312. */
  23313. export class MorphTargetManager {
  23314. private _targets;
  23315. private _targetInfluenceChangedObservers;
  23316. private _targetDataLayoutChangedObservers;
  23317. private _activeTargets;
  23318. private _scene;
  23319. private _influences;
  23320. private _supportsNormals;
  23321. private _supportsTangents;
  23322. private _supportsUVs;
  23323. private _vertexCount;
  23324. private _uniqueId;
  23325. private _tempInfluences;
  23326. /**
  23327. * Gets or sets a boolean indicating if normals must be morphed
  23328. */
  23329. enableNormalMorphing: boolean;
  23330. /**
  23331. * Gets or sets a boolean indicating if tangents must be morphed
  23332. */
  23333. enableTangentMorphing: boolean;
  23334. /**
  23335. * Gets or sets a boolean indicating if UV must be morphed
  23336. */
  23337. enableUVMorphing: boolean;
  23338. /**
  23339. * Creates a new MorphTargetManager
  23340. * @param scene defines the current scene
  23341. */
  23342. constructor(scene?: Nullable<Scene>);
  23343. /**
  23344. * Gets the unique ID of this manager
  23345. */
  23346. get uniqueId(): number;
  23347. /**
  23348. * Gets the number of vertices handled by this manager
  23349. */
  23350. get vertexCount(): number;
  23351. /**
  23352. * Gets a boolean indicating if this manager supports morphing of normals
  23353. */
  23354. get supportsNormals(): boolean;
  23355. /**
  23356. * Gets a boolean indicating if this manager supports morphing of tangents
  23357. */
  23358. get supportsTangents(): boolean;
  23359. /**
  23360. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23361. */
  23362. get supportsUVs(): boolean;
  23363. /**
  23364. * Gets the number of targets stored in this manager
  23365. */
  23366. get numTargets(): number;
  23367. /**
  23368. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23369. */
  23370. get numInfluencers(): number;
  23371. /**
  23372. * Gets the list of influences (one per target)
  23373. */
  23374. get influences(): Float32Array;
  23375. /**
  23376. * Gets the active target at specified index. An active target is a target with an influence > 0
  23377. * @param index defines the index to check
  23378. * @returns the requested target
  23379. */
  23380. getActiveTarget(index: number): MorphTarget;
  23381. /**
  23382. * Gets the target at specified index
  23383. * @param index defines the index to check
  23384. * @returns the requested target
  23385. */
  23386. getTarget(index: number): MorphTarget;
  23387. /**
  23388. * Add a new target to this manager
  23389. * @param target defines the target to add
  23390. */
  23391. addTarget(target: MorphTarget): void;
  23392. /**
  23393. * Removes a target from the manager
  23394. * @param target defines the target to remove
  23395. */
  23396. removeTarget(target: MorphTarget): void;
  23397. /**
  23398. * Clone the current manager
  23399. * @returns a new MorphTargetManager
  23400. */
  23401. clone(): MorphTargetManager;
  23402. /**
  23403. * Serializes the current manager into a Serialization object
  23404. * @returns the serialized object
  23405. */
  23406. serialize(): any;
  23407. private _syncActiveTargets;
  23408. /**
  23409. * Syncrhonize the targets with all the meshes using this morph target manager
  23410. */
  23411. synchronize(): void;
  23412. /**
  23413. * Creates a new MorphTargetManager from serialized data
  23414. * @param serializationObject defines the serialized data
  23415. * @param scene defines the hosting scene
  23416. * @returns the new MorphTargetManager
  23417. */
  23418. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23419. }
  23420. }
  23421. declare module BABYLON {
  23422. /**
  23423. * Class used to represent a specific level of detail of a mesh
  23424. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23425. */
  23426. export class MeshLODLevel {
  23427. /** Defines the distance where this level should start being displayed */
  23428. distance: number;
  23429. /** Defines the mesh to use to render this level */
  23430. mesh: Nullable<Mesh>;
  23431. /**
  23432. * Creates a new LOD level
  23433. * @param distance defines the distance where this level should star being displayed
  23434. * @param mesh defines the mesh to use to render this level
  23435. */
  23436. constructor(
  23437. /** Defines the distance where this level should start being displayed */
  23438. distance: number,
  23439. /** Defines the mesh to use to render this level */
  23440. mesh: Nullable<Mesh>);
  23441. }
  23442. }
  23443. declare module BABYLON {
  23444. /**
  23445. * Mesh representing the gorund
  23446. */
  23447. export class GroundMesh extends Mesh {
  23448. /** If octree should be generated */
  23449. generateOctree: boolean;
  23450. private _heightQuads;
  23451. /** @hidden */
  23452. _subdivisionsX: number;
  23453. /** @hidden */
  23454. _subdivisionsY: number;
  23455. /** @hidden */
  23456. _width: number;
  23457. /** @hidden */
  23458. _height: number;
  23459. /** @hidden */
  23460. _minX: number;
  23461. /** @hidden */
  23462. _maxX: number;
  23463. /** @hidden */
  23464. _minZ: number;
  23465. /** @hidden */
  23466. _maxZ: number;
  23467. constructor(name: string, scene: Scene);
  23468. /**
  23469. * "GroundMesh"
  23470. * @returns "GroundMesh"
  23471. */
  23472. getClassName(): string;
  23473. /**
  23474. * The minimum of x and y subdivisions
  23475. */
  23476. get subdivisions(): number;
  23477. /**
  23478. * X subdivisions
  23479. */
  23480. get subdivisionsX(): number;
  23481. /**
  23482. * Y subdivisions
  23483. */
  23484. get subdivisionsY(): number;
  23485. /**
  23486. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23487. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23488. * @param chunksCount the number of subdivisions for x and y
  23489. * @param octreeBlocksSize (Default: 32)
  23490. */
  23491. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23492. /**
  23493. * Returns a height (y) value in the Worl system :
  23494. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23495. * @param x x coordinate
  23496. * @param z z coordinate
  23497. * @returns the ground y position if (x, z) are outside the ground surface.
  23498. */
  23499. getHeightAtCoordinates(x: number, z: number): number;
  23500. /**
  23501. * Returns a normalized vector (Vector3) orthogonal to the ground
  23502. * at the ground coordinates (x, z) expressed in the World system.
  23503. * @param x x coordinate
  23504. * @param z z coordinate
  23505. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23506. */
  23507. getNormalAtCoordinates(x: number, z: number): Vector3;
  23508. /**
  23509. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23510. * at the ground coordinates (x, z) expressed in the World system.
  23511. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23512. * @param x x coordinate
  23513. * @param z z coordinate
  23514. * @param ref vector to store the result
  23515. * @returns the GroundMesh.
  23516. */
  23517. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23518. /**
  23519. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23520. * if the ground has been updated.
  23521. * This can be used in the render loop.
  23522. * @returns the GroundMesh.
  23523. */
  23524. updateCoordinateHeights(): GroundMesh;
  23525. private _getFacetAt;
  23526. private _initHeightQuads;
  23527. private _computeHeightQuads;
  23528. /**
  23529. * Serializes this ground mesh
  23530. * @param serializationObject object to write serialization to
  23531. */
  23532. serialize(serializationObject: any): void;
  23533. /**
  23534. * Parses a serialized ground mesh
  23535. * @param parsedMesh the serialized mesh
  23536. * @param scene the scene to create the ground mesh in
  23537. * @returns the created ground mesh
  23538. */
  23539. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23540. }
  23541. }
  23542. declare module BABYLON {
  23543. /**
  23544. * Interface for Physics-Joint data
  23545. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23546. */
  23547. export interface PhysicsJointData {
  23548. /**
  23549. * The main pivot of the joint
  23550. */
  23551. mainPivot?: Vector3;
  23552. /**
  23553. * The connected pivot of the joint
  23554. */
  23555. connectedPivot?: Vector3;
  23556. /**
  23557. * The main axis of the joint
  23558. */
  23559. mainAxis?: Vector3;
  23560. /**
  23561. * The connected axis of the joint
  23562. */
  23563. connectedAxis?: Vector3;
  23564. /**
  23565. * The collision of the joint
  23566. */
  23567. collision?: boolean;
  23568. /**
  23569. * Native Oimo/Cannon/Energy data
  23570. */
  23571. nativeParams?: any;
  23572. }
  23573. /**
  23574. * This is a holder class for the physics joint created by the physics plugin
  23575. * It holds a set of functions to control the underlying joint
  23576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23577. */
  23578. export class PhysicsJoint {
  23579. /**
  23580. * The type of the physics joint
  23581. */
  23582. type: number;
  23583. /**
  23584. * The data for the physics joint
  23585. */
  23586. jointData: PhysicsJointData;
  23587. private _physicsJoint;
  23588. protected _physicsPlugin: IPhysicsEnginePlugin;
  23589. /**
  23590. * Initializes the physics joint
  23591. * @param type The type of the physics joint
  23592. * @param jointData The data for the physics joint
  23593. */
  23594. constructor(
  23595. /**
  23596. * The type of the physics joint
  23597. */
  23598. type: number,
  23599. /**
  23600. * The data for the physics joint
  23601. */
  23602. jointData: PhysicsJointData);
  23603. /**
  23604. * Gets the physics joint
  23605. */
  23606. get physicsJoint(): any;
  23607. /**
  23608. * Sets the physics joint
  23609. */
  23610. set physicsJoint(newJoint: any);
  23611. /**
  23612. * Sets the physics plugin
  23613. */
  23614. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23615. /**
  23616. * Execute a function that is physics-plugin specific.
  23617. * @param {Function} func the function that will be executed.
  23618. * It accepts two parameters: the physics world and the physics joint
  23619. */
  23620. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23621. /**
  23622. * Distance-Joint type
  23623. */
  23624. static DistanceJoint: number;
  23625. /**
  23626. * Hinge-Joint type
  23627. */
  23628. static HingeJoint: number;
  23629. /**
  23630. * Ball-and-Socket joint type
  23631. */
  23632. static BallAndSocketJoint: number;
  23633. /**
  23634. * Wheel-Joint type
  23635. */
  23636. static WheelJoint: number;
  23637. /**
  23638. * Slider-Joint type
  23639. */
  23640. static SliderJoint: number;
  23641. /**
  23642. * Prismatic-Joint type
  23643. */
  23644. static PrismaticJoint: number;
  23645. /**
  23646. * Universal-Joint type
  23647. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23648. */
  23649. static UniversalJoint: number;
  23650. /**
  23651. * Hinge-Joint 2 type
  23652. */
  23653. static Hinge2Joint: number;
  23654. /**
  23655. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23656. */
  23657. static PointToPointJoint: number;
  23658. /**
  23659. * Spring-Joint type
  23660. */
  23661. static SpringJoint: number;
  23662. /**
  23663. * Lock-Joint type
  23664. */
  23665. static LockJoint: number;
  23666. }
  23667. /**
  23668. * A class representing a physics distance joint
  23669. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23670. */
  23671. export class DistanceJoint extends PhysicsJoint {
  23672. /**
  23673. *
  23674. * @param jointData The data for the Distance-Joint
  23675. */
  23676. constructor(jointData: DistanceJointData);
  23677. /**
  23678. * Update the predefined distance.
  23679. * @param maxDistance The maximum preferred distance
  23680. * @param minDistance The minimum preferred distance
  23681. */
  23682. updateDistance(maxDistance: number, minDistance?: number): void;
  23683. }
  23684. /**
  23685. * Represents a Motor-Enabled Joint
  23686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23687. */
  23688. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23689. /**
  23690. * Initializes the Motor-Enabled Joint
  23691. * @param type The type of the joint
  23692. * @param jointData The physica joint data for the joint
  23693. */
  23694. constructor(type: number, jointData: PhysicsJointData);
  23695. /**
  23696. * Set the motor values.
  23697. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23698. * @param force the force to apply
  23699. * @param maxForce max force for this motor.
  23700. */
  23701. setMotor(force?: number, maxForce?: number): void;
  23702. /**
  23703. * Set the motor's limits.
  23704. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23705. * @param upperLimit The upper limit of the motor
  23706. * @param lowerLimit The lower limit of the motor
  23707. */
  23708. setLimit(upperLimit: number, lowerLimit?: number): void;
  23709. }
  23710. /**
  23711. * This class represents a single physics Hinge-Joint
  23712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23713. */
  23714. export class HingeJoint extends MotorEnabledJoint {
  23715. /**
  23716. * Initializes the Hinge-Joint
  23717. * @param jointData The joint data for the Hinge-Joint
  23718. */
  23719. constructor(jointData: PhysicsJointData);
  23720. /**
  23721. * Set the motor values.
  23722. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23723. * @param {number} force the force to apply
  23724. * @param {number} maxForce max force for this motor.
  23725. */
  23726. setMotor(force?: number, maxForce?: number): void;
  23727. /**
  23728. * Set the motor's limits.
  23729. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23730. * @param upperLimit The upper limit of the motor
  23731. * @param lowerLimit The lower limit of the motor
  23732. */
  23733. setLimit(upperLimit: number, lowerLimit?: number): void;
  23734. }
  23735. /**
  23736. * This class represents a dual hinge physics joint (same as wheel joint)
  23737. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23738. */
  23739. export class Hinge2Joint extends MotorEnabledJoint {
  23740. /**
  23741. * Initializes the Hinge2-Joint
  23742. * @param jointData The joint data for the Hinge2-Joint
  23743. */
  23744. constructor(jointData: PhysicsJointData);
  23745. /**
  23746. * Set the motor values.
  23747. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23748. * @param {number} targetSpeed the speed the motor is to reach
  23749. * @param {number} maxForce max force for this motor.
  23750. * @param {motorIndex} the motor's index, 0 or 1.
  23751. */
  23752. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23753. /**
  23754. * Set the motor limits.
  23755. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23756. * @param {number} upperLimit the upper limit
  23757. * @param {number} lowerLimit lower limit
  23758. * @param {motorIndex} the motor's index, 0 or 1.
  23759. */
  23760. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23761. }
  23762. /**
  23763. * Interface for a motor enabled joint
  23764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23765. */
  23766. export interface IMotorEnabledJoint {
  23767. /**
  23768. * Physics joint
  23769. */
  23770. physicsJoint: any;
  23771. /**
  23772. * Sets the motor of the motor-enabled joint
  23773. * @param force The force of the motor
  23774. * @param maxForce The maximum force of the motor
  23775. * @param motorIndex The index of the motor
  23776. */
  23777. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23778. /**
  23779. * Sets the limit of the motor
  23780. * @param upperLimit The upper limit of the motor
  23781. * @param lowerLimit The lower limit of the motor
  23782. * @param motorIndex The index of the motor
  23783. */
  23784. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23785. }
  23786. /**
  23787. * Joint data for a Distance-Joint
  23788. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23789. */
  23790. export interface DistanceJointData extends PhysicsJointData {
  23791. /**
  23792. * Max distance the 2 joint objects can be apart
  23793. */
  23794. maxDistance: number;
  23795. }
  23796. /**
  23797. * Joint data from a spring joint
  23798. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23799. */
  23800. export interface SpringJointData extends PhysicsJointData {
  23801. /**
  23802. * Length of the spring
  23803. */
  23804. length: number;
  23805. /**
  23806. * Stiffness of the spring
  23807. */
  23808. stiffness: number;
  23809. /**
  23810. * Damping of the spring
  23811. */
  23812. damping: number;
  23813. /** this callback will be called when applying the force to the impostors. */
  23814. forceApplicationCallback: () => void;
  23815. }
  23816. }
  23817. declare module BABYLON {
  23818. /**
  23819. * Holds the data for the raycast result
  23820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23821. */
  23822. export class PhysicsRaycastResult {
  23823. private _hasHit;
  23824. private _hitDistance;
  23825. private _hitNormalWorld;
  23826. private _hitPointWorld;
  23827. private _rayFromWorld;
  23828. private _rayToWorld;
  23829. /**
  23830. * Gets if there was a hit
  23831. */
  23832. get hasHit(): boolean;
  23833. /**
  23834. * Gets the distance from the hit
  23835. */
  23836. get hitDistance(): number;
  23837. /**
  23838. * Gets the hit normal/direction in the world
  23839. */
  23840. get hitNormalWorld(): Vector3;
  23841. /**
  23842. * Gets the hit point in the world
  23843. */
  23844. get hitPointWorld(): Vector3;
  23845. /**
  23846. * Gets the ray "start point" of the ray in the world
  23847. */
  23848. get rayFromWorld(): Vector3;
  23849. /**
  23850. * Gets the ray "end point" of the ray in the world
  23851. */
  23852. get rayToWorld(): Vector3;
  23853. /**
  23854. * Sets the hit data (normal & point in world space)
  23855. * @param hitNormalWorld defines the normal in world space
  23856. * @param hitPointWorld defines the point in world space
  23857. */
  23858. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23859. /**
  23860. * Sets the distance from the start point to the hit point
  23861. * @param distance
  23862. */
  23863. setHitDistance(distance: number): void;
  23864. /**
  23865. * Calculates the distance manually
  23866. */
  23867. calculateHitDistance(): void;
  23868. /**
  23869. * Resets all the values to default
  23870. * @param from The from point on world space
  23871. * @param to The to point on world space
  23872. */
  23873. reset(from?: Vector3, to?: Vector3): void;
  23874. }
  23875. /**
  23876. * Interface for the size containing width and height
  23877. */
  23878. interface IXYZ {
  23879. /**
  23880. * X
  23881. */
  23882. x: number;
  23883. /**
  23884. * Y
  23885. */
  23886. y: number;
  23887. /**
  23888. * Z
  23889. */
  23890. z: number;
  23891. }
  23892. }
  23893. declare module BABYLON {
  23894. /**
  23895. * Interface used to describe a physics joint
  23896. */
  23897. export interface PhysicsImpostorJoint {
  23898. /** Defines the main impostor to which the joint is linked */
  23899. mainImpostor: PhysicsImpostor;
  23900. /** Defines the impostor that is connected to the main impostor using this joint */
  23901. connectedImpostor: PhysicsImpostor;
  23902. /** Defines the joint itself */
  23903. joint: PhysicsJoint;
  23904. }
  23905. /** @hidden */
  23906. export interface IPhysicsEnginePlugin {
  23907. world: any;
  23908. name: string;
  23909. setGravity(gravity: Vector3): void;
  23910. setTimeStep(timeStep: number): void;
  23911. getTimeStep(): number;
  23912. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23913. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23914. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23915. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23916. removePhysicsBody(impostor: PhysicsImpostor): void;
  23917. generateJoint(joint: PhysicsImpostorJoint): void;
  23918. removeJoint(joint: PhysicsImpostorJoint): void;
  23919. isSupported(): boolean;
  23920. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23921. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23922. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23923. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23924. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23925. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23926. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23927. getBodyMass(impostor: PhysicsImpostor): number;
  23928. getBodyFriction(impostor: PhysicsImpostor): number;
  23929. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23930. getBodyRestitution(impostor: PhysicsImpostor): number;
  23931. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23932. getBodyPressure?(impostor: PhysicsImpostor): number;
  23933. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23934. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23935. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23936. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23937. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23938. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23939. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23940. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23941. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23942. sleepBody(impostor: PhysicsImpostor): void;
  23943. wakeUpBody(impostor: PhysicsImpostor): void;
  23944. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23945. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23946. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23947. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23948. getRadius(impostor: PhysicsImpostor): number;
  23949. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23950. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23951. dispose(): void;
  23952. }
  23953. /**
  23954. * Interface used to define a physics engine
  23955. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23956. */
  23957. export interface IPhysicsEngine {
  23958. /**
  23959. * Gets the gravity vector used by the simulation
  23960. */
  23961. gravity: Vector3;
  23962. /**
  23963. * Sets the gravity vector used by the simulation
  23964. * @param gravity defines the gravity vector to use
  23965. */
  23966. setGravity(gravity: Vector3): void;
  23967. /**
  23968. * Set the time step of the physics engine.
  23969. * Default is 1/60.
  23970. * To slow it down, enter 1/600 for example.
  23971. * To speed it up, 1/30
  23972. * @param newTimeStep the new timestep to apply to this world.
  23973. */
  23974. setTimeStep(newTimeStep: number): void;
  23975. /**
  23976. * Get the time step of the physics engine.
  23977. * @returns the current time step
  23978. */
  23979. getTimeStep(): number;
  23980. /**
  23981. * Set the sub time step of the physics engine.
  23982. * Default is 0 meaning there is no sub steps
  23983. * To increase physics resolution precision, set a small value (like 1 ms)
  23984. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23985. */
  23986. setSubTimeStep(subTimeStep: number): void;
  23987. /**
  23988. * Get the sub time step of the physics engine.
  23989. * @returns the current sub time step
  23990. */
  23991. getSubTimeStep(): number;
  23992. /**
  23993. * Release all resources
  23994. */
  23995. dispose(): void;
  23996. /**
  23997. * Gets the name of the current physics plugin
  23998. * @returns the name of the plugin
  23999. */
  24000. getPhysicsPluginName(): string;
  24001. /**
  24002. * Adding a new impostor for the impostor tracking.
  24003. * This will be done by the impostor itself.
  24004. * @param impostor the impostor to add
  24005. */
  24006. addImpostor(impostor: PhysicsImpostor): void;
  24007. /**
  24008. * Remove an impostor from the engine.
  24009. * This impostor and its mesh will not longer be updated by the physics engine.
  24010. * @param impostor the impostor to remove
  24011. */
  24012. removeImpostor(impostor: PhysicsImpostor): void;
  24013. /**
  24014. * Add a joint to the physics engine
  24015. * @param mainImpostor defines the main impostor to which the joint is added.
  24016. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24017. * @param joint defines the joint that will connect both impostors.
  24018. */
  24019. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24020. /**
  24021. * Removes a joint from the simulation
  24022. * @param mainImpostor defines the impostor used with the joint
  24023. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24024. * @param joint defines the joint to remove
  24025. */
  24026. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24027. /**
  24028. * Gets the current plugin used to run the simulation
  24029. * @returns current plugin
  24030. */
  24031. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24032. /**
  24033. * Gets the list of physic impostors
  24034. * @returns an array of PhysicsImpostor
  24035. */
  24036. getImpostors(): Array<PhysicsImpostor>;
  24037. /**
  24038. * Gets the impostor for a physics enabled object
  24039. * @param object defines the object impersonated by the impostor
  24040. * @returns the PhysicsImpostor or null if not found
  24041. */
  24042. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24043. /**
  24044. * Gets the impostor for a physics body object
  24045. * @param body defines physics body used by the impostor
  24046. * @returns the PhysicsImpostor or null if not found
  24047. */
  24048. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24049. /**
  24050. * Does a raycast in the physics world
  24051. * @param from when should the ray start?
  24052. * @param to when should the ray end?
  24053. * @returns PhysicsRaycastResult
  24054. */
  24055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24056. /**
  24057. * Called by the scene. No need to call it.
  24058. * @param delta defines the timespam between frames
  24059. */
  24060. _step(delta: number): void;
  24061. }
  24062. }
  24063. declare module BABYLON {
  24064. /**
  24065. * The interface for the physics imposter parameters
  24066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24067. */
  24068. export interface PhysicsImpostorParameters {
  24069. /**
  24070. * The mass of the physics imposter
  24071. */
  24072. mass: number;
  24073. /**
  24074. * The friction of the physics imposter
  24075. */
  24076. friction?: number;
  24077. /**
  24078. * The coefficient of restitution of the physics imposter
  24079. */
  24080. restitution?: number;
  24081. /**
  24082. * The native options of the physics imposter
  24083. */
  24084. nativeOptions?: any;
  24085. /**
  24086. * Specifies if the parent should be ignored
  24087. */
  24088. ignoreParent?: boolean;
  24089. /**
  24090. * Specifies if bi-directional transformations should be disabled
  24091. */
  24092. disableBidirectionalTransformation?: boolean;
  24093. /**
  24094. * The pressure inside the physics imposter, soft object only
  24095. */
  24096. pressure?: number;
  24097. /**
  24098. * The stiffness the physics imposter, soft object only
  24099. */
  24100. stiffness?: number;
  24101. /**
  24102. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24103. */
  24104. velocityIterations?: number;
  24105. /**
  24106. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24107. */
  24108. positionIterations?: number;
  24109. /**
  24110. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24111. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24112. * Add to fix multiple points
  24113. */
  24114. fixedPoints?: number;
  24115. /**
  24116. * The collision margin around a soft object
  24117. */
  24118. margin?: number;
  24119. /**
  24120. * The collision margin around a soft object
  24121. */
  24122. damping?: number;
  24123. /**
  24124. * The path for a rope based on an extrusion
  24125. */
  24126. path?: any;
  24127. /**
  24128. * The shape of an extrusion used for a rope based on an extrusion
  24129. */
  24130. shape?: any;
  24131. }
  24132. /**
  24133. * Interface for a physics-enabled object
  24134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24135. */
  24136. export interface IPhysicsEnabledObject {
  24137. /**
  24138. * The position of the physics-enabled object
  24139. */
  24140. position: Vector3;
  24141. /**
  24142. * The rotation of the physics-enabled object
  24143. */
  24144. rotationQuaternion: Nullable<Quaternion>;
  24145. /**
  24146. * The scale of the physics-enabled object
  24147. */
  24148. scaling: Vector3;
  24149. /**
  24150. * The rotation of the physics-enabled object
  24151. */
  24152. rotation?: Vector3;
  24153. /**
  24154. * The parent of the physics-enabled object
  24155. */
  24156. parent?: any;
  24157. /**
  24158. * The bounding info of the physics-enabled object
  24159. * @returns The bounding info of the physics-enabled object
  24160. */
  24161. getBoundingInfo(): BoundingInfo;
  24162. /**
  24163. * Computes the world matrix
  24164. * @param force Specifies if the world matrix should be computed by force
  24165. * @returns A world matrix
  24166. */
  24167. computeWorldMatrix(force: boolean): Matrix;
  24168. /**
  24169. * Gets the world matrix
  24170. * @returns A world matrix
  24171. */
  24172. getWorldMatrix?(): Matrix;
  24173. /**
  24174. * Gets the child meshes
  24175. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24176. * @returns An array of abstract meshes
  24177. */
  24178. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24179. /**
  24180. * Gets the vertex data
  24181. * @param kind The type of vertex data
  24182. * @returns A nullable array of numbers, or a float32 array
  24183. */
  24184. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24185. /**
  24186. * Gets the indices from the mesh
  24187. * @returns A nullable array of index arrays
  24188. */
  24189. getIndices?(): Nullable<IndicesArray>;
  24190. /**
  24191. * Gets the scene from the mesh
  24192. * @returns the indices array or null
  24193. */
  24194. getScene?(): Scene;
  24195. /**
  24196. * Gets the absolute position from the mesh
  24197. * @returns the absolute position
  24198. */
  24199. getAbsolutePosition(): Vector3;
  24200. /**
  24201. * Gets the absolute pivot point from the mesh
  24202. * @returns the absolute pivot point
  24203. */
  24204. getAbsolutePivotPoint(): Vector3;
  24205. /**
  24206. * Rotates the mesh
  24207. * @param axis The axis of rotation
  24208. * @param amount The amount of rotation
  24209. * @param space The space of the rotation
  24210. * @returns The rotation transform node
  24211. */
  24212. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24213. /**
  24214. * Translates the mesh
  24215. * @param axis The axis of translation
  24216. * @param distance The distance of translation
  24217. * @param space The space of the translation
  24218. * @returns The transform node
  24219. */
  24220. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24221. /**
  24222. * Sets the absolute position of the mesh
  24223. * @param absolutePosition The absolute position of the mesh
  24224. * @returns The transform node
  24225. */
  24226. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24227. /**
  24228. * Gets the class name of the mesh
  24229. * @returns The class name
  24230. */
  24231. getClassName(): string;
  24232. }
  24233. /**
  24234. * Represents a physics imposter
  24235. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24236. */
  24237. export class PhysicsImpostor {
  24238. /**
  24239. * The physics-enabled object used as the physics imposter
  24240. */
  24241. object: IPhysicsEnabledObject;
  24242. /**
  24243. * The type of the physics imposter
  24244. */
  24245. type: number;
  24246. private _options;
  24247. private _scene?;
  24248. /**
  24249. * The default object size of the imposter
  24250. */
  24251. static DEFAULT_OBJECT_SIZE: Vector3;
  24252. /**
  24253. * The identity quaternion of the imposter
  24254. */
  24255. static IDENTITY_QUATERNION: Quaternion;
  24256. /** @hidden */
  24257. _pluginData: any;
  24258. private _physicsEngine;
  24259. private _physicsBody;
  24260. private _bodyUpdateRequired;
  24261. private _onBeforePhysicsStepCallbacks;
  24262. private _onAfterPhysicsStepCallbacks;
  24263. /** @hidden */
  24264. _onPhysicsCollideCallbacks: Array<{
  24265. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24266. otherImpostors: Array<PhysicsImpostor>;
  24267. }>;
  24268. private _deltaPosition;
  24269. private _deltaRotation;
  24270. private _deltaRotationConjugated;
  24271. /** @hidden */
  24272. _isFromLine: boolean;
  24273. private _parent;
  24274. private _isDisposed;
  24275. private static _tmpVecs;
  24276. private static _tmpQuat;
  24277. /**
  24278. * Specifies if the physics imposter is disposed
  24279. */
  24280. get isDisposed(): boolean;
  24281. /**
  24282. * Gets the mass of the physics imposter
  24283. */
  24284. get mass(): number;
  24285. set mass(value: number);
  24286. /**
  24287. * Gets the coefficient of friction
  24288. */
  24289. get friction(): number;
  24290. /**
  24291. * Sets the coefficient of friction
  24292. */
  24293. set friction(value: number);
  24294. /**
  24295. * Gets the coefficient of restitution
  24296. */
  24297. get restitution(): number;
  24298. /**
  24299. * Sets the coefficient of restitution
  24300. */
  24301. set restitution(value: number);
  24302. /**
  24303. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24304. */
  24305. get pressure(): number;
  24306. /**
  24307. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24308. */
  24309. set pressure(value: number);
  24310. /**
  24311. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24312. */
  24313. get stiffness(): number;
  24314. /**
  24315. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24316. */
  24317. set stiffness(value: number);
  24318. /**
  24319. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24320. */
  24321. get velocityIterations(): number;
  24322. /**
  24323. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24324. */
  24325. set velocityIterations(value: number);
  24326. /**
  24327. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24328. */
  24329. get positionIterations(): number;
  24330. /**
  24331. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24332. */
  24333. set positionIterations(value: number);
  24334. /**
  24335. * The unique id of the physics imposter
  24336. * set by the physics engine when adding this impostor to the array
  24337. */
  24338. uniqueId: number;
  24339. /**
  24340. * @hidden
  24341. */
  24342. soft: boolean;
  24343. /**
  24344. * @hidden
  24345. */
  24346. segments: number;
  24347. private _joints;
  24348. /**
  24349. * Initializes the physics imposter
  24350. * @param object The physics-enabled object used as the physics imposter
  24351. * @param type The type of the physics imposter
  24352. * @param _options The options for the physics imposter
  24353. * @param _scene The Babylon scene
  24354. */
  24355. constructor(
  24356. /**
  24357. * The physics-enabled object used as the physics imposter
  24358. */
  24359. object: IPhysicsEnabledObject,
  24360. /**
  24361. * The type of the physics imposter
  24362. */
  24363. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24364. /**
  24365. * This function will completly initialize this impostor.
  24366. * It will create a new body - but only if this mesh has no parent.
  24367. * If it has, this impostor will not be used other than to define the impostor
  24368. * of the child mesh.
  24369. * @hidden
  24370. */
  24371. _init(): void;
  24372. private _getPhysicsParent;
  24373. /**
  24374. * Should a new body be generated.
  24375. * @returns boolean specifying if body initialization is required
  24376. */
  24377. isBodyInitRequired(): boolean;
  24378. /**
  24379. * Sets the updated scaling
  24380. * @param updated Specifies if the scaling is updated
  24381. */
  24382. setScalingUpdated(): void;
  24383. /**
  24384. * Force a regeneration of this or the parent's impostor's body.
  24385. * Use under cautious - This will remove all joints already implemented.
  24386. */
  24387. forceUpdate(): void;
  24388. /**
  24389. * Gets the body that holds this impostor. Either its own, or its parent.
  24390. */
  24391. get physicsBody(): any;
  24392. /**
  24393. * Get the parent of the physics imposter
  24394. * @returns Physics imposter or null
  24395. */
  24396. get parent(): Nullable<PhysicsImpostor>;
  24397. /**
  24398. * Sets the parent of the physics imposter
  24399. */
  24400. set parent(value: Nullable<PhysicsImpostor>);
  24401. /**
  24402. * Set the physics body. Used mainly by the physics engine/plugin
  24403. */
  24404. set physicsBody(physicsBody: any);
  24405. /**
  24406. * Resets the update flags
  24407. */
  24408. resetUpdateFlags(): void;
  24409. /**
  24410. * Gets the object extend size
  24411. * @returns the object extend size
  24412. */
  24413. getObjectExtendSize(): Vector3;
  24414. /**
  24415. * Gets the object center
  24416. * @returns The object center
  24417. */
  24418. getObjectCenter(): Vector3;
  24419. /**
  24420. * Get a specific parameter from the options parameters
  24421. * @param paramName The object parameter name
  24422. * @returns The object parameter
  24423. */
  24424. getParam(paramName: string): any;
  24425. /**
  24426. * Sets a specific parameter in the options given to the physics plugin
  24427. * @param paramName The parameter name
  24428. * @param value The value of the parameter
  24429. */
  24430. setParam(paramName: string, value: number): void;
  24431. /**
  24432. * Specifically change the body's mass option. Won't recreate the physics body object
  24433. * @param mass The mass of the physics imposter
  24434. */
  24435. setMass(mass: number): void;
  24436. /**
  24437. * Gets the linear velocity
  24438. * @returns linear velocity or null
  24439. */
  24440. getLinearVelocity(): Nullable<Vector3>;
  24441. /**
  24442. * Sets the linear velocity
  24443. * @param velocity linear velocity or null
  24444. */
  24445. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24446. /**
  24447. * Gets the angular velocity
  24448. * @returns angular velocity or null
  24449. */
  24450. getAngularVelocity(): Nullable<Vector3>;
  24451. /**
  24452. * Sets the angular velocity
  24453. * @param velocity The velocity or null
  24454. */
  24455. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24456. /**
  24457. * Execute a function with the physics plugin native code
  24458. * Provide a function the will have two variables - the world object and the physics body object
  24459. * @param func The function to execute with the physics plugin native code
  24460. */
  24461. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24462. /**
  24463. * Register a function that will be executed before the physics world is stepping forward
  24464. * @param func The function to execute before the physics world is stepped forward
  24465. */
  24466. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24467. /**
  24468. * Unregister a function that will be executed before the physics world is stepping forward
  24469. * @param func The function to execute before the physics world is stepped forward
  24470. */
  24471. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24472. /**
  24473. * Register a function that will be executed after the physics step
  24474. * @param func The function to execute after physics step
  24475. */
  24476. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24477. /**
  24478. * Unregisters a function that will be executed after the physics step
  24479. * @param func The function to execute after physics step
  24480. */
  24481. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24482. /**
  24483. * register a function that will be executed when this impostor collides against a different body
  24484. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24485. * @param func Callback that is executed on collision
  24486. */
  24487. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24488. /**
  24489. * Unregisters the physics imposter on contact
  24490. * @param collideAgainst The physics object to collide against
  24491. * @param func Callback to execute on collision
  24492. */
  24493. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24494. private _tmpQuat;
  24495. private _tmpQuat2;
  24496. /**
  24497. * Get the parent rotation
  24498. * @returns The parent rotation
  24499. */
  24500. getParentsRotation(): Quaternion;
  24501. /**
  24502. * this function is executed by the physics engine.
  24503. */
  24504. beforeStep: () => void;
  24505. /**
  24506. * this function is executed by the physics engine
  24507. */
  24508. afterStep: () => void;
  24509. /**
  24510. * Legacy collision detection event support
  24511. */
  24512. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24513. /**
  24514. * event and body object due to cannon's event-based architecture.
  24515. */
  24516. onCollide: (e: {
  24517. body: any;
  24518. }) => void;
  24519. /**
  24520. * Apply a force
  24521. * @param force The force to apply
  24522. * @param contactPoint The contact point for the force
  24523. * @returns The physics imposter
  24524. */
  24525. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24526. /**
  24527. * Apply an impulse
  24528. * @param force The impulse force
  24529. * @param contactPoint The contact point for the impulse force
  24530. * @returns The physics imposter
  24531. */
  24532. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24533. /**
  24534. * A help function to create a joint
  24535. * @param otherImpostor A physics imposter used to create a joint
  24536. * @param jointType The type of joint
  24537. * @param jointData The data for the joint
  24538. * @returns The physics imposter
  24539. */
  24540. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24541. /**
  24542. * Add a joint to this impostor with a different impostor
  24543. * @param otherImpostor A physics imposter used to add a joint
  24544. * @param joint The joint to add
  24545. * @returns The physics imposter
  24546. */
  24547. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24548. /**
  24549. * Add an anchor to a cloth impostor
  24550. * @param otherImpostor rigid impostor to anchor to
  24551. * @param width ratio across width from 0 to 1
  24552. * @param height ratio up height from 0 to 1
  24553. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24554. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24555. * @returns impostor the soft imposter
  24556. */
  24557. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24558. /**
  24559. * Add a hook to a rope impostor
  24560. * @param otherImpostor rigid impostor to anchor to
  24561. * @param length ratio across rope from 0 to 1
  24562. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24563. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24564. * @returns impostor the rope imposter
  24565. */
  24566. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24567. /**
  24568. * Will keep this body still, in a sleep mode.
  24569. * @returns the physics imposter
  24570. */
  24571. sleep(): PhysicsImpostor;
  24572. /**
  24573. * Wake the body up.
  24574. * @returns The physics imposter
  24575. */
  24576. wakeUp(): PhysicsImpostor;
  24577. /**
  24578. * Clones the physics imposter
  24579. * @param newObject The physics imposter clones to this physics-enabled object
  24580. * @returns A nullable physics imposter
  24581. */
  24582. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24583. /**
  24584. * Disposes the physics imposter
  24585. */
  24586. dispose(): void;
  24587. /**
  24588. * Sets the delta position
  24589. * @param position The delta position amount
  24590. */
  24591. setDeltaPosition(position: Vector3): void;
  24592. /**
  24593. * Sets the delta rotation
  24594. * @param rotation The delta rotation amount
  24595. */
  24596. setDeltaRotation(rotation: Quaternion): void;
  24597. /**
  24598. * Gets the box size of the physics imposter and stores the result in the input parameter
  24599. * @param result Stores the box size
  24600. * @returns The physics imposter
  24601. */
  24602. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24603. /**
  24604. * Gets the radius of the physics imposter
  24605. * @returns Radius of the physics imposter
  24606. */
  24607. getRadius(): number;
  24608. /**
  24609. * Sync a bone with this impostor
  24610. * @param bone The bone to sync to the impostor.
  24611. * @param boneMesh The mesh that the bone is influencing.
  24612. * @param jointPivot The pivot of the joint / bone in local space.
  24613. * @param distToJoint Optional distance from the impostor to the joint.
  24614. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24615. */
  24616. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24617. /**
  24618. * Sync impostor to a bone
  24619. * @param bone The bone that the impostor will be synced to.
  24620. * @param boneMesh The mesh that the bone is influencing.
  24621. * @param jointPivot The pivot of the joint / bone in local space.
  24622. * @param distToJoint Optional distance from the impostor to the joint.
  24623. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24624. * @param boneAxis Optional vector3 axis the bone is aligned with
  24625. */
  24626. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24627. /**
  24628. * No-Imposter type
  24629. */
  24630. static NoImpostor: number;
  24631. /**
  24632. * Sphere-Imposter type
  24633. */
  24634. static SphereImpostor: number;
  24635. /**
  24636. * Box-Imposter type
  24637. */
  24638. static BoxImpostor: number;
  24639. /**
  24640. * Plane-Imposter type
  24641. */
  24642. static PlaneImpostor: number;
  24643. /**
  24644. * Mesh-imposter type
  24645. */
  24646. static MeshImpostor: number;
  24647. /**
  24648. * Capsule-Impostor type (Ammo.js plugin only)
  24649. */
  24650. static CapsuleImpostor: number;
  24651. /**
  24652. * Cylinder-Imposter type
  24653. */
  24654. static CylinderImpostor: number;
  24655. /**
  24656. * Particle-Imposter type
  24657. */
  24658. static ParticleImpostor: number;
  24659. /**
  24660. * Heightmap-Imposter type
  24661. */
  24662. static HeightmapImpostor: number;
  24663. /**
  24664. * ConvexHull-Impostor type (Ammo.js plugin only)
  24665. */
  24666. static ConvexHullImpostor: number;
  24667. /**
  24668. * Custom-Imposter type (Ammo.js plugin only)
  24669. */
  24670. static CustomImpostor: number;
  24671. /**
  24672. * Rope-Imposter type
  24673. */
  24674. static RopeImpostor: number;
  24675. /**
  24676. * Cloth-Imposter type
  24677. */
  24678. static ClothImpostor: number;
  24679. /**
  24680. * Softbody-Imposter type
  24681. */
  24682. static SoftbodyImpostor: number;
  24683. }
  24684. }
  24685. declare module BABYLON {
  24686. /**
  24687. * @hidden
  24688. **/
  24689. export class _CreationDataStorage {
  24690. closePath?: boolean;
  24691. closeArray?: boolean;
  24692. idx: number[];
  24693. dashSize: number;
  24694. gapSize: number;
  24695. path3D: Path3D;
  24696. pathArray: Vector3[][];
  24697. arc: number;
  24698. radius: number;
  24699. cap: number;
  24700. tessellation: number;
  24701. }
  24702. /**
  24703. * @hidden
  24704. **/
  24705. class _InstanceDataStorage {
  24706. visibleInstances: any;
  24707. batchCache: _InstancesBatch;
  24708. instancesBufferSize: number;
  24709. instancesBuffer: Nullable<Buffer>;
  24710. instancesData: Float32Array;
  24711. overridenInstanceCount: number;
  24712. isFrozen: boolean;
  24713. previousBatch: Nullable<_InstancesBatch>;
  24714. hardwareInstancedRendering: boolean;
  24715. sideOrientation: number;
  24716. manualUpdate: boolean;
  24717. }
  24718. /**
  24719. * @hidden
  24720. **/
  24721. export class _InstancesBatch {
  24722. mustReturn: boolean;
  24723. visibleInstances: Nullable<InstancedMesh[]>[];
  24724. renderSelf: boolean[];
  24725. hardwareInstancedRendering: boolean[];
  24726. }
  24727. /**
  24728. * Class used to represent renderable models
  24729. */
  24730. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24731. /**
  24732. * Mesh side orientation : usually the external or front surface
  24733. */
  24734. static readonly FRONTSIDE: number;
  24735. /**
  24736. * Mesh side orientation : usually the internal or back surface
  24737. */
  24738. static readonly BACKSIDE: number;
  24739. /**
  24740. * Mesh side orientation : both internal and external or front and back surfaces
  24741. */
  24742. static readonly DOUBLESIDE: number;
  24743. /**
  24744. * Mesh side orientation : by default, `FRONTSIDE`
  24745. */
  24746. static readonly DEFAULTSIDE: number;
  24747. /**
  24748. * Mesh cap setting : no cap
  24749. */
  24750. static readonly NO_CAP: number;
  24751. /**
  24752. * Mesh cap setting : one cap at the beginning of the mesh
  24753. */
  24754. static readonly CAP_START: number;
  24755. /**
  24756. * Mesh cap setting : one cap at the end of the mesh
  24757. */
  24758. static readonly CAP_END: number;
  24759. /**
  24760. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24761. */
  24762. static readonly CAP_ALL: number;
  24763. /**
  24764. * Mesh pattern setting : no flip or rotate
  24765. */
  24766. static readonly NO_FLIP: number;
  24767. /**
  24768. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24769. */
  24770. static readonly FLIP_TILE: number;
  24771. /**
  24772. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24773. */
  24774. static readonly ROTATE_TILE: number;
  24775. /**
  24776. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24777. */
  24778. static readonly FLIP_ROW: number;
  24779. /**
  24780. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24781. */
  24782. static readonly ROTATE_ROW: number;
  24783. /**
  24784. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24785. */
  24786. static readonly FLIP_N_ROTATE_TILE: number;
  24787. /**
  24788. * Mesh pattern setting : rotate pattern and rotate
  24789. */
  24790. static readonly FLIP_N_ROTATE_ROW: number;
  24791. /**
  24792. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24793. */
  24794. static readonly CENTER: number;
  24795. /**
  24796. * Mesh tile positioning : part tiles on left
  24797. */
  24798. static readonly LEFT: number;
  24799. /**
  24800. * Mesh tile positioning : part tiles on right
  24801. */
  24802. static readonly RIGHT: number;
  24803. /**
  24804. * Mesh tile positioning : part tiles on top
  24805. */
  24806. static readonly TOP: number;
  24807. /**
  24808. * Mesh tile positioning : part tiles on bottom
  24809. */
  24810. static readonly BOTTOM: number;
  24811. /**
  24812. * Gets the default side orientation.
  24813. * @param orientation the orientation to value to attempt to get
  24814. * @returns the default orientation
  24815. * @hidden
  24816. */
  24817. static _GetDefaultSideOrientation(orientation?: number): number;
  24818. private _internalMeshDataInfo;
  24819. /**
  24820. * An event triggered before rendering the mesh
  24821. */
  24822. get onBeforeRenderObservable(): Observable<Mesh>;
  24823. /**
  24824. * An event triggered before binding the mesh
  24825. */
  24826. get onBeforeBindObservable(): Observable<Mesh>;
  24827. /**
  24828. * An event triggered after rendering the mesh
  24829. */
  24830. get onAfterRenderObservable(): Observable<Mesh>;
  24831. /**
  24832. * An event triggered before drawing the mesh
  24833. */
  24834. get onBeforeDrawObservable(): Observable<Mesh>;
  24835. private _onBeforeDrawObserver;
  24836. /**
  24837. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24838. */
  24839. set onBeforeDraw(callback: () => void);
  24840. get hasInstances(): boolean;
  24841. /**
  24842. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24843. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24844. */
  24845. delayLoadState: number;
  24846. /**
  24847. * Gets the list of instances created from this mesh
  24848. * it is not supposed to be modified manually.
  24849. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24850. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24851. */
  24852. instances: InstancedMesh[];
  24853. /**
  24854. * Gets the file containing delay loading data for this mesh
  24855. */
  24856. delayLoadingFile: string;
  24857. /** @hidden */
  24858. _binaryInfo: any;
  24859. /**
  24860. * User defined function used to change how LOD level selection is done
  24861. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24862. */
  24863. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24864. /**
  24865. * Gets or sets the morph target manager
  24866. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24867. */
  24868. get morphTargetManager(): Nullable<MorphTargetManager>;
  24869. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24870. /** @hidden */
  24871. _creationDataStorage: Nullable<_CreationDataStorage>;
  24872. /** @hidden */
  24873. _geometry: Nullable<Geometry>;
  24874. /** @hidden */
  24875. _delayInfo: Array<string>;
  24876. /** @hidden */
  24877. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24878. /** @hidden */
  24879. _instanceDataStorage: _InstanceDataStorage;
  24880. private _effectiveMaterial;
  24881. /** @hidden */
  24882. _shouldGenerateFlatShading: boolean;
  24883. /** @hidden */
  24884. _originalBuilderSideOrientation: number;
  24885. /**
  24886. * Use this property to change the original side orientation defined at construction time
  24887. */
  24888. overrideMaterialSideOrientation: Nullable<number>;
  24889. /**
  24890. * Gets the source mesh (the one used to clone this one from)
  24891. */
  24892. get source(): Nullable<Mesh>;
  24893. /**
  24894. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24895. */
  24896. get isUnIndexed(): boolean;
  24897. set isUnIndexed(value: boolean);
  24898. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24899. get worldMatrixInstancedBuffer(): Float32Array;
  24900. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24901. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24902. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24903. /**
  24904. * @constructor
  24905. * @param name The value used by scene.getMeshByName() to do a lookup.
  24906. * @param scene The scene to add this mesh to.
  24907. * @param parent The parent of this mesh, if it has one
  24908. * @param source An optional Mesh from which geometry is shared, cloned.
  24909. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24910. * When false, achieved by calling a clone(), also passing False.
  24911. * This will make creation of children, recursive.
  24912. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24913. */
  24914. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24915. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24916. doNotInstantiate: boolean;
  24917. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24918. /**
  24919. * Gets the class name
  24920. * @returns the string "Mesh".
  24921. */
  24922. getClassName(): string;
  24923. /** @hidden */
  24924. get _isMesh(): boolean;
  24925. /**
  24926. * Returns a description of this mesh
  24927. * @param fullDetails define if full details about this mesh must be used
  24928. * @returns a descriptive string representing this mesh
  24929. */
  24930. toString(fullDetails?: boolean): string;
  24931. /** @hidden */
  24932. _unBindEffect(): void;
  24933. /**
  24934. * Gets a boolean indicating if this mesh has LOD
  24935. */
  24936. get hasLODLevels(): boolean;
  24937. /**
  24938. * Gets the list of MeshLODLevel associated with the current mesh
  24939. * @returns an array of MeshLODLevel
  24940. */
  24941. getLODLevels(): MeshLODLevel[];
  24942. private _sortLODLevels;
  24943. /**
  24944. * Add a mesh as LOD level triggered at the given distance.
  24945. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24946. * @param distance The distance from the center of the object to show this level
  24947. * @param mesh The mesh to be added as LOD level (can be null)
  24948. * @return This mesh (for chaining)
  24949. */
  24950. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24951. /**
  24952. * Returns the LOD level mesh at the passed distance or null if not found.
  24953. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24954. * @param distance The distance from the center of the object to show this level
  24955. * @returns a Mesh or `null`
  24956. */
  24957. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24958. /**
  24959. * Remove a mesh from the LOD array
  24960. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24961. * @param mesh defines the mesh to be removed
  24962. * @return This mesh (for chaining)
  24963. */
  24964. removeLODLevel(mesh: Mesh): Mesh;
  24965. /**
  24966. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24967. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24968. * @param camera defines the camera to use to compute distance
  24969. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24970. * @return This mesh (for chaining)
  24971. */
  24972. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24973. /**
  24974. * Gets the mesh internal Geometry object
  24975. */
  24976. get geometry(): Nullable<Geometry>;
  24977. /**
  24978. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24979. * @returns the total number of vertices
  24980. */
  24981. getTotalVertices(): number;
  24982. /**
  24983. * Returns the content of an associated vertex buffer
  24984. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24985. * - VertexBuffer.PositionKind
  24986. * - VertexBuffer.UVKind
  24987. * - VertexBuffer.UV2Kind
  24988. * - VertexBuffer.UV3Kind
  24989. * - VertexBuffer.UV4Kind
  24990. * - VertexBuffer.UV5Kind
  24991. * - VertexBuffer.UV6Kind
  24992. * - VertexBuffer.ColorKind
  24993. * - VertexBuffer.MatricesIndicesKind
  24994. * - VertexBuffer.MatricesIndicesExtraKind
  24995. * - VertexBuffer.MatricesWeightsKind
  24996. * - VertexBuffer.MatricesWeightsExtraKind
  24997. * @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
  24998. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24999. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25000. */
  25001. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25002. /**
  25003. * Returns the mesh VertexBuffer object from the requested `kind`
  25004. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25005. * - VertexBuffer.PositionKind
  25006. * - VertexBuffer.NormalKind
  25007. * - VertexBuffer.UVKind
  25008. * - VertexBuffer.UV2Kind
  25009. * - VertexBuffer.UV3Kind
  25010. * - VertexBuffer.UV4Kind
  25011. * - VertexBuffer.UV5Kind
  25012. * - VertexBuffer.UV6Kind
  25013. * - VertexBuffer.ColorKind
  25014. * - VertexBuffer.MatricesIndicesKind
  25015. * - VertexBuffer.MatricesIndicesExtraKind
  25016. * - VertexBuffer.MatricesWeightsKind
  25017. * - VertexBuffer.MatricesWeightsExtraKind
  25018. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25019. */
  25020. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25021. /**
  25022. * Tests if a specific vertex buffer is associated with this mesh
  25023. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25024. * - VertexBuffer.PositionKind
  25025. * - VertexBuffer.NormalKind
  25026. * - VertexBuffer.UVKind
  25027. * - VertexBuffer.UV2Kind
  25028. * - VertexBuffer.UV3Kind
  25029. * - VertexBuffer.UV4Kind
  25030. * - VertexBuffer.UV5Kind
  25031. * - VertexBuffer.UV6Kind
  25032. * - VertexBuffer.ColorKind
  25033. * - VertexBuffer.MatricesIndicesKind
  25034. * - VertexBuffer.MatricesIndicesExtraKind
  25035. * - VertexBuffer.MatricesWeightsKind
  25036. * - VertexBuffer.MatricesWeightsExtraKind
  25037. * @returns a boolean
  25038. */
  25039. isVerticesDataPresent(kind: string): boolean;
  25040. /**
  25041. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25042. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25043. * - VertexBuffer.PositionKind
  25044. * - VertexBuffer.UVKind
  25045. * - VertexBuffer.UV2Kind
  25046. * - VertexBuffer.UV3Kind
  25047. * - VertexBuffer.UV4Kind
  25048. * - VertexBuffer.UV5Kind
  25049. * - VertexBuffer.UV6Kind
  25050. * - VertexBuffer.ColorKind
  25051. * - VertexBuffer.MatricesIndicesKind
  25052. * - VertexBuffer.MatricesIndicesExtraKind
  25053. * - VertexBuffer.MatricesWeightsKind
  25054. * - VertexBuffer.MatricesWeightsExtraKind
  25055. * @returns a boolean
  25056. */
  25057. isVertexBufferUpdatable(kind: string): boolean;
  25058. /**
  25059. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25060. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25061. * - VertexBuffer.PositionKind
  25062. * - VertexBuffer.NormalKind
  25063. * - VertexBuffer.UVKind
  25064. * - VertexBuffer.UV2Kind
  25065. * - VertexBuffer.UV3Kind
  25066. * - VertexBuffer.UV4Kind
  25067. * - VertexBuffer.UV5Kind
  25068. * - VertexBuffer.UV6Kind
  25069. * - VertexBuffer.ColorKind
  25070. * - VertexBuffer.MatricesIndicesKind
  25071. * - VertexBuffer.MatricesIndicesExtraKind
  25072. * - VertexBuffer.MatricesWeightsKind
  25073. * - VertexBuffer.MatricesWeightsExtraKind
  25074. * @returns an array of strings
  25075. */
  25076. getVerticesDataKinds(): string[];
  25077. /**
  25078. * Returns a positive integer : the total number of indices in this mesh geometry.
  25079. * @returns the numner of indices or zero if the mesh has no geometry.
  25080. */
  25081. getTotalIndices(): number;
  25082. /**
  25083. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25084. * @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.
  25085. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25086. * @returns the indices array or an empty array if the mesh has no geometry
  25087. */
  25088. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25089. get isBlocked(): boolean;
  25090. /**
  25091. * Determine if the current mesh is ready to be rendered
  25092. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25093. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25094. * @returns true if all associated assets are ready (material, textures, shaders)
  25095. */
  25096. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25097. /**
  25098. * 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.
  25099. */
  25100. get areNormalsFrozen(): boolean;
  25101. /**
  25102. * 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.
  25103. * @returns the current mesh
  25104. */
  25105. freezeNormals(): Mesh;
  25106. /**
  25107. * 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
  25108. * @returns the current mesh
  25109. */
  25110. unfreezeNormals(): Mesh;
  25111. /**
  25112. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25113. */
  25114. set overridenInstanceCount(count: number);
  25115. /** @hidden */
  25116. _preActivate(): Mesh;
  25117. /** @hidden */
  25118. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25119. /** @hidden */
  25120. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25121. /**
  25122. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25123. * This means the mesh underlying bounding box and sphere are recomputed.
  25124. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25125. * @returns the current mesh
  25126. */
  25127. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25128. /** @hidden */
  25129. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25130. /**
  25131. * This function will subdivide the mesh into multiple submeshes
  25132. * @param count defines the expected number of submeshes
  25133. */
  25134. subdivide(count: number): void;
  25135. /**
  25136. * Copy a FloatArray into a specific associated vertex buffer
  25137. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25138. * - VertexBuffer.PositionKind
  25139. * - VertexBuffer.UVKind
  25140. * - VertexBuffer.UV2Kind
  25141. * - VertexBuffer.UV3Kind
  25142. * - VertexBuffer.UV4Kind
  25143. * - VertexBuffer.UV5Kind
  25144. * - VertexBuffer.UV6Kind
  25145. * - VertexBuffer.ColorKind
  25146. * - VertexBuffer.MatricesIndicesKind
  25147. * - VertexBuffer.MatricesIndicesExtraKind
  25148. * - VertexBuffer.MatricesWeightsKind
  25149. * - VertexBuffer.MatricesWeightsExtraKind
  25150. * @param data defines the data source
  25151. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25152. * @param stride defines the data stride size (can be null)
  25153. * @returns the current mesh
  25154. */
  25155. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25156. /**
  25157. * Delete a vertex buffer associated with this mesh
  25158. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25159. * - VertexBuffer.PositionKind
  25160. * - VertexBuffer.UVKind
  25161. * - VertexBuffer.UV2Kind
  25162. * - VertexBuffer.UV3Kind
  25163. * - VertexBuffer.UV4Kind
  25164. * - VertexBuffer.UV5Kind
  25165. * - VertexBuffer.UV6Kind
  25166. * - VertexBuffer.ColorKind
  25167. * - VertexBuffer.MatricesIndicesKind
  25168. * - VertexBuffer.MatricesIndicesExtraKind
  25169. * - VertexBuffer.MatricesWeightsKind
  25170. * - VertexBuffer.MatricesWeightsExtraKind
  25171. */
  25172. removeVerticesData(kind: string): void;
  25173. /**
  25174. * Flags an associated vertex buffer as updatable
  25175. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25176. * - VertexBuffer.PositionKind
  25177. * - VertexBuffer.UVKind
  25178. * - VertexBuffer.UV2Kind
  25179. * - VertexBuffer.UV3Kind
  25180. * - VertexBuffer.UV4Kind
  25181. * - VertexBuffer.UV5Kind
  25182. * - VertexBuffer.UV6Kind
  25183. * - VertexBuffer.ColorKind
  25184. * - VertexBuffer.MatricesIndicesKind
  25185. * - VertexBuffer.MatricesIndicesExtraKind
  25186. * - VertexBuffer.MatricesWeightsKind
  25187. * - VertexBuffer.MatricesWeightsExtraKind
  25188. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25189. */
  25190. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25191. /**
  25192. * Sets the mesh global Vertex Buffer
  25193. * @param buffer defines the buffer to use
  25194. * @returns the current mesh
  25195. */
  25196. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25197. /**
  25198. * Update a specific associated vertex buffer
  25199. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25200. * - VertexBuffer.PositionKind
  25201. * - VertexBuffer.UVKind
  25202. * - VertexBuffer.UV2Kind
  25203. * - VertexBuffer.UV3Kind
  25204. * - VertexBuffer.UV4Kind
  25205. * - VertexBuffer.UV5Kind
  25206. * - VertexBuffer.UV6Kind
  25207. * - VertexBuffer.ColorKind
  25208. * - VertexBuffer.MatricesIndicesKind
  25209. * - VertexBuffer.MatricesIndicesExtraKind
  25210. * - VertexBuffer.MatricesWeightsKind
  25211. * - VertexBuffer.MatricesWeightsExtraKind
  25212. * @param data defines the data source
  25213. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25214. * @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)
  25215. * @returns the current mesh
  25216. */
  25217. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25218. /**
  25219. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25220. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25221. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25222. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25223. * @returns the current mesh
  25224. */
  25225. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25226. /**
  25227. * Creates a un-shared specific occurence of the geometry for the mesh.
  25228. * @returns the current mesh
  25229. */
  25230. makeGeometryUnique(): Mesh;
  25231. /**
  25232. * Set the index buffer of this mesh
  25233. * @param indices defines the source data
  25234. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25235. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25236. * @returns the current mesh
  25237. */
  25238. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25239. /**
  25240. * Update the current index buffer
  25241. * @param indices defines the source data
  25242. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25243. * @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)
  25244. * @returns the current mesh
  25245. */
  25246. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25247. /**
  25248. * Invert the geometry to move from a right handed system to a left handed one.
  25249. * @returns the current mesh
  25250. */
  25251. toLeftHanded(): Mesh;
  25252. /** @hidden */
  25253. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25254. /** @hidden */
  25255. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25256. /**
  25257. * Registers for this mesh a javascript function called just before the rendering process
  25258. * @param func defines the function to call before rendering this mesh
  25259. * @returns the current mesh
  25260. */
  25261. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25262. /**
  25263. * Disposes a previously registered javascript function called before the rendering
  25264. * @param func defines the function to remove
  25265. * @returns the current mesh
  25266. */
  25267. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25268. /**
  25269. * Registers for this mesh a javascript function called just after the rendering is complete
  25270. * @param func defines the function to call after rendering this mesh
  25271. * @returns the current mesh
  25272. */
  25273. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25274. /**
  25275. * Disposes a previously registered javascript function called after the rendering.
  25276. * @param func defines the function to remove
  25277. * @returns the current mesh
  25278. */
  25279. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25280. /** @hidden */
  25281. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25282. /** @hidden */
  25283. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25284. /** @hidden */
  25285. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25286. /** @hidden */
  25287. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25288. /** @hidden */
  25289. _rebuild(): void;
  25290. /** @hidden */
  25291. _freeze(): void;
  25292. /** @hidden */
  25293. _unFreeze(): void;
  25294. /**
  25295. * 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
  25296. * @param subMesh defines the subMesh to render
  25297. * @param enableAlphaMode defines if alpha mode can be changed
  25298. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25299. * @returns the current mesh
  25300. */
  25301. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25302. private _onBeforeDraw;
  25303. /**
  25304. * Renormalize the mesh and patch it up if there are no weights
  25305. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25306. * However in the case of zero weights then we set just a single influence to 1.
  25307. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25308. */
  25309. cleanMatrixWeights(): void;
  25310. private normalizeSkinFourWeights;
  25311. private normalizeSkinWeightsAndExtra;
  25312. /**
  25313. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25314. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25315. * the user know there was an issue with importing the mesh
  25316. * @returns a validation object with skinned, valid and report string
  25317. */
  25318. validateSkinning(): {
  25319. skinned: boolean;
  25320. valid: boolean;
  25321. report: string;
  25322. };
  25323. /** @hidden */
  25324. _checkDelayState(): Mesh;
  25325. private _queueLoad;
  25326. /**
  25327. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25328. * A mesh is in the frustum if its bounding box intersects the frustum
  25329. * @param frustumPlanes defines the frustum to test
  25330. * @returns true if the mesh is in the frustum planes
  25331. */
  25332. isInFrustum(frustumPlanes: Plane[]): boolean;
  25333. /**
  25334. * Sets the mesh material by the material or multiMaterial `id` property
  25335. * @param id is a string identifying the material or the multiMaterial
  25336. * @returns the current mesh
  25337. */
  25338. setMaterialByID(id: string): Mesh;
  25339. /**
  25340. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25341. * @returns an array of IAnimatable
  25342. */
  25343. getAnimatables(): IAnimatable[];
  25344. /**
  25345. * Modifies the mesh geometry according to the passed transformation matrix.
  25346. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25347. * The mesh normals are modified using the same transformation.
  25348. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25349. * @param transform defines the transform matrix to use
  25350. * @see http://doc.babylonjs.com/resources/baking_transformations
  25351. * @returns the current mesh
  25352. */
  25353. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25354. /**
  25355. * Modifies the mesh geometry according to its own current World Matrix.
  25356. * The mesh World Matrix is then reset.
  25357. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25358. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25359. * @see http://doc.babylonjs.com/resources/baking_transformations
  25360. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25361. * @returns the current mesh
  25362. */
  25363. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25364. /** @hidden */
  25365. get _positions(): Nullable<Vector3[]>;
  25366. /** @hidden */
  25367. _resetPointsArrayCache(): Mesh;
  25368. /** @hidden */
  25369. _generatePointsArray(): boolean;
  25370. /**
  25371. * Returns a new Mesh object generated from the current mesh properties.
  25372. * This method must not get confused with createInstance()
  25373. * @param name is a string, the name given to the new mesh
  25374. * @param newParent can be any Node object (default `null`)
  25375. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25376. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25377. * @returns a new mesh
  25378. */
  25379. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25380. /**
  25381. * Releases resources associated with this mesh.
  25382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25384. */
  25385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25386. /** @hidden */
  25387. _disposeInstanceSpecificData(): void;
  25388. /**
  25389. * Modifies the mesh geometry according to a displacement map.
  25390. * 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.
  25391. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25392. * @param url is a string, the URL from the image file is to be downloaded.
  25393. * @param minHeight is the lower limit of the displacement.
  25394. * @param maxHeight is the upper limit of the displacement.
  25395. * @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.
  25396. * @param uvOffset is an optional vector2 used to offset UV.
  25397. * @param uvScale is an optional vector2 used to scale UV.
  25398. * @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.
  25399. * @returns the Mesh.
  25400. */
  25401. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25402. /**
  25403. * Modifies the mesh geometry according to a displacementMap buffer.
  25404. * 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.
  25405. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25406. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25407. * @param heightMapWidth is the width of the buffer image.
  25408. * @param heightMapHeight is the height of the buffer image.
  25409. * @param minHeight is the lower limit of the displacement.
  25410. * @param maxHeight is the upper limit of the displacement.
  25411. * @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.
  25412. * @param uvOffset is an optional vector2 used to offset UV.
  25413. * @param uvScale is an optional vector2 used to scale UV.
  25414. * @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.
  25415. * @returns the Mesh.
  25416. */
  25417. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25418. /**
  25419. * Modify the mesh to get a flat shading rendering.
  25420. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25421. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25422. * @returns current mesh
  25423. */
  25424. convertToFlatShadedMesh(): Mesh;
  25425. /**
  25426. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25427. * In other words, more vertices, no more indices and a single bigger VBO.
  25428. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25429. * @returns current mesh
  25430. */
  25431. convertToUnIndexedMesh(): Mesh;
  25432. /**
  25433. * Inverses facet orientations.
  25434. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25435. * @param flipNormals will also inverts the normals
  25436. * @returns current mesh
  25437. */
  25438. flipFaces(flipNormals?: boolean): Mesh;
  25439. /**
  25440. * Increase the number of facets and hence vertices in a mesh
  25441. * Vertex normals are interpolated from existing vertex normals
  25442. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25443. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25444. */
  25445. increaseVertices(numberPerEdge: number): void;
  25446. /**
  25447. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25448. * This will undo any application of covertToFlatShadedMesh
  25449. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25450. */
  25451. forceSharedVertices(): void;
  25452. /** @hidden */
  25453. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25454. /** @hidden */
  25455. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25456. /**
  25457. * Creates a new InstancedMesh object from the mesh model.
  25458. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25459. * @param name defines the name of the new instance
  25460. * @returns a new InstancedMesh
  25461. */
  25462. createInstance(name: string): InstancedMesh;
  25463. /**
  25464. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25465. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25466. * @returns the current mesh
  25467. */
  25468. synchronizeInstances(): Mesh;
  25469. /**
  25470. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25471. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25472. * This should be used together with the simplification to avoid disappearing triangles.
  25473. * @param successCallback an optional success callback to be called after the optimization finished.
  25474. * @returns the current mesh
  25475. */
  25476. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25477. /**
  25478. * Serialize current mesh
  25479. * @param serializationObject defines the object which will receive the serialization data
  25480. */
  25481. serialize(serializationObject: any): void;
  25482. /** @hidden */
  25483. _syncGeometryWithMorphTargetManager(): void;
  25484. /** @hidden */
  25485. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25486. /**
  25487. * Returns a new Mesh object parsed from the source provided.
  25488. * @param parsedMesh is the source
  25489. * @param scene defines the hosting scene
  25490. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25491. * @returns a new Mesh
  25492. */
  25493. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25494. /**
  25495. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25496. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25497. * @param name defines the name of the mesh to create
  25498. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25499. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25500. * @param closePath creates a seam between the first and the last points of each path of the path array
  25501. * @param offset is taken in account only if the `pathArray` is containing a single path
  25502. * @param scene defines the hosting scene
  25503. * @param updatable defines if the mesh must be flagged as updatable
  25504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25505. * @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)
  25506. * @returns a new Mesh
  25507. */
  25508. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25509. /**
  25510. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25511. * @param name defines the name of the mesh to create
  25512. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25513. * @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
  25514. * @param scene defines the hosting scene
  25515. * @param updatable defines if the mesh must be flagged as updatable
  25516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25517. * @returns a new Mesh
  25518. */
  25519. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25520. /**
  25521. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25522. * @param name defines the name of the mesh to create
  25523. * @param size sets the size (float) of each box side (default 1)
  25524. * @param scene defines the hosting scene
  25525. * @param updatable defines if the mesh must be flagged as updatable
  25526. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25527. * @returns a new Mesh
  25528. */
  25529. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25530. /**
  25531. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25532. * @param name defines the name of the mesh to create
  25533. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25534. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25535. * @param scene defines the hosting scene
  25536. * @param updatable defines if the mesh must be flagged as updatable
  25537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25538. * @returns a new Mesh
  25539. */
  25540. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25541. /**
  25542. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25543. * @param name defines the name of the mesh to create
  25544. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25545. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25546. * @param scene defines the hosting scene
  25547. * @returns a new Mesh
  25548. */
  25549. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25550. /**
  25551. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25552. * @param name defines the name of the mesh to create
  25553. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25554. * @param diameterTop set the top cap diameter (floats, default 1)
  25555. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25556. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25557. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25558. * @param scene defines the hosting scene
  25559. * @param updatable defines if the mesh must be flagged as updatable
  25560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25561. * @returns a new Mesh
  25562. */
  25563. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25564. /**
  25565. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25566. * @param name defines the name of the mesh to create
  25567. * @param diameter sets the diameter size (float) of the torus (default 1)
  25568. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25569. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25570. * @param scene defines the hosting scene
  25571. * @param updatable defines if the mesh must be flagged as updatable
  25572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25573. * @returns a new Mesh
  25574. */
  25575. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25576. /**
  25577. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25578. * @param name defines the name of the mesh to create
  25579. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25580. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25581. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25582. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25583. * @param p the number of windings on X axis (positive integers, default 2)
  25584. * @param q the number of windings on Y axis (positive integers, default 3)
  25585. * @param scene defines the hosting scene
  25586. * @param updatable defines if the mesh must be flagged as updatable
  25587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25588. * @returns a new Mesh
  25589. */
  25590. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25591. /**
  25592. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25593. * @param name defines the name of the mesh to create
  25594. * @param points is an array successive Vector3
  25595. * @param scene defines the hosting scene
  25596. * @param updatable defines if the mesh must be flagged as updatable
  25597. * @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).
  25598. * @returns a new Mesh
  25599. */
  25600. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25601. /**
  25602. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25603. * @param name defines the name of the mesh to create
  25604. * @param points is an array successive Vector3
  25605. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25606. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25607. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25608. * @param scene defines the hosting scene
  25609. * @param updatable defines if the mesh must be flagged as updatable
  25610. * @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)
  25611. * @returns a new Mesh
  25612. */
  25613. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25614. /**
  25615. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25616. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25617. * 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.
  25618. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25619. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25620. * Remember you can only change the shape positions, not their number when updating a polygon.
  25621. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25622. * @param name defines the name of the mesh to create
  25623. * @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
  25624. * @param scene defines the hosting scene
  25625. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25626. * @param updatable defines if the mesh must be flagged as updatable
  25627. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25628. * @param earcutInjection can be used to inject your own earcut reference
  25629. * @returns a new Mesh
  25630. */
  25631. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25632. /**
  25633. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25634. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25635. * @param name defines the name of the mesh to create
  25636. * @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
  25637. * @param depth defines the height of extrusion
  25638. * @param scene defines the hosting scene
  25639. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25640. * @param updatable defines if the mesh must be flagged as updatable
  25641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25642. * @param earcutInjection can be used to inject your own earcut reference
  25643. * @returns a new Mesh
  25644. */
  25645. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25646. /**
  25647. * Creates an extruded shape mesh.
  25648. * 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
  25649. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25650. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25651. * @param name defines the name of the mesh to create
  25652. * @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
  25653. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25654. * @param scale is the value to scale the shape
  25655. * @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
  25656. * @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
  25657. * @param scene defines the hosting scene
  25658. * @param updatable defines if the mesh must be flagged as updatable
  25659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25660. * @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)
  25661. * @returns a new Mesh
  25662. */
  25663. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25664. /**
  25665. * Creates an custom extruded shape mesh.
  25666. * The custom extrusion is a parametric shape.
  25667. * It has no predefined shape. Its final shape will depend on the input parameters.
  25668. * Please consider using the same method from the MeshBuilder class instead
  25669. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25670. * @param name defines the name of the mesh to create
  25671. * @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
  25672. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25673. * @param scaleFunction is a custom Javascript function called on each path point
  25674. * @param rotationFunction is a custom Javascript function called on each path point
  25675. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25676. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25677. * @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
  25678. * @param scene defines the hosting scene
  25679. * @param updatable defines if the mesh must be flagged as updatable
  25680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25681. * @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)
  25682. * @returns a new Mesh
  25683. */
  25684. 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;
  25685. /**
  25686. * Creates lathe mesh.
  25687. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25688. * Please consider using the same method from the MeshBuilder class instead
  25689. * @param name defines the name of the mesh to create
  25690. * @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
  25691. * @param radius is the radius value of the lathe
  25692. * @param tessellation is the side number of the lathe.
  25693. * @param scene defines the hosting scene
  25694. * @param updatable defines if the mesh must be flagged as updatable
  25695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25696. * @returns a new Mesh
  25697. */
  25698. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25699. /**
  25700. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25701. * @param name defines the name of the mesh to create
  25702. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25703. * @param scene defines the hosting scene
  25704. * @param updatable defines if the mesh must be flagged as updatable
  25705. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25706. * @returns a new Mesh
  25707. */
  25708. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25709. /**
  25710. * Creates a ground mesh.
  25711. * Please consider using the same method from the MeshBuilder class instead
  25712. * @param name defines the name of the mesh to create
  25713. * @param width set the width of the ground
  25714. * @param height set the height of the ground
  25715. * @param subdivisions sets the number of subdivisions per side
  25716. * @param scene defines the hosting scene
  25717. * @param updatable defines if the mesh must be flagged as updatable
  25718. * @returns a new Mesh
  25719. */
  25720. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25721. /**
  25722. * Creates a tiled ground mesh.
  25723. * Please consider using the same method from the MeshBuilder class instead
  25724. * @param name defines the name of the mesh to create
  25725. * @param xmin set the ground minimum X coordinate
  25726. * @param zmin set the ground minimum Y coordinate
  25727. * @param xmax set the ground maximum X coordinate
  25728. * @param zmax set the ground maximum Z coordinate
  25729. * @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
  25730. * @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
  25731. * @param scene defines the hosting scene
  25732. * @param updatable defines if the mesh must be flagged as updatable
  25733. * @returns a new Mesh
  25734. */
  25735. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25736. w: number;
  25737. h: number;
  25738. }, precision: {
  25739. w: number;
  25740. h: number;
  25741. }, scene: Scene, updatable?: boolean): Mesh;
  25742. /**
  25743. * Creates a ground mesh from a height map.
  25744. * Please consider using the same method from the MeshBuilder class instead
  25745. * @see http://doc.babylonjs.com/babylon101/height_map
  25746. * @param name defines the name of the mesh to create
  25747. * @param url sets the URL of the height map image resource
  25748. * @param width set the ground width size
  25749. * @param height set the ground height size
  25750. * @param subdivisions sets the number of subdivision per side
  25751. * @param minHeight is the minimum altitude on the ground
  25752. * @param maxHeight is the maximum altitude on the ground
  25753. * @param scene defines the hosting scene
  25754. * @param updatable defines if the mesh must be flagged as updatable
  25755. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25756. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25757. * @returns a new Mesh
  25758. */
  25759. 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;
  25760. /**
  25761. * Creates a tube mesh.
  25762. * The tube is a parametric shape.
  25763. * It has no predefined shape. Its final shape will depend on the input parameters.
  25764. * Please consider using the same method from the MeshBuilder class instead
  25765. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25766. * @param name defines the name of the mesh to create
  25767. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25768. * @param radius sets the tube radius size
  25769. * @param tessellation is the number of sides on the tubular surface
  25770. * @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
  25771. * @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
  25772. * @param scene defines the hosting scene
  25773. * @param updatable defines if the mesh must be flagged as updatable
  25774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25775. * @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)
  25776. * @returns a new Mesh
  25777. */
  25778. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25779. (i: number, distance: number): number;
  25780. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25781. /**
  25782. * Creates a polyhedron mesh.
  25783. * Please consider using the same method from the MeshBuilder class instead.
  25784. * * 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
  25785. * * The parameter `size` (positive float, default 1) sets the polygon size
  25786. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25787. * * 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`
  25788. * * 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
  25789. * * 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)`)
  25790. * * 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
  25791. * * 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
  25792. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25793. * * 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
  25794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25795. * @param name defines the name of the mesh to create
  25796. * @param options defines the options used to create the mesh
  25797. * @param scene defines the hosting scene
  25798. * @returns a new Mesh
  25799. */
  25800. static CreatePolyhedron(name: string, options: {
  25801. type?: number;
  25802. size?: number;
  25803. sizeX?: number;
  25804. sizeY?: number;
  25805. sizeZ?: number;
  25806. custom?: any;
  25807. faceUV?: Vector4[];
  25808. faceColors?: Color4[];
  25809. updatable?: boolean;
  25810. sideOrientation?: number;
  25811. }, scene: Scene): Mesh;
  25812. /**
  25813. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25814. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25815. * * 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`)
  25816. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25817. * * 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
  25818. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25819. * * 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
  25820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25821. * @param name defines the name of the mesh
  25822. * @param options defines the options used to create the mesh
  25823. * @param scene defines the hosting scene
  25824. * @returns a new Mesh
  25825. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25826. */
  25827. static CreateIcoSphere(name: string, options: {
  25828. radius?: number;
  25829. flat?: boolean;
  25830. subdivisions?: number;
  25831. sideOrientation?: number;
  25832. updatable?: boolean;
  25833. }, scene: Scene): Mesh;
  25834. /**
  25835. * Creates a decal mesh.
  25836. * Please consider using the same method from the MeshBuilder class instead.
  25837. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25838. * @param name defines the name of the mesh
  25839. * @param sourceMesh defines the mesh receiving the decal
  25840. * @param position sets the position of the decal in world coordinates
  25841. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25842. * @param size sets the decal scaling
  25843. * @param angle sets the angle to rotate the decal
  25844. * @returns a new Mesh
  25845. */
  25846. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25847. /**
  25848. * Prepare internal position array for software CPU skinning
  25849. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25850. */
  25851. setPositionsForCPUSkinning(): Float32Array;
  25852. /**
  25853. * Prepare internal normal array for software CPU skinning
  25854. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25855. */
  25856. setNormalsForCPUSkinning(): Float32Array;
  25857. /**
  25858. * Updates the vertex buffer by applying transformation from the bones
  25859. * @param skeleton defines the skeleton to apply to current mesh
  25860. * @returns the current mesh
  25861. */
  25862. applySkeleton(skeleton: Skeleton): Mesh;
  25863. /**
  25864. * 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
  25865. * @param meshes defines the list of meshes to scan
  25866. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25867. */
  25868. static MinMax(meshes: AbstractMesh[]): {
  25869. min: Vector3;
  25870. max: Vector3;
  25871. };
  25872. /**
  25873. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25874. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25875. * @returns a vector3
  25876. */
  25877. static Center(meshesOrMinMaxVector: {
  25878. min: Vector3;
  25879. max: Vector3;
  25880. } | AbstractMesh[]): Vector3;
  25881. /**
  25882. * Merge the array of meshes into a single mesh for performance reasons.
  25883. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25884. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25885. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25886. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25887. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25888. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25889. * @returns a new mesh
  25890. */
  25891. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25892. /** @hidden */
  25893. addInstance(instance: InstancedMesh): void;
  25894. /** @hidden */
  25895. removeInstance(instance: InstancedMesh): void;
  25896. }
  25897. }
  25898. declare module BABYLON {
  25899. /**
  25900. * This is the base class of all the camera used in the application.
  25901. * @see http://doc.babylonjs.com/features/cameras
  25902. */
  25903. export class Camera extends Node {
  25904. /** @hidden */
  25905. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25906. /**
  25907. * This is the default projection mode used by the cameras.
  25908. * It helps recreating a feeling of perspective and better appreciate depth.
  25909. * This is the best way to simulate real life cameras.
  25910. */
  25911. static readonly PERSPECTIVE_CAMERA: number;
  25912. /**
  25913. * This helps creating camera with an orthographic mode.
  25914. * 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.
  25915. */
  25916. static readonly ORTHOGRAPHIC_CAMERA: number;
  25917. /**
  25918. * This is the default FOV mode for perspective cameras.
  25919. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25920. */
  25921. static readonly FOVMODE_VERTICAL_FIXED: number;
  25922. /**
  25923. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25924. */
  25925. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25926. /**
  25927. * This specifies ther is no need for a camera rig.
  25928. * Basically only one eye is rendered corresponding to the camera.
  25929. */
  25930. static readonly RIG_MODE_NONE: number;
  25931. /**
  25932. * Simulates a camera Rig with one blue eye and one red eye.
  25933. * This can be use with 3d blue and red glasses.
  25934. */
  25935. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25936. /**
  25937. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25938. */
  25939. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25940. /**
  25941. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25942. */
  25943. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25944. /**
  25945. * Defines that both eyes of the camera will be rendered over under each other.
  25946. */
  25947. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25948. /**
  25949. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25950. */
  25951. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25952. /**
  25953. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25954. */
  25955. static readonly RIG_MODE_VR: number;
  25956. /**
  25957. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25958. */
  25959. static readonly RIG_MODE_WEBVR: number;
  25960. /**
  25961. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25962. */
  25963. static readonly RIG_MODE_CUSTOM: number;
  25964. /**
  25965. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25966. */
  25967. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25968. /**
  25969. * Define the input manager associated with the camera.
  25970. */
  25971. inputs: CameraInputsManager<Camera>;
  25972. /** @hidden */
  25973. _position: Vector3;
  25974. /**
  25975. * Define the current local position of the camera in the scene
  25976. */
  25977. get position(): Vector3;
  25978. set position(newPosition: Vector3);
  25979. /**
  25980. * The vector the camera should consider as up.
  25981. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25982. */
  25983. upVector: Vector3;
  25984. /**
  25985. * Define the current limit on the left side for an orthographic camera
  25986. * In scene unit
  25987. */
  25988. orthoLeft: Nullable<number>;
  25989. /**
  25990. * Define the current limit on the right side for an orthographic camera
  25991. * In scene unit
  25992. */
  25993. orthoRight: Nullable<number>;
  25994. /**
  25995. * Define the current limit on the bottom side for an orthographic camera
  25996. * In scene unit
  25997. */
  25998. orthoBottom: Nullable<number>;
  25999. /**
  26000. * Define the current limit on the top side for an orthographic camera
  26001. * In scene unit
  26002. */
  26003. orthoTop: Nullable<number>;
  26004. /**
  26005. * Field Of View is set in Radians. (default is 0.8)
  26006. */
  26007. fov: number;
  26008. /**
  26009. * Define the minimum distance the camera can see from.
  26010. * This is important to note that the depth buffer are not infinite and the closer it starts
  26011. * the more your scene might encounter depth fighting issue.
  26012. */
  26013. minZ: number;
  26014. /**
  26015. * Define the maximum distance the camera can see to.
  26016. * This is important to note that the depth buffer are not infinite and the further it end
  26017. * the more your scene might encounter depth fighting issue.
  26018. */
  26019. maxZ: number;
  26020. /**
  26021. * Define the default inertia of the camera.
  26022. * This helps giving a smooth feeling to the camera movement.
  26023. */
  26024. inertia: number;
  26025. /**
  26026. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26027. */
  26028. mode: number;
  26029. /**
  26030. * Define whether the camera is intermediate.
  26031. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26032. */
  26033. isIntermediate: boolean;
  26034. /**
  26035. * Define the viewport of the camera.
  26036. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26037. */
  26038. viewport: Viewport;
  26039. /**
  26040. * Restricts the camera to viewing objects with the same layerMask.
  26041. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26042. */
  26043. layerMask: number;
  26044. /**
  26045. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26046. */
  26047. fovMode: number;
  26048. /**
  26049. * Rig mode of the camera.
  26050. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26051. * This is normally controlled byt the camera themselves as internal use.
  26052. */
  26053. cameraRigMode: number;
  26054. /**
  26055. * Defines the distance between both "eyes" in case of a RIG
  26056. */
  26057. interaxialDistance: number;
  26058. /**
  26059. * Defines if stereoscopic rendering is done side by side or over under.
  26060. */
  26061. isStereoscopicSideBySide: boolean;
  26062. /**
  26063. * 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
  26064. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26065. * else in the scene. (Eg. security camera)
  26066. *
  26067. * 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)
  26068. */
  26069. customRenderTargets: RenderTargetTexture[];
  26070. /**
  26071. * When set, the camera will render to this render target instead of the default canvas
  26072. *
  26073. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26074. */
  26075. outputRenderTarget: Nullable<RenderTargetTexture>;
  26076. /**
  26077. * Observable triggered when the camera view matrix has changed.
  26078. */
  26079. onViewMatrixChangedObservable: Observable<Camera>;
  26080. /**
  26081. * Observable triggered when the camera Projection matrix has changed.
  26082. */
  26083. onProjectionMatrixChangedObservable: Observable<Camera>;
  26084. /**
  26085. * Observable triggered when the inputs have been processed.
  26086. */
  26087. onAfterCheckInputsObservable: Observable<Camera>;
  26088. /**
  26089. * Observable triggered when reset has been called and applied to the camera.
  26090. */
  26091. onRestoreStateObservable: Observable<Camera>;
  26092. /**
  26093. * Is this camera a part of a rig system?
  26094. */
  26095. isRigCamera: boolean;
  26096. /**
  26097. * If isRigCamera set to true this will be set with the parent camera.
  26098. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26099. */
  26100. rigParent?: Camera;
  26101. /** @hidden */
  26102. _cameraRigParams: any;
  26103. /** @hidden */
  26104. _rigCameras: Camera[];
  26105. /** @hidden */
  26106. _rigPostProcess: Nullable<PostProcess>;
  26107. protected _webvrViewMatrix: Matrix;
  26108. /** @hidden */
  26109. _skipRendering: boolean;
  26110. /** @hidden */
  26111. _projectionMatrix: Matrix;
  26112. /** @hidden */
  26113. _postProcesses: Nullable<PostProcess>[];
  26114. /** @hidden */
  26115. _activeMeshes: SmartArray<AbstractMesh>;
  26116. protected _globalPosition: Vector3;
  26117. /** @hidden */
  26118. _computedViewMatrix: Matrix;
  26119. private _doNotComputeProjectionMatrix;
  26120. private _transformMatrix;
  26121. private _frustumPlanes;
  26122. private _refreshFrustumPlanes;
  26123. private _storedFov;
  26124. private _stateStored;
  26125. /**
  26126. * Instantiates a new camera object.
  26127. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26128. * @see http://doc.babylonjs.com/features/cameras
  26129. * @param name Defines the name of the camera in the scene
  26130. * @param position Defines the position of the camera
  26131. * @param scene Defines the scene the camera belongs too
  26132. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26133. */
  26134. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26135. /**
  26136. * Store current camera state (fov, position, etc..)
  26137. * @returns the camera
  26138. */
  26139. storeState(): Camera;
  26140. /**
  26141. * Restores the camera state values if it has been stored. You must call storeState() first
  26142. */
  26143. protected _restoreStateValues(): boolean;
  26144. /**
  26145. * Restored camera state. You must call storeState() first.
  26146. * @returns true if restored and false otherwise
  26147. */
  26148. restoreState(): boolean;
  26149. /**
  26150. * Gets the class name of the camera.
  26151. * @returns the class name
  26152. */
  26153. getClassName(): string;
  26154. /** @hidden */
  26155. readonly _isCamera: boolean;
  26156. /**
  26157. * Gets a string representation of the camera useful for debug purpose.
  26158. * @param fullDetails Defines that a more verboe level of logging is required
  26159. * @returns the string representation
  26160. */
  26161. toString(fullDetails?: boolean): string;
  26162. /**
  26163. * Gets the current world space position of the camera.
  26164. */
  26165. get globalPosition(): Vector3;
  26166. /**
  26167. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26168. * @returns the active meshe list
  26169. */
  26170. getActiveMeshes(): SmartArray<AbstractMesh>;
  26171. /**
  26172. * Check whether a mesh is part of the current active mesh list of the camera
  26173. * @param mesh Defines the mesh to check
  26174. * @returns true if active, false otherwise
  26175. */
  26176. isActiveMesh(mesh: Mesh): boolean;
  26177. /**
  26178. * Is this camera ready to be used/rendered
  26179. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26180. * @return true if the camera is ready
  26181. */
  26182. isReady(completeCheck?: boolean): boolean;
  26183. /** @hidden */
  26184. _initCache(): void;
  26185. /** @hidden */
  26186. _updateCache(ignoreParentClass?: boolean): void;
  26187. /** @hidden */
  26188. _isSynchronized(): boolean;
  26189. /** @hidden */
  26190. _isSynchronizedViewMatrix(): boolean;
  26191. /** @hidden */
  26192. _isSynchronizedProjectionMatrix(): boolean;
  26193. /**
  26194. * Attach the input controls to a specific dom element to get the input from.
  26195. * @param element Defines the element the controls should be listened from
  26196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26197. */
  26198. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26199. /**
  26200. * Detach the current controls from the specified dom element.
  26201. * @param element Defines the element to stop listening the inputs from
  26202. */
  26203. detachControl(element: HTMLElement): void;
  26204. /**
  26205. * Update the camera state according to the different inputs gathered during the frame.
  26206. */
  26207. update(): void;
  26208. /** @hidden */
  26209. _checkInputs(): void;
  26210. /** @hidden */
  26211. get rigCameras(): Camera[];
  26212. /**
  26213. * Gets the post process used by the rig cameras
  26214. */
  26215. get rigPostProcess(): Nullable<PostProcess>;
  26216. /**
  26217. * Internal, gets the first post proces.
  26218. * @returns the first post process to be run on this camera.
  26219. */
  26220. _getFirstPostProcess(): Nullable<PostProcess>;
  26221. private _cascadePostProcessesToRigCams;
  26222. /**
  26223. * Attach a post process to the camera.
  26224. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26225. * @param postProcess The post process to attach to the camera
  26226. * @param insertAt The position of the post process in case several of them are in use in the scene
  26227. * @returns the position the post process has been inserted at
  26228. */
  26229. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26230. /**
  26231. * Detach a post process to the camera.
  26232. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26233. * @param postProcess The post process to detach from the camera
  26234. */
  26235. detachPostProcess(postProcess: PostProcess): void;
  26236. /**
  26237. * Gets the current world matrix of the camera
  26238. */
  26239. getWorldMatrix(): Matrix;
  26240. /** @hidden */
  26241. _getViewMatrix(): Matrix;
  26242. /**
  26243. * Gets the current view matrix of the camera.
  26244. * @param force forces the camera to recompute the matrix without looking at the cached state
  26245. * @returns the view matrix
  26246. */
  26247. getViewMatrix(force?: boolean): Matrix;
  26248. /**
  26249. * Freeze the projection matrix.
  26250. * It will prevent the cache check of the camera projection compute and can speed up perf
  26251. * if no parameter of the camera are meant to change
  26252. * @param projection Defines manually a projection if necessary
  26253. */
  26254. freezeProjectionMatrix(projection?: Matrix): void;
  26255. /**
  26256. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26257. */
  26258. unfreezeProjectionMatrix(): void;
  26259. /**
  26260. * Gets the current projection matrix of the camera.
  26261. * @param force forces the camera to recompute the matrix without looking at the cached state
  26262. * @returns the projection matrix
  26263. */
  26264. getProjectionMatrix(force?: boolean): Matrix;
  26265. /**
  26266. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26267. * @returns a Matrix
  26268. */
  26269. getTransformationMatrix(): Matrix;
  26270. private _updateFrustumPlanes;
  26271. /**
  26272. * Checks if a cullable object (mesh...) is in the camera frustum
  26273. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26274. * @param target The object to check
  26275. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26276. * @returns true if the object is in frustum otherwise false
  26277. */
  26278. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26279. /**
  26280. * Checks if a cullable object (mesh...) is in the camera frustum
  26281. * Unlike isInFrustum this cheks the full bounding box
  26282. * @param target The object to check
  26283. * @returns true if the object is in frustum otherwise false
  26284. */
  26285. isCompletelyInFrustum(target: ICullable): boolean;
  26286. /**
  26287. * Gets a ray in the forward direction from the camera.
  26288. * @param length Defines the length of the ray to create
  26289. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26290. * @param origin Defines the start point of the ray which defaults to the camera position
  26291. * @returns the forward ray
  26292. */
  26293. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26294. /**
  26295. * Releases resources associated with this node.
  26296. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26297. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26298. */
  26299. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26300. /** @hidden */
  26301. _isLeftCamera: boolean;
  26302. /**
  26303. * Gets the left camera of a rig setup in case of Rigged Camera
  26304. */
  26305. get isLeftCamera(): boolean;
  26306. /** @hidden */
  26307. _isRightCamera: boolean;
  26308. /**
  26309. * Gets the right camera of a rig setup in case of Rigged Camera
  26310. */
  26311. get isRightCamera(): boolean;
  26312. /**
  26313. * Gets the left camera of a rig setup in case of Rigged Camera
  26314. */
  26315. get leftCamera(): Nullable<FreeCamera>;
  26316. /**
  26317. * Gets the right camera of a rig setup in case of Rigged Camera
  26318. */
  26319. get rightCamera(): Nullable<FreeCamera>;
  26320. /**
  26321. * Gets the left camera target of a rig setup in case of Rigged Camera
  26322. * @returns the target position
  26323. */
  26324. getLeftTarget(): Nullable<Vector3>;
  26325. /**
  26326. * Gets the right camera target of a rig setup in case of Rigged Camera
  26327. * @returns the target position
  26328. */
  26329. getRightTarget(): Nullable<Vector3>;
  26330. /**
  26331. * @hidden
  26332. */
  26333. setCameraRigMode(mode: number, rigParams: any): void;
  26334. /** @hidden */
  26335. static _setStereoscopicRigMode(camera: Camera): void;
  26336. /** @hidden */
  26337. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26338. /** @hidden */
  26339. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26340. /** @hidden */
  26341. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26342. /** @hidden */
  26343. _getVRProjectionMatrix(): Matrix;
  26344. protected _updateCameraRotationMatrix(): void;
  26345. protected _updateWebVRCameraRotationMatrix(): void;
  26346. /**
  26347. * This function MUST be overwritten by the different WebVR cameras available.
  26348. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26349. * @hidden
  26350. */
  26351. _getWebVRProjectionMatrix(): Matrix;
  26352. /**
  26353. * This function MUST be overwritten by the different WebVR cameras available.
  26354. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26355. * @hidden
  26356. */
  26357. _getWebVRViewMatrix(): Matrix;
  26358. /** @hidden */
  26359. setCameraRigParameter(name: string, value: any): void;
  26360. /**
  26361. * needs to be overridden by children so sub has required properties to be copied
  26362. * @hidden
  26363. */
  26364. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26365. /**
  26366. * May need to be overridden by children
  26367. * @hidden
  26368. */
  26369. _updateRigCameras(): void;
  26370. /** @hidden */
  26371. _setupInputs(): void;
  26372. /**
  26373. * Serialiaze the camera setup to a json represention
  26374. * @returns the JSON representation
  26375. */
  26376. serialize(): any;
  26377. /**
  26378. * Clones the current camera.
  26379. * @param name The cloned camera name
  26380. * @returns the cloned camera
  26381. */
  26382. clone(name: string): Camera;
  26383. /**
  26384. * Gets the direction of the camera relative to a given local axis.
  26385. * @param localAxis Defines the reference axis to provide a relative direction.
  26386. * @return the direction
  26387. */
  26388. getDirection(localAxis: Vector3): Vector3;
  26389. /**
  26390. * Returns the current camera absolute rotation
  26391. */
  26392. get absoluteRotation(): Quaternion;
  26393. /**
  26394. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26395. * @param localAxis Defines the reference axis to provide a relative direction.
  26396. * @param result Defines the vector to store the result in
  26397. */
  26398. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26399. /**
  26400. * Gets a camera constructor for a given camera type
  26401. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26402. * @param name The name of the camera the result will be able to instantiate
  26403. * @param scene The scene the result will construct the camera in
  26404. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26405. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26406. * @returns a factory method to construc the camera
  26407. */
  26408. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26409. /**
  26410. * Compute the world matrix of the camera.
  26411. * @returns the camera world matrix
  26412. */
  26413. computeWorldMatrix(): Matrix;
  26414. /**
  26415. * Parse a JSON and creates the camera from the parsed information
  26416. * @param parsedCamera The JSON to parse
  26417. * @param scene The scene to instantiate the camera in
  26418. * @returns the newly constructed camera
  26419. */
  26420. static Parse(parsedCamera: any, scene: Scene): Camera;
  26421. }
  26422. }
  26423. declare module BABYLON {
  26424. /**
  26425. * Class containing static functions to help procedurally build meshes
  26426. */
  26427. export class DiscBuilder {
  26428. /**
  26429. * Creates a plane polygonal mesh. By default, this is a disc
  26430. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26431. * * 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
  26432. * * 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
  26433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26434. * * 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
  26435. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26436. * @param name defines the name of the mesh
  26437. * @param options defines the options used to create the mesh
  26438. * @param scene defines the hosting scene
  26439. * @returns the plane polygonal mesh
  26440. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26441. */
  26442. static CreateDisc(name: string, options: {
  26443. radius?: number;
  26444. tessellation?: number;
  26445. arc?: number;
  26446. updatable?: boolean;
  26447. sideOrientation?: number;
  26448. frontUVs?: Vector4;
  26449. backUVs?: Vector4;
  26450. }, scene?: Nullable<Scene>): Mesh;
  26451. }
  26452. }
  26453. declare module BABYLON {
  26454. /**
  26455. * Options to be used when creating a FresnelParameters.
  26456. */
  26457. export type IFresnelParametersCreationOptions = {
  26458. /**
  26459. * Define the color used on edges (grazing angle)
  26460. */
  26461. leftColor?: Color3;
  26462. /**
  26463. * Define the color used on center
  26464. */
  26465. rightColor?: Color3;
  26466. /**
  26467. * Define bias applied to computed fresnel term
  26468. */
  26469. bias?: number;
  26470. /**
  26471. * Defined the power exponent applied to fresnel term
  26472. */
  26473. power?: number;
  26474. /**
  26475. * Define if the fresnel effect is enable or not.
  26476. */
  26477. isEnabled?: boolean;
  26478. };
  26479. /**
  26480. * Serialized format for FresnelParameters.
  26481. */
  26482. export type IFresnelParametersSerialized = {
  26483. /**
  26484. * Define the color used on edges (grazing angle) [as an array]
  26485. */
  26486. leftColor: number[];
  26487. /**
  26488. * Define the color used on center [as an array]
  26489. */
  26490. rightColor: number[];
  26491. /**
  26492. * Define bias applied to computed fresnel term
  26493. */
  26494. bias: number;
  26495. /**
  26496. * Defined the power exponent applied to fresnel term
  26497. */
  26498. power?: number;
  26499. /**
  26500. * Define if the fresnel effect is enable or not.
  26501. */
  26502. isEnabled: boolean;
  26503. };
  26504. /**
  26505. * This represents all the required information to add a fresnel effect on a material:
  26506. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26507. */
  26508. export class FresnelParameters {
  26509. private _isEnabled;
  26510. /**
  26511. * Define if the fresnel effect is enable or not.
  26512. */
  26513. get isEnabled(): boolean;
  26514. set isEnabled(value: boolean);
  26515. /**
  26516. * Define the color used on edges (grazing angle)
  26517. */
  26518. leftColor: Color3;
  26519. /**
  26520. * Define the color used on center
  26521. */
  26522. rightColor: Color3;
  26523. /**
  26524. * Define bias applied to computed fresnel term
  26525. */
  26526. bias: number;
  26527. /**
  26528. * Defined the power exponent applied to fresnel term
  26529. */
  26530. power: number;
  26531. /**
  26532. * Creates a new FresnelParameters object.
  26533. *
  26534. * @param options provide your own settings to optionally to override defaults
  26535. */
  26536. constructor(options?: IFresnelParametersCreationOptions);
  26537. /**
  26538. * Clones the current fresnel and its valuues
  26539. * @returns a clone fresnel configuration
  26540. */
  26541. clone(): FresnelParameters;
  26542. /**
  26543. * Determines equality between FresnelParameters objects
  26544. * @param otherFresnelParameters defines the second operand
  26545. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26546. */
  26547. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26548. /**
  26549. * Serializes the current fresnel parameters to a JSON representation.
  26550. * @return the JSON serialization
  26551. */
  26552. serialize(): IFresnelParametersSerialized;
  26553. /**
  26554. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26555. * @param parsedFresnelParameters Define the JSON representation
  26556. * @returns the parsed parameters
  26557. */
  26558. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26559. }
  26560. }
  26561. declare module BABYLON {
  26562. /**
  26563. * Base class of materials working in push mode in babylon JS
  26564. * @hidden
  26565. */
  26566. export class PushMaterial extends Material {
  26567. protected _activeEffect: Effect;
  26568. protected _normalMatrix: Matrix;
  26569. /**
  26570. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26571. * This means that the material can keep using a previous shader while a new one is being compiled.
  26572. * This is mostly used when shader parallel compilation is supported (true by default)
  26573. */
  26574. allowShaderHotSwapping: boolean;
  26575. constructor(name: string, scene: Scene);
  26576. getEffect(): Effect;
  26577. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26578. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  26579. /**
  26580. * Binds the given world matrix to the active effect
  26581. *
  26582. * @param world the matrix to bind
  26583. */
  26584. bindOnlyWorldMatrix(world: Matrix): void;
  26585. /**
  26586. * Binds the given normal matrix to the active effect
  26587. *
  26588. * @param normalMatrix the matrix to bind
  26589. */
  26590. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26591. bind(world: Matrix, mesh?: Mesh): void;
  26592. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26593. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26594. }
  26595. }
  26596. declare module BABYLON {
  26597. /**
  26598. * This groups all the flags used to control the materials channel.
  26599. */
  26600. export class MaterialFlags {
  26601. private static _DiffuseTextureEnabled;
  26602. /**
  26603. * Are diffuse textures enabled in the application.
  26604. */
  26605. static get DiffuseTextureEnabled(): boolean;
  26606. static set DiffuseTextureEnabled(value: boolean);
  26607. private static _AmbientTextureEnabled;
  26608. /**
  26609. * Are ambient textures enabled in the application.
  26610. */
  26611. static get AmbientTextureEnabled(): boolean;
  26612. static set AmbientTextureEnabled(value: boolean);
  26613. private static _OpacityTextureEnabled;
  26614. /**
  26615. * Are opacity textures enabled in the application.
  26616. */
  26617. static get OpacityTextureEnabled(): boolean;
  26618. static set OpacityTextureEnabled(value: boolean);
  26619. private static _ReflectionTextureEnabled;
  26620. /**
  26621. * Are reflection textures enabled in the application.
  26622. */
  26623. static get ReflectionTextureEnabled(): boolean;
  26624. static set ReflectionTextureEnabled(value: boolean);
  26625. private static _EmissiveTextureEnabled;
  26626. /**
  26627. * Are emissive textures enabled in the application.
  26628. */
  26629. static get EmissiveTextureEnabled(): boolean;
  26630. static set EmissiveTextureEnabled(value: boolean);
  26631. private static _SpecularTextureEnabled;
  26632. /**
  26633. * Are specular textures enabled in the application.
  26634. */
  26635. static get SpecularTextureEnabled(): boolean;
  26636. static set SpecularTextureEnabled(value: boolean);
  26637. private static _BumpTextureEnabled;
  26638. /**
  26639. * Are bump textures enabled in the application.
  26640. */
  26641. static get BumpTextureEnabled(): boolean;
  26642. static set BumpTextureEnabled(value: boolean);
  26643. private static _LightmapTextureEnabled;
  26644. /**
  26645. * Are lightmap textures enabled in the application.
  26646. */
  26647. static get LightmapTextureEnabled(): boolean;
  26648. static set LightmapTextureEnabled(value: boolean);
  26649. private static _RefractionTextureEnabled;
  26650. /**
  26651. * Are refraction textures enabled in the application.
  26652. */
  26653. static get RefractionTextureEnabled(): boolean;
  26654. static set RefractionTextureEnabled(value: boolean);
  26655. private static _ColorGradingTextureEnabled;
  26656. /**
  26657. * Are color grading textures enabled in the application.
  26658. */
  26659. static get ColorGradingTextureEnabled(): boolean;
  26660. static set ColorGradingTextureEnabled(value: boolean);
  26661. private static _FresnelEnabled;
  26662. /**
  26663. * Are fresnels enabled in the application.
  26664. */
  26665. static get FresnelEnabled(): boolean;
  26666. static set FresnelEnabled(value: boolean);
  26667. private static _ClearCoatTextureEnabled;
  26668. /**
  26669. * Are clear coat textures enabled in the application.
  26670. */
  26671. static get ClearCoatTextureEnabled(): boolean;
  26672. static set ClearCoatTextureEnabled(value: boolean);
  26673. private static _ClearCoatBumpTextureEnabled;
  26674. /**
  26675. * Are clear coat bump textures enabled in the application.
  26676. */
  26677. static get ClearCoatBumpTextureEnabled(): boolean;
  26678. static set ClearCoatBumpTextureEnabled(value: boolean);
  26679. private static _ClearCoatTintTextureEnabled;
  26680. /**
  26681. * Are clear coat tint textures enabled in the application.
  26682. */
  26683. static get ClearCoatTintTextureEnabled(): boolean;
  26684. static set ClearCoatTintTextureEnabled(value: boolean);
  26685. private static _SheenTextureEnabled;
  26686. /**
  26687. * Are sheen textures enabled in the application.
  26688. */
  26689. static get SheenTextureEnabled(): boolean;
  26690. static set SheenTextureEnabled(value: boolean);
  26691. private static _AnisotropicTextureEnabled;
  26692. /**
  26693. * Are anisotropic textures enabled in the application.
  26694. */
  26695. static get AnisotropicTextureEnabled(): boolean;
  26696. static set AnisotropicTextureEnabled(value: boolean);
  26697. private static _ThicknessTextureEnabled;
  26698. /**
  26699. * Are thickness textures enabled in the application.
  26700. */
  26701. static get ThicknessTextureEnabled(): boolean;
  26702. static set ThicknessTextureEnabled(value: boolean);
  26703. }
  26704. }
  26705. declare module BABYLON {
  26706. /** @hidden */
  26707. export var defaultFragmentDeclaration: {
  26708. name: string;
  26709. shader: string;
  26710. };
  26711. }
  26712. declare module BABYLON {
  26713. /** @hidden */
  26714. export var defaultUboDeclaration: {
  26715. name: string;
  26716. shader: string;
  26717. };
  26718. }
  26719. declare module BABYLON {
  26720. /** @hidden */
  26721. export var lightFragmentDeclaration: {
  26722. name: string;
  26723. shader: string;
  26724. };
  26725. }
  26726. declare module BABYLON {
  26727. /** @hidden */
  26728. export var lightUboDeclaration: {
  26729. name: string;
  26730. shader: string;
  26731. };
  26732. }
  26733. declare module BABYLON {
  26734. /** @hidden */
  26735. export var lightsFragmentFunctions: {
  26736. name: string;
  26737. shader: string;
  26738. };
  26739. }
  26740. declare module BABYLON {
  26741. /** @hidden */
  26742. export var shadowsFragmentFunctions: {
  26743. name: string;
  26744. shader: string;
  26745. };
  26746. }
  26747. declare module BABYLON {
  26748. /** @hidden */
  26749. export var fresnelFunction: {
  26750. name: string;
  26751. shader: string;
  26752. };
  26753. }
  26754. declare module BABYLON {
  26755. /** @hidden */
  26756. export var reflectionFunction: {
  26757. name: string;
  26758. shader: string;
  26759. };
  26760. }
  26761. declare module BABYLON {
  26762. /** @hidden */
  26763. export var bumpFragmentMainFunctions: {
  26764. name: string;
  26765. shader: string;
  26766. };
  26767. }
  26768. declare module BABYLON {
  26769. /** @hidden */
  26770. export var bumpFragmentFunctions: {
  26771. name: string;
  26772. shader: string;
  26773. };
  26774. }
  26775. declare module BABYLON {
  26776. /** @hidden */
  26777. export var logDepthDeclaration: {
  26778. name: string;
  26779. shader: string;
  26780. };
  26781. }
  26782. declare module BABYLON {
  26783. /** @hidden */
  26784. export var bumpFragment: {
  26785. name: string;
  26786. shader: string;
  26787. };
  26788. }
  26789. declare module BABYLON {
  26790. /** @hidden */
  26791. export var depthPrePass: {
  26792. name: string;
  26793. shader: string;
  26794. };
  26795. }
  26796. declare module BABYLON {
  26797. /** @hidden */
  26798. export var lightFragment: {
  26799. name: string;
  26800. shader: string;
  26801. };
  26802. }
  26803. declare module BABYLON {
  26804. /** @hidden */
  26805. export var logDepthFragment: {
  26806. name: string;
  26807. shader: string;
  26808. };
  26809. }
  26810. declare module BABYLON {
  26811. /** @hidden */
  26812. export var defaultPixelShader: {
  26813. name: string;
  26814. shader: string;
  26815. };
  26816. }
  26817. declare module BABYLON {
  26818. /** @hidden */
  26819. export var defaultVertexDeclaration: {
  26820. name: string;
  26821. shader: string;
  26822. };
  26823. }
  26824. declare module BABYLON {
  26825. /** @hidden */
  26826. export var bumpVertexDeclaration: {
  26827. name: string;
  26828. shader: string;
  26829. };
  26830. }
  26831. declare module BABYLON {
  26832. /** @hidden */
  26833. export var bumpVertex: {
  26834. name: string;
  26835. shader: string;
  26836. };
  26837. }
  26838. declare module BABYLON {
  26839. /** @hidden */
  26840. export var fogVertex: {
  26841. name: string;
  26842. shader: string;
  26843. };
  26844. }
  26845. declare module BABYLON {
  26846. /** @hidden */
  26847. export var shadowsVertex: {
  26848. name: string;
  26849. shader: string;
  26850. };
  26851. }
  26852. declare module BABYLON {
  26853. /** @hidden */
  26854. export var pointCloudVertex: {
  26855. name: string;
  26856. shader: string;
  26857. };
  26858. }
  26859. declare module BABYLON {
  26860. /** @hidden */
  26861. export var logDepthVertex: {
  26862. name: string;
  26863. shader: string;
  26864. };
  26865. }
  26866. declare module BABYLON {
  26867. /** @hidden */
  26868. export var defaultVertexShader: {
  26869. name: string;
  26870. shader: string;
  26871. };
  26872. }
  26873. declare module BABYLON {
  26874. /** @hidden */
  26875. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26876. MAINUV1: boolean;
  26877. MAINUV2: boolean;
  26878. DIFFUSE: boolean;
  26879. DIFFUSEDIRECTUV: number;
  26880. AMBIENT: boolean;
  26881. AMBIENTDIRECTUV: number;
  26882. OPACITY: boolean;
  26883. OPACITYDIRECTUV: number;
  26884. OPACITYRGB: boolean;
  26885. REFLECTION: boolean;
  26886. EMISSIVE: boolean;
  26887. EMISSIVEDIRECTUV: number;
  26888. SPECULAR: boolean;
  26889. SPECULARDIRECTUV: number;
  26890. BUMP: boolean;
  26891. BUMPDIRECTUV: number;
  26892. PARALLAX: boolean;
  26893. PARALLAXOCCLUSION: boolean;
  26894. SPECULAROVERALPHA: boolean;
  26895. CLIPPLANE: boolean;
  26896. CLIPPLANE2: boolean;
  26897. CLIPPLANE3: boolean;
  26898. CLIPPLANE4: boolean;
  26899. CLIPPLANE5: boolean;
  26900. CLIPPLANE6: boolean;
  26901. ALPHATEST: boolean;
  26902. DEPTHPREPASS: boolean;
  26903. ALPHAFROMDIFFUSE: boolean;
  26904. POINTSIZE: boolean;
  26905. FOG: boolean;
  26906. SPECULARTERM: boolean;
  26907. DIFFUSEFRESNEL: boolean;
  26908. OPACITYFRESNEL: boolean;
  26909. REFLECTIONFRESNEL: boolean;
  26910. REFRACTIONFRESNEL: boolean;
  26911. EMISSIVEFRESNEL: boolean;
  26912. FRESNEL: boolean;
  26913. NORMAL: boolean;
  26914. UV1: boolean;
  26915. UV2: boolean;
  26916. VERTEXCOLOR: boolean;
  26917. VERTEXALPHA: boolean;
  26918. NUM_BONE_INFLUENCERS: number;
  26919. BonesPerMesh: number;
  26920. BONETEXTURE: boolean;
  26921. INSTANCES: boolean;
  26922. GLOSSINESS: boolean;
  26923. ROUGHNESS: boolean;
  26924. EMISSIVEASILLUMINATION: boolean;
  26925. LINKEMISSIVEWITHDIFFUSE: boolean;
  26926. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26927. LIGHTMAP: boolean;
  26928. LIGHTMAPDIRECTUV: number;
  26929. OBJECTSPACE_NORMALMAP: boolean;
  26930. USELIGHTMAPASSHADOWMAP: boolean;
  26931. REFLECTIONMAP_3D: boolean;
  26932. REFLECTIONMAP_SPHERICAL: boolean;
  26933. REFLECTIONMAP_PLANAR: boolean;
  26934. REFLECTIONMAP_CUBIC: boolean;
  26935. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26936. REFLECTIONMAP_PROJECTION: boolean;
  26937. REFLECTIONMAP_SKYBOX: boolean;
  26938. REFLECTIONMAP_EXPLICIT: boolean;
  26939. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26940. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26941. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26942. INVERTCUBICMAP: boolean;
  26943. LOGARITHMICDEPTH: boolean;
  26944. REFRACTION: boolean;
  26945. REFRACTIONMAP_3D: boolean;
  26946. REFLECTIONOVERALPHA: boolean;
  26947. TWOSIDEDLIGHTING: boolean;
  26948. SHADOWFLOAT: boolean;
  26949. MORPHTARGETS: boolean;
  26950. MORPHTARGETS_NORMAL: boolean;
  26951. MORPHTARGETS_TANGENT: boolean;
  26952. MORPHTARGETS_UV: boolean;
  26953. NUM_MORPH_INFLUENCERS: number;
  26954. NONUNIFORMSCALING: boolean;
  26955. PREMULTIPLYALPHA: boolean;
  26956. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26957. ALPHABLEND: boolean;
  26958. RGBDLIGHTMAP: boolean;
  26959. RGBDREFLECTION: boolean;
  26960. RGBDREFRACTION: boolean;
  26961. IMAGEPROCESSING: boolean;
  26962. VIGNETTE: boolean;
  26963. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26964. VIGNETTEBLENDMODEOPAQUE: boolean;
  26965. TONEMAPPING: boolean;
  26966. TONEMAPPING_ACES: boolean;
  26967. CONTRAST: boolean;
  26968. COLORCURVES: boolean;
  26969. COLORGRADING: boolean;
  26970. COLORGRADING3D: boolean;
  26971. SAMPLER3DGREENDEPTH: boolean;
  26972. SAMPLER3DBGRMAP: boolean;
  26973. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26974. MULTIVIEW: boolean;
  26975. /**
  26976. * If the reflection texture on this material is in linear color space
  26977. * @hidden
  26978. */
  26979. IS_REFLECTION_LINEAR: boolean;
  26980. /**
  26981. * If the refraction texture on this material is in linear color space
  26982. * @hidden
  26983. */
  26984. IS_REFRACTION_LINEAR: boolean;
  26985. EXPOSURE: boolean;
  26986. constructor();
  26987. setReflectionMode(modeToEnable: string): void;
  26988. }
  26989. /**
  26990. * This is the default material used in Babylon. It is the best trade off between quality
  26991. * and performances.
  26992. * @see http://doc.babylonjs.com/babylon101/materials
  26993. */
  26994. export class StandardMaterial extends PushMaterial {
  26995. private _diffuseTexture;
  26996. /**
  26997. * The basic texture of the material as viewed under a light.
  26998. */
  26999. diffuseTexture: Nullable<BaseTexture>;
  27000. private _ambientTexture;
  27001. /**
  27002. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27003. */
  27004. ambientTexture: Nullable<BaseTexture>;
  27005. private _opacityTexture;
  27006. /**
  27007. * Define the transparency of the material from a texture.
  27008. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27009. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27010. */
  27011. opacityTexture: Nullable<BaseTexture>;
  27012. private _reflectionTexture;
  27013. /**
  27014. * Define the texture used to display the reflection.
  27015. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27016. */
  27017. reflectionTexture: Nullable<BaseTexture>;
  27018. private _emissiveTexture;
  27019. /**
  27020. * Define texture of the material as if self lit.
  27021. * This will be mixed in the final result even in the absence of light.
  27022. */
  27023. emissiveTexture: Nullable<BaseTexture>;
  27024. private _specularTexture;
  27025. /**
  27026. * Define how the color and intensity of the highlight given by the light in the material.
  27027. */
  27028. specularTexture: Nullable<BaseTexture>;
  27029. private _bumpTexture;
  27030. /**
  27031. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27032. * 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.
  27033. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27034. */
  27035. bumpTexture: Nullable<BaseTexture>;
  27036. private _lightmapTexture;
  27037. /**
  27038. * Complex lighting can be computationally expensive to compute at runtime.
  27039. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27040. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27041. */
  27042. lightmapTexture: Nullable<BaseTexture>;
  27043. private _refractionTexture;
  27044. /**
  27045. * Define the texture used to display the refraction.
  27046. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27047. */
  27048. refractionTexture: Nullable<BaseTexture>;
  27049. /**
  27050. * The color of the material lit by the environmental background lighting.
  27051. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27052. */
  27053. ambientColor: Color3;
  27054. /**
  27055. * The basic color of the material as viewed under a light.
  27056. */
  27057. diffuseColor: Color3;
  27058. /**
  27059. * Define how the color and intensity of the highlight given by the light in the material.
  27060. */
  27061. specularColor: Color3;
  27062. /**
  27063. * Define the color of the material as if self lit.
  27064. * This will be mixed in the final result even in the absence of light.
  27065. */
  27066. emissiveColor: Color3;
  27067. /**
  27068. * Defines how sharp are the highlights in the material.
  27069. * The bigger the value the sharper giving a more glossy feeling to the result.
  27070. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27071. */
  27072. specularPower: number;
  27073. private _useAlphaFromDiffuseTexture;
  27074. /**
  27075. * Does the transparency come from the diffuse texture alpha channel.
  27076. */
  27077. useAlphaFromDiffuseTexture: boolean;
  27078. private _useEmissiveAsIllumination;
  27079. /**
  27080. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27081. */
  27082. useEmissiveAsIllumination: boolean;
  27083. private _linkEmissiveWithDiffuse;
  27084. /**
  27085. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27086. * the emissive level when the final color is close to one.
  27087. */
  27088. linkEmissiveWithDiffuse: boolean;
  27089. private _useSpecularOverAlpha;
  27090. /**
  27091. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27092. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27093. */
  27094. useSpecularOverAlpha: boolean;
  27095. private _useReflectionOverAlpha;
  27096. /**
  27097. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27098. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27099. */
  27100. useReflectionOverAlpha: boolean;
  27101. private _disableLighting;
  27102. /**
  27103. * Does lights from the scene impacts this material.
  27104. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27105. */
  27106. disableLighting: boolean;
  27107. private _useObjectSpaceNormalMap;
  27108. /**
  27109. * Allows using an object space normal map (instead of tangent space).
  27110. */
  27111. useObjectSpaceNormalMap: boolean;
  27112. private _useParallax;
  27113. /**
  27114. * Is parallax enabled or not.
  27115. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27116. */
  27117. useParallax: boolean;
  27118. private _useParallaxOcclusion;
  27119. /**
  27120. * Is parallax occlusion enabled or not.
  27121. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27122. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27123. */
  27124. useParallaxOcclusion: boolean;
  27125. /**
  27126. * 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.
  27127. */
  27128. parallaxScaleBias: number;
  27129. private _roughness;
  27130. /**
  27131. * Helps to define how blurry the reflections should appears in the material.
  27132. */
  27133. roughness: number;
  27134. /**
  27135. * In case of refraction, define the value of the index of refraction.
  27136. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27137. */
  27138. indexOfRefraction: number;
  27139. /**
  27140. * Invert the refraction texture alongside the y axis.
  27141. * It can be useful with procedural textures or probe for instance.
  27142. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27143. */
  27144. invertRefractionY: boolean;
  27145. /**
  27146. * Defines the alpha limits in alpha test mode.
  27147. */
  27148. alphaCutOff: number;
  27149. private _useLightmapAsShadowmap;
  27150. /**
  27151. * In case of light mapping, define whether the map contains light or shadow informations.
  27152. */
  27153. useLightmapAsShadowmap: boolean;
  27154. private _diffuseFresnelParameters;
  27155. /**
  27156. * Define the diffuse fresnel parameters of the material.
  27157. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27158. */
  27159. diffuseFresnelParameters: FresnelParameters;
  27160. private _opacityFresnelParameters;
  27161. /**
  27162. * Define the opacity fresnel parameters of the material.
  27163. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27164. */
  27165. opacityFresnelParameters: FresnelParameters;
  27166. private _reflectionFresnelParameters;
  27167. /**
  27168. * Define the reflection fresnel parameters of the material.
  27169. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27170. */
  27171. reflectionFresnelParameters: FresnelParameters;
  27172. private _refractionFresnelParameters;
  27173. /**
  27174. * Define the refraction fresnel parameters of the material.
  27175. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27176. */
  27177. refractionFresnelParameters: FresnelParameters;
  27178. private _emissiveFresnelParameters;
  27179. /**
  27180. * Define the emissive fresnel parameters of the material.
  27181. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27182. */
  27183. emissiveFresnelParameters: FresnelParameters;
  27184. private _useReflectionFresnelFromSpecular;
  27185. /**
  27186. * If true automatically deducts the fresnels values from the material specularity.
  27187. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27188. */
  27189. useReflectionFresnelFromSpecular: boolean;
  27190. private _useGlossinessFromSpecularMapAlpha;
  27191. /**
  27192. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27193. */
  27194. useGlossinessFromSpecularMapAlpha: boolean;
  27195. private _maxSimultaneousLights;
  27196. /**
  27197. * Defines the maximum number of lights that can be used in the material
  27198. */
  27199. maxSimultaneousLights: number;
  27200. private _invertNormalMapX;
  27201. /**
  27202. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27203. */
  27204. invertNormalMapX: boolean;
  27205. private _invertNormalMapY;
  27206. /**
  27207. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27208. */
  27209. invertNormalMapY: boolean;
  27210. private _twoSidedLighting;
  27211. /**
  27212. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27213. */
  27214. twoSidedLighting: boolean;
  27215. /**
  27216. * Default configuration related to image processing available in the standard Material.
  27217. */
  27218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27219. /**
  27220. * Gets the image processing configuration used either in this material.
  27221. */
  27222. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27223. /**
  27224. * Sets the Default image processing configuration used either in the this material.
  27225. *
  27226. * If sets to null, the scene one is in use.
  27227. */
  27228. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27229. /**
  27230. * Keep track of the image processing observer to allow dispose and replace.
  27231. */
  27232. private _imageProcessingObserver;
  27233. /**
  27234. * Attaches a new image processing configuration to the Standard Material.
  27235. * @param configuration
  27236. */
  27237. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27238. /**
  27239. * Gets wether the color curves effect is enabled.
  27240. */
  27241. get cameraColorCurvesEnabled(): boolean;
  27242. /**
  27243. * Sets wether the color curves effect is enabled.
  27244. */
  27245. set cameraColorCurvesEnabled(value: boolean);
  27246. /**
  27247. * Gets wether the color grading effect is enabled.
  27248. */
  27249. get cameraColorGradingEnabled(): boolean;
  27250. /**
  27251. * Gets wether the color grading effect is enabled.
  27252. */
  27253. set cameraColorGradingEnabled(value: boolean);
  27254. /**
  27255. * Gets wether tonemapping is enabled or not.
  27256. */
  27257. get cameraToneMappingEnabled(): boolean;
  27258. /**
  27259. * Sets wether tonemapping is enabled or not
  27260. */
  27261. set cameraToneMappingEnabled(value: boolean);
  27262. /**
  27263. * The camera exposure used on this material.
  27264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27265. * This corresponds to a photographic exposure.
  27266. */
  27267. get cameraExposure(): number;
  27268. /**
  27269. * The camera exposure used on this material.
  27270. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27271. * This corresponds to a photographic exposure.
  27272. */
  27273. set cameraExposure(value: number);
  27274. /**
  27275. * Gets The camera contrast used on this material.
  27276. */
  27277. get cameraContrast(): number;
  27278. /**
  27279. * Sets The camera contrast used on this material.
  27280. */
  27281. set cameraContrast(value: number);
  27282. /**
  27283. * Gets the Color Grading 2D Lookup Texture.
  27284. */
  27285. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27286. /**
  27287. * Sets the Color Grading 2D Lookup Texture.
  27288. */
  27289. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27290. /**
  27291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27293. * 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;
  27294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27295. */
  27296. get cameraColorCurves(): Nullable<ColorCurves>;
  27297. /**
  27298. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27299. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27300. * 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;
  27301. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27302. */
  27303. set cameraColorCurves(value: Nullable<ColorCurves>);
  27304. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27305. protected _worldViewProjectionMatrix: Matrix;
  27306. protected _globalAmbientColor: Color3;
  27307. protected _useLogarithmicDepth: boolean;
  27308. protected _rebuildInParallel: boolean;
  27309. /**
  27310. * Instantiates a new standard material.
  27311. * This is the default material used in Babylon. It is the best trade off between quality
  27312. * and performances.
  27313. * @see http://doc.babylonjs.com/babylon101/materials
  27314. * @param name Define the name of the material in the scene
  27315. * @param scene Define the scene the material belong to
  27316. */
  27317. constructor(name: string, scene: Scene);
  27318. /**
  27319. * Gets a boolean indicating that current material needs to register RTT
  27320. */
  27321. get hasRenderTargetTextures(): boolean;
  27322. /**
  27323. * Gets the current class name of the material e.g. "StandardMaterial"
  27324. * Mainly use in serialization.
  27325. * @returns the class name
  27326. */
  27327. getClassName(): string;
  27328. /**
  27329. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27330. * You can try switching to logarithmic depth.
  27331. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27332. */
  27333. get useLogarithmicDepth(): boolean;
  27334. set useLogarithmicDepth(value: boolean);
  27335. /**
  27336. * Specifies if the material will require alpha blending
  27337. * @returns a boolean specifying if alpha blending is needed
  27338. */
  27339. needAlphaBlending(): boolean;
  27340. /**
  27341. * Specifies if this material should be rendered in alpha test mode
  27342. * @returns a boolean specifying if an alpha test is needed.
  27343. */
  27344. needAlphaTesting(): boolean;
  27345. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27346. /**
  27347. * Get the texture used for alpha test purpose.
  27348. * @returns the diffuse texture in case of the standard material.
  27349. */
  27350. getAlphaTestTexture(): Nullable<BaseTexture>;
  27351. /**
  27352. * Get if the submesh is ready to be used and all its information available.
  27353. * Child classes can use it to update shaders
  27354. * @param mesh defines the mesh to check
  27355. * @param subMesh defines which submesh to check
  27356. * @param useInstances specifies that instances should be used
  27357. * @returns a boolean indicating that the submesh is ready or not
  27358. */
  27359. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27360. /**
  27361. * Builds the material UBO layouts.
  27362. * Used internally during the effect preparation.
  27363. */
  27364. buildUniformLayout(): void;
  27365. /**
  27366. * Unbinds the material from the mesh
  27367. */
  27368. unbind(): void;
  27369. /**
  27370. * Binds the submesh to this material by preparing the effect and shader to draw
  27371. * @param world defines the world transformation matrix
  27372. * @param mesh defines the mesh containing the submesh
  27373. * @param subMesh defines the submesh to bind the material to
  27374. */
  27375. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27376. /**
  27377. * Get the list of animatables in the material.
  27378. * @returns the list of animatables object used in the material
  27379. */
  27380. getAnimatables(): IAnimatable[];
  27381. /**
  27382. * Gets the active textures from the material
  27383. * @returns an array of textures
  27384. */
  27385. getActiveTextures(): BaseTexture[];
  27386. /**
  27387. * Specifies if the material uses a texture
  27388. * @param texture defines the texture to check against the material
  27389. * @returns a boolean specifying if the material uses the texture
  27390. */
  27391. hasTexture(texture: BaseTexture): boolean;
  27392. /**
  27393. * Disposes the material
  27394. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27395. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27396. */
  27397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27398. /**
  27399. * Makes a duplicate of the material, and gives it a new name
  27400. * @param name defines the new name for the duplicated material
  27401. * @returns the cloned material
  27402. */
  27403. clone(name: string): StandardMaterial;
  27404. /**
  27405. * Serializes this material in a JSON representation
  27406. * @returns the serialized material object
  27407. */
  27408. serialize(): any;
  27409. /**
  27410. * Creates a standard material from parsed material data
  27411. * @param source defines the JSON representation of the material
  27412. * @param scene defines the hosting scene
  27413. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27414. * @returns a new standard material
  27415. */
  27416. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27417. /**
  27418. * Are diffuse textures enabled in the application.
  27419. */
  27420. static get DiffuseTextureEnabled(): boolean;
  27421. static set DiffuseTextureEnabled(value: boolean);
  27422. /**
  27423. * Are ambient textures enabled in the application.
  27424. */
  27425. static get AmbientTextureEnabled(): boolean;
  27426. static set AmbientTextureEnabled(value: boolean);
  27427. /**
  27428. * Are opacity textures enabled in the application.
  27429. */
  27430. static get OpacityTextureEnabled(): boolean;
  27431. static set OpacityTextureEnabled(value: boolean);
  27432. /**
  27433. * Are reflection textures enabled in the application.
  27434. */
  27435. static get ReflectionTextureEnabled(): boolean;
  27436. static set ReflectionTextureEnabled(value: boolean);
  27437. /**
  27438. * Are emissive textures enabled in the application.
  27439. */
  27440. static get EmissiveTextureEnabled(): boolean;
  27441. static set EmissiveTextureEnabled(value: boolean);
  27442. /**
  27443. * Are specular textures enabled in the application.
  27444. */
  27445. static get SpecularTextureEnabled(): boolean;
  27446. static set SpecularTextureEnabled(value: boolean);
  27447. /**
  27448. * Are bump textures enabled in the application.
  27449. */
  27450. static get BumpTextureEnabled(): boolean;
  27451. static set BumpTextureEnabled(value: boolean);
  27452. /**
  27453. * Are lightmap textures enabled in the application.
  27454. */
  27455. static get LightmapTextureEnabled(): boolean;
  27456. static set LightmapTextureEnabled(value: boolean);
  27457. /**
  27458. * Are refraction textures enabled in the application.
  27459. */
  27460. static get RefractionTextureEnabled(): boolean;
  27461. static set RefractionTextureEnabled(value: boolean);
  27462. /**
  27463. * Are color grading textures enabled in the application.
  27464. */
  27465. static get ColorGradingTextureEnabled(): boolean;
  27466. static set ColorGradingTextureEnabled(value: boolean);
  27467. /**
  27468. * Are fresnels enabled in the application.
  27469. */
  27470. static get FresnelEnabled(): boolean;
  27471. static set FresnelEnabled(value: boolean);
  27472. }
  27473. }
  27474. declare module BABYLON {
  27475. /**
  27476. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27477. *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.
  27478. * The SPS is also a particle system. It provides some methods to manage the particles.
  27479. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27480. *
  27481. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27482. */
  27483. export class SolidParticleSystem implements IDisposable {
  27484. /**
  27485. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27486. * Example : var p = SPS.particles[i];
  27487. */
  27488. particles: SolidParticle[];
  27489. /**
  27490. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27491. */
  27492. nbParticles: number;
  27493. /**
  27494. * If the particles must ever face the camera (default false). Useful for planar particles.
  27495. */
  27496. billboard: boolean;
  27497. /**
  27498. * Recompute normals when adding a shape
  27499. */
  27500. recomputeNormals: boolean;
  27501. /**
  27502. * This a counter ofr your own usage. It's not set by any SPS functions.
  27503. */
  27504. counter: number;
  27505. /**
  27506. * The SPS name. This name is also given to the underlying mesh.
  27507. */
  27508. name: string;
  27509. /**
  27510. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27511. */
  27512. mesh: Mesh;
  27513. /**
  27514. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27515. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27516. */
  27517. vars: any;
  27518. /**
  27519. * This array is populated when the SPS is set as 'pickable'.
  27520. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27521. * Each element of this array is an object `{idx: int, faceId: int}`.
  27522. * `idx` is the picked particle index in the `SPS.particles` array
  27523. * `faceId` is the picked face index counted within this particle.
  27524. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27525. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27526. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27527. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27528. */
  27529. pickedParticles: {
  27530. idx: number;
  27531. faceId: number;
  27532. }[];
  27533. /**
  27534. * This array is populated when the SPS is set as 'pickable'
  27535. * Each key of this array is a submesh index.
  27536. * Each element of this array is a second array defined like this :
  27537. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27538. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27539. * `idx` is the picked particle index in the `SPS.particles` array
  27540. * `faceId` is the picked face index counted within this particle.
  27541. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27542. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27543. */
  27544. pickedBySubMesh: {
  27545. idx: number;
  27546. faceId: number;
  27547. }[][];
  27548. /**
  27549. * This array is populated when `enableDepthSort` is set to true.
  27550. * Each element of this array is an instance of the class DepthSortedParticle.
  27551. */
  27552. depthSortedParticles: DepthSortedParticle[];
  27553. /**
  27554. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27555. * @hidden
  27556. */
  27557. _bSphereOnly: boolean;
  27558. /**
  27559. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27560. * @hidden
  27561. */
  27562. _bSphereRadiusFactor: number;
  27563. private _scene;
  27564. private _positions;
  27565. private _indices;
  27566. private _normals;
  27567. private _colors;
  27568. private _uvs;
  27569. private _indices32;
  27570. private _positions32;
  27571. private _normals32;
  27572. private _fixedNormal32;
  27573. private _colors32;
  27574. private _uvs32;
  27575. private _index;
  27576. private _updatable;
  27577. private _pickable;
  27578. private _isVisibilityBoxLocked;
  27579. private _alwaysVisible;
  27580. private _depthSort;
  27581. private _expandable;
  27582. private _shapeCounter;
  27583. private _copy;
  27584. private _color;
  27585. private _computeParticleColor;
  27586. private _computeParticleTexture;
  27587. private _computeParticleRotation;
  27588. private _computeParticleVertex;
  27589. private _computeBoundingBox;
  27590. private _depthSortParticles;
  27591. private _camera;
  27592. private _mustUnrotateFixedNormals;
  27593. private _particlesIntersect;
  27594. private _needs32Bits;
  27595. private _isNotBuilt;
  27596. private _lastParticleId;
  27597. private _idxOfId;
  27598. private _multimaterialEnabled;
  27599. private _useModelMaterial;
  27600. private _indicesByMaterial;
  27601. private _materialIndexes;
  27602. private _depthSortFunction;
  27603. private _materialSortFunction;
  27604. private _materials;
  27605. private _multimaterial;
  27606. private _materialIndexesById;
  27607. private _defaultMaterial;
  27608. private _autoUpdateSubMeshes;
  27609. private _tmpVertex;
  27610. /**
  27611. * Creates a SPS (Solid Particle System) object.
  27612. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27613. * @param scene (Scene) is the scene in which the SPS is added.
  27614. * @param options defines the options of the sps e.g.
  27615. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27616. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27617. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27618. * * 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.
  27619. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27620. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27621. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27622. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27623. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27624. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27625. */
  27626. constructor(name: string, scene: Scene, options?: {
  27627. updatable?: boolean;
  27628. isPickable?: boolean;
  27629. enableDepthSort?: boolean;
  27630. particleIntersection?: boolean;
  27631. boundingSphereOnly?: boolean;
  27632. bSphereRadiusFactor?: number;
  27633. expandable?: boolean;
  27634. useModelMaterial?: boolean;
  27635. enableMultiMaterial?: boolean;
  27636. });
  27637. /**
  27638. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27639. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27640. * @returns the created mesh
  27641. */
  27642. buildMesh(): Mesh;
  27643. /**
  27644. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27645. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27646. * Thus the particles generated from `digest()` have their property `position` set yet.
  27647. * @param mesh ( Mesh ) is the mesh to be digested
  27648. * @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
  27649. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27650. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27651. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27652. * @returns the current SPS
  27653. */
  27654. digest(mesh: Mesh, options?: {
  27655. facetNb?: number;
  27656. number?: number;
  27657. delta?: number;
  27658. storage?: [];
  27659. }): SolidParticleSystem;
  27660. /**
  27661. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27662. * @hidden
  27663. */
  27664. private _unrotateFixedNormals;
  27665. /**
  27666. * Resets the temporary working copy particle
  27667. * @hidden
  27668. */
  27669. private _resetCopy;
  27670. /**
  27671. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27672. * @param p the current index in the positions array to be updated
  27673. * @param ind the current index in the indices array
  27674. * @param shape a Vector3 array, the shape geometry
  27675. * @param positions the positions array to be updated
  27676. * @param meshInd the shape indices array
  27677. * @param indices the indices array to be updated
  27678. * @param meshUV the shape uv array
  27679. * @param uvs the uv array to be updated
  27680. * @param meshCol the shape color array
  27681. * @param colors the color array to be updated
  27682. * @param meshNor the shape normals array
  27683. * @param normals the normals array to be updated
  27684. * @param idx the particle index
  27685. * @param idxInShape the particle index in its shape
  27686. * @param options the addShape() method passed options
  27687. * @model the particle model
  27688. * @hidden
  27689. */
  27690. private _meshBuilder;
  27691. /**
  27692. * Returns a shape Vector3 array from positions float array
  27693. * @param positions float array
  27694. * @returns a vector3 array
  27695. * @hidden
  27696. */
  27697. private _posToShape;
  27698. /**
  27699. * Returns a shapeUV array from a float uvs (array deep copy)
  27700. * @param uvs as a float array
  27701. * @returns a shapeUV array
  27702. * @hidden
  27703. */
  27704. private _uvsToShapeUV;
  27705. /**
  27706. * Adds a new particle object in the particles array
  27707. * @param idx particle index in particles array
  27708. * @param id particle id
  27709. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27710. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27711. * @param model particle ModelShape object
  27712. * @param shapeId model shape identifier
  27713. * @param idxInShape index of the particle in the current model
  27714. * @param bInfo model bounding info object
  27715. * @param storage target storage array, if any
  27716. * @hidden
  27717. */
  27718. private _addParticle;
  27719. /**
  27720. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27721. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27722. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27723. * @param nb (positive integer) the number of particles to be created from this model
  27724. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27725. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27726. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27727. * @returns the number of shapes in the system
  27728. */
  27729. addShape(mesh: Mesh, nb: number, options?: {
  27730. positionFunction?: any;
  27731. vertexFunction?: any;
  27732. storage?: [];
  27733. }): number;
  27734. /**
  27735. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27736. * @hidden
  27737. */
  27738. private _rebuildParticle;
  27739. /**
  27740. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27741. * @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.
  27742. * @returns the SPS.
  27743. */
  27744. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27745. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27746. * Returns an array with the removed particles.
  27747. * 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.
  27748. * The SPS can't be empty so at least one particle needs to remain in place.
  27749. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27750. * @param start index of the first particle to remove
  27751. * @param end index of the last particle to remove (included)
  27752. * @returns an array populated with the removed particles
  27753. */
  27754. removeParticles(start: number, end: number): SolidParticle[];
  27755. /**
  27756. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27757. * @param solidParticleArray an array populated with Solid Particles objects
  27758. * @returns the SPS
  27759. */
  27760. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27761. /**
  27762. * Creates a new particle and modifies the SPS mesh geometry :
  27763. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27764. * - calls _addParticle() to populate the particle array
  27765. * factorized code from addShape() and insertParticlesFromArray()
  27766. * @param idx particle index in the particles array
  27767. * @param i particle index in its shape
  27768. * @param modelShape particle ModelShape object
  27769. * @param shape shape vertex array
  27770. * @param meshInd shape indices array
  27771. * @param meshUV shape uv array
  27772. * @param meshCol shape color array
  27773. * @param meshNor shape normals array
  27774. * @param bbInfo shape bounding info
  27775. * @param storage target particle storage
  27776. * @options addShape() passed options
  27777. * @hidden
  27778. */
  27779. private _insertNewParticle;
  27780. /**
  27781. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27782. * This method calls `updateParticle()` for each particle of the SPS.
  27783. * For an animated SPS, it is usually called within the render loop.
  27784. * 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.
  27785. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27786. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27787. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27788. * @returns the SPS.
  27789. */
  27790. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27791. /**
  27792. * Disposes the SPS.
  27793. */
  27794. dispose(): void;
  27795. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27796. * idx is the particle index in the SPS
  27797. * faceId is the picked face index counted within this particle.
  27798. * Returns null if the pickInfo can't identify a picked particle.
  27799. * @param pickingInfo (PickingInfo object)
  27800. * @returns {idx: number, faceId: number} or null
  27801. */
  27802. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27803. idx: number;
  27804. faceId: number;
  27805. }>;
  27806. /**
  27807. * Returns a SolidParticle object from its identifier : particle.id
  27808. * @param id (integer) the particle Id
  27809. * @returns the searched particle or null if not found in the SPS.
  27810. */
  27811. getParticleById(id: number): Nullable<SolidParticle>;
  27812. /**
  27813. * Returns a new array populated with the particles having the passed shapeId.
  27814. * @param shapeId (integer) the shape identifier
  27815. * @returns a new solid particle array
  27816. */
  27817. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27818. /**
  27819. * Populates the passed array "ref" with the particles having the passed shapeId.
  27820. * @param shapeId the shape identifier
  27821. * @returns the SPS
  27822. * @param ref
  27823. */
  27824. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27825. /**
  27826. * Computes the required SubMeshes according the materials assigned to the particles.
  27827. * @returns the solid particle system.
  27828. * Does nothing if called before the SPS mesh is built.
  27829. */
  27830. computeSubMeshes(): SolidParticleSystem;
  27831. /**
  27832. * Sorts the solid particles by material when MultiMaterial is enabled.
  27833. * Updates the indices32 array.
  27834. * Updates the indicesByMaterial array.
  27835. * Updates the mesh indices array.
  27836. * @returns the SPS
  27837. * @hidden
  27838. */
  27839. private _sortParticlesByMaterial;
  27840. /**
  27841. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27842. * @hidden
  27843. */
  27844. private _setMaterialIndexesById;
  27845. /**
  27846. * Returns an array with unique values of Materials from the passed array
  27847. * @param array the material array to be checked and filtered
  27848. * @hidden
  27849. */
  27850. private _filterUniqueMaterialId;
  27851. /**
  27852. * Sets a new Standard Material as _defaultMaterial if not already set.
  27853. * @hidden
  27854. */
  27855. private _setDefaultMaterial;
  27856. /**
  27857. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27858. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27859. * @returns the SPS.
  27860. */
  27861. refreshVisibleSize(): SolidParticleSystem;
  27862. /**
  27863. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27864. * @param size the size (float) of the visibility box
  27865. * note : this doesn't lock the SPS mesh bounding box.
  27866. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27867. */
  27868. setVisibilityBox(size: number): void;
  27869. /**
  27870. * Gets whether the SPS as always visible or not
  27871. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27872. */
  27873. get isAlwaysVisible(): boolean;
  27874. /**
  27875. * Sets the SPS as always visible or not
  27876. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27877. */
  27878. set isAlwaysVisible(val: boolean);
  27879. /**
  27880. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27881. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27882. */
  27883. set isVisibilityBoxLocked(val: boolean);
  27884. /**
  27885. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27886. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27887. */
  27888. get isVisibilityBoxLocked(): boolean;
  27889. /**
  27890. * Tells to `setParticles()` to compute the particle rotations or not.
  27891. * Default value : true. The SPS is faster when it's set to false.
  27892. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27893. */
  27894. set computeParticleRotation(val: boolean);
  27895. /**
  27896. * Tells to `setParticles()` to compute the particle colors or not.
  27897. * Default value : true. The SPS is faster when it's set to false.
  27898. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27899. */
  27900. set computeParticleColor(val: boolean);
  27901. set computeParticleTexture(val: boolean);
  27902. /**
  27903. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27904. * Default value : false. The SPS is faster when it's set to false.
  27905. * Note : the particle custom vertex positions aren't stored values.
  27906. */
  27907. set computeParticleVertex(val: boolean);
  27908. /**
  27909. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27910. */
  27911. set computeBoundingBox(val: boolean);
  27912. /**
  27913. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27914. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27915. * Default : `true`
  27916. */
  27917. set depthSortParticles(val: boolean);
  27918. /**
  27919. * Gets if `setParticles()` computes the particle rotations or not.
  27920. * Default value : true. The SPS is faster when it's set to false.
  27921. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27922. */
  27923. get computeParticleRotation(): boolean;
  27924. /**
  27925. * Gets if `setParticles()` computes the particle colors or not.
  27926. * Default value : true. The SPS is faster when it's set to false.
  27927. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27928. */
  27929. get computeParticleColor(): boolean;
  27930. /**
  27931. * Gets if `setParticles()` computes the particle textures or not.
  27932. * Default value : true. The SPS is faster when it's set to false.
  27933. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27934. */
  27935. get computeParticleTexture(): boolean;
  27936. /**
  27937. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27938. * Default value : false. The SPS is faster when it's set to false.
  27939. * Note : the particle custom vertex positions aren't stored values.
  27940. */
  27941. get computeParticleVertex(): boolean;
  27942. /**
  27943. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27944. */
  27945. get computeBoundingBox(): boolean;
  27946. /**
  27947. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27948. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27949. * Default : `true`
  27950. */
  27951. get depthSortParticles(): boolean;
  27952. /**
  27953. * Gets if the SPS is created as expandable at construction time.
  27954. * Default : `false`
  27955. */
  27956. get expandable(): boolean;
  27957. /**
  27958. * Gets if the SPS supports the Multi Materials
  27959. */
  27960. get multimaterialEnabled(): boolean;
  27961. /**
  27962. * Gets if the SPS uses the model materials for its own multimaterial.
  27963. */
  27964. get useModelMaterial(): boolean;
  27965. /**
  27966. * The SPS used material array.
  27967. */
  27968. get materials(): Material[];
  27969. /**
  27970. * Sets the SPS MultiMaterial from the passed materials.
  27971. * Note : the passed array is internally copied and not used then by reference.
  27972. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27973. */
  27974. setMultiMaterial(materials: Material[]): void;
  27975. /**
  27976. * The SPS computed multimaterial object
  27977. */
  27978. get multimaterial(): MultiMaterial;
  27979. set multimaterial(mm: MultiMaterial);
  27980. /**
  27981. * If the subMeshes must be updated on the next call to setParticles()
  27982. */
  27983. get autoUpdateSubMeshes(): boolean;
  27984. set autoUpdateSubMeshes(val: boolean);
  27985. /**
  27986. * This function does nothing. It may be overwritten to set all the particle first values.
  27987. * The SPS doesn't call this function, you may have to call it by your own.
  27988. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27989. */
  27990. initParticles(): void;
  27991. /**
  27992. * This function does nothing. It may be overwritten to recycle a particle.
  27993. * The SPS doesn't call this function, you may have to call it by your own.
  27994. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27995. * @param particle The particle to recycle
  27996. * @returns the recycled particle
  27997. */
  27998. recycleParticle(particle: SolidParticle): SolidParticle;
  27999. /**
  28000. * Updates a particle : this function should be overwritten by the user.
  28001. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28002. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28003. * @example : just set a particle position or velocity and recycle conditions
  28004. * @param particle The particle to update
  28005. * @returns the updated particle
  28006. */
  28007. updateParticle(particle: SolidParticle): SolidParticle;
  28008. /**
  28009. * Updates a vertex of a particle : it can be overwritten by the user.
  28010. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28011. * @param particle the current particle
  28012. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  28013. * @param pt the index of the current vertex in the particle shape
  28014. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28015. * @example : just set a vertex particle position or color
  28016. * @returns the sps
  28017. */
  28018. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  28019. /**
  28020. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28021. * This does nothing and may be overwritten by the user.
  28022. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28023. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28024. * @param update the boolean update value actually passed to setParticles()
  28025. */
  28026. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28027. /**
  28028. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28029. * This will be passed three parameters.
  28030. * This does nothing and may be overwritten by the user.
  28031. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28032. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28033. * @param update the boolean update value actually passed to setParticles()
  28034. */
  28035. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28036. }
  28037. }
  28038. declare module BABYLON {
  28039. /**
  28040. * Represents one particle of a solid particle system.
  28041. */
  28042. export class SolidParticle {
  28043. /**
  28044. * particle global index
  28045. */
  28046. idx: number;
  28047. /**
  28048. * particle identifier
  28049. */
  28050. id: number;
  28051. /**
  28052. * The color of the particle
  28053. */
  28054. color: Nullable<Color4>;
  28055. /**
  28056. * The world space position of the particle.
  28057. */
  28058. position: Vector3;
  28059. /**
  28060. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28061. */
  28062. rotation: Vector3;
  28063. /**
  28064. * The world space rotation quaternion of the particle.
  28065. */
  28066. rotationQuaternion: Nullable<Quaternion>;
  28067. /**
  28068. * The scaling of the particle.
  28069. */
  28070. scaling: Vector3;
  28071. /**
  28072. * The uvs of the particle.
  28073. */
  28074. uvs: Vector4;
  28075. /**
  28076. * The current speed of the particle.
  28077. */
  28078. velocity: Vector3;
  28079. /**
  28080. * The pivot point in the particle local space.
  28081. */
  28082. pivot: Vector3;
  28083. /**
  28084. * Must the particle be translated from its pivot point in its local space ?
  28085. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28086. * Default : false
  28087. */
  28088. translateFromPivot: boolean;
  28089. /**
  28090. * Is the particle active or not ?
  28091. */
  28092. alive: boolean;
  28093. /**
  28094. * Is the particle visible or not ?
  28095. */
  28096. isVisible: boolean;
  28097. /**
  28098. * Index of this particle in the global "positions" array (Internal use)
  28099. * @hidden
  28100. */
  28101. _pos: number;
  28102. /**
  28103. * @hidden Index of this particle in the global "indices" array (Internal use)
  28104. */
  28105. _ind: number;
  28106. /**
  28107. * @hidden ModelShape of this particle (Internal use)
  28108. */
  28109. _model: ModelShape;
  28110. /**
  28111. * ModelShape id of this particle
  28112. */
  28113. shapeId: number;
  28114. /**
  28115. * Index of the particle in its shape id
  28116. */
  28117. idxInShape: number;
  28118. /**
  28119. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28120. */
  28121. _modelBoundingInfo: BoundingInfo;
  28122. /**
  28123. * @hidden Particle BoundingInfo object (Internal use)
  28124. */
  28125. _boundingInfo: BoundingInfo;
  28126. /**
  28127. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28128. */
  28129. _sps: SolidParticleSystem;
  28130. /**
  28131. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28132. */
  28133. _stillInvisible: boolean;
  28134. /**
  28135. * @hidden Last computed particle rotation matrix
  28136. */
  28137. _rotationMatrix: number[];
  28138. /**
  28139. * Parent particle Id, if any.
  28140. * Default null.
  28141. */
  28142. parentId: Nullable<number>;
  28143. /**
  28144. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28145. */
  28146. materialIndex: Nullable<number>;
  28147. /**
  28148. * Custom object or properties.
  28149. */
  28150. props: Nullable<any>;
  28151. /**
  28152. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28153. * The possible values are :
  28154. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28155. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28156. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28157. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28158. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28159. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28160. * */
  28161. cullingStrategy: number;
  28162. /**
  28163. * @hidden Internal global position in the SPS.
  28164. */
  28165. _globalPosition: Vector3;
  28166. /**
  28167. * Creates a Solid Particle object.
  28168. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28169. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28170. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28171. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28172. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28173. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28174. * @param shapeId (integer) is the model shape identifier in the SPS.
  28175. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28176. * @param sps defines the sps it is associated to
  28177. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28178. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28179. */
  28180. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28181. /**
  28182. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28183. * @param target the particle target
  28184. * @returns the current particle
  28185. */
  28186. copyToRef(target: SolidParticle): SolidParticle;
  28187. /**
  28188. * Legacy support, changed scale to scaling
  28189. */
  28190. get scale(): Vector3;
  28191. /**
  28192. * Legacy support, changed scale to scaling
  28193. */
  28194. set scale(scale: Vector3);
  28195. /**
  28196. * Legacy support, changed quaternion to rotationQuaternion
  28197. */
  28198. get quaternion(): Nullable<Quaternion>;
  28199. /**
  28200. * Legacy support, changed quaternion to rotationQuaternion
  28201. */
  28202. set quaternion(q: Nullable<Quaternion>);
  28203. /**
  28204. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28205. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28206. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28207. * @returns true if it intersects
  28208. */
  28209. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28210. /**
  28211. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28212. * A particle is in the frustum if its bounding box intersects the frustum
  28213. * @param frustumPlanes defines the frustum to test
  28214. * @returns true if the particle is in the frustum planes
  28215. */
  28216. isInFrustum(frustumPlanes: Plane[]): boolean;
  28217. /**
  28218. * get the rotation matrix of the particle
  28219. * @hidden
  28220. */
  28221. getRotationMatrix(m: Matrix): void;
  28222. }
  28223. /**
  28224. * Represents the shape of the model used by one particle of a solid particle system.
  28225. * SPS internal tool, don't use it manually.
  28226. */
  28227. export class ModelShape {
  28228. /**
  28229. * The shape id
  28230. * @hidden
  28231. */
  28232. shapeID: number;
  28233. /**
  28234. * flat array of model positions (internal use)
  28235. * @hidden
  28236. */
  28237. _shape: Vector3[];
  28238. /**
  28239. * flat array of model UVs (internal use)
  28240. * @hidden
  28241. */
  28242. _shapeUV: number[];
  28243. /**
  28244. * color array of the model
  28245. * @hidden
  28246. */
  28247. _shapeColors: number[];
  28248. /**
  28249. * indices array of the model
  28250. * @hidden
  28251. */
  28252. _indices: number[];
  28253. /**
  28254. * normals array of the model
  28255. * @hidden
  28256. */
  28257. _normals: number[];
  28258. /**
  28259. * length of the shape in the model indices array (internal use)
  28260. * @hidden
  28261. */
  28262. _indicesLength: number;
  28263. /**
  28264. * Custom position function (internal use)
  28265. * @hidden
  28266. */
  28267. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28268. /**
  28269. * Custom vertex function (internal use)
  28270. * @hidden
  28271. */
  28272. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28273. /**
  28274. * Model material (internal use)
  28275. * @hidden
  28276. */
  28277. _material: Nullable<Material>;
  28278. /**
  28279. * 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.
  28280. * SPS internal tool, don't use it manually.
  28281. * @hidden
  28282. */
  28283. 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>);
  28284. }
  28285. /**
  28286. * Represents a Depth Sorted Particle in the solid particle system.
  28287. * @hidden
  28288. */
  28289. export class DepthSortedParticle {
  28290. /**
  28291. * Particle index
  28292. */
  28293. idx: number;
  28294. /**
  28295. * Index of the particle in the "indices" array
  28296. */
  28297. ind: number;
  28298. /**
  28299. * Length of the particle shape in the "indices" array
  28300. */
  28301. indicesLength: number;
  28302. /**
  28303. * Squared distance from the particle to the camera
  28304. */
  28305. sqDistance: number;
  28306. /**
  28307. * Material index when used with MultiMaterials
  28308. */
  28309. materialIndex: number;
  28310. /**
  28311. * Creates a new sorted particle
  28312. * @param materialIndex
  28313. */
  28314. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28315. }
  28316. /**
  28317. * Represents a solid particle vertex
  28318. */
  28319. export class SolidParticleVertex {
  28320. /**
  28321. * Vertex position
  28322. */
  28323. position: Vector3;
  28324. /**
  28325. * Vertex color
  28326. */
  28327. color: Color4;
  28328. /**
  28329. * Vertex UV
  28330. */
  28331. uv: Vector2;
  28332. /**
  28333. * Creates a new solid particle vertex
  28334. */
  28335. constructor();
  28336. /** Vertex x coordinate */
  28337. get x(): number;
  28338. set x(val: number);
  28339. /** Vertex y coordinate */
  28340. get y(): number;
  28341. set y(val: number);
  28342. /** Vertex z coordinate */
  28343. get z(): number;
  28344. set z(val: number);
  28345. }
  28346. }
  28347. declare module BABYLON {
  28348. /**
  28349. * @hidden
  28350. */
  28351. export class _MeshCollisionData {
  28352. _checkCollisions: boolean;
  28353. _collisionMask: number;
  28354. _collisionGroup: number;
  28355. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28356. _collider: Nullable<Collider>;
  28357. _oldPositionForCollisions: Vector3;
  28358. _diffPositionForCollisions: Vector3;
  28359. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28360. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28361. }
  28362. }
  28363. declare module BABYLON {
  28364. /** @hidden */
  28365. class _FacetDataStorage {
  28366. facetPositions: Vector3[];
  28367. facetNormals: Vector3[];
  28368. facetPartitioning: number[][];
  28369. facetNb: number;
  28370. partitioningSubdivisions: number;
  28371. partitioningBBoxRatio: number;
  28372. facetDataEnabled: boolean;
  28373. facetParameters: any;
  28374. bbSize: Vector3;
  28375. subDiv: {
  28376. max: number;
  28377. X: number;
  28378. Y: number;
  28379. Z: number;
  28380. };
  28381. facetDepthSort: boolean;
  28382. facetDepthSortEnabled: boolean;
  28383. depthSortedIndices: IndicesArray;
  28384. depthSortedFacets: {
  28385. ind: number;
  28386. sqDistance: number;
  28387. }[];
  28388. facetDepthSortFunction: (f1: {
  28389. ind: number;
  28390. sqDistance: number;
  28391. }, f2: {
  28392. ind: number;
  28393. sqDistance: number;
  28394. }) => number;
  28395. facetDepthSortFrom: Vector3;
  28396. facetDepthSortOrigin: Vector3;
  28397. invertedMatrix: Matrix;
  28398. }
  28399. /**
  28400. * @hidden
  28401. **/
  28402. class _InternalAbstractMeshDataInfo {
  28403. _hasVertexAlpha: boolean;
  28404. _useVertexColors: boolean;
  28405. _numBoneInfluencers: number;
  28406. _applyFog: boolean;
  28407. _receiveShadows: boolean;
  28408. _facetData: _FacetDataStorage;
  28409. _visibility: number;
  28410. _skeleton: Nullable<Skeleton>;
  28411. _layerMask: number;
  28412. _computeBonesUsingShaders: boolean;
  28413. _isActive: boolean;
  28414. _onlyForInstances: boolean;
  28415. _isActiveIntermediate: boolean;
  28416. _onlyForInstancesIntermediate: boolean;
  28417. _actAsRegularMesh: boolean;
  28418. }
  28419. /**
  28420. * Class used to store all common mesh properties
  28421. */
  28422. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28423. /** No occlusion */
  28424. static OCCLUSION_TYPE_NONE: number;
  28425. /** Occlusion set to optimisitic */
  28426. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28427. /** Occlusion set to strict */
  28428. static OCCLUSION_TYPE_STRICT: number;
  28429. /** Use an accurante occlusion algorithm */
  28430. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28431. /** Use a conservative occlusion algorithm */
  28432. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28433. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28434. * Test order :
  28435. * Is the bounding sphere outside the frustum ?
  28436. * If not, are the bounding box vertices outside the frustum ?
  28437. * It not, then the cullable object is in the frustum.
  28438. */
  28439. static readonly CULLINGSTRATEGY_STANDARD: number;
  28440. /** Culling strategy : Bounding Sphere Only.
  28441. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28442. * It's also less accurate than the standard because some not visible objects can still be selected.
  28443. * Test : is the bounding sphere outside the frustum ?
  28444. * If not, then the cullable object is in the frustum.
  28445. */
  28446. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28447. /** Culling strategy : Optimistic Inclusion.
  28448. * This in an inclusion test first, then the standard exclusion test.
  28449. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28450. * 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.
  28451. * Anyway, it's as accurate as the standard strategy.
  28452. * Test :
  28453. * Is the cullable object bounding sphere center in the frustum ?
  28454. * If not, apply the default culling strategy.
  28455. */
  28456. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28457. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28458. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28459. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28460. * 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.
  28461. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28462. * Test :
  28463. * Is the cullable object bounding sphere center in the frustum ?
  28464. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28465. */
  28466. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28467. /**
  28468. * No billboard
  28469. */
  28470. static get BILLBOARDMODE_NONE(): number;
  28471. /** Billboard on X axis */
  28472. static get BILLBOARDMODE_X(): number;
  28473. /** Billboard on Y axis */
  28474. static get BILLBOARDMODE_Y(): number;
  28475. /** Billboard on Z axis */
  28476. static get BILLBOARDMODE_Z(): number;
  28477. /** Billboard on all axes */
  28478. static get BILLBOARDMODE_ALL(): number;
  28479. /** Billboard on using position instead of orientation */
  28480. static get BILLBOARDMODE_USE_POSITION(): number;
  28481. /** @hidden */
  28482. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28483. /**
  28484. * The culling strategy to use to check whether the mesh must be rendered or not.
  28485. * This value can be changed at any time and will be used on the next render mesh selection.
  28486. * The possible values are :
  28487. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28488. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28489. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28490. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28491. * Please read each static variable documentation to get details about the culling process.
  28492. * */
  28493. cullingStrategy: number;
  28494. /**
  28495. * Gets the number of facets in the mesh
  28496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28497. */
  28498. get facetNb(): number;
  28499. /**
  28500. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28502. */
  28503. get partitioningSubdivisions(): number;
  28504. set partitioningSubdivisions(nb: number);
  28505. /**
  28506. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28507. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28509. */
  28510. get partitioningBBoxRatio(): number;
  28511. set partitioningBBoxRatio(ratio: number);
  28512. /**
  28513. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28514. * Works only for updatable meshes.
  28515. * Doesn't work with multi-materials
  28516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28517. */
  28518. get mustDepthSortFacets(): boolean;
  28519. set mustDepthSortFacets(sort: boolean);
  28520. /**
  28521. * The location (Vector3) where the facet depth sort must be computed from.
  28522. * By default, the active camera position.
  28523. * Used only when facet depth sort is enabled
  28524. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28525. */
  28526. get facetDepthSortFrom(): Vector3;
  28527. set facetDepthSortFrom(location: Vector3);
  28528. /**
  28529. * gets a boolean indicating if facetData is enabled
  28530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28531. */
  28532. get isFacetDataEnabled(): boolean;
  28533. /** @hidden */
  28534. _updateNonUniformScalingState(value: boolean): boolean;
  28535. /**
  28536. * An event triggered when this mesh collides with another one
  28537. */
  28538. onCollideObservable: Observable<AbstractMesh>;
  28539. /** Set a function to call when this mesh collides with another one */
  28540. set onCollide(callback: () => void);
  28541. /**
  28542. * An event triggered when the collision's position changes
  28543. */
  28544. onCollisionPositionChangeObservable: Observable<Vector3>;
  28545. /** Set a function to call when the collision's position changes */
  28546. set onCollisionPositionChange(callback: () => void);
  28547. /**
  28548. * An event triggered when material is changed
  28549. */
  28550. onMaterialChangedObservable: Observable<AbstractMesh>;
  28551. /**
  28552. * Gets or sets the orientation for POV movement & rotation
  28553. */
  28554. definedFacingForward: boolean;
  28555. /** @hidden */
  28556. _occlusionQuery: Nullable<WebGLQuery>;
  28557. /** @hidden */
  28558. _renderingGroup: Nullable<RenderingGroup>;
  28559. /**
  28560. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28561. */
  28562. get visibility(): number;
  28563. /**
  28564. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28565. */
  28566. set visibility(value: number);
  28567. /** Gets or sets the alpha index used to sort transparent meshes
  28568. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28569. */
  28570. alphaIndex: number;
  28571. /**
  28572. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28573. */
  28574. isVisible: boolean;
  28575. /**
  28576. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28577. */
  28578. isPickable: boolean;
  28579. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28580. showSubMeshesBoundingBox: boolean;
  28581. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28582. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28583. */
  28584. isBlocker: boolean;
  28585. /**
  28586. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28587. */
  28588. enablePointerMoveEvents: boolean;
  28589. /**
  28590. * Specifies the rendering group id for this mesh (0 by default)
  28591. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28592. */
  28593. renderingGroupId: number;
  28594. private _material;
  28595. /** Gets or sets current material */
  28596. get material(): Nullable<Material>;
  28597. set material(value: Nullable<Material>);
  28598. /**
  28599. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28600. * @see http://doc.babylonjs.com/babylon101/shadows
  28601. */
  28602. get receiveShadows(): boolean;
  28603. set receiveShadows(value: boolean);
  28604. /** Defines color to use when rendering outline */
  28605. outlineColor: Color3;
  28606. /** Define width to use when rendering outline */
  28607. outlineWidth: number;
  28608. /** Defines color to use when rendering overlay */
  28609. overlayColor: Color3;
  28610. /** Defines alpha to use when rendering overlay */
  28611. overlayAlpha: number;
  28612. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28613. get hasVertexAlpha(): boolean;
  28614. set hasVertexAlpha(value: boolean);
  28615. /** 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) */
  28616. get useVertexColors(): boolean;
  28617. set useVertexColors(value: boolean);
  28618. /**
  28619. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28620. */
  28621. get computeBonesUsingShaders(): boolean;
  28622. set computeBonesUsingShaders(value: boolean);
  28623. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28624. get numBoneInfluencers(): number;
  28625. set numBoneInfluencers(value: number);
  28626. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28627. get applyFog(): boolean;
  28628. set applyFog(value: boolean);
  28629. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28630. useOctreeForRenderingSelection: boolean;
  28631. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28632. useOctreeForPicking: boolean;
  28633. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28634. useOctreeForCollisions: boolean;
  28635. /**
  28636. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28637. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28638. */
  28639. get layerMask(): number;
  28640. set layerMask(value: number);
  28641. /**
  28642. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28643. */
  28644. alwaysSelectAsActiveMesh: boolean;
  28645. /**
  28646. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28647. */
  28648. doNotSyncBoundingInfo: boolean;
  28649. /**
  28650. * Gets or sets the current action manager
  28651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28652. */
  28653. actionManager: Nullable<AbstractActionManager>;
  28654. private _meshCollisionData;
  28655. /**
  28656. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28657. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28658. */
  28659. ellipsoid: Vector3;
  28660. /**
  28661. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28662. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28663. */
  28664. ellipsoidOffset: Vector3;
  28665. /**
  28666. * Gets or sets a collision mask used to mask collisions (default is -1).
  28667. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28668. */
  28669. get collisionMask(): number;
  28670. set collisionMask(mask: number);
  28671. /**
  28672. * Gets or sets the current collision group mask (-1 by default).
  28673. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28674. */
  28675. get collisionGroup(): number;
  28676. set collisionGroup(mask: number);
  28677. /**
  28678. * Gets or sets current surrounding meshes (null by default).
  28679. *
  28680. * By default collision detection is tested against every mesh in the scene.
  28681. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28682. * meshes will be tested for the collision.
  28683. *
  28684. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28685. */
  28686. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28687. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28688. /**
  28689. * Defines edge width used when edgesRenderer is enabled
  28690. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28691. */
  28692. edgesWidth: number;
  28693. /**
  28694. * Defines edge color used when edgesRenderer is enabled
  28695. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28696. */
  28697. edgesColor: Color4;
  28698. /** @hidden */
  28699. _edgesRenderer: Nullable<IEdgesRenderer>;
  28700. /** @hidden */
  28701. _masterMesh: Nullable<AbstractMesh>;
  28702. /** @hidden */
  28703. _boundingInfo: Nullable<BoundingInfo>;
  28704. /** @hidden */
  28705. _renderId: number;
  28706. /**
  28707. * Gets or sets the list of subMeshes
  28708. * @see http://doc.babylonjs.com/how_to/multi_materials
  28709. */
  28710. subMeshes: SubMesh[];
  28711. /** @hidden */
  28712. _intersectionsInProgress: AbstractMesh[];
  28713. /** @hidden */
  28714. _unIndexed: boolean;
  28715. /** @hidden */
  28716. _lightSources: Light[];
  28717. /** Gets the list of lights affecting that mesh */
  28718. get lightSources(): Light[];
  28719. /** @hidden */
  28720. get _positions(): Nullable<Vector3[]>;
  28721. /** @hidden */
  28722. _waitingData: {
  28723. lods: Nullable<any>;
  28724. actions: Nullable<any>;
  28725. freezeWorldMatrix: Nullable<boolean>;
  28726. };
  28727. /** @hidden */
  28728. _bonesTransformMatrices: Nullable<Float32Array>;
  28729. /** @hidden */
  28730. _transformMatrixTexture: Nullable<RawTexture>;
  28731. /**
  28732. * Gets or sets a skeleton to apply skining transformations
  28733. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28734. */
  28735. set skeleton(value: Nullable<Skeleton>);
  28736. get skeleton(): Nullable<Skeleton>;
  28737. /**
  28738. * An event triggered when the mesh is rebuilt.
  28739. */
  28740. onRebuildObservable: Observable<AbstractMesh>;
  28741. /**
  28742. * Creates a new AbstractMesh
  28743. * @param name defines the name of the mesh
  28744. * @param scene defines the hosting scene
  28745. */
  28746. constructor(name: string, scene?: Nullable<Scene>);
  28747. /**
  28748. * Returns the string "AbstractMesh"
  28749. * @returns "AbstractMesh"
  28750. */
  28751. getClassName(): string;
  28752. /**
  28753. * Gets a string representation of the current mesh
  28754. * @param fullDetails defines a boolean indicating if full details must be included
  28755. * @returns a string representation of the current mesh
  28756. */
  28757. toString(fullDetails?: boolean): string;
  28758. /**
  28759. * @hidden
  28760. */
  28761. protected _getEffectiveParent(): Nullable<Node>;
  28762. /** @hidden */
  28763. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28764. /** @hidden */
  28765. _rebuild(): void;
  28766. /** @hidden */
  28767. _resyncLightSources(): void;
  28768. /** @hidden */
  28769. _resyncLightSource(light: Light): void;
  28770. /** @hidden */
  28771. _unBindEffect(): void;
  28772. /** @hidden */
  28773. _removeLightSource(light: Light, dispose: boolean): void;
  28774. private _markSubMeshesAsDirty;
  28775. /** @hidden */
  28776. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28777. /** @hidden */
  28778. _markSubMeshesAsAttributesDirty(): void;
  28779. /** @hidden */
  28780. _markSubMeshesAsMiscDirty(): void;
  28781. /**
  28782. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28783. */
  28784. get scaling(): Vector3;
  28785. set scaling(newScaling: Vector3);
  28786. /**
  28787. * Returns true if the mesh is blocked. Implemented by child classes
  28788. */
  28789. get isBlocked(): boolean;
  28790. /**
  28791. * Returns the mesh itself by default. Implemented by child classes
  28792. * @param camera defines the camera to use to pick the right LOD level
  28793. * @returns the currentAbstractMesh
  28794. */
  28795. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28796. /**
  28797. * Returns 0 by default. Implemented by child classes
  28798. * @returns an integer
  28799. */
  28800. getTotalVertices(): number;
  28801. /**
  28802. * Returns a positive integer : the total number of indices in this mesh geometry.
  28803. * @returns the numner of indices or zero if the mesh has no geometry.
  28804. */
  28805. getTotalIndices(): number;
  28806. /**
  28807. * Returns null by default. Implemented by child classes
  28808. * @returns null
  28809. */
  28810. getIndices(): Nullable<IndicesArray>;
  28811. /**
  28812. * Returns the array of the requested vertex data kind. Implemented by child classes
  28813. * @param kind defines the vertex data kind to use
  28814. * @returns null
  28815. */
  28816. getVerticesData(kind: string): Nullable<FloatArray>;
  28817. /**
  28818. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28819. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28820. * Note that a new underlying VertexBuffer object is created each call.
  28821. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28822. * @param kind defines vertex data kind:
  28823. * * VertexBuffer.PositionKind
  28824. * * VertexBuffer.UVKind
  28825. * * VertexBuffer.UV2Kind
  28826. * * VertexBuffer.UV3Kind
  28827. * * VertexBuffer.UV4Kind
  28828. * * VertexBuffer.UV5Kind
  28829. * * VertexBuffer.UV6Kind
  28830. * * VertexBuffer.ColorKind
  28831. * * VertexBuffer.MatricesIndicesKind
  28832. * * VertexBuffer.MatricesIndicesExtraKind
  28833. * * VertexBuffer.MatricesWeightsKind
  28834. * * VertexBuffer.MatricesWeightsExtraKind
  28835. * @param data defines the data source
  28836. * @param updatable defines if the data must be flagged as updatable (or static)
  28837. * @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
  28838. * @returns the current mesh
  28839. */
  28840. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28841. /**
  28842. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28843. * If the mesh has no geometry, it is simply returned as it is.
  28844. * @param kind defines vertex data kind:
  28845. * * VertexBuffer.PositionKind
  28846. * * VertexBuffer.UVKind
  28847. * * VertexBuffer.UV2Kind
  28848. * * VertexBuffer.UV3Kind
  28849. * * VertexBuffer.UV4Kind
  28850. * * VertexBuffer.UV5Kind
  28851. * * VertexBuffer.UV6Kind
  28852. * * VertexBuffer.ColorKind
  28853. * * VertexBuffer.MatricesIndicesKind
  28854. * * VertexBuffer.MatricesIndicesExtraKind
  28855. * * VertexBuffer.MatricesWeightsKind
  28856. * * VertexBuffer.MatricesWeightsExtraKind
  28857. * @param data defines the data source
  28858. * @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
  28859. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28860. * @returns the current mesh
  28861. */
  28862. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28863. /**
  28864. * Sets the mesh indices,
  28865. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28866. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28867. * @param totalVertices Defines the total number of vertices
  28868. * @returns the current mesh
  28869. */
  28870. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28871. /**
  28872. * Gets a boolean indicating if specific vertex data is present
  28873. * @param kind defines the vertex data kind to use
  28874. * @returns true is data kind is present
  28875. */
  28876. isVerticesDataPresent(kind: string): boolean;
  28877. /**
  28878. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28879. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28880. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28881. * @returns a BoundingInfo
  28882. */
  28883. getBoundingInfo(): BoundingInfo;
  28884. /**
  28885. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28886. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28887. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28888. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28889. * @returns the current mesh
  28890. */
  28891. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28892. /**
  28893. * Overwrite the current bounding info
  28894. * @param boundingInfo defines the new bounding info
  28895. * @returns the current mesh
  28896. */
  28897. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28898. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28899. get useBones(): boolean;
  28900. /** @hidden */
  28901. _preActivate(): void;
  28902. /** @hidden */
  28903. _preActivateForIntermediateRendering(renderId: number): void;
  28904. /** @hidden */
  28905. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28906. /** @hidden */
  28907. _postActivate(): void;
  28908. /** @hidden */
  28909. _freeze(): void;
  28910. /** @hidden */
  28911. _unFreeze(): void;
  28912. /**
  28913. * Gets the current world matrix
  28914. * @returns a Matrix
  28915. */
  28916. getWorldMatrix(): Matrix;
  28917. /** @hidden */
  28918. _getWorldMatrixDeterminant(): number;
  28919. /**
  28920. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28921. */
  28922. get isAnInstance(): boolean;
  28923. /**
  28924. * Gets a boolean indicating if this mesh has instances
  28925. */
  28926. get hasInstances(): boolean;
  28927. /**
  28928. * Perform relative position change from the point of view of behind the front of the mesh.
  28929. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28930. * Supports definition of mesh facing forward or backward
  28931. * @param amountRight defines the distance on the right axis
  28932. * @param amountUp defines the distance on the up axis
  28933. * @param amountForward defines the distance on the forward axis
  28934. * @returns the current mesh
  28935. */
  28936. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28937. /**
  28938. * Calculate relative position change from the point of view of behind the front of the mesh.
  28939. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28940. * Supports definition of mesh facing forward or backward
  28941. * @param amountRight defines the distance on the right axis
  28942. * @param amountUp defines the distance on the up axis
  28943. * @param amountForward defines the distance on the forward axis
  28944. * @returns the new displacement vector
  28945. */
  28946. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28947. /**
  28948. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28949. * Supports definition of mesh facing forward or backward
  28950. * @param flipBack defines the flip
  28951. * @param twirlClockwise defines the twirl
  28952. * @param tiltRight defines the tilt
  28953. * @returns the current mesh
  28954. */
  28955. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28956. /**
  28957. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28958. * Supports definition of mesh facing forward or backward.
  28959. * @param flipBack defines the flip
  28960. * @param twirlClockwise defines the twirl
  28961. * @param tiltRight defines the tilt
  28962. * @returns the new rotation vector
  28963. */
  28964. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28965. /**
  28966. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28967. * This means the mesh underlying bounding box and sphere are recomputed.
  28968. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28969. * @returns the current mesh
  28970. */
  28971. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28972. /** @hidden */
  28973. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28974. /** @hidden */
  28975. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28976. /** @hidden */
  28977. _updateBoundingInfo(): AbstractMesh;
  28978. /** @hidden */
  28979. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28980. /** @hidden */
  28981. protected _afterComputeWorldMatrix(): void;
  28982. /** @hidden */
  28983. get _effectiveMesh(): AbstractMesh;
  28984. /**
  28985. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28986. * A mesh is in the frustum if its bounding box intersects the frustum
  28987. * @param frustumPlanes defines the frustum to test
  28988. * @returns true if the mesh is in the frustum planes
  28989. */
  28990. isInFrustum(frustumPlanes: Plane[]): boolean;
  28991. /**
  28992. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28993. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28994. * @param frustumPlanes defines the frustum to test
  28995. * @returns true if the mesh is completely in the frustum planes
  28996. */
  28997. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28998. /**
  28999. * True if the mesh intersects another mesh or a SolidParticle object
  29000. * @param mesh defines a target mesh or SolidParticle to test
  29001. * @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)
  29002. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29003. * @returns true if there is an intersection
  29004. */
  29005. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29006. /**
  29007. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29008. * @param point defines the point to test
  29009. * @returns true if there is an intersection
  29010. */
  29011. intersectsPoint(point: Vector3): boolean;
  29012. /**
  29013. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29014. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29015. */
  29016. get checkCollisions(): boolean;
  29017. set checkCollisions(collisionEnabled: boolean);
  29018. /**
  29019. * Gets Collider object used to compute collisions (not physics)
  29020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29021. */
  29022. get collider(): Nullable<Collider>;
  29023. /**
  29024. * Move the mesh using collision engine
  29025. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29026. * @param displacement defines the requested displacement vector
  29027. * @returns the current mesh
  29028. */
  29029. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29030. private _onCollisionPositionChange;
  29031. /** @hidden */
  29032. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29033. /** @hidden */
  29034. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29035. /** @hidden */
  29036. _checkCollision(collider: Collider): AbstractMesh;
  29037. /** @hidden */
  29038. _generatePointsArray(): boolean;
  29039. /**
  29040. * Checks if the passed Ray intersects with the mesh
  29041. * @param ray defines the ray to use
  29042. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29043. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29044. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  29045. * @returns the picking info
  29046. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29047. */
  29048. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  29049. /**
  29050. * Clones the current mesh
  29051. * @param name defines the mesh name
  29052. * @param newParent defines the new mesh parent
  29053. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29054. * @returns the new mesh
  29055. */
  29056. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29057. /**
  29058. * Disposes all the submeshes of the current meshnp
  29059. * @returns the current mesh
  29060. */
  29061. releaseSubMeshes(): AbstractMesh;
  29062. /**
  29063. * Releases resources associated with this abstract mesh.
  29064. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29065. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29066. */
  29067. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29068. /**
  29069. * Adds the passed mesh as a child to the current mesh
  29070. * @param mesh defines the child mesh
  29071. * @returns the current mesh
  29072. */
  29073. addChild(mesh: AbstractMesh): AbstractMesh;
  29074. /**
  29075. * Removes the passed mesh from the current mesh children list
  29076. * @param mesh defines the child mesh
  29077. * @returns the current mesh
  29078. */
  29079. removeChild(mesh: AbstractMesh): AbstractMesh;
  29080. /** @hidden */
  29081. private _initFacetData;
  29082. /**
  29083. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29084. * This method can be called within the render loop.
  29085. * 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
  29086. * @returns the current mesh
  29087. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29088. */
  29089. updateFacetData(): AbstractMesh;
  29090. /**
  29091. * Returns the facetLocalNormals array.
  29092. * The normals are expressed in the mesh local spac
  29093. * @returns an array of Vector3
  29094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29095. */
  29096. getFacetLocalNormals(): Vector3[];
  29097. /**
  29098. * Returns the facetLocalPositions array.
  29099. * The facet positions are expressed in the mesh local space
  29100. * @returns an array of Vector3
  29101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29102. */
  29103. getFacetLocalPositions(): Vector3[];
  29104. /**
  29105. * Returns the facetLocalPartioning array
  29106. * @returns an array of array of numbers
  29107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29108. */
  29109. getFacetLocalPartitioning(): number[][];
  29110. /**
  29111. * Returns the i-th facet position in the world system.
  29112. * This method allocates a new Vector3 per call
  29113. * @param i defines the facet index
  29114. * @returns a new Vector3
  29115. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29116. */
  29117. getFacetPosition(i: number): Vector3;
  29118. /**
  29119. * Sets the reference Vector3 with the i-th facet position in the world system
  29120. * @param i defines the facet index
  29121. * @param ref defines the target vector
  29122. * @returns the current mesh
  29123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29124. */
  29125. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29126. /**
  29127. * Returns the i-th facet normal in the world system.
  29128. * This method allocates a new Vector3 per call
  29129. * @param i defines the facet index
  29130. * @returns a new Vector3
  29131. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29132. */
  29133. getFacetNormal(i: number): Vector3;
  29134. /**
  29135. * Sets the reference Vector3 with the i-th facet normal in the world system
  29136. * @param i defines the facet index
  29137. * @param ref defines the target vector
  29138. * @returns the current mesh
  29139. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29140. */
  29141. getFacetNormalToRef(i: number, ref: Vector3): this;
  29142. /**
  29143. * 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)
  29144. * @param x defines x coordinate
  29145. * @param y defines y coordinate
  29146. * @param z defines z coordinate
  29147. * @returns the array of facet indexes
  29148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29149. */
  29150. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29151. /**
  29152. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29153. * @param projected sets as the (x,y,z) world projection on the facet
  29154. * @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
  29155. * @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
  29156. * @param x defines x coordinate
  29157. * @param y defines y coordinate
  29158. * @param z defines z coordinate
  29159. * @returns the face index if found (or null instead)
  29160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29161. */
  29162. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29163. /**
  29164. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29165. * @param projected sets as the (x,y,z) local projection on the facet
  29166. * @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
  29167. * @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
  29168. * @param x defines x coordinate
  29169. * @param y defines y coordinate
  29170. * @param z defines z coordinate
  29171. * @returns the face index if found (or null instead)
  29172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29173. */
  29174. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29175. /**
  29176. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29177. * @returns the parameters
  29178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29179. */
  29180. getFacetDataParameters(): any;
  29181. /**
  29182. * Disables the feature FacetData and frees the related memory
  29183. * @returns the current mesh
  29184. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29185. */
  29186. disableFacetData(): AbstractMesh;
  29187. /**
  29188. * Updates the AbstractMesh indices array
  29189. * @param indices defines the data source
  29190. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29191. * @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)
  29192. * @returns the current mesh
  29193. */
  29194. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29195. /**
  29196. * Creates new normals data for the mesh
  29197. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29198. * @returns the current mesh
  29199. */
  29200. createNormals(updatable: boolean): AbstractMesh;
  29201. /**
  29202. * Align the mesh with a normal
  29203. * @param normal defines the normal to use
  29204. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29205. * @returns the current mesh
  29206. */
  29207. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29208. /** @hidden */
  29209. _checkOcclusionQuery(): boolean;
  29210. /**
  29211. * Disables the mesh edge rendering mode
  29212. * @returns the currentAbstractMesh
  29213. */
  29214. disableEdgesRendering(): AbstractMesh;
  29215. /**
  29216. * Enables the edge rendering mode on the mesh.
  29217. * This mode makes the mesh edges visible
  29218. * @param epsilon defines the maximal distance between two angles to detect a face
  29219. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29220. * @returns the currentAbstractMesh
  29221. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29222. */
  29223. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29224. }
  29225. }
  29226. declare module BABYLON {
  29227. /**
  29228. * Interface used to define ActionEvent
  29229. */
  29230. export interface IActionEvent {
  29231. /** The mesh or sprite that triggered the action */
  29232. source: any;
  29233. /** The X mouse cursor position at the time of the event */
  29234. pointerX: number;
  29235. /** The Y mouse cursor position at the time of the event */
  29236. pointerY: number;
  29237. /** The mesh that is currently pointed at (can be null) */
  29238. meshUnderPointer: Nullable<AbstractMesh>;
  29239. /** the original (browser) event that triggered the ActionEvent */
  29240. sourceEvent?: any;
  29241. /** additional data for the event */
  29242. additionalData?: any;
  29243. }
  29244. /**
  29245. * ActionEvent is the event being sent when an action is triggered.
  29246. */
  29247. export class ActionEvent implements IActionEvent {
  29248. /** The mesh or sprite that triggered the action */
  29249. source: any;
  29250. /** The X mouse cursor position at the time of the event */
  29251. pointerX: number;
  29252. /** The Y mouse cursor position at the time of the event */
  29253. pointerY: number;
  29254. /** The mesh that is currently pointed at (can be null) */
  29255. meshUnderPointer: Nullable<AbstractMesh>;
  29256. /** the original (browser) event that triggered the ActionEvent */
  29257. sourceEvent?: any;
  29258. /** additional data for the event */
  29259. additionalData?: any;
  29260. /**
  29261. * Creates a new ActionEvent
  29262. * @param source The mesh or sprite that triggered the action
  29263. * @param pointerX The X mouse cursor position at the time of the event
  29264. * @param pointerY The Y mouse cursor position at the time of the event
  29265. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29266. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29267. * @param additionalData additional data for the event
  29268. */
  29269. constructor(
  29270. /** The mesh or sprite that triggered the action */
  29271. source: any,
  29272. /** The X mouse cursor position at the time of the event */
  29273. pointerX: number,
  29274. /** The Y mouse cursor position at the time of the event */
  29275. pointerY: number,
  29276. /** The mesh that is currently pointed at (can be null) */
  29277. meshUnderPointer: Nullable<AbstractMesh>,
  29278. /** the original (browser) event that triggered the ActionEvent */
  29279. sourceEvent?: any,
  29280. /** additional data for the event */
  29281. additionalData?: any);
  29282. /**
  29283. * Helper function to auto-create an ActionEvent from a source mesh.
  29284. * @param source The source mesh that triggered the event
  29285. * @param evt The original (browser) event
  29286. * @param additionalData additional data for the event
  29287. * @returns the new ActionEvent
  29288. */
  29289. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29290. /**
  29291. * Helper function to auto-create an ActionEvent from a source sprite
  29292. * @param source The source sprite that triggered the event
  29293. * @param scene Scene associated with the sprite
  29294. * @param evt The original (browser) event
  29295. * @param additionalData additional data for the event
  29296. * @returns the new ActionEvent
  29297. */
  29298. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29299. /**
  29300. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29301. * @param scene the scene where the event occurred
  29302. * @param evt The original (browser) event
  29303. * @returns the new ActionEvent
  29304. */
  29305. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29306. /**
  29307. * Helper function to auto-create an ActionEvent from a primitive
  29308. * @param prim defines the target primitive
  29309. * @param pointerPos defines the pointer position
  29310. * @param evt The original (browser) event
  29311. * @param additionalData additional data for the event
  29312. * @returns the new ActionEvent
  29313. */
  29314. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29315. }
  29316. }
  29317. declare module BABYLON {
  29318. /**
  29319. * Abstract class used to decouple action Manager from scene and meshes.
  29320. * Do not instantiate.
  29321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29322. */
  29323. export abstract class AbstractActionManager implements IDisposable {
  29324. /** Gets the list of active triggers */
  29325. static Triggers: {
  29326. [key: string]: number;
  29327. };
  29328. /** Gets the cursor to use when hovering items */
  29329. hoverCursor: string;
  29330. /** Gets the list of actions */
  29331. actions: IAction[];
  29332. /**
  29333. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29334. */
  29335. isRecursive: boolean;
  29336. /**
  29337. * Releases all associated resources
  29338. */
  29339. abstract dispose(): void;
  29340. /**
  29341. * Does this action manager has pointer triggers
  29342. */
  29343. abstract get hasPointerTriggers(): boolean;
  29344. /**
  29345. * Does this action manager has pick triggers
  29346. */
  29347. abstract get hasPickTriggers(): boolean;
  29348. /**
  29349. * Process a specific trigger
  29350. * @param trigger defines the trigger to process
  29351. * @param evt defines the event details to be processed
  29352. */
  29353. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29354. /**
  29355. * Does this action manager handles actions of any of the given triggers
  29356. * @param triggers defines the triggers to be tested
  29357. * @return a boolean indicating whether one (or more) of the triggers is handled
  29358. */
  29359. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29360. /**
  29361. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29362. * speed.
  29363. * @param triggerA defines the trigger to be tested
  29364. * @param triggerB defines the trigger to be tested
  29365. * @return a boolean indicating whether one (or more) of the triggers is handled
  29366. */
  29367. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29368. /**
  29369. * Does this action manager handles actions of a given trigger
  29370. * @param trigger defines the trigger to be tested
  29371. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29372. * @return whether the trigger is handled
  29373. */
  29374. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29375. /**
  29376. * Serialize this manager to a JSON object
  29377. * @param name defines the property name to store this manager
  29378. * @returns a JSON representation of this manager
  29379. */
  29380. abstract serialize(name: string): any;
  29381. /**
  29382. * Registers an action to this action manager
  29383. * @param action defines the action to be registered
  29384. * @return the action amended (prepared) after registration
  29385. */
  29386. abstract registerAction(action: IAction): Nullable<IAction>;
  29387. /**
  29388. * Unregisters an action to this action manager
  29389. * @param action defines the action to be unregistered
  29390. * @return a boolean indicating whether the action has been unregistered
  29391. */
  29392. abstract unregisterAction(action: IAction): Boolean;
  29393. /**
  29394. * Does exist one action manager with at least one trigger
  29395. **/
  29396. static get HasTriggers(): boolean;
  29397. /**
  29398. * Does exist one action manager with at least one pick trigger
  29399. **/
  29400. static get HasPickTriggers(): boolean;
  29401. /**
  29402. * Does exist one action manager that handles actions of a given trigger
  29403. * @param trigger defines the trigger to be tested
  29404. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29405. **/
  29406. static HasSpecificTrigger(trigger: number): boolean;
  29407. }
  29408. }
  29409. declare module BABYLON {
  29410. /**
  29411. * Defines how a node can be built from a string name.
  29412. */
  29413. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29414. /**
  29415. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29416. */
  29417. export class Node implements IBehaviorAware<Node> {
  29418. /** @hidden */
  29419. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29420. private static _NodeConstructors;
  29421. /**
  29422. * Add a new node constructor
  29423. * @param type defines the type name of the node to construct
  29424. * @param constructorFunc defines the constructor function
  29425. */
  29426. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29427. /**
  29428. * Returns a node constructor based on type name
  29429. * @param type defines the type name
  29430. * @param name defines the new node name
  29431. * @param scene defines the hosting scene
  29432. * @param options defines optional options to transmit to constructors
  29433. * @returns the new constructor or null
  29434. */
  29435. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29436. /**
  29437. * Gets or sets the name of the node
  29438. */
  29439. name: string;
  29440. /**
  29441. * Gets or sets the id of the node
  29442. */
  29443. id: string;
  29444. /**
  29445. * Gets or sets the unique id of the node
  29446. */
  29447. uniqueId: number;
  29448. /**
  29449. * Gets or sets a string used to store user defined state for the node
  29450. */
  29451. state: string;
  29452. /**
  29453. * Gets or sets an object used to store user defined information for the node
  29454. */
  29455. metadata: any;
  29456. /**
  29457. * For internal use only. Please do not use.
  29458. */
  29459. reservedDataStore: any;
  29460. /**
  29461. * List of inspectable custom properties (used by the Inspector)
  29462. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29463. */
  29464. inspectableCustomProperties: IInspectable[];
  29465. private _doNotSerialize;
  29466. /**
  29467. * Gets or sets a boolean used to define if the node must be serialized
  29468. */
  29469. get doNotSerialize(): boolean;
  29470. set doNotSerialize(value: boolean);
  29471. /** @hidden */
  29472. _isDisposed: boolean;
  29473. /**
  29474. * Gets a list of Animations associated with the node
  29475. */
  29476. animations: Animation[];
  29477. protected _ranges: {
  29478. [name: string]: Nullable<AnimationRange>;
  29479. };
  29480. /**
  29481. * Callback raised when the node is ready to be used
  29482. */
  29483. onReady: Nullable<(node: Node) => void>;
  29484. private _isEnabled;
  29485. private _isParentEnabled;
  29486. private _isReady;
  29487. /** @hidden */
  29488. _currentRenderId: number;
  29489. private _parentUpdateId;
  29490. /** @hidden */
  29491. _childUpdateId: number;
  29492. /** @hidden */
  29493. _waitingParentId: Nullable<string>;
  29494. /** @hidden */
  29495. _scene: Scene;
  29496. /** @hidden */
  29497. _cache: any;
  29498. private _parentNode;
  29499. private _children;
  29500. /** @hidden */
  29501. _worldMatrix: Matrix;
  29502. /** @hidden */
  29503. _worldMatrixDeterminant: number;
  29504. /** @hidden */
  29505. _worldMatrixDeterminantIsDirty: boolean;
  29506. /** @hidden */
  29507. private _sceneRootNodesIndex;
  29508. /**
  29509. * Gets a boolean indicating if the node has been disposed
  29510. * @returns true if the node was disposed
  29511. */
  29512. isDisposed(): boolean;
  29513. /**
  29514. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29515. * @see https://doc.babylonjs.com/how_to/parenting
  29516. */
  29517. set parent(parent: Nullable<Node>);
  29518. get parent(): Nullable<Node>;
  29519. /** @hidden */
  29520. _addToSceneRootNodes(): void;
  29521. /** @hidden */
  29522. _removeFromSceneRootNodes(): void;
  29523. private _animationPropertiesOverride;
  29524. /**
  29525. * Gets or sets the animation properties override
  29526. */
  29527. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29528. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29529. /**
  29530. * Gets a string idenfifying the name of the class
  29531. * @returns "Node" string
  29532. */
  29533. getClassName(): string;
  29534. /** @hidden */
  29535. readonly _isNode: boolean;
  29536. /**
  29537. * An event triggered when the mesh is disposed
  29538. */
  29539. onDisposeObservable: Observable<Node>;
  29540. private _onDisposeObserver;
  29541. /**
  29542. * Sets a callback that will be raised when the node will be disposed
  29543. */
  29544. set onDispose(callback: () => void);
  29545. /**
  29546. * Creates a new Node
  29547. * @param name the name and id to be given to this node
  29548. * @param scene the scene this node will be added to
  29549. */
  29550. constructor(name: string, scene?: Nullable<Scene>);
  29551. /**
  29552. * Gets the scene of the node
  29553. * @returns a scene
  29554. */
  29555. getScene(): Scene;
  29556. /**
  29557. * Gets the engine of the node
  29558. * @returns a Engine
  29559. */
  29560. getEngine(): Engine;
  29561. private _behaviors;
  29562. /**
  29563. * Attach a behavior to the node
  29564. * @see http://doc.babylonjs.com/features/behaviour
  29565. * @param behavior defines the behavior to attach
  29566. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29567. * @returns the current Node
  29568. */
  29569. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29570. /**
  29571. * Remove an attached behavior
  29572. * @see http://doc.babylonjs.com/features/behaviour
  29573. * @param behavior defines the behavior to attach
  29574. * @returns the current Node
  29575. */
  29576. removeBehavior(behavior: Behavior<Node>): Node;
  29577. /**
  29578. * Gets the list of attached behaviors
  29579. * @see http://doc.babylonjs.com/features/behaviour
  29580. */
  29581. get behaviors(): Behavior<Node>[];
  29582. /**
  29583. * Gets an attached behavior by name
  29584. * @param name defines the name of the behavior to look for
  29585. * @see http://doc.babylonjs.com/features/behaviour
  29586. * @returns null if behavior was not found else the requested behavior
  29587. */
  29588. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29589. /**
  29590. * Returns the latest update of the World matrix
  29591. * @returns a Matrix
  29592. */
  29593. getWorldMatrix(): Matrix;
  29594. /** @hidden */
  29595. _getWorldMatrixDeterminant(): number;
  29596. /**
  29597. * Returns directly the latest state of the mesh World matrix.
  29598. * A Matrix is returned.
  29599. */
  29600. get worldMatrixFromCache(): Matrix;
  29601. /** @hidden */
  29602. _initCache(): void;
  29603. /** @hidden */
  29604. updateCache(force?: boolean): void;
  29605. /** @hidden */
  29606. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29607. /** @hidden */
  29608. _updateCache(ignoreParentClass?: boolean): void;
  29609. /** @hidden */
  29610. _isSynchronized(): boolean;
  29611. /** @hidden */
  29612. _markSyncedWithParent(): void;
  29613. /** @hidden */
  29614. isSynchronizedWithParent(): boolean;
  29615. /** @hidden */
  29616. isSynchronized(): boolean;
  29617. /**
  29618. * Is this node ready to be used/rendered
  29619. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29620. * @return true if the node is ready
  29621. */
  29622. isReady(completeCheck?: boolean): boolean;
  29623. /**
  29624. * Is this node enabled?
  29625. * 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
  29626. * @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
  29627. * @return whether this node (and its parent) is enabled
  29628. */
  29629. isEnabled(checkAncestors?: boolean): boolean;
  29630. /** @hidden */
  29631. protected _syncParentEnabledState(): void;
  29632. /**
  29633. * Set the enabled state of this node
  29634. * @param value defines the new enabled state
  29635. */
  29636. setEnabled(value: boolean): void;
  29637. /**
  29638. * Is this node a descendant of the given node?
  29639. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29640. * @param ancestor defines the parent node to inspect
  29641. * @returns a boolean indicating if this node is a descendant of the given node
  29642. */
  29643. isDescendantOf(ancestor: Node): boolean;
  29644. /** @hidden */
  29645. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29646. /**
  29647. * Will return all nodes that have this node as ascendant
  29648. * @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
  29649. * @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
  29650. * @return all children nodes of all types
  29651. */
  29652. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29653. /**
  29654. * Get all child-meshes of this node
  29655. * @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)
  29656. * @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
  29657. * @returns an array of AbstractMesh
  29658. */
  29659. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29660. /**
  29661. * Get all direct children of this node
  29662. * @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
  29663. * @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)
  29664. * @returns an array of Node
  29665. */
  29666. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29667. /** @hidden */
  29668. _setReady(state: boolean): void;
  29669. /**
  29670. * Get an animation by name
  29671. * @param name defines the name of the animation to look for
  29672. * @returns null if not found else the requested animation
  29673. */
  29674. getAnimationByName(name: string): Nullable<Animation>;
  29675. /**
  29676. * Creates an animation range for this node
  29677. * @param name defines the name of the range
  29678. * @param from defines the starting key
  29679. * @param to defines the end key
  29680. */
  29681. createAnimationRange(name: string, from: number, to: number): void;
  29682. /**
  29683. * Delete a specific animation range
  29684. * @param name defines the name of the range to delete
  29685. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29686. */
  29687. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29688. /**
  29689. * Get an animation range by name
  29690. * @param name defines the name of the animation range to look for
  29691. * @returns null if not found else the requested animation range
  29692. */
  29693. getAnimationRange(name: string): Nullable<AnimationRange>;
  29694. /**
  29695. * Gets the list of all animation ranges defined on this node
  29696. * @returns an array
  29697. */
  29698. getAnimationRanges(): Nullable<AnimationRange>[];
  29699. /**
  29700. * Will start the animation sequence
  29701. * @param name defines the range frames for animation sequence
  29702. * @param loop defines if the animation should loop (false by default)
  29703. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29704. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29705. * @returns the object created for this animation. If range does not exist, it will return null
  29706. */
  29707. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29708. /**
  29709. * Serialize animation ranges into a JSON compatible object
  29710. * @returns serialization object
  29711. */
  29712. serializeAnimationRanges(): any;
  29713. /**
  29714. * Computes the world matrix of the node
  29715. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29716. * @returns the world matrix
  29717. */
  29718. computeWorldMatrix(force?: boolean): Matrix;
  29719. /**
  29720. * Releases resources associated with this node.
  29721. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29722. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29723. */
  29724. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29725. /**
  29726. * Parse animation range data from a serialization object and store them into a given node
  29727. * @param node defines where to store the animation ranges
  29728. * @param parsedNode defines the serialization object to read data from
  29729. * @param scene defines the hosting scene
  29730. */
  29731. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29732. /**
  29733. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29734. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29735. * @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
  29736. * @returns the new bounding vectors
  29737. */
  29738. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29739. min: Vector3;
  29740. max: Vector3;
  29741. };
  29742. }
  29743. }
  29744. declare module BABYLON {
  29745. /**
  29746. * @hidden
  29747. */
  29748. export class _IAnimationState {
  29749. key: number;
  29750. repeatCount: number;
  29751. workValue?: any;
  29752. loopMode?: number;
  29753. offsetValue?: any;
  29754. highLimitValue?: any;
  29755. }
  29756. /**
  29757. * Class used to store any kind of animation
  29758. */
  29759. export class Animation {
  29760. /**Name of the animation */
  29761. name: string;
  29762. /**Property to animate */
  29763. targetProperty: string;
  29764. /**The frames per second of the animation */
  29765. framePerSecond: number;
  29766. /**The data type of the animation */
  29767. dataType: number;
  29768. /**The loop mode of the animation */
  29769. loopMode?: number | undefined;
  29770. /**Specifies if blending should be enabled */
  29771. enableBlending?: boolean | undefined;
  29772. /**
  29773. * Use matrix interpolation instead of using direct key value when animating matrices
  29774. */
  29775. static AllowMatricesInterpolation: boolean;
  29776. /**
  29777. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29778. */
  29779. static AllowMatrixDecomposeForInterpolation: boolean;
  29780. /**
  29781. * Stores the key frames of the animation
  29782. */
  29783. private _keys;
  29784. /**
  29785. * Stores the easing function of the animation
  29786. */
  29787. private _easingFunction;
  29788. /**
  29789. * @hidden Internal use only
  29790. */
  29791. _runtimeAnimations: RuntimeAnimation[];
  29792. /**
  29793. * The set of event that will be linked to this animation
  29794. */
  29795. private _events;
  29796. /**
  29797. * Stores an array of target property paths
  29798. */
  29799. targetPropertyPath: string[];
  29800. /**
  29801. * Stores the blending speed of the animation
  29802. */
  29803. blendingSpeed: number;
  29804. /**
  29805. * Stores the animation ranges for the animation
  29806. */
  29807. private _ranges;
  29808. /**
  29809. * @hidden Internal use
  29810. */
  29811. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29812. /**
  29813. * Sets up an animation
  29814. * @param property The property to animate
  29815. * @param animationType The animation type to apply
  29816. * @param framePerSecond The frames per second of the animation
  29817. * @param easingFunction The easing function used in the animation
  29818. * @returns The created animation
  29819. */
  29820. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29821. /**
  29822. * Create and start an animation on a node
  29823. * @param name defines the name of the global animation that will be run on all nodes
  29824. * @param node defines the root node where the animation will take place
  29825. * @param targetProperty defines property to animate
  29826. * @param framePerSecond defines the number of frame per second yo use
  29827. * @param totalFrame defines the number of frames in total
  29828. * @param from defines the initial value
  29829. * @param to defines the final value
  29830. * @param loopMode defines which loop mode you want to use (off by default)
  29831. * @param easingFunction defines the easing function to use (linear by default)
  29832. * @param onAnimationEnd defines the callback to call when animation end
  29833. * @returns the animatable created for this animation
  29834. */
  29835. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29836. /**
  29837. * Create and start an animation on a node and its descendants
  29838. * @param name defines the name of the global animation that will be run on all nodes
  29839. * @param node defines the root node where the animation will take place
  29840. * @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
  29841. * @param targetProperty defines property to animate
  29842. * @param framePerSecond defines the number of frame per second to use
  29843. * @param totalFrame defines the number of frames in total
  29844. * @param from defines the initial value
  29845. * @param to defines the final value
  29846. * @param loopMode defines which loop mode you want to use (off by default)
  29847. * @param easingFunction defines the easing function to use (linear by default)
  29848. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29849. * @returns the list of animatables created for all nodes
  29850. * @example https://www.babylonjs-playground.com/#MH0VLI
  29851. */
  29852. 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[]>;
  29853. /**
  29854. * Creates a new animation, merges it with the existing animations and starts it
  29855. * @param name Name of the animation
  29856. * @param node Node which contains the scene that begins the animations
  29857. * @param targetProperty Specifies which property to animate
  29858. * @param framePerSecond The frames per second of the animation
  29859. * @param totalFrame The total number of frames
  29860. * @param from The frame at the beginning of the animation
  29861. * @param to The frame at the end of the animation
  29862. * @param loopMode Specifies the loop mode of the animation
  29863. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29864. * @param onAnimationEnd Callback to run once the animation is complete
  29865. * @returns Nullable animation
  29866. */
  29867. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29868. /**
  29869. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29870. * @param sourceAnimation defines the Animation containing keyframes to convert
  29871. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29872. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29873. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29874. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29875. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29876. */
  29877. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29878. /**
  29879. * Transition property of an host to the target Value
  29880. * @param property The property to transition
  29881. * @param targetValue The target Value of the property
  29882. * @param host The object where the property to animate belongs
  29883. * @param scene Scene used to run the animation
  29884. * @param frameRate Framerate (in frame/s) to use
  29885. * @param transition The transition type we want to use
  29886. * @param duration The duration of the animation, in milliseconds
  29887. * @param onAnimationEnd Callback trigger at the end of the animation
  29888. * @returns Nullable animation
  29889. */
  29890. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29891. /**
  29892. * Return the array of runtime animations currently using this animation
  29893. */
  29894. get runtimeAnimations(): RuntimeAnimation[];
  29895. /**
  29896. * Specifies if any of the runtime animations are currently running
  29897. */
  29898. get hasRunningRuntimeAnimations(): boolean;
  29899. /**
  29900. * Initializes the animation
  29901. * @param name Name of the animation
  29902. * @param targetProperty Property to animate
  29903. * @param framePerSecond The frames per second of the animation
  29904. * @param dataType The data type of the animation
  29905. * @param loopMode The loop mode of the animation
  29906. * @param enableBlending Specifies if blending should be enabled
  29907. */
  29908. constructor(
  29909. /**Name of the animation */
  29910. name: string,
  29911. /**Property to animate */
  29912. targetProperty: string,
  29913. /**The frames per second of the animation */
  29914. framePerSecond: number,
  29915. /**The data type of the animation */
  29916. dataType: number,
  29917. /**The loop mode of the animation */
  29918. loopMode?: number | undefined,
  29919. /**Specifies if blending should be enabled */
  29920. enableBlending?: boolean | undefined);
  29921. /**
  29922. * Converts the animation to a string
  29923. * @param fullDetails support for multiple levels of logging within scene loading
  29924. * @returns String form of the animation
  29925. */
  29926. toString(fullDetails?: boolean): string;
  29927. /**
  29928. * Add an event to this animation
  29929. * @param event Event to add
  29930. */
  29931. addEvent(event: AnimationEvent): void;
  29932. /**
  29933. * Remove all events found at the given frame
  29934. * @param frame The frame to remove events from
  29935. */
  29936. removeEvents(frame: number): void;
  29937. /**
  29938. * Retrieves all the events from the animation
  29939. * @returns Events from the animation
  29940. */
  29941. getEvents(): AnimationEvent[];
  29942. /**
  29943. * Creates an animation range
  29944. * @param name Name of the animation range
  29945. * @param from Starting frame of the animation range
  29946. * @param to Ending frame of the animation
  29947. */
  29948. createRange(name: string, from: number, to: number): void;
  29949. /**
  29950. * Deletes an animation range by name
  29951. * @param name Name of the animation range to delete
  29952. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29953. */
  29954. deleteRange(name: string, deleteFrames?: boolean): void;
  29955. /**
  29956. * Gets the animation range by name, or null if not defined
  29957. * @param name Name of the animation range
  29958. * @returns Nullable animation range
  29959. */
  29960. getRange(name: string): Nullable<AnimationRange>;
  29961. /**
  29962. * Gets the key frames from the animation
  29963. * @returns The key frames of the animation
  29964. */
  29965. getKeys(): Array<IAnimationKey>;
  29966. /**
  29967. * Gets the highest frame rate of the animation
  29968. * @returns Highest frame rate of the animation
  29969. */
  29970. getHighestFrame(): number;
  29971. /**
  29972. * Gets the easing function of the animation
  29973. * @returns Easing function of the animation
  29974. */
  29975. getEasingFunction(): IEasingFunction;
  29976. /**
  29977. * Sets the easing function of the animation
  29978. * @param easingFunction A custom mathematical formula for animation
  29979. */
  29980. setEasingFunction(easingFunction: EasingFunction): void;
  29981. /**
  29982. * Interpolates a scalar linearly
  29983. * @param startValue Start value of the animation curve
  29984. * @param endValue End value of the animation curve
  29985. * @param gradient Scalar amount to interpolate
  29986. * @returns Interpolated scalar value
  29987. */
  29988. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29989. /**
  29990. * Interpolates a scalar cubically
  29991. * @param startValue Start value of the animation curve
  29992. * @param outTangent End tangent of the animation
  29993. * @param endValue End value of the animation curve
  29994. * @param inTangent Start tangent of the animation curve
  29995. * @param gradient Scalar amount to interpolate
  29996. * @returns Interpolated scalar value
  29997. */
  29998. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29999. /**
  30000. * Interpolates a quaternion using a spherical linear interpolation
  30001. * @param startValue Start value of the animation curve
  30002. * @param endValue End value of the animation curve
  30003. * @param gradient Scalar amount to interpolate
  30004. * @returns Interpolated quaternion value
  30005. */
  30006. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30007. /**
  30008. * Interpolates a quaternion cubically
  30009. * @param startValue Start value of the animation curve
  30010. * @param outTangent End tangent of the animation curve
  30011. * @param endValue End value of the animation curve
  30012. * @param inTangent Start tangent of the animation curve
  30013. * @param gradient Scalar amount to interpolate
  30014. * @returns Interpolated quaternion value
  30015. */
  30016. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30017. /**
  30018. * Interpolates a Vector3 linearl
  30019. * @param startValue Start value of the animation curve
  30020. * @param endValue End value of the animation curve
  30021. * @param gradient Scalar amount to interpolate
  30022. * @returns Interpolated scalar value
  30023. */
  30024. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30025. /**
  30026. * Interpolates a Vector3 cubically
  30027. * @param startValue Start value of the animation curve
  30028. * @param outTangent End tangent of the animation
  30029. * @param endValue End value of the animation curve
  30030. * @param inTangent Start tangent of the animation curve
  30031. * @param gradient Scalar amount to interpolate
  30032. * @returns InterpolatedVector3 value
  30033. */
  30034. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30035. /**
  30036. * Interpolates a Vector2 linearly
  30037. * @param startValue Start value of the animation curve
  30038. * @param endValue End value of the animation curve
  30039. * @param gradient Scalar amount to interpolate
  30040. * @returns Interpolated Vector2 value
  30041. */
  30042. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30043. /**
  30044. * Interpolates a Vector2 cubically
  30045. * @param startValue Start value of the animation curve
  30046. * @param outTangent End tangent of the animation
  30047. * @param endValue End value of the animation curve
  30048. * @param inTangent Start tangent of the animation curve
  30049. * @param gradient Scalar amount to interpolate
  30050. * @returns Interpolated Vector2 value
  30051. */
  30052. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30053. /**
  30054. * Interpolates a size linearly
  30055. * @param startValue Start value of the animation curve
  30056. * @param endValue End value of the animation curve
  30057. * @param gradient Scalar amount to interpolate
  30058. * @returns Interpolated Size value
  30059. */
  30060. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30061. /**
  30062. * Interpolates a Color3 linearly
  30063. * @param startValue Start value of the animation curve
  30064. * @param endValue End value of the animation curve
  30065. * @param gradient Scalar amount to interpolate
  30066. * @returns Interpolated Color3 value
  30067. */
  30068. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30069. /**
  30070. * Interpolates a Color4 linearly
  30071. * @param startValue Start value of the animation curve
  30072. * @param endValue End value of the animation curve
  30073. * @param gradient Scalar amount to interpolate
  30074. * @returns Interpolated Color3 value
  30075. */
  30076. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30077. /**
  30078. * @hidden Internal use only
  30079. */
  30080. _getKeyValue(value: any): any;
  30081. /**
  30082. * @hidden Internal use only
  30083. */
  30084. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30085. /**
  30086. * Defines the function to use to interpolate matrices
  30087. * @param startValue defines the start matrix
  30088. * @param endValue defines the end matrix
  30089. * @param gradient defines the gradient between both matrices
  30090. * @param result defines an optional target matrix where to store the interpolation
  30091. * @returns the interpolated matrix
  30092. */
  30093. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30094. /**
  30095. * Makes a copy of the animation
  30096. * @returns Cloned animation
  30097. */
  30098. clone(): Animation;
  30099. /**
  30100. * Sets the key frames of the animation
  30101. * @param values The animation key frames to set
  30102. */
  30103. setKeys(values: Array<IAnimationKey>): void;
  30104. /**
  30105. * Serializes the animation to an object
  30106. * @returns Serialized object
  30107. */
  30108. serialize(): any;
  30109. /**
  30110. * Float animation type
  30111. */
  30112. static readonly ANIMATIONTYPE_FLOAT: number;
  30113. /**
  30114. * Vector3 animation type
  30115. */
  30116. static readonly ANIMATIONTYPE_VECTOR3: number;
  30117. /**
  30118. * Quaternion animation type
  30119. */
  30120. static readonly ANIMATIONTYPE_QUATERNION: number;
  30121. /**
  30122. * Matrix animation type
  30123. */
  30124. static readonly ANIMATIONTYPE_MATRIX: number;
  30125. /**
  30126. * Color3 animation type
  30127. */
  30128. static readonly ANIMATIONTYPE_COLOR3: number;
  30129. /**
  30130. * Color3 animation type
  30131. */
  30132. static readonly ANIMATIONTYPE_COLOR4: number;
  30133. /**
  30134. * Vector2 animation type
  30135. */
  30136. static readonly ANIMATIONTYPE_VECTOR2: number;
  30137. /**
  30138. * Size animation type
  30139. */
  30140. static readonly ANIMATIONTYPE_SIZE: number;
  30141. /**
  30142. * Relative Loop Mode
  30143. */
  30144. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30145. /**
  30146. * Cycle Loop Mode
  30147. */
  30148. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30149. /**
  30150. * Constant Loop Mode
  30151. */
  30152. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30153. /** @hidden */
  30154. static _UniversalLerp(left: any, right: any, amount: number): any;
  30155. /**
  30156. * Parses an animation object and creates an animation
  30157. * @param parsedAnimation Parsed animation object
  30158. * @returns Animation object
  30159. */
  30160. static Parse(parsedAnimation: any): Animation;
  30161. /**
  30162. * Appends the serialized animations from the source animations
  30163. * @param source Source containing the animations
  30164. * @param destination Target to store the animations
  30165. */
  30166. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30167. }
  30168. }
  30169. declare module BABYLON {
  30170. /**
  30171. * Interface containing an array of animations
  30172. */
  30173. export interface IAnimatable {
  30174. /**
  30175. * Array of animations
  30176. */
  30177. animations: Nullable<Array<Animation>>;
  30178. }
  30179. }
  30180. declare module BABYLON {
  30181. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30182. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30183. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30184. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30185. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30186. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30187. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30188. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30189. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30190. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30191. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30192. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30193. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30194. /**
  30195. * Decorator used to define property that can be serialized as reference to a camera
  30196. * @param sourceName defines the name of the property to decorate
  30197. */
  30198. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30199. /**
  30200. * Class used to help serialization objects
  30201. */
  30202. export class SerializationHelper {
  30203. /** @hidden */
  30204. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  30205. /** @hidden */
  30206. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  30207. /** @hidden */
  30208. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  30209. /** @hidden */
  30210. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  30211. /**
  30212. * Appends the serialized animations from the source animations
  30213. * @param source Source containing the animations
  30214. * @param destination Target to store the animations
  30215. */
  30216. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30217. /**
  30218. * Static function used to serialized a specific entity
  30219. * @param entity defines the entity to serialize
  30220. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30221. * @returns a JSON compatible object representing the serialization of the entity
  30222. */
  30223. static Serialize<T>(entity: T, serializationObject?: any): any;
  30224. /**
  30225. * Creates a new entity from a serialization data object
  30226. * @param creationFunction defines a function used to instanciated the new entity
  30227. * @param source defines the source serialization data
  30228. * @param scene defines the hosting scene
  30229. * @param rootUrl defines the root url for resources
  30230. * @returns a new entity
  30231. */
  30232. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30233. /**
  30234. * Clones an object
  30235. * @param creationFunction defines the function used to instanciate the new object
  30236. * @param source defines the source object
  30237. * @returns the cloned object
  30238. */
  30239. static Clone<T>(creationFunction: () => T, source: T): T;
  30240. /**
  30241. * Instanciates a new object based on a source one (some data will be shared between both object)
  30242. * @param creationFunction defines the function used to instanciate the new object
  30243. * @param source defines the source object
  30244. * @returns the new object
  30245. */
  30246. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30247. }
  30248. }
  30249. declare module BABYLON {
  30250. /**
  30251. * Base class of all the textures in babylon.
  30252. * It groups all the common properties the materials, post process, lights... might need
  30253. * in order to make a correct use of the texture.
  30254. */
  30255. export class BaseTexture implements IAnimatable {
  30256. /**
  30257. * Default anisotropic filtering level for the application.
  30258. * It is set to 4 as a good tradeoff between perf and quality.
  30259. */
  30260. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30261. /**
  30262. * Gets or sets the unique id of the texture
  30263. */
  30264. uniqueId: number;
  30265. /**
  30266. * Define the name of the texture.
  30267. */
  30268. name: string;
  30269. /**
  30270. * Gets or sets an object used to store user defined information.
  30271. */
  30272. metadata: any;
  30273. /**
  30274. * For internal use only. Please do not use.
  30275. */
  30276. reservedDataStore: any;
  30277. private _hasAlpha;
  30278. /**
  30279. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30280. */
  30281. set hasAlpha(value: boolean);
  30282. get hasAlpha(): boolean;
  30283. /**
  30284. * Defines if the alpha value should be determined via the rgb values.
  30285. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30286. */
  30287. getAlphaFromRGB: boolean;
  30288. /**
  30289. * Intensity or strength of the texture.
  30290. * It is commonly used by materials to fine tune the intensity of the texture
  30291. */
  30292. level: number;
  30293. /**
  30294. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30295. * This is part of the texture as textures usually maps to one uv set.
  30296. */
  30297. coordinatesIndex: number;
  30298. private _coordinatesMode;
  30299. /**
  30300. * How a texture is mapped.
  30301. *
  30302. * | Value | Type | Description |
  30303. * | ----- | ----------------------------------- | ----------- |
  30304. * | 0 | EXPLICIT_MODE | |
  30305. * | 1 | SPHERICAL_MODE | |
  30306. * | 2 | PLANAR_MODE | |
  30307. * | 3 | CUBIC_MODE | |
  30308. * | 4 | PROJECTION_MODE | |
  30309. * | 5 | SKYBOX_MODE | |
  30310. * | 6 | INVCUBIC_MODE | |
  30311. * | 7 | EQUIRECTANGULAR_MODE | |
  30312. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30313. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30314. */
  30315. set coordinatesMode(value: number);
  30316. get coordinatesMode(): number;
  30317. /**
  30318. * | Value | Type | Description |
  30319. * | ----- | ------------------ | ----------- |
  30320. * | 0 | CLAMP_ADDRESSMODE | |
  30321. * | 1 | WRAP_ADDRESSMODE | |
  30322. * | 2 | MIRROR_ADDRESSMODE | |
  30323. */
  30324. wrapU: number;
  30325. /**
  30326. * | Value | Type | Description |
  30327. * | ----- | ------------------ | ----------- |
  30328. * | 0 | CLAMP_ADDRESSMODE | |
  30329. * | 1 | WRAP_ADDRESSMODE | |
  30330. * | 2 | MIRROR_ADDRESSMODE | |
  30331. */
  30332. wrapV: number;
  30333. /**
  30334. * | Value | Type | Description |
  30335. * | ----- | ------------------ | ----------- |
  30336. * | 0 | CLAMP_ADDRESSMODE | |
  30337. * | 1 | WRAP_ADDRESSMODE | |
  30338. * | 2 | MIRROR_ADDRESSMODE | |
  30339. */
  30340. wrapR: number;
  30341. /**
  30342. * With compliant hardware and browser (supporting anisotropic filtering)
  30343. * this defines the level of anisotropic filtering in the texture.
  30344. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30345. */
  30346. anisotropicFilteringLevel: number;
  30347. /**
  30348. * Define if the texture is a cube texture or if false a 2d texture.
  30349. */
  30350. get isCube(): boolean;
  30351. set isCube(value: boolean);
  30352. /**
  30353. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30354. */
  30355. get is3D(): boolean;
  30356. set is3D(value: boolean);
  30357. /**
  30358. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30359. */
  30360. get is2DArray(): boolean;
  30361. set is2DArray(value: boolean);
  30362. /**
  30363. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30364. * HDR texture are usually stored in linear space.
  30365. * This only impacts the PBR and Background materials
  30366. */
  30367. gammaSpace: boolean;
  30368. /**
  30369. * Gets or sets whether or not the texture contains RGBD data.
  30370. */
  30371. get isRGBD(): boolean;
  30372. set isRGBD(value: boolean);
  30373. /**
  30374. * Is Z inverted in the texture (useful in a cube texture).
  30375. */
  30376. invertZ: boolean;
  30377. /**
  30378. * Are mip maps generated for this texture or not.
  30379. */
  30380. get noMipmap(): boolean;
  30381. /**
  30382. * @hidden
  30383. */
  30384. lodLevelInAlpha: boolean;
  30385. /**
  30386. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30387. */
  30388. get lodGenerationOffset(): number;
  30389. set lodGenerationOffset(value: number);
  30390. /**
  30391. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30392. */
  30393. get lodGenerationScale(): number;
  30394. set lodGenerationScale(value: number);
  30395. /**
  30396. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30397. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30398. * average roughness values.
  30399. */
  30400. get linearSpecularLOD(): boolean;
  30401. set linearSpecularLOD(value: boolean);
  30402. /**
  30403. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30404. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30405. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30406. */
  30407. get irradianceTexture(): Nullable<BaseTexture>;
  30408. set irradianceTexture(value: Nullable<BaseTexture>);
  30409. /**
  30410. * Define if the texture is a render target.
  30411. */
  30412. isRenderTarget: boolean;
  30413. /**
  30414. * Define the unique id of the texture in the scene.
  30415. */
  30416. get uid(): string;
  30417. /**
  30418. * Return a string representation of the texture.
  30419. * @returns the texture as a string
  30420. */
  30421. toString(): string;
  30422. /**
  30423. * Get the class name of the texture.
  30424. * @returns "BaseTexture"
  30425. */
  30426. getClassName(): string;
  30427. /**
  30428. * Define the list of animation attached to the texture.
  30429. */
  30430. animations: Animation[];
  30431. /**
  30432. * An event triggered when the texture is disposed.
  30433. */
  30434. onDisposeObservable: Observable<BaseTexture>;
  30435. private _onDisposeObserver;
  30436. /**
  30437. * Callback triggered when the texture has been disposed.
  30438. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30439. */
  30440. set onDispose(callback: () => void);
  30441. /**
  30442. * Define the current state of the loading sequence when in delayed load mode.
  30443. */
  30444. delayLoadState: number;
  30445. private _scene;
  30446. private _engine;
  30447. /** @hidden */
  30448. _texture: Nullable<InternalTexture>;
  30449. private _uid;
  30450. /**
  30451. * Define if the texture is preventinga material to render or not.
  30452. * If not and the texture is not ready, the engine will use a default black texture instead.
  30453. */
  30454. get isBlocking(): boolean;
  30455. /**
  30456. * Instantiates a new BaseTexture.
  30457. * Base class of all the textures in babylon.
  30458. * It groups all the common properties the materials, post process, lights... might need
  30459. * in order to make a correct use of the texture.
  30460. * @param sceneOrEngine Define the scene or engine the texture blongs to
  30461. */
  30462. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  30463. /**
  30464. * Get the scene the texture belongs to.
  30465. * @returns the scene or null if undefined
  30466. */
  30467. getScene(): Nullable<Scene>;
  30468. /** @hidden */
  30469. protected _getEngine(): Nullable<ThinEngine>;
  30470. /**
  30471. * Get the texture transform matrix used to offset tile the texture for istance.
  30472. * @returns the transformation matrix
  30473. */
  30474. getTextureMatrix(): Matrix;
  30475. /**
  30476. * Get the texture reflection matrix used to rotate/transform the reflection.
  30477. * @returns the reflection matrix
  30478. */
  30479. getReflectionTextureMatrix(): Matrix;
  30480. /**
  30481. * Get the underlying lower level texture from Babylon.
  30482. * @returns the insternal texture
  30483. */
  30484. getInternalTexture(): Nullable<InternalTexture>;
  30485. /**
  30486. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30487. * @returns true if ready or not blocking
  30488. */
  30489. isReadyOrNotBlocking(): boolean;
  30490. /**
  30491. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30492. * @returns true if fully ready
  30493. */
  30494. isReady(): boolean;
  30495. private _cachedSize;
  30496. /**
  30497. * Get the size of the texture.
  30498. * @returns the texture size.
  30499. */
  30500. getSize(): ISize;
  30501. /**
  30502. * Get the base size of the texture.
  30503. * It can be different from the size if the texture has been resized for POT for instance
  30504. * @returns the base size
  30505. */
  30506. getBaseSize(): ISize;
  30507. /**
  30508. * Update the sampling mode of the texture.
  30509. * Default is Trilinear mode.
  30510. *
  30511. * | Value | Type | Description |
  30512. * | ----- | ------------------ | ----------- |
  30513. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30514. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30515. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30516. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30517. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30518. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30519. * | 7 | NEAREST_LINEAR | |
  30520. * | 8 | NEAREST_NEAREST | |
  30521. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30522. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30523. * | 11 | LINEAR_LINEAR | |
  30524. * | 12 | LINEAR_NEAREST | |
  30525. *
  30526. * > _mag_: magnification filter (close to the viewer)
  30527. * > _min_: minification filter (far from the viewer)
  30528. * > _mip_: filter used between mip map levels
  30529. *@param samplingMode Define the new sampling mode of the texture
  30530. */
  30531. updateSamplingMode(samplingMode: number): void;
  30532. /**
  30533. * Scales the texture if is `canRescale()`
  30534. * @param ratio the resize factor we want to use to rescale
  30535. */
  30536. scale(ratio: number): void;
  30537. /**
  30538. * Get if the texture can rescale.
  30539. */
  30540. get canRescale(): boolean;
  30541. /** @hidden */
  30542. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30543. /** @hidden */
  30544. _rebuild(): void;
  30545. /**
  30546. * Triggers the load sequence in delayed load mode.
  30547. */
  30548. delayLoad(): void;
  30549. /**
  30550. * Clones the texture.
  30551. * @returns the cloned texture
  30552. */
  30553. clone(): Nullable<BaseTexture>;
  30554. /**
  30555. * Get the texture underlying type (INT, FLOAT...)
  30556. */
  30557. get textureType(): number;
  30558. /**
  30559. * Get the texture underlying format (RGB, RGBA...)
  30560. */
  30561. get textureFormat(): number;
  30562. /**
  30563. * Indicates that textures need to be re-calculated for all materials
  30564. */
  30565. protected _markAllSubMeshesAsTexturesDirty(): void;
  30566. /**
  30567. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30568. * This will returns an RGBA array buffer containing either in values (0-255) or
  30569. * float values (0-1) depending of the underlying buffer type.
  30570. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30571. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30572. * @param buffer defines a user defined buffer to fill with data (can be null)
  30573. * @returns The Array buffer containing the pixels data.
  30574. */
  30575. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30576. /**
  30577. * Release and destroy the underlying lower level texture aka internalTexture.
  30578. */
  30579. releaseInternalTexture(): void;
  30580. /** @hidden */
  30581. get _lodTextureHigh(): Nullable<BaseTexture>;
  30582. /** @hidden */
  30583. get _lodTextureMid(): Nullable<BaseTexture>;
  30584. /** @hidden */
  30585. get _lodTextureLow(): Nullable<BaseTexture>;
  30586. /**
  30587. * Dispose the texture and release its associated resources.
  30588. */
  30589. dispose(): void;
  30590. /**
  30591. * Serialize the texture into a JSON representation that can be parsed later on.
  30592. * @returns the JSON representation of the texture
  30593. */
  30594. serialize(): any;
  30595. /**
  30596. * Helper function to be called back once a list of texture contains only ready textures.
  30597. * @param textures Define the list of textures to wait for
  30598. * @param callback Define the callback triggered once the entire list will be ready
  30599. */
  30600. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30601. private static _isScene;
  30602. }
  30603. }
  30604. declare module BABYLON {
  30605. /**
  30606. * Options to be used when creating an effect.
  30607. */
  30608. export interface IEffectCreationOptions {
  30609. /**
  30610. * Atrributes that will be used in the shader.
  30611. */
  30612. attributes: string[];
  30613. /**
  30614. * Uniform varible names that will be set in the shader.
  30615. */
  30616. uniformsNames: string[];
  30617. /**
  30618. * Uniform buffer variable names that will be set in the shader.
  30619. */
  30620. uniformBuffersNames: string[];
  30621. /**
  30622. * Sampler texture variable names that will be set in the shader.
  30623. */
  30624. samplers: string[];
  30625. /**
  30626. * Define statements that will be set in the shader.
  30627. */
  30628. defines: any;
  30629. /**
  30630. * Possible fallbacks for this effect to improve performance when needed.
  30631. */
  30632. fallbacks: Nullable<IEffectFallbacks>;
  30633. /**
  30634. * Callback that will be called when the shader is compiled.
  30635. */
  30636. onCompiled: Nullable<(effect: Effect) => void>;
  30637. /**
  30638. * Callback that will be called if an error occurs during shader compilation.
  30639. */
  30640. onError: Nullable<(effect: Effect, errors: string) => void>;
  30641. /**
  30642. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30643. */
  30644. indexParameters?: any;
  30645. /**
  30646. * Max number of lights that can be used in the shader.
  30647. */
  30648. maxSimultaneousLights?: number;
  30649. /**
  30650. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30651. */
  30652. transformFeedbackVaryings?: Nullable<string[]>;
  30653. }
  30654. /**
  30655. * Effect containing vertex and fragment shader that can be executed on an object.
  30656. */
  30657. export class Effect implements IDisposable {
  30658. /**
  30659. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30660. */
  30661. static ShadersRepository: string;
  30662. /**
  30663. * Enable logging of the shader code when a compilation error occurs
  30664. */
  30665. static LogShaderCodeOnCompilationError: boolean;
  30666. /**
  30667. * Name of the effect.
  30668. */
  30669. name: any;
  30670. /**
  30671. * String container all the define statements that should be set on the shader.
  30672. */
  30673. defines: string;
  30674. /**
  30675. * Callback that will be called when the shader is compiled.
  30676. */
  30677. onCompiled: Nullable<(effect: Effect) => void>;
  30678. /**
  30679. * Callback that will be called if an error occurs during shader compilation.
  30680. */
  30681. onError: Nullable<(effect: Effect, errors: string) => void>;
  30682. /**
  30683. * Callback that will be called when effect is bound.
  30684. */
  30685. onBind: Nullable<(effect: Effect) => void>;
  30686. /**
  30687. * Unique ID of the effect.
  30688. */
  30689. uniqueId: number;
  30690. /**
  30691. * Observable that will be called when the shader is compiled.
  30692. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30693. */
  30694. onCompileObservable: Observable<Effect>;
  30695. /**
  30696. * Observable that will be called if an error occurs during shader compilation.
  30697. */
  30698. onErrorObservable: Observable<Effect>;
  30699. /** @hidden */
  30700. _onBindObservable: Nullable<Observable<Effect>>;
  30701. /**
  30702. * @hidden
  30703. * Specifies if the effect was previously ready
  30704. */
  30705. _wasPreviouslyReady: boolean;
  30706. /**
  30707. * Observable that will be called when effect is bound.
  30708. */
  30709. get onBindObservable(): Observable<Effect>;
  30710. /** @hidden */
  30711. _bonesComputationForcedToCPU: boolean;
  30712. private static _uniqueIdSeed;
  30713. private _engine;
  30714. private _uniformBuffersNames;
  30715. private _uniformBuffersNamesList;
  30716. private _uniformsNames;
  30717. private _samplerList;
  30718. private _samplers;
  30719. private _isReady;
  30720. private _compilationError;
  30721. private _allFallbacksProcessed;
  30722. private _attributesNames;
  30723. private _attributes;
  30724. private _attributeLocationByName;
  30725. private _uniforms;
  30726. /**
  30727. * Key for the effect.
  30728. * @hidden
  30729. */
  30730. _key: string;
  30731. private _indexParameters;
  30732. private _fallbacks;
  30733. private _vertexSourceCode;
  30734. private _fragmentSourceCode;
  30735. private _vertexSourceCodeOverride;
  30736. private _fragmentSourceCodeOverride;
  30737. private _transformFeedbackVaryings;
  30738. /**
  30739. * Compiled shader to webGL program.
  30740. * @hidden
  30741. */
  30742. _pipelineContext: Nullable<IPipelineContext>;
  30743. private _valueCache;
  30744. private static _baseCache;
  30745. /**
  30746. * Instantiates an effect.
  30747. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30748. * @param baseName Name of the effect.
  30749. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30750. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30751. * @param samplers List of sampler variables that will be passed to the shader.
  30752. * @param engine Engine to be used to render the effect
  30753. * @param defines Define statements to be added to the shader.
  30754. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30755. * @param onCompiled Callback that will be called when the shader is compiled.
  30756. * @param onError Callback that will be called if an error occurs during shader compilation.
  30757. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30758. */
  30759. 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);
  30760. private _useFinalCode;
  30761. /**
  30762. * Unique key for this effect
  30763. */
  30764. get key(): string;
  30765. /**
  30766. * If the effect has been compiled and prepared.
  30767. * @returns if the effect is compiled and prepared.
  30768. */
  30769. isReady(): boolean;
  30770. private _isReadyInternal;
  30771. /**
  30772. * The engine the effect was initialized with.
  30773. * @returns the engine.
  30774. */
  30775. getEngine(): Engine;
  30776. /**
  30777. * The pipeline context for this effect
  30778. * @returns the associated pipeline context
  30779. */
  30780. getPipelineContext(): Nullable<IPipelineContext>;
  30781. /**
  30782. * The set of names of attribute variables for the shader.
  30783. * @returns An array of attribute names.
  30784. */
  30785. getAttributesNames(): string[];
  30786. /**
  30787. * Returns the attribute at the given index.
  30788. * @param index The index of the attribute.
  30789. * @returns The location of the attribute.
  30790. */
  30791. getAttributeLocation(index: number): number;
  30792. /**
  30793. * Returns the attribute based on the name of the variable.
  30794. * @param name of the attribute to look up.
  30795. * @returns the attribute location.
  30796. */
  30797. getAttributeLocationByName(name: string): number;
  30798. /**
  30799. * The number of attributes.
  30800. * @returns the numnber of attributes.
  30801. */
  30802. getAttributesCount(): number;
  30803. /**
  30804. * Gets the index of a uniform variable.
  30805. * @param uniformName of the uniform to look up.
  30806. * @returns the index.
  30807. */
  30808. getUniformIndex(uniformName: string): number;
  30809. /**
  30810. * Returns the attribute based on the name of the variable.
  30811. * @param uniformName of the uniform to look up.
  30812. * @returns the location of the uniform.
  30813. */
  30814. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30815. /**
  30816. * Returns an array of sampler variable names
  30817. * @returns The array of sampler variable names.
  30818. */
  30819. getSamplers(): string[];
  30820. /**
  30821. * Returns an array of uniform variable names
  30822. * @returns The array of uniform variable names.
  30823. */
  30824. getUniformNames(): string[];
  30825. /**
  30826. * Returns an array of uniform buffer variable names
  30827. * @returns The array of uniform buffer variable names.
  30828. */
  30829. getUniformBuffersNames(): string[];
  30830. /**
  30831. * Returns the index parameters used to create the effect
  30832. * @returns The index parameters object
  30833. */
  30834. getIndexParameters(): any;
  30835. /**
  30836. * The error from the last compilation.
  30837. * @returns the error string.
  30838. */
  30839. getCompilationError(): string;
  30840. /**
  30841. * Gets a boolean indicating that all fallbacks were used during compilation
  30842. * @returns true if all fallbacks were used
  30843. */
  30844. allFallbacksProcessed(): boolean;
  30845. /**
  30846. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30847. * @param func The callback to be used.
  30848. */
  30849. executeWhenCompiled(func: (effect: Effect) => void): void;
  30850. private _checkIsReady;
  30851. private _loadShader;
  30852. /**
  30853. * Gets the vertex shader source code of this effect
  30854. */
  30855. get vertexSourceCode(): string;
  30856. /**
  30857. * Gets the fragment shader source code of this effect
  30858. */
  30859. get fragmentSourceCode(): string;
  30860. /**
  30861. * Recompiles the webGL program
  30862. * @param vertexSourceCode The source code for the vertex shader.
  30863. * @param fragmentSourceCode The source code for the fragment shader.
  30864. * @param onCompiled Callback called when completed.
  30865. * @param onError Callback called on error.
  30866. * @hidden
  30867. */
  30868. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30869. /**
  30870. * Prepares the effect
  30871. * @hidden
  30872. */
  30873. _prepareEffect(): void;
  30874. private _getShaderCodeAndErrorLine;
  30875. private _processCompilationErrors;
  30876. /**
  30877. * Checks if the effect is supported. (Must be called after compilation)
  30878. */
  30879. get isSupported(): boolean;
  30880. /**
  30881. * Binds a texture to the engine to be used as output of the shader.
  30882. * @param channel Name of the output variable.
  30883. * @param texture Texture to bind.
  30884. * @hidden
  30885. */
  30886. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30887. /**
  30888. * Sets a texture on the engine to be used in the shader.
  30889. * @param channel Name of the sampler variable.
  30890. * @param texture Texture to set.
  30891. */
  30892. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30893. /**
  30894. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30895. * @param channel Name of the sampler variable.
  30896. * @param texture Texture to set.
  30897. */
  30898. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30899. /**
  30900. * Sets an array of textures on the engine to be used in the shader.
  30901. * @param channel Name of the variable.
  30902. * @param textures Textures to set.
  30903. */
  30904. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30905. /**
  30906. * 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)
  30907. * @param channel Name of the sampler variable.
  30908. * @param postProcess Post process to get the input texture from.
  30909. */
  30910. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30911. /**
  30912. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30913. * 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)
  30914. * @param channel Name of the sampler variable.
  30915. * @param postProcess Post process to get the output texture from.
  30916. */
  30917. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30918. /** @hidden */
  30919. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30920. /** @hidden */
  30921. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30922. /** @hidden */
  30923. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30924. /** @hidden */
  30925. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30926. /**
  30927. * Binds a buffer to a uniform.
  30928. * @param buffer Buffer to bind.
  30929. * @param name Name of the uniform variable to bind to.
  30930. */
  30931. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30932. /**
  30933. * Binds block to a uniform.
  30934. * @param blockName Name of the block to bind.
  30935. * @param index Index to bind.
  30936. */
  30937. bindUniformBlock(blockName: string, index: number): void;
  30938. /**
  30939. * Sets an interger value on a uniform variable.
  30940. * @param uniformName Name of the variable.
  30941. * @param value Value to be set.
  30942. * @returns this effect.
  30943. */
  30944. setInt(uniformName: string, value: number): Effect;
  30945. /**
  30946. * Sets an int array on a uniform variable.
  30947. * @param uniformName Name of the variable.
  30948. * @param array array to be set.
  30949. * @returns this effect.
  30950. */
  30951. setIntArray(uniformName: string, array: Int32Array): Effect;
  30952. /**
  30953. * 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)
  30954. * @param uniformName Name of the variable.
  30955. * @param array array to be set.
  30956. * @returns this effect.
  30957. */
  30958. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30959. /**
  30960. * 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)
  30961. * @param uniformName Name of the variable.
  30962. * @param array array to be set.
  30963. * @returns this effect.
  30964. */
  30965. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30966. /**
  30967. * 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)
  30968. * @param uniformName Name of the variable.
  30969. * @param array array to be set.
  30970. * @returns this effect.
  30971. */
  30972. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30973. /**
  30974. * Sets an float array on a uniform variable.
  30975. * @param uniformName Name of the variable.
  30976. * @param array array to be set.
  30977. * @returns this effect.
  30978. */
  30979. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30980. /**
  30981. * 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)
  30982. * @param uniformName Name of the variable.
  30983. * @param array array to be set.
  30984. * @returns this effect.
  30985. */
  30986. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30987. /**
  30988. * 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)
  30989. * @param uniformName Name of the variable.
  30990. * @param array array to be set.
  30991. * @returns this effect.
  30992. */
  30993. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30994. /**
  30995. * 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)
  30996. * @param uniformName Name of the variable.
  30997. * @param array array to be set.
  30998. * @returns this effect.
  30999. */
  31000. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31001. /**
  31002. * Sets an array on a uniform variable.
  31003. * @param uniformName Name of the variable.
  31004. * @param array array to be set.
  31005. * @returns this effect.
  31006. */
  31007. setArray(uniformName: string, array: number[]): Effect;
  31008. /**
  31009. * 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)
  31010. * @param uniformName Name of the variable.
  31011. * @param array array to be set.
  31012. * @returns this effect.
  31013. */
  31014. setArray2(uniformName: string, array: number[]): Effect;
  31015. /**
  31016. * 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)
  31017. * @param uniformName Name of the variable.
  31018. * @param array array to be set.
  31019. * @returns this effect.
  31020. */
  31021. setArray3(uniformName: string, array: number[]): Effect;
  31022. /**
  31023. * 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)
  31024. * @param uniformName Name of the variable.
  31025. * @param array array to be set.
  31026. * @returns this effect.
  31027. */
  31028. setArray4(uniformName: string, array: number[]): Effect;
  31029. /**
  31030. * Sets matrices on a uniform variable.
  31031. * @param uniformName Name of the variable.
  31032. * @param matrices matrices to be set.
  31033. * @returns this effect.
  31034. */
  31035. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31036. /**
  31037. * Sets matrix on a uniform variable.
  31038. * @param uniformName Name of the variable.
  31039. * @param matrix matrix to be set.
  31040. * @returns this effect.
  31041. */
  31042. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31043. /**
  31044. * 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)
  31045. * @param uniformName Name of the variable.
  31046. * @param matrix matrix to be set.
  31047. * @returns this effect.
  31048. */
  31049. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31050. /**
  31051. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31052. * @param uniformName Name of the variable.
  31053. * @param matrix matrix to be set.
  31054. * @returns this effect.
  31055. */
  31056. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31057. /**
  31058. * Sets a float on a uniform variable.
  31059. * @param uniformName Name of the variable.
  31060. * @param value value to be set.
  31061. * @returns this effect.
  31062. */
  31063. setFloat(uniformName: string, value: number): Effect;
  31064. /**
  31065. * Sets a boolean on a uniform variable.
  31066. * @param uniformName Name of the variable.
  31067. * @param bool value to be set.
  31068. * @returns this effect.
  31069. */
  31070. setBool(uniformName: string, bool: boolean): Effect;
  31071. /**
  31072. * Sets a Vector2 on a uniform variable.
  31073. * @param uniformName Name of the variable.
  31074. * @param vector2 vector2 to be set.
  31075. * @returns this effect.
  31076. */
  31077. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31078. /**
  31079. * Sets a float2 on a uniform variable.
  31080. * @param uniformName Name of the variable.
  31081. * @param x First float in float2.
  31082. * @param y Second float in float2.
  31083. * @returns this effect.
  31084. */
  31085. setFloat2(uniformName: string, x: number, y: number): Effect;
  31086. /**
  31087. * Sets a Vector3 on a uniform variable.
  31088. * @param uniformName Name of the variable.
  31089. * @param vector3 Value to be set.
  31090. * @returns this effect.
  31091. */
  31092. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31093. /**
  31094. * Sets a float3 on a uniform variable.
  31095. * @param uniformName Name of the variable.
  31096. * @param x First float in float3.
  31097. * @param y Second float in float3.
  31098. * @param z Third float in float3.
  31099. * @returns this effect.
  31100. */
  31101. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31102. /**
  31103. * Sets a Vector4 on a uniform variable.
  31104. * @param uniformName Name of the variable.
  31105. * @param vector4 Value to be set.
  31106. * @returns this effect.
  31107. */
  31108. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31109. /**
  31110. * Sets a float4 on a uniform variable.
  31111. * @param uniformName Name of the variable.
  31112. * @param x First float in float4.
  31113. * @param y Second float in float4.
  31114. * @param z Third float in float4.
  31115. * @param w Fourth float in float4.
  31116. * @returns this effect.
  31117. */
  31118. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31119. /**
  31120. * Sets a Color3 on a uniform variable.
  31121. * @param uniformName Name of the variable.
  31122. * @param color3 Value to be set.
  31123. * @returns this effect.
  31124. */
  31125. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31126. /**
  31127. * Sets a Color4 on a uniform variable.
  31128. * @param uniformName Name of the variable.
  31129. * @param color3 Value to be set.
  31130. * @param alpha Alpha value to be set.
  31131. * @returns this effect.
  31132. */
  31133. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31134. /**
  31135. * Sets a Color4 on a uniform variable
  31136. * @param uniformName defines the name of the variable
  31137. * @param color4 defines the value to be set
  31138. * @returns this effect.
  31139. */
  31140. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31141. /** Release all associated resources */
  31142. dispose(): void;
  31143. /**
  31144. * This function will add a new shader to the shader store
  31145. * @param name the name of the shader
  31146. * @param pixelShader optional pixel shader content
  31147. * @param vertexShader optional vertex shader content
  31148. */
  31149. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31150. /**
  31151. * Store of each shader (The can be looked up using effect.key)
  31152. */
  31153. static ShadersStore: {
  31154. [key: string]: string;
  31155. };
  31156. /**
  31157. * Store of each included file for a shader (The can be looked up using effect.key)
  31158. */
  31159. static IncludesShadersStore: {
  31160. [key: string]: string;
  31161. };
  31162. /**
  31163. * Resets the cache of effects.
  31164. */
  31165. static ResetCache(): void;
  31166. }
  31167. }
  31168. declare module BABYLON {
  31169. /**
  31170. * Interface used to describe the capabilities of the engine relatively to the current browser
  31171. */
  31172. export interface EngineCapabilities {
  31173. /** Maximum textures units per fragment shader */
  31174. maxTexturesImageUnits: number;
  31175. /** Maximum texture units per vertex shader */
  31176. maxVertexTextureImageUnits: number;
  31177. /** Maximum textures units in the entire pipeline */
  31178. maxCombinedTexturesImageUnits: number;
  31179. /** Maximum texture size */
  31180. maxTextureSize: number;
  31181. /** Maximum texture samples */
  31182. maxSamples?: number;
  31183. /** Maximum cube texture size */
  31184. maxCubemapTextureSize: number;
  31185. /** Maximum render texture size */
  31186. maxRenderTextureSize: number;
  31187. /** Maximum number of vertex attributes */
  31188. maxVertexAttribs: number;
  31189. /** Maximum number of varyings */
  31190. maxVaryingVectors: number;
  31191. /** Maximum number of uniforms per vertex shader */
  31192. maxVertexUniformVectors: number;
  31193. /** Maximum number of uniforms per fragment shader */
  31194. maxFragmentUniformVectors: number;
  31195. /** Defines if standard derivates (dx/dy) are supported */
  31196. standardDerivatives: boolean;
  31197. /** Defines if s3tc texture compression is supported */
  31198. s3tc?: WEBGL_compressed_texture_s3tc;
  31199. /** Defines if pvrtc texture compression is supported */
  31200. pvrtc: any;
  31201. /** Defines if etc1 texture compression is supported */
  31202. etc1: any;
  31203. /** Defines if etc2 texture compression is supported */
  31204. etc2: any;
  31205. /** Defines if astc texture compression is supported */
  31206. astc: any;
  31207. /** Defines if float textures are supported */
  31208. textureFloat: boolean;
  31209. /** Defines if vertex array objects are supported */
  31210. vertexArrayObject: boolean;
  31211. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31212. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31213. /** Gets the maximum level of anisotropy supported */
  31214. maxAnisotropy: number;
  31215. /** Defines if instancing is supported */
  31216. instancedArrays: boolean;
  31217. /** Defines if 32 bits indices are supported */
  31218. uintIndices: boolean;
  31219. /** Defines if high precision shaders are supported */
  31220. highPrecisionShaderSupported: boolean;
  31221. /** Defines if depth reading in the fragment shader is supported */
  31222. fragmentDepthSupported: boolean;
  31223. /** Defines if float texture linear filtering is supported*/
  31224. textureFloatLinearFiltering: boolean;
  31225. /** Defines if rendering to float textures is supported */
  31226. textureFloatRender: boolean;
  31227. /** Defines if half float textures are supported*/
  31228. textureHalfFloat: boolean;
  31229. /** Defines if half float texture linear filtering is supported*/
  31230. textureHalfFloatLinearFiltering: boolean;
  31231. /** Defines if rendering to half float textures is supported */
  31232. textureHalfFloatRender: boolean;
  31233. /** Defines if textureLOD shader command is supported */
  31234. textureLOD: boolean;
  31235. /** Defines if draw buffers extension is supported */
  31236. drawBuffersExtension: boolean;
  31237. /** Defines if depth textures are supported */
  31238. depthTextureExtension: boolean;
  31239. /** Defines if float color buffer are supported */
  31240. colorBufferFloat: boolean;
  31241. /** Gets disjoint timer query extension (null if not supported) */
  31242. timerQuery?: EXT_disjoint_timer_query;
  31243. /** Defines if timestamp can be used with timer query */
  31244. canUseTimestampForTimerQuery: boolean;
  31245. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31246. multiview?: any;
  31247. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31248. oculusMultiview?: any;
  31249. /** Function used to let the system compiles shaders in background */
  31250. parallelShaderCompile?: {
  31251. COMPLETION_STATUS_KHR: number;
  31252. };
  31253. /** Max number of texture samples for MSAA */
  31254. maxMSAASamples: number;
  31255. /** Defines if the blend min max extension is supported */
  31256. blendMinMax: boolean;
  31257. }
  31258. }
  31259. declare module BABYLON {
  31260. /**
  31261. * @hidden
  31262. **/
  31263. export class DepthCullingState {
  31264. private _isDepthTestDirty;
  31265. private _isDepthMaskDirty;
  31266. private _isDepthFuncDirty;
  31267. private _isCullFaceDirty;
  31268. private _isCullDirty;
  31269. private _isZOffsetDirty;
  31270. private _isFrontFaceDirty;
  31271. private _depthTest;
  31272. private _depthMask;
  31273. private _depthFunc;
  31274. private _cull;
  31275. private _cullFace;
  31276. private _zOffset;
  31277. private _frontFace;
  31278. /**
  31279. * Initializes the state.
  31280. */
  31281. constructor();
  31282. get isDirty(): boolean;
  31283. get zOffset(): number;
  31284. set zOffset(value: number);
  31285. get cullFace(): Nullable<number>;
  31286. set cullFace(value: Nullable<number>);
  31287. get cull(): Nullable<boolean>;
  31288. set cull(value: Nullable<boolean>);
  31289. get depthFunc(): Nullable<number>;
  31290. set depthFunc(value: Nullable<number>);
  31291. get depthMask(): boolean;
  31292. set depthMask(value: boolean);
  31293. get depthTest(): boolean;
  31294. set depthTest(value: boolean);
  31295. get frontFace(): Nullable<number>;
  31296. set frontFace(value: Nullable<number>);
  31297. reset(): void;
  31298. apply(gl: WebGLRenderingContext): void;
  31299. }
  31300. }
  31301. declare module BABYLON {
  31302. /**
  31303. * @hidden
  31304. **/
  31305. export class StencilState {
  31306. /** 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 */
  31307. static readonly ALWAYS: number;
  31308. /** Passed to stencilOperation to specify that stencil value must be kept */
  31309. static readonly KEEP: number;
  31310. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31311. static readonly REPLACE: number;
  31312. private _isStencilTestDirty;
  31313. private _isStencilMaskDirty;
  31314. private _isStencilFuncDirty;
  31315. private _isStencilOpDirty;
  31316. private _stencilTest;
  31317. private _stencilMask;
  31318. private _stencilFunc;
  31319. private _stencilFuncRef;
  31320. private _stencilFuncMask;
  31321. private _stencilOpStencilFail;
  31322. private _stencilOpDepthFail;
  31323. private _stencilOpStencilDepthPass;
  31324. get isDirty(): boolean;
  31325. get stencilFunc(): number;
  31326. set stencilFunc(value: number);
  31327. get stencilFuncRef(): number;
  31328. set stencilFuncRef(value: number);
  31329. get stencilFuncMask(): number;
  31330. set stencilFuncMask(value: number);
  31331. get stencilOpStencilFail(): number;
  31332. set stencilOpStencilFail(value: number);
  31333. get stencilOpDepthFail(): number;
  31334. set stencilOpDepthFail(value: number);
  31335. get stencilOpStencilDepthPass(): number;
  31336. set stencilOpStencilDepthPass(value: number);
  31337. get stencilMask(): number;
  31338. set stencilMask(value: number);
  31339. get stencilTest(): boolean;
  31340. set stencilTest(value: boolean);
  31341. constructor();
  31342. reset(): void;
  31343. apply(gl: WebGLRenderingContext): void;
  31344. }
  31345. }
  31346. declare module BABYLON {
  31347. /**
  31348. * @hidden
  31349. **/
  31350. export class AlphaState {
  31351. private _isAlphaBlendDirty;
  31352. private _isBlendFunctionParametersDirty;
  31353. private _isBlendEquationParametersDirty;
  31354. private _isBlendConstantsDirty;
  31355. private _alphaBlend;
  31356. private _blendFunctionParameters;
  31357. private _blendEquationParameters;
  31358. private _blendConstants;
  31359. /**
  31360. * Initializes the state.
  31361. */
  31362. constructor();
  31363. get isDirty(): boolean;
  31364. get alphaBlend(): boolean;
  31365. set alphaBlend(value: boolean);
  31366. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31367. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31368. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31369. reset(): void;
  31370. apply(gl: WebGLRenderingContext): void;
  31371. }
  31372. }
  31373. declare module BABYLON {
  31374. /** @hidden */
  31375. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31376. attributeProcessor(attribute: string): string;
  31377. varyingProcessor(varying: string, isFragment: boolean): string;
  31378. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31379. }
  31380. }
  31381. declare module BABYLON {
  31382. /**
  31383. * Interface for attribute information associated with buffer instanciation
  31384. */
  31385. export interface InstancingAttributeInfo {
  31386. /**
  31387. * Name of the GLSL attribute
  31388. * if attribute index is not specified, this is used to retrieve the index from the effect
  31389. */
  31390. attributeName: string;
  31391. /**
  31392. * Index/offset of the attribute in the vertex shader
  31393. * if not specified, this will be computes from the name.
  31394. */
  31395. index?: number;
  31396. /**
  31397. * size of the attribute, 1, 2, 3 or 4
  31398. */
  31399. attributeSize: number;
  31400. /**
  31401. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31402. */
  31403. offset: number;
  31404. /**
  31405. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31406. * default to 1
  31407. */
  31408. divisor?: number;
  31409. /**
  31410. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31411. * default is FLOAT
  31412. */
  31413. attributeType?: number;
  31414. /**
  31415. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31416. */
  31417. normalized?: boolean;
  31418. }
  31419. }
  31420. declare module BABYLON {
  31421. interface ThinEngine {
  31422. /**
  31423. * Update a video texture
  31424. * @param texture defines the texture to update
  31425. * @param video defines the video element to use
  31426. * @param invertY defines if data must be stored with Y axis inverted
  31427. */
  31428. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31429. }
  31430. }
  31431. declare module BABYLON {
  31432. /**
  31433. * Settings for finer control over video usage
  31434. */
  31435. export interface VideoTextureSettings {
  31436. /**
  31437. * Applies `autoplay` to video, if specified
  31438. */
  31439. autoPlay?: boolean;
  31440. /**
  31441. * Applies `loop` to video, if specified
  31442. */
  31443. loop?: boolean;
  31444. /**
  31445. * Automatically updates internal texture from video at every frame in the render loop
  31446. */
  31447. autoUpdateTexture: boolean;
  31448. /**
  31449. * Image src displayed during the video loading or until the user interacts with the video.
  31450. */
  31451. poster?: string;
  31452. }
  31453. /**
  31454. * If you want to display a video in your scene, this is the special texture for that.
  31455. * This special texture works similar to other textures, with the exception of a few parameters.
  31456. * @see https://doc.babylonjs.com/how_to/video_texture
  31457. */
  31458. export class VideoTexture extends Texture {
  31459. /**
  31460. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31461. */
  31462. readonly autoUpdateTexture: boolean;
  31463. /**
  31464. * The video instance used by the texture internally
  31465. */
  31466. readonly video: HTMLVideoElement;
  31467. private _onUserActionRequestedObservable;
  31468. /**
  31469. * Event triggerd when a dom action is required by the user to play the video.
  31470. * This happens due to recent changes in browser policies preventing video to auto start.
  31471. */
  31472. get onUserActionRequestedObservable(): Observable<Texture>;
  31473. private _generateMipMaps;
  31474. private _stillImageCaptured;
  31475. private _displayingPosterTexture;
  31476. private _settings;
  31477. private _createInternalTextureOnEvent;
  31478. private _frameId;
  31479. private _currentSrc;
  31480. /**
  31481. * Creates a video texture.
  31482. * If you want to display a video in your scene, this is the special texture for that.
  31483. * This special texture works similar to other textures, with the exception of a few parameters.
  31484. * @see https://doc.babylonjs.com/how_to/video_texture
  31485. * @param name optional name, will detect from video source, if not defined
  31486. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31487. * @param scene is obviously the current scene.
  31488. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31489. * @param invertY is false by default but can be used to invert video on Y axis
  31490. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31491. * @param settings allows finer control over video usage
  31492. */
  31493. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31494. private _getName;
  31495. private _getVideo;
  31496. private _createInternalTexture;
  31497. private reset;
  31498. /**
  31499. * @hidden Internal method to initiate `update`.
  31500. */
  31501. _rebuild(): void;
  31502. /**
  31503. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31504. */
  31505. update(): void;
  31506. /**
  31507. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31508. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31509. */
  31510. updateTexture(isVisible: boolean): void;
  31511. protected _updateInternalTexture: () => void;
  31512. /**
  31513. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31514. * @param url New url.
  31515. */
  31516. updateURL(url: string): void;
  31517. /**
  31518. * Clones the texture.
  31519. * @returns the cloned texture
  31520. */
  31521. clone(): VideoTexture;
  31522. /**
  31523. * Dispose the texture and release its associated resources.
  31524. */
  31525. dispose(): void;
  31526. /**
  31527. * Creates a video texture straight from a stream.
  31528. * @param scene Define the scene the texture should be created in
  31529. * @param stream Define the stream the texture should be created from
  31530. * @returns The created video texture as a promise
  31531. */
  31532. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31533. /**
  31534. * Creates a video texture straight from your WebCam video feed.
  31535. * @param scene Define the scene the texture should be created in
  31536. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31537. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31538. * @returns The created video texture as a promise
  31539. */
  31540. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31541. minWidth: number;
  31542. maxWidth: number;
  31543. minHeight: number;
  31544. maxHeight: number;
  31545. deviceId: string;
  31546. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31547. /**
  31548. * Creates a video texture straight from your WebCam video feed.
  31549. * @param scene Define the scene the texture should be created in
  31550. * @param onReady Define a callback to triggered once the texture will be ready
  31551. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31552. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31553. */
  31554. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31555. minWidth: number;
  31556. maxWidth: number;
  31557. minHeight: number;
  31558. maxHeight: number;
  31559. deviceId: string;
  31560. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31561. }
  31562. }
  31563. declare module BABYLON {
  31564. /**
  31565. * Defines the interface used by objects working like Scene
  31566. * @hidden
  31567. */
  31568. export interface ISceneLike {
  31569. _addPendingData(data: any): void;
  31570. _removePendingData(data: any): void;
  31571. offlineProvider: IOfflineProvider;
  31572. }
  31573. /** Interface defining initialization parameters for Engine class */
  31574. export interface EngineOptions extends WebGLContextAttributes {
  31575. /**
  31576. * Defines if the engine should no exceed a specified device ratio
  31577. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31578. */
  31579. limitDeviceRatio?: number;
  31580. /**
  31581. * Defines if webvr should be enabled automatically
  31582. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31583. */
  31584. autoEnableWebVR?: boolean;
  31585. /**
  31586. * Defines if webgl2 should be turned off even if supported
  31587. * @see http://doc.babylonjs.com/features/webgl2
  31588. */
  31589. disableWebGL2Support?: boolean;
  31590. /**
  31591. * Defines if webaudio should be initialized as well
  31592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31593. */
  31594. audioEngine?: boolean;
  31595. /**
  31596. * Defines if animations should run using a deterministic lock step
  31597. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31598. */
  31599. deterministicLockstep?: boolean;
  31600. /** Defines the maximum steps to use with deterministic lock step mode */
  31601. lockstepMaxSteps?: number;
  31602. /** Defines the seconds between each deterministic lock step */
  31603. timeStep?: number;
  31604. /**
  31605. * Defines that engine should ignore context lost events
  31606. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31607. */
  31608. doNotHandleContextLost?: boolean;
  31609. /**
  31610. * Defines that engine should ignore modifying touch action attribute and style
  31611. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31612. */
  31613. doNotHandleTouchAction?: boolean;
  31614. /**
  31615. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31616. */
  31617. useHighPrecisionFloats?: boolean;
  31618. }
  31619. /**
  31620. * The base engine class (root of all engines)
  31621. */
  31622. export class ThinEngine {
  31623. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31624. static ExceptionList: ({
  31625. key: string;
  31626. capture: string;
  31627. captureConstraint: number;
  31628. targets: string[];
  31629. } | {
  31630. key: string;
  31631. capture: null;
  31632. captureConstraint: null;
  31633. targets: string[];
  31634. })[];
  31635. /** @hidden */
  31636. static _TextureLoaders: IInternalTextureLoader[];
  31637. /**
  31638. * Returns the current npm package of the sdk
  31639. */
  31640. static get NpmPackage(): string;
  31641. /**
  31642. * Returns the current version of the framework
  31643. */
  31644. static get Version(): string;
  31645. /**
  31646. * Returns a string describing the current engine
  31647. */
  31648. get description(): string;
  31649. /**
  31650. * Gets or sets the epsilon value used by collision engine
  31651. */
  31652. static CollisionsEpsilon: number;
  31653. /**
  31654. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31655. */
  31656. static get ShadersRepository(): string;
  31657. static set ShadersRepository(value: string);
  31658. /** @hidden */
  31659. _shaderProcessor: IShaderProcessor;
  31660. /**
  31661. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31662. */
  31663. forcePOTTextures: boolean;
  31664. /**
  31665. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31666. */
  31667. isFullscreen: boolean;
  31668. /**
  31669. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31670. */
  31671. cullBackFaces: boolean;
  31672. /**
  31673. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31674. */
  31675. renderEvenInBackground: boolean;
  31676. /**
  31677. * Gets or sets a boolean indicating that cache can be kept between frames
  31678. */
  31679. preventCacheWipeBetweenFrames: boolean;
  31680. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31681. validateShaderPrograms: boolean;
  31682. /**
  31683. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31684. * This can provide greater z depth for distant objects.
  31685. */
  31686. useReverseDepthBuffer: boolean;
  31687. /**
  31688. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31689. */
  31690. disableUniformBuffers: boolean;
  31691. /** @hidden */
  31692. _uniformBuffers: UniformBuffer[];
  31693. /**
  31694. * Gets a boolean indicating that the engine supports uniform buffers
  31695. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31696. */
  31697. get supportsUniformBuffers(): boolean;
  31698. /** @hidden */
  31699. _gl: WebGLRenderingContext;
  31700. /** @hidden */
  31701. _webGLVersion: number;
  31702. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31703. protected _windowIsBackground: boolean;
  31704. protected _creationOptions: EngineOptions;
  31705. protected _highPrecisionShadersAllowed: boolean;
  31706. /** @hidden */
  31707. get _shouldUseHighPrecisionShader(): boolean;
  31708. /**
  31709. * Gets a boolean indicating that only power of 2 textures are supported
  31710. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31711. */
  31712. get needPOTTextures(): boolean;
  31713. /** @hidden */
  31714. _badOS: boolean;
  31715. /** @hidden */
  31716. _badDesktopOS: boolean;
  31717. private _hardwareScalingLevel;
  31718. /** @hidden */
  31719. _caps: EngineCapabilities;
  31720. private _isStencilEnable;
  31721. private _glVersion;
  31722. private _glRenderer;
  31723. private _glVendor;
  31724. /** @hidden */
  31725. _videoTextureSupported: boolean;
  31726. protected _renderingQueueLaunched: boolean;
  31727. protected _activeRenderLoops: (() => void)[];
  31728. /**
  31729. * Observable signaled when a context lost event is raised
  31730. */
  31731. onContextLostObservable: Observable<ThinEngine>;
  31732. /**
  31733. * Observable signaled when a context restored event is raised
  31734. */
  31735. onContextRestoredObservable: Observable<ThinEngine>;
  31736. private _onContextLost;
  31737. private _onContextRestored;
  31738. protected _contextWasLost: boolean;
  31739. /** @hidden */
  31740. _doNotHandleContextLost: boolean;
  31741. /**
  31742. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31744. */
  31745. get doNotHandleContextLost(): boolean;
  31746. set doNotHandleContextLost(value: boolean);
  31747. /**
  31748. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31749. */
  31750. disableVertexArrayObjects: boolean;
  31751. /** @hidden */
  31752. protected _colorWrite: boolean;
  31753. /** @hidden */
  31754. protected _colorWriteChanged: boolean;
  31755. /** @hidden */
  31756. protected _depthCullingState: DepthCullingState;
  31757. /** @hidden */
  31758. protected _stencilState: StencilState;
  31759. /** @hidden */
  31760. _alphaState: AlphaState;
  31761. /** @hidden */
  31762. _alphaMode: number;
  31763. /** @hidden */
  31764. _alphaEquation: number;
  31765. /** @hidden */
  31766. _internalTexturesCache: InternalTexture[];
  31767. /** @hidden */
  31768. protected _activeChannel: number;
  31769. private _currentTextureChannel;
  31770. /** @hidden */
  31771. protected _boundTexturesCache: {
  31772. [key: string]: Nullable<InternalTexture>;
  31773. };
  31774. /** @hidden */
  31775. protected _currentEffect: Nullable<Effect>;
  31776. /** @hidden */
  31777. protected _currentProgram: Nullable<WebGLProgram>;
  31778. private _compiledEffects;
  31779. private _vertexAttribArraysEnabled;
  31780. /** @hidden */
  31781. protected _cachedViewport: Nullable<IViewportLike>;
  31782. private _cachedVertexArrayObject;
  31783. /** @hidden */
  31784. protected _cachedVertexBuffers: any;
  31785. /** @hidden */
  31786. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31787. /** @hidden */
  31788. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31789. /** @hidden */
  31790. _currentRenderTarget: Nullable<InternalTexture>;
  31791. private _uintIndicesCurrentlySet;
  31792. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31793. /** @hidden */
  31794. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31795. /** @hidden */
  31796. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  31797. private _currentBufferPointers;
  31798. private _currentInstanceLocations;
  31799. private _currentInstanceBuffers;
  31800. private _textureUnits;
  31801. /** @hidden */
  31802. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31803. /** @hidden */
  31804. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31805. /** @hidden */
  31806. _boundRenderFunction: any;
  31807. private _vaoRecordInProgress;
  31808. private _mustWipeVertexAttributes;
  31809. private _emptyTexture;
  31810. private _emptyCubeTexture;
  31811. private _emptyTexture3D;
  31812. private _emptyTexture2DArray;
  31813. /** @hidden */
  31814. _frameHandler: number;
  31815. private _nextFreeTextureSlots;
  31816. private _maxSimultaneousTextures;
  31817. private _activeRequests;
  31818. /** @hidden */
  31819. _transformTextureUrl: Nullable<(url: string) => string>;
  31820. protected get _supportsHardwareTextureRescaling(): boolean;
  31821. private _framebufferDimensionsObject;
  31822. /**
  31823. * sets the object from which width and height will be taken from when getting render width and height
  31824. * Will fallback to the gl object
  31825. * @param dimensions the framebuffer width and height that will be used.
  31826. */
  31827. set framebufferDimensionsObject(dimensions: Nullable<{
  31828. framebufferWidth: number;
  31829. framebufferHeight: number;
  31830. }>);
  31831. /**
  31832. * Gets the current viewport
  31833. */
  31834. get currentViewport(): Nullable<IViewportLike>;
  31835. /**
  31836. * Gets the default empty texture
  31837. */
  31838. get emptyTexture(): InternalTexture;
  31839. /**
  31840. * Gets the default empty 3D texture
  31841. */
  31842. get emptyTexture3D(): InternalTexture;
  31843. /**
  31844. * Gets the default empty 2D array texture
  31845. */
  31846. get emptyTexture2DArray(): InternalTexture;
  31847. /**
  31848. * Gets the default empty cube texture
  31849. */
  31850. get emptyCubeTexture(): InternalTexture;
  31851. /**
  31852. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31853. */
  31854. readonly premultipliedAlpha: boolean;
  31855. /**
  31856. * Observable event triggered before each texture is initialized
  31857. */
  31858. onBeforeTextureInitObservable: Observable<Texture>;
  31859. /**
  31860. * Creates a new engine
  31861. * @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
  31862. * @param antialias defines enable antialiasing (default: false)
  31863. * @param options defines further options to be sent to the getContext() function
  31864. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31865. */
  31866. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31867. private _rebuildInternalTextures;
  31868. private _rebuildEffects;
  31869. /**
  31870. * Gets a boolean indicating if all created effects are ready
  31871. * @returns true if all effects are ready
  31872. */
  31873. areAllEffectsReady(): boolean;
  31874. protected _rebuildBuffers(): void;
  31875. protected _initGLContext(): void;
  31876. /**
  31877. * Gets version of the current webGL context
  31878. */
  31879. get webGLVersion(): number;
  31880. /**
  31881. * Gets a string idenfifying the name of the class
  31882. * @returns "Engine" string
  31883. */
  31884. getClassName(): string;
  31885. /**
  31886. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31887. */
  31888. get isStencilEnable(): boolean;
  31889. /** @hidden */
  31890. _prepareWorkingCanvas(): void;
  31891. /**
  31892. * Reset the texture cache to empty state
  31893. */
  31894. resetTextureCache(): void;
  31895. /**
  31896. * Gets an object containing information about the current webGL context
  31897. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31898. */
  31899. getGlInfo(): {
  31900. vendor: string;
  31901. renderer: string;
  31902. version: string;
  31903. };
  31904. /**
  31905. * Defines the hardware scaling level.
  31906. * By default the hardware scaling level is computed from the window device ratio.
  31907. * 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.
  31908. * @param level defines the level to use
  31909. */
  31910. setHardwareScalingLevel(level: number): void;
  31911. /**
  31912. * Gets the current hardware scaling level.
  31913. * By default the hardware scaling level is computed from the window device ratio.
  31914. * 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.
  31915. * @returns a number indicating the current hardware scaling level
  31916. */
  31917. getHardwareScalingLevel(): number;
  31918. /**
  31919. * Gets the list of loaded textures
  31920. * @returns an array containing all loaded textures
  31921. */
  31922. getLoadedTexturesCache(): InternalTexture[];
  31923. /**
  31924. * Gets the object containing all engine capabilities
  31925. * @returns the EngineCapabilities object
  31926. */
  31927. getCaps(): EngineCapabilities;
  31928. /**
  31929. * stop executing a render loop function and remove it from the execution array
  31930. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31931. */
  31932. stopRenderLoop(renderFunction?: () => void): void;
  31933. /** @hidden */
  31934. _renderLoop(): void;
  31935. /**
  31936. * Gets the HTML canvas attached with the current webGL context
  31937. * @returns a HTML canvas
  31938. */
  31939. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31940. /**
  31941. * Gets host window
  31942. * @returns the host window object
  31943. */
  31944. getHostWindow(): Nullable<Window>;
  31945. /**
  31946. * Gets the current render width
  31947. * @param useScreen defines if screen size must be used (or the current render target if any)
  31948. * @returns a number defining the current render width
  31949. */
  31950. getRenderWidth(useScreen?: boolean): number;
  31951. /**
  31952. * Gets the current render height
  31953. * @param useScreen defines if screen size must be used (or the current render target if any)
  31954. * @returns a number defining the current render height
  31955. */
  31956. getRenderHeight(useScreen?: boolean): number;
  31957. /**
  31958. * Can be used to override the current requestAnimationFrame requester.
  31959. * @hidden
  31960. */
  31961. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31962. /**
  31963. * Register and execute a render loop. The engine can have more than one render function
  31964. * @param renderFunction defines the function to continuously execute
  31965. */
  31966. runRenderLoop(renderFunction: () => void): void;
  31967. /**
  31968. * Clear the current render buffer or the current render target (if any is set up)
  31969. * @param color defines the color to use
  31970. * @param backBuffer defines if the back buffer must be cleared
  31971. * @param depth defines if the depth buffer must be cleared
  31972. * @param stencil defines if the stencil buffer must be cleared
  31973. */
  31974. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31975. private _viewportCached;
  31976. /** @hidden */
  31977. _viewport(x: number, y: number, width: number, height: number): void;
  31978. /**
  31979. * Set the WebGL's viewport
  31980. * @param viewport defines the viewport element to be used
  31981. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31982. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31983. */
  31984. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31985. /**
  31986. * Begin a new frame
  31987. */
  31988. beginFrame(): void;
  31989. /**
  31990. * Enf the current frame
  31991. */
  31992. endFrame(): void;
  31993. /**
  31994. * Resize the view according to the canvas' size
  31995. */
  31996. resize(): void;
  31997. /**
  31998. * Force a specific size of the canvas
  31999. * @param width defines the new canvas' width
  32000. * @param height defines the new canvas' height
  32001. */
  32002. setSize(width: number, height: number): void;
  32003. /**
  32004. * Binds the frame buffer to the specified texture.
  32005. * @param texture The texture to render to or null for the default canvas
  32006. * @param faceIndex The face of the texture to render to in case of cube texture
  32007. * @param requiredWidth The width of the target to render to
  32008. * @param requiredHeight The height of the target to render to
  32009. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32010. * @param lodLevel defines the lod level to bind to the frame buffer
  32011. * @param layer defines the 2d array index to bind to frame buffer to
  32012. */
  32013. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32014. /** @hidden */
  32015. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32016. /**
  32017. * Unbind the current render target texture from the webGL context
  32018. * @param texture defines the render target texture to unbind
  32019. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32020. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32021. */
  32022. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32023. /**
  32024. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32025. */
  32026. flushFramebuffer(): void;
  32027. /**
  32028. * Unbind the current render target and bind the default framebuffer
  32029. */
  32030. restoreDefaultFramebuffer(): void;
  32031. /** @hidden */
  32032. protected _resetVertexBufferBinding(): void;
  32033. /**
  32034. * Creates a vertex buffer
  32035. * @param data the data for the vertex buffer
  32036. * @returns the new WebGL static buffer
  32037. */
  32038. createVertexBuffer(data: DataArray): DataBuffer;
  32039. private _createVertexBuffer;
  32040. /**
  32041. * Creates a dynamic vertex buffer
  32042. * @param data the data for the dynamic vertex buffer
  32043. * @returns the new WebGL dynamic buffer
  32044. */
  32045. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32046. protected _resetIndexBufferBinding(): void;
  32047. /**
  32048. * Creates a new index buffer
  32049. * @param indices defines the content of the index buffer
  32050. * @param updatable defines if the index buffer must be updatable
  32051. * @returns a new webGL buffer
  32052. */
  32053. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32054. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32055. /**
  32056. * Bind a webGL buffer to the webGL context
  32057. * @param buffer defines the buffer to bind
  32058. */
  32059. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32060. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32061. private bindBuffer;
  32062. /**
  32063. * update the bound buffer with the given data
  32064. * @param data defines the data to update
  32065. */
  32066. updateArrayBuffer(data: Float32Array): void;
  32067. private _vertexAttribPointer;
  32068. /** @hidden */
  32069. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32070. private _bindVertexBuffersAttributes;
  32071. /**
  32072. * Records a vertex array object
  32073. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32074. * @param vertexBuffers defines the list of vertex buffers to store
  32075. * @param indexBuffer defines the index buffer to store
  32076. * @param effect defines the effect to store
  32077. * @returns the new vertex array object
  32078. */
  32079. recordVertexArrayObject(vertexBuffers: {
  32080. [key: string]: VertexBuffer;
  32081. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32082. /**
  32083. * Bind a specific vertex array object
  32084. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32085. * @param vertexArrayObject defines the vertex array object to bind
  32086. * @param indexBuffer defines the index buffer to bind
  32087. */
  32088. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32089. /**
  32090. * Bind webGl buffers directly to the webGL context
  32091. * @param vertexBuffer defines the vertex buffer to bind
  32092. * @param indexBuffer defines the index buffer to bind
  32093. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32094. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32095. * @param effect defines the effect associated with the vertex buffer
  32096. */
  32097. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32098. private _unbindVertexArrayObject;
  32099. /**
  32100. * Bind a list of vertex buffers to the webGL context
  32101. * @param vertexBuffers defines the list of vertex buffers to bind
  32102. * @param indexBuffer defines the index buffer to bind
  32103. * @param effect defines the effect associated with the vertex buffers
  32104. */
  32105. bindBuffers(vertexBuffers: {
  32106. [key: string]: Nullable<VertexBuffer>;
  32107. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32108. /**
  32109. * Unbind all instance attributes
  32110. */
  32111. unbindInstanceAttributes(): void;
  32112. /**
  32113. * Release and free the memory of a vertex array object
  32114. * @param vao defines the vertex array object to delete
  32115. */
  32116. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32117. /** @hidden */
  32118. _releaseBuffer(buffer: DataBuffer): boolean;
  32119. protected _deleteBuffer(buffer: DataBuffer): void;
  32120. /**
  32121. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32122. * @param instancesBuffer defines the webGL buffer to update and bind
  32123. * @param data defines the data to store in the buffer
  32124. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32125. */
  32126. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32127. /**
  32128. * Bind the content of a webGL buffer used with instantiation
  32129. * @param instancesBuffer defines the webGL buffer to bind
  32130. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32131. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32132. */
  32133. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32134. /**
  32135. * Disable the instance attribute corresponding to the name in parameter
  32136. * @param name defines the name of the attribute to disable
  32137. */
  32138. disableInstanceAttributeByName(name: string): void;
  32139. /**
  32140. * Disable the instance attribute corresponding to the location in parameter
  32141. * @param attributeLocation defines the attribute location of the attribute to disable
  32142. */
  32143. disableInstanceAttribute(attributeLocation: number): void;
  32144. /**
  32145. * Disable the attribute corresponding to the location in parameter
  32146. * @param attributeLocation defines the attribute location of the attribute to disable
  32147. */
  32148. disableAttributeByIndex(attributeLocation: number): void;
  32149. /**
  32150. * Send a draw order
  32151. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32152. * @param indexStart defines the starting index
  32153. * @param indexCount defines the number of index to draw
  32154. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32155. */
  32156. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32157. /**
  32158. * Draw a list of points
  32159. * @param verticesStart defines the index of first vertex to draw
  32160. * @param verticesCount defines the count of vertices to draw
  32161. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32162. */
  32163. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32164. /**
  32165. * Draw a list of unindexed primitives
  32166. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32167. * @param verticesStart defines the index of first vertex to draw
  32168. * @param verticesCount defines the count of vertices to draw
  32169. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32170. */
  32171. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32172. /**
  32173. * Draw a list of indexed primitives
  32174. * @param fillMode defines the primitive to use
  32175. * @param indexStart defines the starting index
  32176. * @param indexCount defines the number of index to draw
  32177. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32178. */
  32179. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32180. /**
  32181. * Draw a list of unindexed primitives
  32182. * @param fillMode defines the primitive to use
  32183. * @param verticesStart defines the index of first vertex to draw
  32184. * @param verticesCount defines the count of vertices to draw
  32185. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32186. */
  32187. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32188. private _drawMode;
  32189. /** @hidden */
  32190. protected _reportDrawCall(): void;
  32191. /** @hidden */
  32192. _releaseEffect(effect: Effect): void;
  32193. /** @hidden */
  32194. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32195. /**
  32196. * Create a new effect (used to store vertex/fragment shaders)
  32197. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32198. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32199. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32200. * @param samplers defines an array of string used to represent textures
  32201. * @param defines defines the string containing the defines to use to compile the shaders
  32202. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32203. * @param onCompiled defines a function to call when the effect creation is successful
  32204. * @param onError defines a function to call when the effect creation has failed
  32205. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32206. * @returns the new Effect
  32207. */
  32208. 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;
  32209. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32210. private _compileShader;
  32211. private _compileRawShader;
  32212. /** @hidden */
  32213. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32214. /**
  32215. * Directly creates a webGL program
  32216. * @param pipelineContext defines the pipeline context to attach to
  32217. * @param vertexCode defines the vertex shader code to use
  32218. * @param fragmentCode defines the fragment shader code to use
  32219. * @param context defines the webGL context to use (if not set, the current one will be used)
  32220. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32221. * @returns the new webGL program
  32222. */
  32223. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32224. /**
  32225. * Creates a webGL program
  32226. * @param pipelineContext defines the pipeline context to attach to
  32227. * @param vertexCode defines the vertex shader code to use
  32228. * @param fragmentCode defines the fragment shader code to use
  32229. * @param defines defines the string containing the defines to use to compile the shaders
  32230. * @param context defines the webGL context to use (if not set, the current one will be used)
  32231. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32232. * @returns the new webGL program
  32233. */
  32234. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32235. /**
  32236. * Creates a new pipeline context
  32237. * @returns the new pipeline
  32238. */
  32239. createPipelineContext(): IPipelineContext;
  32240. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32241. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32242. /** @hidden */
  32243. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32244. /** @hidden */
  32245. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32246. /** @hidden */
  32247. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32248. /**
  32249. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32250. * @param pipelineContext defines the pipeline context to use
  32251. * @param uniformsNames defines the list of uniform names
  32252. * @returns an array of webGL uniform locations
  32253. */
  32254. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32255. /**
  32256. * Gets the lsit of active attributes for a given webGL program
  32257. * @param pipelineContext defines the pipeline context to use
  32258. * @param attributesNames defines the list of attribute names to get
  32259. * @returns an array of indices indicating the offset of each attribute
  32260. */
  32261. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32262. /**
  32263. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32264. * @param effect defines the effect to activate
  32265. */
  32266. enableEffect(effect: Nullable<Effect>): void;
  32267. /**
  32268. * Set the value of an uniform to a number (int)
  32269. * @param uniform defines the webGL uniform location where to store the value
  32270. * @param value defines the int number to store
  32271. */
  32272. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32273. /**
  32274. * Set the value of an uniform to an array of int32
  32275. * @param uniform defines the webGL uniform location where to store the value
  32276. * @param array defines the array of int32 to store
  32277. */
  32278. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32279. /**
  32280. * Set the value of an uniform to an array of int32 (stored as vec2)
  32281. * @param uniform defines the webGL uniform location where to store the value
  32282. * @param array defines the array of int32 to store
  32283. */
  32284. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32285. /**
  32286. * Set the value of an uniform to an array of int32 (stored as vec3)
  32287. * @param uniform defines the webGL uniform location where to store the value
  32288. * @param array defines the array of int32 to store
  32289. */
  32290. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32291. /**
  32292. * Set the value of an uniform to an array of int32 (stored as vec4)
  32293. * @param uniform defines the webGL uniform location where to store the value
  32294. * @param array defines the array of int32 to store
  32295. */
  32296. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32297. /**
  32298. * Set the value of an uniform to an array of number
  32299. * @param uniform defines the webGL uniform location where to store the value
  32300. * @param array defines the array of number to store
  32301. */
  32302. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32303. /**
  32304. * Set the value of an uniform to an array of number (stored as vec2)
  32305. * @param uniform defines the webGL uniform location where to store the value
  32306. * @param array defines the array of number to store
  32307. */
  32308. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32309. /**
  32310. * Set the value of an uniform to an array of number (stored as vec3)
  32311. * @param uniform defines the webGL uniform location where to store the value
  32312. * @param array defines the array of number to store
  32313. */
  32314. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32315. /**
  32316. * Set the value of an uniform to an array of number (stored as vec4)
  32317. * @param uniform defines the webGL uniform location where to store the value
  32318. * @param array defines the array of number to store
  32319. */
  32320. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32321. /**
  32322. * Set the value of an uniform to an array of float32 (stored as matrices)
  32323. * @param uniform defines the webGL uniform location where to store the value
  32324. * @param matrices defines the array of float32 to store
  32325. */
  32326. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32327. /**
  32328. * Set the value of an uniform to a matrix (3x3)
  32329. * @param uniform defines the webGL uniform location where to store the value
  32330. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32331. */
  32332. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32333. /**
  32334. * Set the value of an uniform to a matrix (2x2)
  32335. * @param uniform defines the webGL uniform location where to store the value
  32336. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32337. */
  32338. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32339. /**
  32340. * Set the value of an uniform to a number (float)
  32341. * @param uniform defines the webGL uniform location where to store the value
  32342. * @param value defines the float number to store
  32343. */
  32344. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32345. /**
  32346. * Set the value of an uniform to a vec2
  32347. * @param uniform defines the webGL uniform location where to store the value
  32348. * @param x defines the 1st component of the value
  32349. * @param y defines the 2nd component of the value
  32350. */
  32351. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32352. /**
  32353. * Set the value of an uniform to a vec3
  32354. * @param uniform defines the webGL uniform location where to store the value
  32355. * @param x defines the 1st component of the value
  32356. * @param y defines the 2nd component of the value
  32357. * @param z defines the 3rd component of the value
  32358. */
  32359. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32360. /**
  32361. * Set the value of an uniform to a vec4
  32362. * @param uniform defines the webGL uniform location where to store the value
  32363. * @param x defines the 1st component of the value
  32364. * @param y defines the 2nd component of the value
  32365. * @param z defines the 3rd component of the value
  32366. * @param w defines the 4th component of the value
  32367. */
  32368. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32369. /**
  32370. * Apply all cached states (depth, culling, stencil and alpha)
  32371. */
  32372. applyStates(): void;
  32373. /**
  32374. * Enable or disable color writing
  32375. * @param enable defines the state to set
  32376. */
  32377. setColorWrite(enable: boolean): void;
  32378. /**
  32379. * Gets a boolean indicating if color writing is enabled
  32380. * @returns the current color writing state
  32381. */
  32382. getColorWrite(): boolean;
  32383. /**
  32384. * Gets the depth culling state manager
  32385. */
  32386. get depthCullingState(): DepthCullingState;
  32387. /**
  32388. * Gets the alpha state manager
  32389. */
  32390. get alphaState(): AlphaState;
  32391. /**
  32392. * Gets the stencil state manager
  32393. */
  32394. get stencilState(): StencilState;
  32395. /**
  32396. * Clears the list of texture accessible through engine.
  32397. * This can help preventing texture load conflict due to name collision.
  32398. */
  32399. clearInternalTexturesCache(): void;
  32400. /**
  32401. * Force the entire cache to be cleared
  32402. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32403. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32404. */
  32405. wipeCaches(bruteForce?: boolean): void;
  32406. /** @hidden */
  32407. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32408. min: number;
  32409. mag: number;
  32410. };
  32411. /** @hidden */
  32412. _createTexture(): WebGLTexture;
  32413. /**
  32414. * Usually called from Texture.ts.
  32415. * Passed information to create a WebGLTexture
  32416. * @param url defines a value which contains one of the following:
  32417. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32418. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32419. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32420. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32421. * @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)
  32422. * @param scene needed for loading to the correct scene
  32423. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32424. * @param onLoad optional callback to be called upon successful completion
  32425. * @param onError optional callback to be called upon failure
  32426. * @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
  32427. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32428. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32429. * @param forcedExtension defines the extension to use to pick the right loader
  32430. * @param mimeType defines an optional mime type
  32431. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32432. */
  32433. createTexture(url: 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;
  32434. /**
  32435. * Loads an image as an HTMLImageElement.
  32436. * @param input url string, ArrayBuffer, or Blob to load
  32437. * @param onLoad callback called when the image successfully loads
  32438. * @param onError callback called when the image fails to load
  32439. * @param offlineProvider offline provider for caching
  32440. * @param mimeType optional mime type
  32441. * @returns the HTMLImageElement of the loaded image
  32442. * @hidden
  32443. */
  32444. 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>;
  32445. /**
  32446. * @hidden
  32447. */
  32448. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32449. private _unpackFlipYCached;
  32450. /**
  32451. * In case you are sharing the context with other applications, it might
  32452. * be interested to not cache the unpack flip y state to ensure a consistent
  32453. * value would be set.
  32454. */
  32455. enableUnpackFlipYCached: boolean;
  32456. /** @hidden */
  32457. _unpackFlipY(value: boolean): void;
  32458. /** @hidden */
  32459. _getUnpackAlignement(): number;
  32460. private _getTextureTarget;
  32461. /**
  32462. * Update the sampling mode of a given texture
  32463. * @param samplingMode defines the required sampling mode
  32464. * @param texture defines the texture to update
  32465. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32466. */
  32467. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32468. /**
  32469. * Update the sampling mode of a given texture
  32470. * @param texture defines the texture to update
  32471. * @param wrapU defines the texture wrap mode of the u coordinates
  32472. * @param wrapV defines the texture wrap mode of the v coordinates
  32473. * @param wrapR defines the texture wrap mode of the r coordinates
  32474. */
  32475. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32476. /** @hidden */
  32477. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32478. width: number;
  32479. height: number;
  32480. layers?: number;
  32481. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32482. /** @hidden */
  32483. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32484. /** @hidden */
  32485. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32486. /**
  32487. * Update a portion of an internal texture
  32488. * @param texture defines the texture to update
  32489. * @param imageData defines the data to store into the texture
  32490. * @param xOffset defines the x coordinates of the update rectangle
  32491. * @param yOffset defines the y coordinates of the update rectangle
  32492. * @param width defines the width of the update rectangle
  32493. * @param height defines the height of the update rectangle
  32494. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32495. * @param lod defines the lod level to update (0 by default)
  32496. */
  32497. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32498. /** @hidden */
  32499. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32500. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32501. private _prepareWebGLTexture;
  32502. /** @hidden */
  32503. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32504. private _getDepthStencilBuffer;
  32505. /** @hidden */
  32506. _releaseFramebufferObjects(texture: InternalTexture): void;
  32507. /** @hidden */
  32508. _releaseTexture(texture: InternalTexture): void;
  32509. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32510. protected _setProgram(program: WebGLProgram): void;
  32511. protected _boundUniforms: {
  32512. [key: number]: WebGLUniformLocation;
  32513. };
  32514. /**
  32515. * Binds an effect to the webGL context
  32516. * @param effect defines the effect to bind
  32517. */
  32518. bindSamplers(effect: Effect): void;
  32519. private _activateCurrentTexture;
  32520. /** @hidden */
  32521. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32522. /** @hidden */
  32523. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32524. /**
  32525. * Unbind all textures from the webGL context
  32526. */
  32527. unbindAllTextures(): void;
  32528. /**
  32529. * Sets a texture to the according uniform.
  32530. * @param channel The texture channel
  32531. * @param uniform The uniform to set
  32532. * @param texture The texture to apply
  32533. */
  32534. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32535. private _bindSamplerUniformToChannel;
  32536. private _getTextureWrapMode;
  32537. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32538. /**
  32539. * Sets an array of texture to the webGL context
  32540. * @param channel defines the channel where the texture array must be set
  32541. * @param uniform defines the associated uniform location
  32542. * @param textures defines the array of textures to bind
  32543. */
  32544. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32545. /** @hidden */
  32546. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32547. private _setTextureParameterFloat;
  32548. private _setTextureParameterInteger;
  32549. /**
  32550. * Unbind all vertex attributes from the webGL context
  32551. */
  32552. unbindAllAttributes(): void;
  32553. /**
  32554. * 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
  32555. */
  32556. releaseEffects(): void;
  32557. /**
  32558. * Dispose and release all associated resources
  32559. */
  32560. dispose(): void;
  32561. /**
  32562. * Attach a new callback raised when context lost event is fired
  32563. * @param callback defines the callback to call
  32564. */
  32565. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32566. /**
  32567. * Attach a new callback raised when context restored event is fired
  32568. * @param callback defines the callback to call
  32569. */
  32570. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32571. /**
  32572. * Get the current error code of the webGL context
  32573. * @returns the error code
  32574. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32575. */
  32576. getError(): number;
  32577. private _canRenderToFloatFramebuffer;
  32578. private _canRenderToHalfFloatFramebuffer;
  32579. private _canRenderToFramebuffer;
  32580. /** @hidden */
  32581. _getWebGLTextureType(type: number): number;
  32582. /** @hidden */
  32583. _getInternalFormat(format: number): number;
  32584. /** @hidden */
  32585. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32586. /** @hidden */
  32587. _getRGBAMultiSampleBufferFormat(type: number): number;
  32588. /** @hidden */
  32589. _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;
  32590. /**
  32591. * Loads a file from a url
  32592. * @param url url to load
  32593. * @param onSuccess callback called when the file successfully loads
  32594. * @param onProgress callback called while file is loading (if the server supports this mode)
  32595. * @param offlineProvider defines the offline provider for caching
  32596. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32597. * @param onError callback called when the file fails to load
  32598. * @returns a file request object
  32599. * @hidden
  32600. */
  32601. 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;
  32602. /**
  32603. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32604. * @param x defines the x coordinate of the rectangle where pixels must be read
  32605. * @param y defines the y coordinate of the rectangle where pixels must be read
  32606. * @param width defines the width of the rectangle where pixels must be read
  32607. * @param height defines the height of the rectangle where pixels must be read
  32608. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32609. * @returns a Uint8Array containing RGBA colors
  32610. */
  32611. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32612. private static _isSupported;
  32613. /**
  32614. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32615. * @returns true if the engine can be created
  32616. * @ignorenaming
  32617. */
  32618. static isSupported(): boolean;
  32619. /**
  32620. * Find the next highest power of two.
  32621. * @param x Number to start search from.
  32622. * @return Next highest power of two.
  32623. */
  32624. static CeilingPOT(x: number): number;
  32625. /**
  32626. * Find the next lowest power of two.
  32627. * @param x Number to start search from.
  32628. * @return Next lowest power of two.
  32629. */
  32630. static FloorPOT(x: number): number;
  32631. /**
  32632. * Find the nearest power of two.
  32633. * @param x Number to start search from.
  32634. * @return Next nearest power of two.
  32635. */
  32636. static NearestPOT(x: number): number;
  32637. /**
  32638. * Get the closest exponent of two
  32639. * @param value defines the value to approximate
  32640. * @param max defines the maximum value to return
  32641. * @param mode defines how to define the closest value
  32642. * @returns closest exponent of two of the given value
  32643. */
  32644. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32645. /**
  32646. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32647. * @param func - the function to be called
  32648. * @param requester - the object that will request the next frame. Falls back to window.
  32649. * @returns frame number
  32650. */
  32651. static QueueNewFrame(func: () => void, requester?: any): number;
  32652. /**
  32653. * Gets host document
  32654. * @returns the host document object
  32655. */
  32656. getHostDocument(): Nullable<Document>;
  32657. }
  32658. }
  32659. declare module BABYLON {
  32660. /**
  32661. * Class representing spherical harmonics coefficients to the 3rd degree
  32662. */
  32663. export class SphericalHarmonics {
  32664. /**
  32665. * Defines whether or not the harmonics have been prescaled for rendering.
  32666. */
  32667. preScaled: boolean;
  32668. /**
  32669. * The l0,0 coefficients of the spherical harmonics
  32670. */
  32671. l00: Vector3;
  32672. /**
  32673. * The l1,-1 coefficients of the spherical harmonics
  32674. */
  32675. l1_1: Vector3;
  32676. /**
  32677. * The l1,0 coefficients of the spherical harmonics
  32678. */
  32679. l10: Vector3;
  32680. /**
  32681. * The l1,1 coefficients of the spherical harmonics
  32682. */
  32683. l11: Vector3;
  32684. /**
  32685. * The l2,-2 coefficients of the spherical harmonics
  32686. */
  32687. l2_2: Vector3;
  32688. /**
  32689. * The l2,-1 coefficients of the spherical harmonics
  32690. */
  32691. l2_1: Vector3;
  32692. /**
  32693. * The l2,0 coefficients of the spherical harmonics
  32694. */
  32695. l20: Vector3;
  32696. /**
  32697. * The l2,1 coefficients of the spherical harmonics
  32698. */
  32699. l21: Vector3;
  32700. /**
  32701. * The l2,2 coefficients of the spherical harmonics
  32702. */
  32703. l22: Vector3;
  32704. /**
  32705. * Adds a light to the spherical harmonics
  32706. * @param direction the direction of the light
  32707. * @param color the color of the light
  32708. * @param deltaSolidAngle the delta solid angle of the light
  32709. */
  32710. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32711. /**
  32712. * Scales the spherical harmonics by the given amount
  32713. * @param scale the amount to scale
  32714. */
  32715. scaleInPlace(scale: number): void;
  32716. /**
  32717. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32718. *
  32719. * ```
  32720. * E_lm = A_l * L_lm
  32721. * ```
  32722. *
  32723. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32724. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32725. * the scaling factors are given in equation 9.
  32726. */
  32727. convertIncidentRadianceToIrradiance(): void;
  32728. /**
  32729. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32730. *
  32731. * ```
  32732. * L = (1/pi) * E * rho
  32733. * ```
  32734. *
  32735. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32736. */
  32737. convertIrradianceToLambertianRadiance(): void;
  32738. /**
  32739. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32740. * required operations at run time.
  32741. *
  32742. * This is simply done by scaling back the SH with Ylm constants parameter.
  32743. * The trigonometric part being applied by the shader at run time.
  32744. */
  32745. preScaleForRendering(): void;
  32746. /**
  32747. * Constructs a spherical harmonics from an array.
  32748. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32749. * @returns the spherical harmonics
  32750. */
  32751. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32752. /**
  32753. * Gets the spherical harmonics from polynomial
  32754. * @param polynomial the spherical polynomial
  32755. * @returns the spherical harmonics
  32756. */
  32757. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32758. }
  32759. /**
  32760. * Class representing spherical polynomial coefficients to the 3rd degree
  32761. */
  32762. export class SphericalPolynomial {
  32763. private _harmonics;
  32764. /**
  32765. * The spherical harmonics used to create the polynomials.
  32766. */
  32767. get preScaledHarmonics(): SphericalHarmonics;
  32768. /**
  32769. * The x coefficients of the spherical polynomial
  32770. */
  32771. x: Vector3;
  32772. /**
  32773. * The y coefficients of the spherical polynomial
  32774. */
  32775. y: Vector3;
  32776. /**
  32777. * The z coefficients of the spherical polynomial
  32778. */
  32779. z: Vector3;
  32780. /**
  32781. * The xx coefficients of the spherical polynomial
  32782. */
  32783. xx: Vector3;
  32784. /**
  32785. * The yy coefficients of the spherical polynomial
  32786. */
  32787. yy: Vector3;
  32788. /**
  32789. * The zz coefficients of the spherical polynomial
  32790. */
  32791. zz: Vector3;
  32792. /**
  32793. * The xy coefficients of the spherical polynomial
  32794. */
  32795. xy: Vector3;
  32796. /**
  32797. * The yz coefficients of the spherical polynomial
  32798. */
  32799. yz: Vector3;
  32800. /**
  32801. * The zx coefficients of the spherical polynomial
  32802. */
  32803. zx: Vector3;
  32804. /**
  32805. * Adds an ambient color to the spherical polynomial
  32806. * @param color the color to add
  32807. */
  32808. addAmbient(color: Color3): void;
  32809. /**
  32810. * Scales the spherical polynomial by the given amount
  32811. * @param scale the amount to scale
  32812. */
  32813. scaleInPlace(scale: number): void;
  32814. /**
  32815. * Gets the spherical polynomial from harmonics
  32816. * @param harmonics the spherical harmonics
  32817. * @returns the spherical polynomial
  32818. */
  32819. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32820. /**
  32821. * Constructs a spherical polynomial from an array.
  32822. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32823. * @returns the spherical polynomial
  32824. */
  32825. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32826. }
  32827. }
  32828. declare module BABYLON {
  32829. /**
  32830. * Defines the source of the internal texture
  32831. */
  32832. export enum InternalTextureSource {
  32833. /**
  32834. * The source of the texture data is unknown
  32835. */
  32836. Unknown = 0,
  32837. /**
  32838. * Texture data comes from an URL
  32839. */
  32840. Url = 1,
  32841. /**
  32842. * Texture data is only used for temporary storage
  32843. */
  32844. Temp = 2,
  32845. /**
  32846. * Texture data comes from raw data (ArrayBuffer)
  32847. */
  32848. Raw = 3,
  32849. /**
  32850. * Texture content is dynamic (video or dynamic texture)
  32851. */
  32852. Dynamic = 4,
  32853. /**
  32854. * Texture content is generated by rendering to it
  32855. */
  32856. RenderTarget = 5,
  32857. /**
  32858. * Texture content is part of a multi render target process
  32859. */
  32860. MultiRenderTarget = 6,
  32861. /**
  32862. * Texture data comes from a cube data file
  32863. */
  32864. Cube = 7,
  32865. /**
  32866. * Texture data comes from a raw cube data
  32867. */
  32868. CubeRaw = 8,
  32869. /**
  32870. * Texture data come from a prefiltered cube data file
  32871. */
  32872. CubePrefiltered = 9,
  32873. /**
  32874. * Texture content is raw 3D data
  32875. */
  32876. Raw3D = 10,
  32877. /**
  32878. * Texture content is raw 2D array data
  32879. */
  32880. Raw2DArray = 11,
  32881. /**
  32882. * Texture content is a depth texture
  32883. */
  32884. Depth = 12,
  32885. /**
  32886. * Texture data comes from a raw cube data encoded with RGBD
  32887. */
  32888. CubeRawRGBD = 13
  32889. }
  32890. /**
  32891. * Class used to store data associated with WebGL texture data for the engine
  32892. * This class should not be used directly
  32893. */
  32894. export class InternalTexture {
  32895. /** @hidden */
  32896. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32897. /**
  32898. * Defines if the texture is ready
  32899. */
  32900. isReady: boolean;
  32901. /**
  32902. * Defines if the texture is a cube texture
  32903. */
  32904. isCube: boolean;
  32905. /**
  32906. * Defines if the texture contains 3D data
  32907. */
  32908. is3D: boolean;
  32909. /**
  32910. * Defines if the texture contains 2D array data
  32911. */
  32912. is2DArray: boolean;
  32913. /**
  32914. * Defines if the texture contains multiview data
  32915. */
  32916. isMultiview: boolean;
  32917. /**
  32918. * Gets the URL used to load this texture
  32919. */
  32920. url: string;
  32921. /**
  32922. * Gets the sampling mode of the texture
  32923. */
  32924. samplingMode: number;
  32925. /**
  32926. * Gets a boolean indicating if the texture needs mipmaps generation
  32927. */
  32928. generateMipMaps: boolean;
  32929. /**
  32930. * Gets the number of samples used by the texture (WebGL2+ only)
  32931. */
  32932. samples: number;
  32933. /**
  32934. * Gets the type of the texture (int, float...)
  32935. */
  32936. type: number;
  32937. /**
  32938. * Gets the format of the texture (RGB, RGBA...)
  32939. */
  32940. format: number;
  32941. /**
  32942. * Observable called when the texture is loaded
  32943. */
  32944. onLoadedObservable: Observable<InternalTexture>;
  32945. /**
  32946. * Gets the width of the texture
  32947. */
  32948. width: number;
  32949. /**
  32950. * Gets the height of the texture
  32951. */
  32952. height: number;
  32953. /**
  32954. * Gets the depth of the texture
  32955. */
  32956. depth: number;
  32957. /**
  32958. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32959. */
  32960. baseWidth: number;
  32961. /**
  32962. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32963. */
  32964. baseHeight: number;
  32965. /**
  32966. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32967. */
  32968. baseDepth: number;
  32969. /**
  32970. * Gets a boolean indicating if the texture is inverted on Y axis
  32971. */
  32972. invertY: boolean;
  32973. /** @hidden */
  32974. _invertVScale: boolean;
  32975. /** @hidden */
  32976. _associatedChannel: number;
  32977. /** @hidden */
  32978. _source: InternalTextureSource;
  32979. /** @hidden */
  32980. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32981. /** @hidden */
  32982. _bufferView: Nullable<ArrayBufferView>;
  32983. /** @hidden */
  32984. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32985. /** @hidden */
  32986. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32987. /** @hidden */
  32988. _size: number;
  32989. /** @hidden */
  32990. _extension: string;
  32991. /** @hidden */
  32992. _files: Nullable<string[]>;
  32993. /** @hidden */
  32994. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32995. /** @hidden */
  32996. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32997. /** @hidden */
  32998. _framebuffer: Nullable<WebGLFramebuffer>;
  32999. /** @hidden */
  33000. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33001. /** @hidden */
  33002. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33003. /** @hidden */
  33004. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33005. /** @hidden */
  33006. _attachments: Nullable<number[]>;
  33007. /** @hidden */
  33008. _cachedCoordinatesMode: Nullable<number>;
  33009. /** @hidden */
  33010. _cachedWrapU: Nullable<number>;
  33011. /** @hidden */
  33012. _cachedWrapV: Nullable<number>;
  33013. /** @hidden */
  33014. _cachedWrapR: Nullable<number>;
  33015. /** @hidden */
  33016. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33017. /** @hidden */
  33018. _isDisabled: boolean;
  33019. /** @hidden */
  33020. _compression: Nullable<string>;
  33021. /** @hidden */
  33022. _generateStencilBuffer: boolean;
  33023. /** @hidden */
  33024. _generateDepthBuffer: boolean;
  33025. /** @hidden */
  33026. _comparisonFunction: number;
  33027. /** @hidden */
  33028. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33029. /** @hidden */
  33030. _lodGenerationScale: number;
  33031. /** @hidden */
  33032. _lodGenerationOffset: number;
  33033. /** @hidden */
  33034. _depthStencilTexture: Nullable<InternalTexture>;
  33035. /** @hidden */
  33036. _colorTextureArray: Nullable<WebGLTexture>;
  33037. /** @hidden */
  33038. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33039. /** @hidden */
  33040. _lodTextureHigh: Nullable<BaseTexture>;
  33041. /** @hidden */
  33042. _lodTextureMid: Nullable<BaseTexture>;
  33043. /** @hidden */
  33044. _lodTextureLow: Nullable<BaseTexture>;
  33045. /** @hidden */
  33046. _isRGBD: boolean;
  33047. /** @hidden */
  33048. _linearSpecularLOD: boolean;
  33049. /** @hidden */
  33050. _irradianceTexture: Nullable<BaseTexture>;
  33051. /** @hidden */
  33052. _webGLTexture: Nullable<WebGLTexture>;
  33053. /** @hidden */
  33054. _references: number;
  33055. private _engine;
  33056. /**
  33057. * Gets the Engine the texture belongs to.
  33058. * @returns The babylon engine
  33059. */
  33060. getEngine(): ThinEngine;
  33061. /**
  33062. * Gets the data source type of the texture
  33063. */
  33064. get source(): InternalTextureSource;
  33065. /**
  33066. * Creates a new InternalTexture
  33067. * @param engine defines the engine to use
  33068. * @param source defines the type of data that will be used
  33069. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33070. */
  33071. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33072. /**
  33073. * Increments the number of references (ie. the number of Texture that point to it)
  33074. */
  33075. incrementReferences(): void;
  33076. /**
  33077. * Change the size of the texture (not the size of the content)
  33078. * @param width defines the new width
  33079. * @param height defines the new height
  33080. * @param depth defines the new depth (1 by default)
  33081. */
  33082. updateSize(width: int, height: int, depth?: int): void;
  33083. /** @hidden */
  33084. _rebuild(): void;
  33085. /** @hidden */
  33086. _swapAndDie(target: InternalTexture): void;
  33087. /**
  33088. * Dispose the current allocated resources
  33089. */
  33090. dispose(): void;
  33091. }
  33092. }
  33093. declare module BABYLON {
  33094. /**
  33095. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33097. */
  33098. export class Analyser {
  33099. /**
  33100. * Gets or sets the smoothing
  33101. * @ignorenaming
  33102. */
  33103. SMOOTHING: number;
  33104. /**
  33105. * Gets or sets the FFT table size
  33106. * @ignorenaming
  33107. */
  33108. FFT_SIZE: number;
  33109. /**
  33110. * Gets or sets the bar graph amplitude
  33111. * @ignorenaming
  33112. */
  33113. BARGRAPHAMPLITUDE: number;
  33114. /**
  33115. * Gets or sets the position of the debug canvas
  33116. * @ignorenaming
  33117. */
  33118. DEBUGCANVASPOS: {
  33119. x: number;
  33120. y: number;
  33121. };
  33122. /**
  33123. * Gets or sets the debug canvas size
  33124. * @ignorenaming
  33125. */
  33126. DEBUGCANVASSIZE: {
  33127. width: number;
  33128. height: number;
  33129. };
  33130. private _byteFreqs;
  33131. private _byteTime;
  33132. private _floatFreqs;
  33133. private _webAudioAnalyser;
  33134. private _debugCanvas;
  33135. private _debugCanvasContext;
  33136. private _scene;
  33137. private _registerFunc;
  33138. private _audioEngine;
  33139. /**
  33140. * Creates a new analyser
  33141. * @param scene defines hosting scene
  33142. */
  33143. constructor(scene: Scene);
  33144. /**
  33145. * Get the number of data values you will have to play with for the visualization
  33146. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33147. * @returns a number
  33148. */
  33149. getFrequencyBinCount(): number;
  33150. /**
  33151. * Gets the current frequency data as a byte array
  33152. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33153. * @returns a Uint8Array
  33154. */
  33155. getByteFrequencyData(): Uint8Array;
  33156. /**
  33157. * Gets the current waveform as a byte array
  33158. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33159. * @returns a Uint8Array
  33160. */
  33161. getByteTimeDomainData(): Uint8Array;
  33162. /**
  33163. * Gets the current frequency data as a float array
  33164. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33165. * @returns a Float32Array
  33166. */
  33167. getFloatFrequencyData(): Float32Array;
  33168. /**
  33169. * Renders the debug canvas
  33170. */
  33171. drawDebugCanvas(): void;
  33172. /**
  33173. * Stops rendering the debug canvas and removes it
  33174. */
  33175. stopDebugCanvas(): void;
  33176. /**
  33177. * Connects two audio nodes
  33178. * @param inputAudioNode defines first node to connect
  33179. * @param outputAudioNode defines second node to connect
  33180. */
  33181. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33182. /**
  33183. * Releases all associated resources
  33184. */
  33185. dispose(): void;
  33186. }
  33187. }
  33188. declare module BABYLON {
  33189. /**
  33190. * This represents an audio engine and it is responsible
  33191. * to play, synchronize and analyse sounds throughout the application.
  33192. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33193. */
  33194. export interface IAudioEngine extends IDisposable {
  33195. /**
  33196. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33197. */
  33198. readonly canUseWebAudio: boolean;
  33199. /**
  33200. * Gets the current AudioContext if available.
  33201. */
  33202. readonly audioContext: Nullable<AudioContext>;
  33203. /**
  33204. * The master gain node defines the global audio volume of your audio engine.
  33205. */
  33206. readonly masterGain: GainNode;
  33207. /**
  33208. * Gets whether or not mp3 are supported by your browser.
  33209. */
  33210. readonly isMP3supported: boolean;
  33211. /**
  33212. * Gets whether or not ogg are supported by your browser.
  33213. */
  33214. readonly isOGGsupported: boolean;
  33215. /**
  33216. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33217. * @ignoreNaming
  33218. */
  33219. WarnedWebAudioUnsupported: boolean;
  33220. /**
  33221. * Defines if the audio engine relies on a custom unlocked button.
  33222. * In this case, the embedded button will not be displayed.
  33223. */
  33224. useCustomUnlockedButton: boolean;
  33225. /**
  33226. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33227. */
  33228. readonly unlocked: boolean;
  33229. /**
  33230. * Event raised when audio has been unlocked on the browser.
  33231. */
  33232. onAudioUnlockedObservable: Observable<AudioEngine>;
  33233. /**
  33234. * Event raised when audio has been locked on the browser.
  33235. */
  33236. onAudioLockedObservable: Observable<AudioEngine>;
  33237. /**
  33238. * Flags the audio engine in Locked state.
  33239. * This happens due to new browser policies preventing audio to autoplay.
  33240. */
  33241. lock(): void;
  33242. /**
  33243. * Unlocks the audio engine once a user action has been done on the dom.
  33244. * This is helpful to resume play once browser policies have been satisfied.
  33245. */
  33246. unlock(): void;
  33247. /**
  33248. * Gets the global volume sets on the master gain.
  33249. * @returns the global volume if set or -1 otherwise
  33250. */
  33251. getGlobalVolume(): number;
  33252. /**
  33253. * Sets the global volume of your experience (sets on the master gain).
  33254. * @param newVolume Defines the new global volume of the application
  33255. */
  33256. setGlobalVolume(newVolume: number): void;
  33257. /**
  33258. * Connect the audio engine to an audio analyser allowing some amazing
  33259. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33261. * @param analyser The analyser to connect to the engine
  33262. */
  33263. connectToAnalyser(analyser: Analyser): void;
  33264. }
  33265. /**
  33266. * This represents the default audio engine used in babylon.
  33267. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33269. */
  33270. export class AudioEngine implements IAudioEngine {
  33271. private _audioContext;
  33272. private _audioContextInitialized;
  33273. private _muteButton;
  33274. private _hostElement;
  33275. /**
  33276. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33277. */
  33278. canUseWebAudio: boolean;
  33279. /**
  33280. * The master gain node defines the global audio volume of your audio engine.
  33281. */
  33282. masterGain: GainNode;
  33283. /**
  33284. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33285. * @ignoreNaming
  33286. */
  33287. WarnedWebAudioUnsupported: boolean;
  33288. /**
  33289. * Gets whether or not mp3 are supported by your browser.
  33290. */
  33291. isMP3supported: boolean;
  33292. /**
  33293. * Gets whether or not ogg are supported by your browser.
  33294. */
  33295. isOGGsupported: boolean;
  33296. /**
  33297. * Gets whether audio has been unlocked on the device.
  33298. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33299. * a user interaction has happened.
  33300. */
  33301. unlocked: boolean;
  33302. /**
  33303. * Defines if the audio engine relies on a custom unlocked button.
  33304. * In this case, the embedded button will not be displayed.
  33305. */
  33306. useCustomUnlockedButton: boolean;
  33307. /**
  33308. * Event raised when audio has been unlocked on the browser.
  33309. */
  33310. onAudioUnlockedObservable: Observable<AudioEngine>;
  33311. /**
  33312. * Event raised when audio has been locked on the browser.
  33313. */
  33314. onAudioLockedObservable: Observable<AudioEngine>;
  33315. /**
  33316. * Gets the current AudioContext if available.
  33317. */
  33318. get audioContext(): Nullable<AudioContext>;
  33319. private _connectedAnalyser;
  33320. /**
  33321. * Instantiates a new audio engine.
  33322. *
  33323. * There should be only one per page as some browsers restrict the number
  33324. * of audio contexts you can create.
  33325. * @param hostElement defines the host element where to display the mute icon if necessary
  33326. */
  33327. constructor(hostElement?: Nullable<HTMLElement>);
  33328. /**
  33329. * Flags the audio engine in Locked state.
  33330. * This happens due to new browser policies preventing audio to autoplay.
  33331. */
  33332. lock(): void;
  33333. /**
  33334. * Unlocks the audio engine once a user action has been done on the dom.
  33335. * This is helpful to resume play once browser policies have been satisfied.
  33336. */
  33337. unlock(): void;
  33338. private _resumeAudioContext;
  33339. private _initializeAudioContext;
  33340. private _tryToRun;
  33341. private _triggerRunningState;
  33342. private _triggerSuspendedState;
  33343. private _displayMuteButton;
  33344. private _moveButtonToTopLeft;
  33345. private _onResize;
  33346. private _hideMuteButton;
  33347. /**
  33348. * Destroy and release the resources associated with the audio ccontext.
  33349. */
  33350. dispose(): void;
  33351. /**
  33352. * Gets the global volume sets on the master gain.
  33353. * @returns the global volume if set or -1 otherwise
  33354. */
  33355. getGlobalVolume(): number;
  33356. /**
  33357. * Sets the global volume of your experience (sets on the master gain).
  33358. * @param newVolume Defines the new global volume of the application
  33359. */
  33360. setGlobalVolume(newVolume: number): void;
  33361. /**
  33362. * Connect the audio engine to an audio analyser allowing some amazing
  33363. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33365. * @param analyser The analyser to connect to the engine
  33366. */
  33367. connectToAnalyser(analyser: Analyser): void;
  33368. }
  33369. }
  33370. declare module BABYLON {
  33371. /**
  33372. * Interface used to present a loading screen while loading a scene
  33373. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33374. */
  33375. export interface ILoadingScreen {
  33376. /**
  33377. * Function called to display the loading screen
  33378. */
  33379. displayLoadingUI: () => void;
  33380. /**
  33381. * Function called to hide the loading screen
  33382. */
  33383. hideLoadingUI: () => void;
  33384. /**
  33385. * Gets or sets the color to use for the background
  33386. */
  33387. loadingUIBackgroundColor: string;
  33388. /**
  33389. * Gets or sets the text to display while loading
  33390. */
  33391. loadingUIText: string;
  33392. }
  33393. /**
  33394. * Class used for the default loading screen
  33395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33396. */
  33397. export class DefaultLoadingScreen implements ILoadingScreen {
  33398. private _renderingCanvas;
  33399. private _loadingText;
  33400. private _loadingDivBackgroundColor;
  33401. private _loadingDiv;
  33402. private _loadingTextDiv;
  33403. /** Gets or sets the logo url to use for the default loading screen */
  33404. static DefaultLogoUrl: string;
  33405. /** Gets or sets the spinner url to use for the default loading screen */
  33406. static DefaultSpinnerUrl: string;
  33407. /**
  33408. * Creates a new default loading screen
  33409. * @param _renderingCanvas defines the canvas used to render the scene
  33410. * @param _loadingText defines the default text to display
  33411. * @param _loadingDivBackgroundColor defines the default background color
  33412. */
  33413. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33414. /**
  33415. * Function called to display the loading screen
  33416. */
  33417. displayLoadingUI(): void;
  33418. /**
  33419. * Function called to hide the loading screen
  33420. */
  33421. hideLoadingUI(): void;
  33422. /**
  33423. * Gets or sets the text to display while loading
  33424. */
  33425. set loadingUIText(text: string);
  33426. get loadingUIText(): string;
  33427. /**
  33428. * Gets or sets the color to use for the background
  33429. */
  33430. get loadingUIBackgroundColor(): string;
  33431. set loadingUIBackgroundColor(color: string);
  33432. private _resizeLoadingUI;
  33433. }
  33434. }
  33435. declare module BABYLON {
  33436. /**
  33437. * Interface for any object that can request an animation frame
  33438. */
  33439. export interface ICustomAnimationFrameRequester {
  33440. /**
  33441. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33442. */
  33443. renderFunction?: Function;
  33444. /**
  33445. * Called to request the next frame to render to
  33446. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33447. */
  33448. requestAnimationFrame: Function;
  33449. /**
  33450. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33451. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33452. */
  33453. requestID?: number;
  33454. }
  33455. }
  33456. declare module BABYLON {
  33457. /**
  33458. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33459. */
  33460. export class PerformanceMonitor {
  33461. private _enabled;
  33462. private _rollingFrameTime;
  33463. private _lastFrameTimeMs;
  33464. /**
  33465. * constructor
  33466. * @param frameSampleSize The number of samples required to saturate the sliding window
  33467. */
  33468. constructor(frameSampleSize?: number);
  33469. /**
  33470. * Samples current frame
  33471. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33472. */
  33473. sampleFrame(timeMs?: number): void;
  33474. /**
  33475. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33476. */
  33477. get averageFrameTime(): number;
  33478. /**
  33479. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33480. */
  33481. get averageFrameTimeVariance(): number;
  33482. /**
  33483. * Returns the frame time of the most recent frame
  33484. */
  33485. get instantaneousFrameTime(): number;
  33486. /**
  33487. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33488. */
  33489. get averageFPS(): number;
  33490. /**
  33491. * Returns the average framerate in frames per second using the most recent frame time
  33492. */
  33493. get instantaneousFPS(): number;
  33494. /**
  33495. * Returns true if enough samples have been taken to completely fill the sliding window
  33496. */
  33497. get isSaturated(): boolean;
  33498. /**
  33499. * Enables contributions to the sliding window sample set
  33500. */
  33501. enable(): void;
  33502. /**
  33503. * Disables contributions to the sliding window sample set
  33504. * Samples will not be interpolated over the disabled period
  33505. */
  33506. disable(): void;
  33507. /**
  33508. * Returns true if sampling is enabled
  33509. */
  33510. get isEnabled(): boolean;
  33511. /**
  33512. * Resets performance monitor
  33513. */
  33514. reset(): void;
  33515. }
  33516. /**
  33517. * RollingAverage
  33518. *
  33519. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33520. */
  33521. export class RollingAverage {
  33522. /**
  33523. * Current average
  33524. */
  33525. average: number;
  33526. /**
  33527. * Current variance
  33528. */
  33529. variance: number;
  33530. protected _samples: Array<number>;
  33531. protected _sampleCount: number;
  33532. protected _pos: number;
  33533. protected _m2: number;
  33534. /**
  33535. * constructor
  33536. * @param length The number of samples required to saturate the sliding window
  33537. */
  33538. constructor(length: number);
  33539. /**
  33540. * Adds a sample to the sample set
  33541. * @param v The sample value
  33542. */
  33543. add(v: number): void;
  33544. /**
  33545. * Returns previously added values or null if outside of history or outside the sliding window domain
  33546. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33547. * @return Value previously recorded with add() or null if outside of range
  33548. */
  33549. history(i: number): number;
  33550. /**
  33551. * Returns true if enough samples have been taken to completely fill the sliding window
  33552. * @return true if sample-set saturated
  33553. */
  33554. isSaturated(): boolean;
  33555. /**
  33556. * Resets the rolling average (equivalent to 0 samples taken so far)
  33557. */
  33558. reset(): void;
  33559. /**
  33560. * Wraps a value around the sample range boundaries
  33561. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33562. * @return Wrapped position in sample range
  33563. */
  33564. protected _wrapPosition(i: number): number;
  33565. }
  33566. }
  33567. declare module BABYLON {
  33568. /**
  33569. * This class is used to track a performance counter which is number based.
  33570. * The user has access to many properties which give statistics of different nature.
  33571. *
  33572. * The implementer can track two kinds of Performance Counter: time and count.
  33573. * 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.
  33574. * 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.
  33575. */
  33576. export class PerfCounter {
  33577. /**
  33578. * Gets or sets a global boolean to turn on and off all the counters
  33579. */
  33580. static Enabled: boolean;
  33581. /**
  33582. * Returns the smallest value ever
  33583. */
  33584. get min(): number;
  33585. /**
  33586. * Returns the biggest value ever
  33587. */
  33588. get max(): number;
  33589. /**
  33590. * Returns the average value since the performance counter is running
  33591. */
  33592. get average(): number;
  33593. /**
  33594. * Returns the average value of the last second the counter was monitored
  33595. */
  33596. get lastSecAverage(): number;
  33597. /**
  33598. * Returns the current value
  33599. */
  33600. get current(): number;
  33601. /**
  33602. * Gets the accumulated total
  33603. */
  33604. get total(): number;
  33605. /**
  33606. * Gets the total value count
  33607. */
  33608. get count(): number;
  33609. /**
  33610. * Creates a new counter
  33611. */
  33612. constructor();
  33613. /**
  33614. * Call this method to start monitoring a new frame.
  33615. * 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.
  33616. */
  33617. fetchNewFrame(): void;
  33618. /**
  33619. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33620. * @param newCount the count value to add to the monitored count
  33621. * @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.
  33622. */
  33623. addCount(newCount: number, fetchResult: boolean): void;
  33624. /**
  33625. * Start monitoring this performance counter
  33626. */
  33627. beginMonitoring(): void;
  33628. /**
  33629. * Compute the time lapsed since the previous beginMonitoring() call.
  33630. * @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
  33631. */
  33632. endMonitoring(newFrame?: boolean): void;
  33633. private _fetchResult;
  33634. private _startMonitoringTime;
  33635. private _min;
  33636. private _max;
  33637. private _average;
  33638. private _current;
  33639. private _totalValueCount;
  33640. private _totalAccumulated;
  33641. private _lastSecAverage;
  33642. private _lastSecAccumulated;
  33643. private _lastSecTime;
  33644. private _lastSecValueCount;
  33645. }
  33646. }
  33647. declare module BABYLON {
  33648. interface ThinEngine {
  33649. /**
  33650. * Sets alpha constants used by some alpha blending modes
  33651. * @param r defines the red component
  33652. * @param g defines the green component
  33653. * @param b defines the blue component
  33654. * @param a defines the alpha component
  33655. */
  33656. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33657. /**
  33658. * Sets the current alpha mode
  33659. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33660. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33661. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33662. */
  33663. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33664. /**
  33665. * Gets the current alpha mode
  33666. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33667. * @returns the current alpha mode
  33668. */
  33669. getAlphaMode(): number;
  33670. /**
  33671. * Sets the current alpha equation
  33672. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33673. */
  33674. setAlphaEquation(equation: number): void;
  33675. /**
  33676. * Gets the current alpha equation.
  33677. * @returns the current alpha equation
  33678. */
  33679. getAlphaEquation(): number;
  33680. }
  33681. }
  33682. declare module BABYLON {
  33683. interface ThinEngine {
  33684. /** @hidden */
  33685. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33686. }
  33687. }
  33688. declare module BABYLON {
  33689. /**
  33690. * Defines the interface used by display changed events
  33691. */
  33692. export interface IDisplayChangedEventArgs {
  33693. /** Gets the vrDisplay object (if any) */
  33694. vrDisplay: Nullable<any>;
  33695. /** Gets a boolean indicating if webVR is supported */
  33696. vrSupported: boolean;
  33697. }
  33698. /**
  33699. * Defines the interface used by objects containing a viewport (like a camera)
  33700. */
  33701. interface IViewportOwnerLike {
  33702. /**
  33703. * Gets or sets the viewport
  33704. */
  33705. viewport: IViewportLike;
  33706. }
  33707. /**
  33708. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33709. */
  33710. export class Engine extends ThinEngine {
  33711. /** Defines that alpha blending is disabled */
  33712. static readonly ALPHA_DISABLE: number;
  33713. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33714. static readonly ALPHA_ADD: number;
  33715. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33716. static readonly ALPHA_COMBINE: number;
  33717. /** Defines that alpha blending to DEST - SRC * DEST */
  33718. static readonly ALPHA_SUBTRACT: number;
  33719. /** Defines that alpha blending to SRC * DEST */
  33720. static readonly ALPHA_MULTIPLY: number;
  33721. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33722. static readonly ALPHA_MAXIMIZED: number;
  33723. /** Defines that alpha blending to SRC + DEST */
  33724. static readonly ALPHA_ONEONE: number;
  33725. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33726. static readonly ALPHA_PREMULTIPLIED: number;
  33727. /**
  33728. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33729. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33730. */
  33731. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33732. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33733. static readonly ALPHA_INTERPOLATE: number;
  33734. /**
  33735. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33736. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33737. */
  33738. static readonly ALPHA_SCREENMODE: number;
  33739. /** Defines that the ressource is not delayed*/
  33740. static readonly DELAYLOADSTATE_NONE: number;
  33741. /** Defines that the ressource was successfully delay loaded */
  33742. static readonly DELAYLOADSTATE_LOADED: number;
  33743. /** Defines that the ressource is currently delay loading */
  33744. static readonly DELAYLOADSTATE_LOADING: number;
  33745. /** Defines that the ressource is delayed and has not started loading */
  33746. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33747. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33748. static readonly NEVER: number;
  33749. /** 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 */
  33750. static readonly ALWAYS: number;
  33751. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33752. static readonly LESS: number;
  33753. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33754. static readonly EQUAL: number;
  33755. /** 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 */
  33756. static readonly LEQUAL: number;
  33757. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33758. static readonly GREATER: number;
  33759. /** 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 */
  33760. static readonly GEQUAL: number;
  33761. /** 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 */
  33762. static readonly NOTEQUAL: number;
  33763. /** Passed to stencilOperation to specify that stencil value must be kept */
  33764. static readonly KEEP: number;
  33765. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33766. static readonly REPLACE: number;
  33767. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33768. static readonly INCR: number;
  33769. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33770. static readonly DECR: number;
  33771. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33772. static readonly INVERT: number;
  33773. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33774. static readonly INCR_WRAP: number;
  33775. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33776. static readonly DECR_WRAP: number;
  33777. /** Texture is not repeating outside of 0..1 UVs */
  33778. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33779. /** Texture is repeating outside of 0..1 UVs */
  33780. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33781. /** Texture is repeating and mirrored */
  33782. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33783. /** ALPHA */
  33784. static readonly TEXTUREFORMAT_ALPHA: number;
  33785. /** LUMINANCE */
  33786. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33787. /** LUMINANCE_ALPHA */
  33788. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33789. /** RGB */
  33790. static readonly TEXTUREFORMAT_RGB: number;
  33791. /** RGBA */
  33792. static readonly TEXTUREFORMAT_RGBA: number;
  33793. /** RED */
  33794. static readonly TEXTUREFORMAT_RED: number;
  33795. /** RED (2nd reference) */
  33796. static readonly TEXTUREFORMAT_R: number;
  33797. /** RG */
  33798. static readonly TEXTUREFORMAT_RG: number;
  33799. /** RED_INTEGER */
  33800. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33801. /** RED_INTEGER (2nd reference) */
  33802. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33803. /** RG_INTEGER */
  33804. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33805. /** RGB_INTEGER */
  33806. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33807. /** RGBA_INTEGER */
  33808. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33809. /** UNSIGNED_BYTE */
  33810. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33811. /** UNSIGNED_BYTE (2nd reference) */
  33812. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33813. /** FLOAT */
  33814. static readonly TEXTURETYPE_FLOAT: number;
  33815. /** HALF_FLOAT */
  33816. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33817. /** BYTE */
  33818. static readonly TEXTURETYPE_BYTE: number;
  33819. /** SHORT */
  33820. static readonly TEXTURETYPE_SHORT: number;
  33821. /** UNSIGNED_SHORT */
  33822. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33823. /** INT */
  33824. static readonly TEXTURETYPE_INT: number;
  33825. /** UNSIGNED_INT */
  33826. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33827. /** UNSIGNED_SHORT_4_4_4_4 */
  33828. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33829. /** UNSIGNED_SHORT_5_5_5_1 */
  33830. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33831. /** UNSIGNED_SHORT_5_6_5 */
  33832. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33833. /** UNSIGNED_INT_2_10_10_10_REV */
  33834. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33835. /** UNSIGNED_INT_24_8 */
  33836. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33837. /** UNSIGNED_INT_10F_11F_11F_REV */
  33838. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33839. /** UNSIGNED_INT_5_9_9_9_REV */
  33840. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33841. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33842. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33843. /** nearest is mag = nearest and min = nearest and mip = linear */
  33844. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33845. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33846. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33847. /** Trilinear is mag = linear and min = linear and mip = linear */
  33848. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33849. /** nearest is mag = nearest and min = nearest and mip = linear */
  33850. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33851. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33852. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33853. /** Trilinear is mag = linear and min = linear and mip = linear */
  33854. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33855. /** mag = nearest and min = nearest and mip = nearest */
  33856. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33857. /** mag = nearest and min = linear and mip = nearest */
  33858. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33859. /** mag = nearest and min = linear and mip = linear */
  33860. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33861. /** mag = nearest and min = linear and mip = none */
  33862. static readonly TEXTURE_NEAREST_LINEAR: number;
  33863. /** mag = nearest and min = nearest and mip = none */
  33864. static readonly TEXTURE_NEAREST_NEAREST: number;
  33865. /** mag = linear and min = nearest and mip = nearest */
  33866. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33867. /** mag = linear and min = nearest and mip = linear */
  33868. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33869. /** mag = linear and min = linear and mip = none */
  33870. static readonly TEXTURE_LINEAR_LINEAR: number;
  33871. /** mag = linear and min = nearest and mip = none */
  33872. static readonly TEXTURE_LINEAR_NEAREST: number;
  33873. /** Explicit coordinates mode */
  33874. static readonly TEXTURE_EXPLICIT_MODE: number;
  33875. /** Spherical coordinates mode */
  33876. static readonly TEXTURE_SPHERICAL_MODE: number;
  33877. /** Planar coordinates mode */
  33878. static readonly TEXTURE_PLANAR_MODE: number;
  33879. /** Cubic coordinates mode */
  33880. static readonly TEXTURE_CUBIC_MODE: number;
  33881. /** Projection coordinates mode */
  33882. static readonly TEXTURE_PROJECTION_MODE: number;
  33883. /** Skybox coordinates mode */
  33884. static readonly TEXTURE_SKYBOX_MODE: number;
  33885. /** Inverse Cubic coordinates mode */
  33886. static readonly TEXTURE_INVCUBIC_MODE: number;
  33887. /** Equirectangular coordinates mode */
  33888. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33889. /** Equirectangular Fixed coordinates mode */
  33890. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33891. /** Equirectangular Fixed Mirrored coordinates mode */
  33892. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33893. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33894. static readonly SCALEMODE_FLOOR: number;
  33895. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33896. static readonly SCALEMODE_NEAREST: number;
  33897. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33898. static readonly SCALEMODE_CEILING: number;
  33899. /**
  33900. * Returns the current npm package of the sdk
  33901. */
  33902. static get NpmPackage(): string;
  33903. /**
  33904. * Returns the current version of the framework
  33905. */
  33906. static get Version(): string;
  33907. /** Gets the list of created engines */
  33908. static get Instances(): Engine[];
  33909. /**
  33910. * Gets the latest created engine
  33911. */
  33912. static get LastCreatedEngine(): Nullable<Engine>;
  33913. /**
  33914. * Gets the latest created scene
  33915. */
  33916. static get LastCreatedScene(): Nullable<Scene>;
  33917. /**
  33918. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33919. * @param flag defines which part of the materials must be marked as dirty
  33920. * @param predicate defines a predicate used to filter which materials should be affected
  33921. */
  33922. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33923. /**
  33924. * Method called to create the default loading screen.
  33925. * This can be overriden in your own app.
  33926. * @param canvas The rendering canvas element
  33927. * @returns The loading screen
  33928. */
  33929. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33930. /**
  33931. * Method called to create the default rescale post process on each engine.
  33932. */
  33933. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33934. /**
  33935. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33936. **/
  33937. enableOfflineSupport: boolean;
  33938. /**
  33939. * 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)
  33940. **/
  33941. disableManifestCheck: boolean;
  33942. /**
  33943. * Gets the list of created scenes
  33944. */
  33945. scenes: Scene[];
  33946. /**
  33947. * Event raised when a new scene is created
  33948. */
  33949. onNewSceneAddedObservable: Observable<Scene>;
  33950. /**
  33951. * Gets the list of created postprocesses
  33952. */
  33953. postProcesses: PostProcess[];
  33954. /**
  33955. * Gets a boolean indicating if the pointer is currently locked
  33956. */
  33957. isPointerLock: boolean;
  33958. /**
  33959. * Observable event triggered each time the rendering canvas is resized
  33960. */
  33961. onResizeObservable: Observable<Engine>;
  33962. /**
  33963. * Observable event triggered each time the canvas loses focus
  33964. */
  33965. onCanvasBlurObservable: Observable<Engine>;
  33966. /**
  33967. * Observable event triggered each time the canvas gains focus
  33968. */
  33969. onCanvasFocusObservable: Observable<Engine>;
  33970. /**
  33971. * Observable event triggered each time the canvas receives pointerout event
  33972. */
  33973. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33974. /**
  33975. * Observable raised when the engine begins a new frame
  33976. */
  33977. onBeginFrameObservable: Observable<Engine>;
  33978. /**
  33979. * If set, will be used to request the next animation frame for the render loop
  33980. */
  33981. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33982. /**
  33983. * Observable raised when the engine ends the current frame
  33984. */
  33985. onEndFrameObservable: Observable<Engine>;
  33986. /**
  33987. * Observable raised when the engine is about to compile a shader
  33988. */
  33989. onBeforeShaderCompilationObservable: Observable<Engine>;
  33990. /**
  33991. * Observable raised when the engine has jsut compiled a shader
  33992. */
  33993. onAfterShaderCompilationObservable: Observable<Engine>;
  33994. /**
  33995. * Gets the audio engine
  33996. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33997. * @ignorenaming
  33998. */
  33999. static audioEngine: IAudioEngine;
  34000. /**
  34001. * Default AudioEngine factory responsible of creating the Audio Engine.
  34002. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34003. */
  34004. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34005. /**
  34006. * Default offline support factory responsible of creating a tool used to store data locally.
  34007. * By default, this will create a Database object if the workload has been embedded.
  34008. */
  34009. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34010. private _loadingScreen;
  34011. private _pointerLockRequested;
  34012. private _rescalePostProcess;
  34013. private _deterministicLockstep;
  34014. private _lockstepMaxSteps;
  34015. private _timeStep;
  34016. protected get _supportsHardwareTextureRescaling(): boolean;
  34017. private _fps;
  34018. private _deltaTime;
  34019. /** @hidden */
  34020. _drawCalls: PerfCounter;
  34021. /** 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 */
  34022. canvasTabIndex: number;
  34023. /**
  34024. * Turn this value on if you want to pause FPS computation when in background
  34025. */
  34026. disablePerformanceMonitorInBackground: boolean;
  34027. private _performanceMonitor;
  34028. /**
  34029. * Gets the performance monitor attached to this engine
  34030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34031. */
  34032. get performanceMonitor(): PerformanceMonitor;
  34033. private _onFocus;
  34034. private _onBlur;
  34035. private _onCanvasPointerOut;
  34036. private _onCanvasBlur;
  34037. private _onCanvasFocus;
  34038. private _onFullscreenChange;
  34039. private _onPointerLockChange;
  34040. /**
  34041. * Gets the HTML element used to attach event listeners
  34042. * @returns a HTML element
  34043. */
  34044. getInputElement(): Nullable<HTMLElement>;
  34045. /**
  34046. * Creates a new engine
  34047. * @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
  34048. * @param antialias defines enable antialiasing (default: false)
  34049. * @param options defines further options to be sent to the getContext() function
  34050. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34051. */
  34052. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34053. /**
  34054. * Gets current aspect ratio
  34055. * @param viewportOwner defines the camera to use to get the aspect ratio
  34056. * @param useScreen defines if screen size must be used (or the current render target if any)
  34057. * @returns a number defining the aspect ratio
  34058. */
  34059. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34060. /**
  34061. * Gets current screen aspect ratio
  34062. * @returns a number defining the aspect ratio
  34063. */
  34064. getScreenAspectRatio(): number;
  34065. /**
  34066. * Gets the client rect of the HTML canvas attached with the current webGL context
  34067. * @returns a client rectanglee
  34068. */
  34069. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34070. /**
  34071. * Gets the client rect of the HTML element used for events
  34072. * @returns a client rectanglee
  34073. */
  34074. getInputElementClientRect(): Nullable<ClientRect>;
  34075. /**
  34076. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34077. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34078. * @returns true if engine is in deterministic lock step mode
  34079. */
  34080. isDeterministicLockStep(): boolean;
  34081. /**
  34082. * Gets the max steps when engine is running in deterministic lock step
  34083. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34084. * @returns the max steps
  34085. */
  34086. getLockstepMaxSteps(): number;
  34087. /**
  34088. * Returns the time in ms between steps when using deterministic lock step.
  34089. * @returns time step in (ms)
  34090. */
  34091. getTimeStep(): number;
  34092. /**
  34093. * Force the mipmap generation for the given render target texture
  34094. * @param texture defines the render target texture to use
  34095. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34096. */
  34097. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34098. /** States */
  34099. /**
  34100. * Set various states to the webGL context
  34101. * @param culling defines backface culling state
  34102. * @param zOffset defines the value to apply to zOffset (0 by default)
  34103. * @param force defines if states must be applied even if cache is up to date
  34104. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34105. */
  34106. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34107. /**
  34108. * Set the z offset to apply to current rendering
  34109. * @param value defines the offset to apply
  34110. */
  34111. setZOffset(value: number): void;
  34112. /**
  34113. * Gets the current value of the zOffset
  34114. * @returns the current zOffset state
  34115. */
  34116. getZOffset(): number;
  34117. /**
  34118. * Enable or disable depth buffering
  34119. * @param enable defines the state to set
  34120. */
  34121. setDepthBuffer(enable: boolean): void;
  34122. /**
  34123. * Gets a boolean indicating if depth writing is enabled
  34124. * @returns the current depth writing state
  34125. */
  34126. getDepthWrite(): boolean;
  34127. /**
  34128. * Enable or disable depth writing
  34129. * @param enable defines the state to set
  34130. */
  34131. setDepthWrite(enable: boolean): void;
  34132. /**
  34133. * Gets a boolean indicating if stencil buffer is enabled
  34134. * @returns the current stencil buffer state
  34135. */
  34136. getStencilBuffer(): boolean;
  34137. /**
  34138. * Enable or disable the stencil buffer
  34139. * @param enable defines if the stencil buffer must be enabled or disabled
  34140. */
  34141. setStencilBuffer(enable: boolean): void;
  34142. /**
  34143. * Gets the current stencil mask
  34144. * @returns a number defining the new stencil mask to use
  34145. */
  34146. getStencilMask(): number;
  34147. /**
  34148. * Sets the current stencil mask
  34149. * @param mask defines the new stencil mask to use
  34150. */
  34151. setStencilMask(mask: number): void;
  34152. /**
  34153. * Gets the current stencil function
  34154. * @returns a number defining the stencil function to use
  34155. */
  34156. getStencilFunction(): number;
  34157. /**
  34158. * Gets the current stencil reference value
  34159. * @returns a number defining the stencil reference value to use
  34160. */
  34161. getStencilFunctionReference(): number;
  34162. /**
  34163. * Gets the current stencil mask
  34164. * @returns a number defining the stencil mask to use
  34165. */
  34166. getStencilFunctionMask(): number;
  34167. /**
  34168. * Sets the current stencil function
  34169. * @param stencilFunc defines the new stencil function to use
  34170. */
  34171. setStencilFunction(stencilFunc: number): void;
  34172. /**
  34173. * Sets the current stencil reference
  34174. * @param reference defines the new stencil reference to use
  34175. */
  34176. setStencilFunctionReference(reference: number): void;
  34177. /**
  34178. * Sets the current stencil mask
  34179. * @param mask defines the new stencil mask to use
  34180. */
  34181. setStencilFunctionMask(mask: number): void;
  34182. /**
  34183. * Gets the current stencil operation when stencil fails
  34184. * @returns a number defining stencil operation to use when stencil fails
  34185. */
  34186. getStencilOperationFail(): number;
  34187. /**
  34188. * Gets the current stencil operation when depth fails
  34189. * @returns a number defining stencil operation to use when depth fails
  34190. */
  34191. getStencilOperationDepthFail(): number;
  34192. /**
  34193. * Gets the current stencil operation when stencil passes
  34194. * @returns a number defining stencil operation to use when stencil passes
  34195. */
  34196. getStencilOperationPass(): number;
  34197. /**
  34198. * Sets the stencil operation to use when stencil fails
  34199. * @param operation defines the stencil operation to use when stencil fails
  34200. */
  34201. setStencilOperationFail(operation: number): void;
  34202. /**
  34203. * Sets the stencil operation to use when depth fails
  34204. * @param operation defines the stencil operation to use when depth fails
  34205. */
  34206. setStencilOperationDepthFail(operation: number): void;
  34207. /**
  34208. * Sets the stencil operation to use when stencil passes
  34209. * @param operation defines the stencil operation to use when stencil passes
  34210. */
  34211. setStencilOperationPass(operation: number): void;
  34212. /**
  34213. * Sets a boolean indicating if the dithering state is enabled or disabled
  34214. * @param value defines the dithering state
  34215. */
  34216. setDitheringState(value: boolean): void;
  34217. /**
  34218. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34219. * @param value defines the rasterizer state
  34220. */
  34221. setRasterizerState(value: boolean): void;
  34222. /**
  34223. * Gets the current depth function
  34224. * @returns a number defining the depth function
  34225. */
  34226. getDepthFunction(): Nullable<number>;
  34227. /**
  34228. * Sets the current depth function
  34229. * @param depthFunc defines the function to use
  34230. */
  34231. setDepthFunction(depthFunc: number): void;
  34232. /**
  34233. * Sets the current depth function to GREATER
  34234. */
  34235. setDepthFunctionToGreater(): void;
  34236. /**
  34237. * Sets the current depth function to GEQUAL
  34238. */
  34239. setDepthFunctionToGreaterOrEqual(): void;
  34240. /**
  34241. * Sets the current depth function to LESS
  34242. */
  34243. setDepthFunctionToLess(): void;
  34244. /**
  34245. * Sets the current depth function to LEQUAL
  34246. */
  34247. setDepthFunctionToLessOrEqual(): void;
  34248. private _cachedStencilBuffer;
  34249. private _cachedStencilFunction;
  34250. private _cachedStencilMask;
  34251. private _cachedStencilOperationPass;
  34252. private _cachedStencilOperationFail;
  34253. private _cachedStencilOperationDepthFail;
  34254. private _cachedStencilReference;
  34255. /**
  34256. * Caches the the state of the stencil buffer
  34257. */
  34258. cacheStencilState(): void;
  34259. /**
  34260. * Restores the state of the stencil buffer
  34261. */
  34262. restoreStencilState(): void;
  34263. /**
  34264. * Directly set the WebGL Viewport
  34265. * @param x defines the x coordinate of the viewport (in screen space)
  34266. * @param y defines the y coordinate of the viewport (in screen space)
  34267. * @param width defines the width of the viewport (in screen space)
  34268. * @param height defines the height of the viewport (in screen space)
  34269. * @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
  34270. */
  34271. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34272. /**
  34273. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34274. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34275. * @param y defines the y-coordinate of the corner of the clear rectangle
  34276. * @param width defines the width of the clear rectangle
  34277. * @param height defines the height of the clear rectangle
  34278. * @param clearColor defines the clear color
  34279. */
  34280. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34281. /**
  34282. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34283. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34284. * @param y defines the y-coordinate of the corner of the clear rectangle
  34285. * @param width defines the width of the clear rectangle
  34286. * @param height defines the height of the clear rectangle
  34287. */
  34288. enableScissor(x: number, y: number, width: number, height: number): void;
  34289. /**
  34290. * Disable previously set scissor test rectangle
  34291. */
  34292. disableScissor(): void;
  34293. protected _reportDrawCall(): void;
  34294. /**
  34295. * Initializes a webVR display and starts listening to display change events
  34296. * The onVRDisplayChangedObservable will be notified upon these changes
  34297. * @returns The onVRDisplayChangedObservable
  34298. */
  34299. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34300. /** @hidden */
  34301. _prepareVRComponent(): void;
  34302. /** @hidden */
  34303. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34304. /** @hidden */
  34305. _submitVRFrame(): void;
  34306. /**
  34307. * Call this function to leave webVR mode
  34308. * Will do nothing if webVR is not supported or if there is no webVR device
  34309. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34310. */
  34311. disableVR(): void;
  34312. /**
  34313. * Gets a boolean indicating that the system is in VR mode and is presenting
  34314. * @returns true if VR mode is engaged
  34315. */
  34316. isVRPresenting(): boolean;
  34317. /** @hidden */
  34318. _requestVRFrame(): void;
  34319. /** @hidden */
  34320. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34321. /**
  34322. * Gets the source code of the vertex shader associated with a specific webGL program
  34323. * @param program defines the program to use
  34324. * @returns a string containing the source code of the vertex shader associated with the program
  34325. */
  34326. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34327. /**
  34328. * Gets the source code of the fragment shader associated with a specific webGL program
  34329. * @param program defines the program to use
  34330. * @returns a string containing the source code of the fragment shader associated with the program
  34331. */
  34332. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34333. /**
  34334. * Sets a depth stencil texture from a render target to the according uniform.
  34335. * @param channel The texture channel
  34336. * @param uniform The uniform to set
  34337. * @param texture The render target texture containing the depth stencil texture to apply
  34338. */
  34339. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34340. /**
  34341. * Sets a texture to the webGL context from a postprocess
  34342. * @param channel defines the channel to use
  34343. * @param postProcess defines the source postprocess
  34344. */
  34345. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34346. /**
  34347. * Binds the output of the passed in post process to the texture channel specified
  34348. * @param channel The channel the texture should be bound to
  34349. * @param postProcess The post process which's output should be bound
  34350. */
  34351. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34352. protected _rebuildBuffers(): void;
  34353. /** @hidden */
  34354. _renderFrame(): void;
  34355. _renderLoop(): void;
  34356. /** @hidden */
  34357. _renderViews(): boolean;
  34358. /**
  34359. * Toggle full screen mode
  34360. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34361. */
  34362. switchFullscreen(requestPointerLock: boolean): void;
  34363. /**
  34364. * Enters full screen mode
  34365. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34366. */
  34367. enterFullscreen(requestPointerLock: boolean): void;
  34368. /**
  34369. * Exits full screen mode
  34370. */
  34371. exitFullscreen(): void;
  34372. /**
  34373. * Enters Pointerlock mode
  34374. */
  34375. enterPointerlock(): void;
  34376. /**
  34377. * Exits Pointerlock mode
  34378. */
  34379. exitPointerlock(): void;
  34380. /**
  34381. * Begin a new frame
  34382. */
  34383. beginFrame(): void;
  34384. /**
  34385. * Enf the current frame
  34386. */
  34387. endFrame(): void;
  34388. resize(): void;
  34389. /**
  34390. * Force a specific size of the canvas
  34391. * @param width defines the new canvas' width
  34392. * @param height defines the new canvas' height
  34393. */
  34394. setSize(width: number, height: number): void;
  34395. /**
  34396. * Updates a dynamic vertex buffer.
  34397. * @param vertexBuffer the vertex buffer to update
  34398. * @param data the data used to update the vertex buffer
  34399. * @param byteOffset the byte offset of the data
  34400. * @param byteLength the byte length of the data
  34401. */
  34402. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34403. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34404. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34405. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34406. _releaseTexture(texture: InternalTexture): void;
  34407. /**
  34408. * @hidden
  34409. * Rescales a texture
  34410. * @param source input texutre
  34411. * @param destination destination texture
  34412. * @param scene scene to use to render the resize
  34413. * @param internalFormat format to use when resizing
  34414. * @param onComplete callback to be called when resize has completed
  34415. */
  34416. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34417. /**
  34418. * Gets the current framerate
  34419. * @returns a number representing the framerate
  34420. */
  34421. getFps(): number;
  34422. /**
  34423. * Gets the time spent between current and previous frame
  34424. * @returns a number representing the delta time in ms
  34425. */
  34426. getDeltaTime(): number;
  34427. private _measureFps;
  34428. /** @hidden */
  34429. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34430. /**
  34431. * Update a dynamic index buffer
  34432. * @param indexBuffer defines the target index buffer
  34433. * @param indices defines the data to update
  34434. * @param offset defines the offset in the target index buffer where update should start
  34435. */
  34436. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34437. /**
  34438. * Updates the sample count of a render target texture
  34439. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34440. * @param texture defines the texture to update
  34441. * @param samples defines the sample count to set
  34442. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34443. */
  34444. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34445. /**
  34446. * Updates a depth texture Comparison Mode and Function.
  34447. * If the comparison Function is equal to 0, the mode will be set to none.
  34448. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34449. * @param texture The texture to set the comparison function for
  34450. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34451. */
  34452. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34453. /**
  34454. * Creates a webGL buffer to use with instanciation
  34455. * @param capacity defines the size of the buffer
  34456. * @returns the webGL buffer
  34457. */
  34458. createInstancesBuffer(capacity: number): DataBuffer;
  34459. /**
  34460. * Delete a webGL buffer used with instanciation
  34461. * @param buffer defines the webGL buffer to delete
  34462. */
  34463. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34464. private _clientWaitAsync;
  34465. /** @hidden */
  34466. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34467. dispose(): void;
  34468. private _disableTouchAction;
  34469. /**
  34470. * Display the loading screen
  34471. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34472. */
  34473. displayLoadingUI(): void;
  34474. /**
  34475. * Hide the loading screen
  34476. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34477. */
  34478. hideLoadingUI(): void;
  34479. /**
  34480. * Gets the current loading screen object
  34481. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34482. */
  34483. get loadingScreen(): ILoadingScreen;
  34484. /**
  34485. * Sets the current loading screen object
  34486. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34487. */
  34488. set loadingScreen(loadingScreen: ILoadingScreen);
  34489. /**
  34490. * Sets the current loading screen text
  34491. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34492. */
  34493. set loadingUIText(text: string);
  34494. /**
  34495. * Sets the current loading screen background color
  34496. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34497. */
  34498. set loadingUIBackgroundColor(color: string);
  34499. /** Pointerlock and fullscreen */
  34500. /**
  34501. * Ask the browser to promote the current element to pointerlock mode
  34502. * @param element defines the DOM element to promote
  34503. */
  34504. static _RequestPointerlock(element: HTMLElement): void;
  34505. /**
  34506. * Asks the browser to exit pointerlock mode
  34507. */
  34508. static _ExitPointerlock(): void;
  34509. /**
  34510. * Ask the browser to promote the current element to fullscreen rendering mode
  34511. * @param element defines the DOM element to promote
  34512. */
  34513. static _RequestFullscreen(element: HTMLElement): void;
  34514. /**
  34515. * Asks the browser to exit fullscreen mode
  34516. */
  34517. static _ExitFullscreen(): void;
  34518. }
  34519. }
  34520. declare module BABYLON {
  34521. /**
  34522. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34523. * during the life time of the application.
  34524. */
  34525. export class EngineStore {
  34526. /** Gets the list of created engines */
  34527. static Instances: Engine[];
  34528. /** @hidden */
  34529. static _LastCreatedScene: Nullable<Scene>;
  34530. /**
  34531. * Gets the latest created engine
  34532. */
  34533. static get LastCreatedEngine(): Nullable<Engine>;
  34534. /**
  34535. * Gets the latest created scene
  34536. */
  34537. static get LastCreatedScene(): Nullable<Scene>;
  34538. /**
  34539. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34540. * @ignorenaming
  34541. */
  34542. static UseFallbackTexture: boolean;
  34543. /**
  34544. * Texture content used if a texture cannot loaded
  34545. * @ignorenaming
  34546. */
  34547. static FallbackTexture: string;
  34548. }
  34549. }
  34550. declare module BABYLON {
  34551. /**
  34552. * Helper class that provides a small promise polyfill
  34553. */
  34554. export class PromisePolyfill {
  34555. /**
  34556. * Static function used to check if the polyfill is required
  34557. * If this is the case then the function will inject the polyfill to window.Promise
  34558. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34559. */
  34560. static Apply(force?: boolean): void;
  34561. }
  34562. }
  34563. declare module BABYLON {
  34564. /**
  34565. * Interface for screenshot methods with describe argument called `size` as object with options
  34566. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34567. */
  34568. export interface IScreenshotSize {
  34569. /**
  34570. * number in pixels for canvas height
  34571. */
  34572. height?: number;
  34573. /**
  34574. * multiplier allowing render at a higher or lower resolution
  34575. * If value is defined then height and width will be ignored and taken from camera
  34576. */
  34577. precision?: number;
  34578. /**
  34579. * number in pixels for canvas width
  34580. */
  34581. width?: number;
  34582. }
  34583. }
  34584. declare module BABYLON {
  34585. interface IColor4Like {
  34586. r: float;
  34587. g: float;
  34588. b: float;
  34589. a: float;
  34590. }
  34591. /**
  34592. * Class containing a set of static utilities functions
  34593. */
  34594. export class Tools {
  34595. /**
  34596. * Gets or sets the base URL to use to load assets
  34597. */
  34598. static get BaseUrl(): string;
  34599. static set BaseUrl(value: string);
  34600. /**
  34601. * Enable/Disable Custom HTTP Request Headers globally.
  34602. * default = false
  34603. * @see CustomRequestHeaders
  34604. */
  34605. static UseCustomRequestHeaders: boolean;
  34606. /**
  34607. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34608. * i.e. when loading files, where the server/service expects an Authorization header
  34609. */
  34610. static CustomRequestHeaders: {
  34611. [key: string]: string;
  34612. };
  34613. /**
  34614. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34615. */
  34616. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34617. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34618. /**
  34619. * Default behaviour for cors in the application.
  34620. * It can be a string if the expected behavior is identical in the entire app.
  34621. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34622. */
  34623. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34624. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34625. /**
  34626. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34627. * @ignorenaming
  34628. */
  34629. static get UseFallbackTexture(): boolean;
  34630. static set UseFallbackTexture(value: boolean);
  34631. /**
  34632. * Use this object to register external classes like custom textures or material
  34633. * to allow the laoders to instantiate them
  34634. */
  34635. static get RegisteredExternalClasses(): {
  34636. [key: string]: Object;
  34637. };
  34638. static set RegisteredExternalClasses(classes: {
  34639. [key: string]: Object;
  34640. });
  34641. /**
  34642. * Texture content used if a texture cannot loaded
  34643. * @ignorenaming
  34644. */
  34645. static get fallbackTexture(): string;
  34646. static set fallbackTexture(value: string);
  34647. /**
  34648. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34649. * @param u defines the coordinate on X axis
  34650. * @param v defines the coordinate on Y axis
  34651. * @param width defines the width of the source data
  34652. * @param height defines the height of the source data
  34653. * @param pixels defines the source byte array
  34654. * @param color defines the output color
  34655. */
  34656. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34657. /**
  34658. * Interpolates between a and b via alpha
  34659. * @param a The lower value (returned when alpha = 0)
  34660. * @param b The upper value (returned when alpha = 1)
  34661. * @param alpha The interpolation-factor
  34662. * @return The mixed value
  34663. */
  34664. static Mix(a: number, b: number, alpha: number): number;
  34665. /**
  34666. * Tries to instantiate a new object from a given class name
  34667. * @param className defines the class name to instantiate
  34668. * @returns the new object or null if the system was not able to do the instantiation
  34669. */
  34670. static Instantiate(className: string): any;
  34671. /**
  34672. * Provides a slice function that will work even on IE
  34673. * @param data defines the array to slice
  34674. * @param start defines the start of the data (optional)
  34675. * @param end defines the end of the data (optional)
  34676. * @returns the new sliced array
  34677. */
  34678. static Slice<T>(data: T, start?: number, end?: number): T;
  34679. /**
  34680. * Polyfill for setImmediate
  34681. * @param action defines the action to execute after the current execution block
  34682. */
  34683. static SetImmediate(action: () => void): void;
  34684. /**
  34685. * Function indicating if a number is an exponent of 2
  34686. * @param value defines the value to test
  34687. * @returns true if the value is an exponent of 2
  34688. */
  34689. static IsExponentOfTwo(value: number): boolean;
  34690. private static _tmpFloatArray;
  34691. /**
  34692. * Returns the nearest 32-bit single precision float representation of a Number
  34693. * @param value A Number. If the parameter is of a different type, it will get converted
  34694. * to a number or to NaN if it cannot be converted
  34695. * @returns number
  34696. */
  34697. static FloatRound(value: number): number;
  34698. /**
  34699. * Extracts the filename from a path
  34700. * @param path defines the path to use
  34701. * @returns the filename
  34702. */
  34703. static GetFilename(path: string): string;
  34704. /**
  34705. * Extracts the "folder" part of a path (everything before the filename).
  34706. * @param uri The URI to extract the info from
  34707. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34708. * @returns The "folder" part of the path
  34709. */
  34710. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34711. /**
  34712. * Extracts text content from a DOM element hierarchy
  34713. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34714. */
  34715. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34716. /**
  34717. * Convert an angle in radians to degrees
  34718. * @param angle defines the angle to convert
  34719. * @returns the angle in degrees
  34720. */
  34721. static ToDegrees(angle: number): number;
  34722. /**
  34723. * Convert an angle in degrees to radians
  34724. * @param angle defines the angle to convert
  34725. * @returns the angle in radians
  34726. */
  34727. static ToRadians(angle: number): number;
  34728. /**
  34729. * Returns an array if obj is not an array
  34730. * @param obj defines the object to evaluate as an array
  34731. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34732. * @returns either obj directly if obj is an array or a new array containing obj
  34733. */
  34734. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34735. /**
  34736. * Gets the pointer prefix to use
  34737. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34738. */
  34739. static GetPointerPrefix(): string;
  34740. /**
  34741. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34742. * @param url define the url we are trying
  34743. * @param element define the dom element where to configure the cors policy
  34744. */
  34745. static SetCorsBehavior(url: string | string[], element: {
  34746. crossOrigin: string | null;
  34747. }): void;
  34748. /**
  34749. * Removes unwanted characters from an url
  34750. * @param url defines the url to clean
  34751. * @returns the cleaned url
  34752. */
  34753. static CleanUrl(url: string): string;
  34754. /**
  34755. * Gets or sets a function used to pre-process url before using them to load assets
  34756. */
  34757. static get PreprocessUrl(): (url: string) => string;
  34758. static set PreprocessUrl(processor: (url: string) => string);
  34759. /**
  34760. * Loads an image as an HTMLImageElement.
  34761. * @param input url string, ArrayBuffer, or Blob to load
  34762. * @param onLoad callback called when the image successfully loads
  34763. * @param onError callback called when the image fails to load
  34764. * @param offlineProvider offline provider for caching
  34765. * @param mimeType optional mime type
  34766. * @returns the HTMLImageElement of the loaded image
  34767. */
  34768. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34769. /**
  34770. * Loads a file from a url
  34771. * @param url url string, ArrayBuffer, or Blob to load
  34772. * @param onSuccess callback called when the file successfully loads
  34773. * @param onProgress callback called while file is loading (if the server supports this mode)
  34774. * @param offlineProvider defines the offline provider for caching
  34775. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34776. * @param onError callback called when the file fails to load
  34777. * @returns a file request object
  34778. */
  34779. 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;
  34780. /**
  34781. * Loads a file from a url
  34782. * @param url the file url to load
  34783. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34784. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34785. */
  34786. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34787. /**
  34788. * Load a script (identified by an url). When the url returns, the
  34789. * content of this file is added into a new script element, attached to the DOM (body element)
  34790. * @param scriptUrl defines the url of the script to laod
  34791. * @param onSuccess defines the callback called when the script is loaded
  34792. * @param onError defines the callback to call if an error occurs
  34793. * @param scriptId defines the id of the script element
  34794. */
  34795. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34796. /**
  34797. * Load an asynchronous script (identified by an url). When the url returns, the
  34798. * content of this file is added into a new script element, attached to the DOM (body element)
  34799. * @param scriptUrl defines the url of the script to laod
  34800. * @param scriptId defines the id of the script element
  34801. * @returns a promise request object
  34802. */
  34803. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34804. /**
  34805. * Loads a file from a blob
  34806. * @param fileToLoad defines the blob to use
  34807. * @param callback defines the callback to call when data is loaded
  34808. * @param progressCallback defines the callback to call during loading process
  34809. * @returns a file request object
  34810. */
  34811. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34812. /**
  34813. * Reads a file from a File object
  34814. * @param file defines the file to load
  34815. * @param onSuccess defines the callback to call when data is loaded
  34816. * @param onProgress defines the callback to call during loading process
  34817. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34818. * @param onError defines the callback to call when an error occurs
  34819. * @returns a file request object
  34820. */
  34821. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34822. /**
  34823. * Creates a data url from a given string content
  34824. * @param content defines the content to convert
  34825. * @returns the new data url link
  34826. */
  34827. static FileAsURL(content: string): string;
  34828. /**
  34829. * Format the given number to a specific decimal format
  34830. * @param value defines the number to format
  34831. * @param decimals defines the number of decimals to use
  34832. * @returns the formatted string
  34833. */
  34834. static Format(value: number, decimals?: number): string;
  34835. /**
  34836. * Tries to copy an object by duplicating every property
  34837. * @param source defines the source object
  34838. * @param destination defines the target object
  34839. * @param doNotCopyList defines a list of properties to avoid
  34840. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34841. */
  34842. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34843. /**
  34844. * Gets a boolean indicating if the given object has no own property
  34845. * @param obj defines the object to test
  34846. * @returns true if object has no own property
  34847. */
  34848. static IsEmpty(obj: any): boolean;
  34849. /**
  34850. * Function used to register events at window level
  34851. * @param windowElement defines the Window object to use
  34852. * @param events defines the events to register
  34853. */
  34854. static RegisterTopRootEvents(windowElement: Window, events: {
  34855. name: string;
  34856. handler: Nullable<(e: FocusEvent) => any>;
  34857. }[]): void;
  34858. /**
  34859. * Function used to unregister events from window level
  34860. * @param windowElement defines the Window object to use
  34861. * @param events defines the events to unregister
  34862. */
  34863. static UnregisterTopRootEvents(windowElement: Window, events: {
  34864. name: string;
  34865. handler: Nullable<(e: FocusEvent) => any>;
  34866. }[]): void;
  34867. /**
  34868. * @ignore
  34869. */
  34870. static _ScreenshotCanvas: HTMLCanvasElement;
  34871. /**
  34872. * Dumps the current bound framebuffer
  34873. * @param width defines the rendering width
  34874. * @param height defines the rendering height
  34875. * @param engine defines the hosting engine
  34876. * @param successCallback defines the callback triggered once the data are available
  34877. * @param mimeType defines the mime type of the result
  34878. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34879. */
  34880. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34881. /**
  34882. * Converts the canvas data to blob.
  34883. * This acts as a polyfill for browsers not supporting the to blob function.
  34884. * @param canvas Defines the canvas to extract the data from
  34885. * @param successCallback Defines the callback triggered once the data are available
  34886. * @param mimeType Defines the mime type of the result
  34887. */
  34888. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34889. /**
  34890. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34891. * @param successCallback defines the callback triggered once the data are available
  34892. * @param mimeType defines the mime type of the result
  34893. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34894. */
  34895. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34896. /**
  34897. * Downloads a blob in the browser
  34898. * @param blob defines the blob to download
  34899. * @param fileName defines the name of the downloaded file
  34900. */
  34901. static Download(blob: Blob, fileName: string): void;
  34902. /**
  34903. * Captures a screenshot of the current rendering
  34904. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34905. * @param engine defines the rendering engine
  34906. * @param camera defines the source camera
  34907. * @param size This parameter can be set to a single number or to an object with the
  34908. * following (optional) properties: precision, width, height. If a single number is passed,
  34909. * it will be used for both width and height. If an object is passed, the screenshot size
  34910. * will be derived from the parameters. The precision property is a multiplier allowing
  34911. * rendering at a higher or lower resolution
  34912. * @param successCallback defines the callback receives a single parameter which contains the
  34913. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34914. * src parameter of an <img> to display it
  34915. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34916. * Check your browser for supported MIME types
  34917. */
  34918. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34919. /**
  34920. * Captures a screenshot of the current rendering
  34921. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34922. * @param engine defines the rendering engine
  34923. * @param camera defines the source camera
  34924. * @param size This parameter can be set to a single number or to an object with the
  34925. * following (optional) properties: precision, width, height. If a single number is passed,
  34926. * it will be used for both width and height. If an object is passed, the screenshot size
  34927. * will be derived from the parameters. The precision property is a multiplier allowing
  34928. * rendering at a higher or lower resolution
  34929. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34930. * Check your browser for supported MIME types
  34931. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34932. * to the src parameter of an <img> to display it
  34933. */
  34934. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34935. /**
  34936. * Generates an image screenshot from the specified camera.
  34937. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34938. * @param engine The engine to use for rendering
  34939. * @param camera The camera to use for rendering
  34940. * @param size This parameter can be set to a single number or to an object with the
  34941. * following (optional) properties: precision, width, height. If a single number is passed,
  34942. * it will be used for both width and height. If an object is passed, the screenshot size
  34943. * will be derived from the parameters. The precision property is a multiplier allowing
  34944. * rendering at a higher or lower resolution
  34945. * @param successCallback The callback receives a single parameter which contains the
  34946. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34947. * src parameter of an <img> to display it
  34948. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34949. * Check your browser for supported MIME types
  34950. * @param samples Texture samples (default: 1)
  34951. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34952. * @param fileName A name for for the downloaded file.
  34953. */
  34954. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34955. /**
  34956. * Generates an image screenshot from the specified camera.
  34957. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34958. * @param engine The engine to use for rendering
  34959. * @param camera The camera to use for rendering
  34960. * @param size This parameter can be set to a single number or to an object with the
  34961. * following (optional) properties: precision, width, height. If a single number is passed,
  34962. * it will be used for both width and height. If an object is passed, the screenshot size
  34963. * will be derived from the parameters. The precision property is a multiplier allowing
  34964. * rendering at a higher or lower resolution
  34965. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34966. * Check your browser for supported MIME types
  34967. * @param samples Texture samples (default: 1)
  34968. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34969. * @param fileName A name for for the downloaded file.
  34970. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34971. * to the src parameter of an <img> to display it
  34972. */
  34973. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34974. /**
  34975. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34976. * Be aware Math.random() could cause collisions, but:
  34977. * "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"
  34978. * @returns a pseudo random id
  34979. */
  34980. static RandomId(): string;
  34981. /**
  34982. * Test if the given uri is a base64 string
  34983. * @param uri The uri to test
  34984. * @return True if the uri is a base64 string or false otherwise
  34985. */
  34986. static IsBase64(uri: string): boolean;
  34987. /**
  34988. * Decode the given base64 uri.
  34989. * @param uri The uri to decode
  34990. * @return The decoded base64 data.
  34991. */
  34992. static DecodeBase64(uri: string): ArrayBuffer;
  34993. /**
  34994. * Gets the absolute url.
  34995. * @param url the input url
  34996. * @return the absolute url
  34997. */
  34998. static GetAbsoluteUrl(url: string): string;
  34999. /**
  35000. * No log
  35001. */
  35002. static readonly NoneLogLevel: number;
  35003. /**
  35004. * Only message logs
  35005. */
  35006. static readonly MessageLogLevel: number;
  35007. /**
  35008. * Only warning logs
  35009. */
  35010. static readonly WarningLogLevel: number;
  35011. /**
  35012. * Only error logs
  35013. */
  35014. static readonly ErrorLogLevel: number;
  35015. /**
  35016. * All logs
  35017. */
  35018. static readonly AllLogLevel: number;
  35019. /**
  35020. * Gets a value indicating the number of loading errors
  35021. * @ignorenaming
  35022. */
  35023. static get errorsCount(): number;
  35024. /**
  35025. * Callback called when a new log is added
  35026. */
  35027. static OnNewCacheEntry: (entry: string) => void;
  35028. /**
  35029. * Log a message to the console
  35030. * @param message defines the message to log
  35031. */
  35032. static Log(message: string): void;
  35033. /**
  35034. * Write a warning message to the console
  35035. * @param message defines the message to log
  35036. */
  35037. static Warn(message: string): void;
  35038. /**
  35039. * Write an error message to the console
  35040. * @param message defines the message to log
  35041. */
  35042. static Error(message: string): void;
  35043. /**
  35044. * Gets current log cache (list of logs)
  35045. */
  35046. static get LogCache(): string;
  35047. /**
  35048. * Clears the log cache
  35049. */
  35050. static ClearLogCache(): void;
  35051. /**
  35052. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35053. */
  35054. static set LogLevels(level: number);
  35055. /**
  35056. * Checks if the window object exists
  35057. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35058. */
  35059. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35060. /**
  35061. * No performance log
  35062. */
  35063. static readonly PerformanceNoneLogLevel: number;
  35064. /**
  35065. * Use user marks to log performance
  35066. */
  35067. static readonly PerformanceUserMarkLogLevel: number;
  35068. /**
  35069. * Log performance to the console
  35070. */
  35071. static readonly PerformanceConsoleLogLevel: number;
  35072. private static _performance;
  35073. /**
  35074. * Sets the current performance log level
  35075. */
  35076. static set PerformanceLogLevel(level: number);
  35077. private static _StartPerformanceCounterDisabled;
  35078. private static _EndPerformanceCounterDisabled;
  35079. private static _StartUserMark;
  35080. private static _EndUserMark;
  35081. private static _StartPerformanceConsole;
  35082. private static _EndPerformanceConsole;
  35083. /**
  35084. * Starts a performance counter
  35085. */
  35086. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35087. /**
  35088. * Ends a specific performance coutner
  35089. */
  35090. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35091. /**
  35092. * Gets either window.performance.now() if supported or Date.now() else
  35093. */
  35094. static get Now(): number;
  35095. /**
  35096. * This method will return the name of the class used to create the instance of the given object.
  35097. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35098. * @param object the object to get the class name from
  35099. * @param isType defines if the object is actually a type
  35100. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35101. */
  35102. static GetClassName(object: any, isType?: boolean): string;
  35103. /**
  35104. * Gets the first element of an array satisfying a given predicate
  35105. * @param array defines the array to browse
  35106. * @param predicate defines the predicate to use
  35107. * @returns null if not found or the element
  35108. */
  35109. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35110. /**
  35111. * This method will return the name of the full name of the class, including its owning module (if any).
  35112. * 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).
  35113. * @param object the object to get the class name from
  35114. * @param isType defines if the object is actually a type
  35115. * @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.
  35116. * @ignorenaming
  35117. */
  35118. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35119. /**
  35120. * Returns a promise that resolves after the given amount of time.
  35121. * @param delay Number of milliseconds to delay
  35122. * @returns Promise that resolves after the given amount of time
  35123. */
  35124. static DelayAsync(delay: number): Promise<void>;
  35125. /**
  35126. * Utility function to detect if the current user agent is Safari
  35127. * @returns whether or not the current user agent is safari
  35128. */
  35129. static IsSafari(): boolean;
  35130. }
  35131. /**
  35132. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35133. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35134. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35135. * @param name The name of the class, case should be preserved
  35136. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35137. */
  35138. export function className(name: string, module?: string): (target: Object) => void;
  35139. /**
  35140. * An implementation of a loop for asynchronous functions.
  35141. */
  35142. export class AsyncLoop {
  35143. /**
  35144. * Defines the number of iterations for the loop
  35145. */
  35146. iterations: number;
  35147. /**
  35148. * Defines the current index of the loop.
  35149. */
  35150. index: number;
  35151. private _done;
  35152. private _fn;
  35153. private _successCallback;
  35154. /**
  35155. * Constructor.
  35156. * @param iterations the number of iterations.
  35157. * @param func the function to run each iteration
  35158. * @param successCallback the callback that will be called upon succesful execution
  35159. * @param offset starting offset.
  35160. */
  35161. constructor(
  35162. /**
  35163. * Defines the number of iterations for the loop
  35164. */
  35165. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35166. /**
  35167. * Execute the next iteration. Must be called after the last iteration was finished.
  35168. */
  35169. executeNext(): void;
  35170. /**
  35171. * Break the loop and run the success callback.
  35172. */
  35173. breakLoop(): void;
  35174. /**
  35175. * Create and run an async loop.
  35176. * @param iterations the number of iterations.
  35177. * @param fn the function to run each iteration
  35178. * @param successCallback the callback that will be called upon succesful execution
  35179. * @param offset starting offset.
  35180. * @returns the created async loop object
  35181. */
  35182. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35183. /**
  35184. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35185. * @param iterations total number of iterations
  35186. * @param syncedIterations number of synchronous iterations in each async iteration.
  35187. * @param fn the function to call each iteration.
  35188. * @param callback a success call back that will be called when iterating stops.
  35189. * @param breakFunction a break condition (optional)
  35190. * @param timeout timeout settings for the setTimeout function. default - 0.
  35191. * @returns the created async loop object
  35192. */
  35193. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35194. }
  35195. }
  35196. declare module BABYLON {
  35197. /**
  35198. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35199. * The underlying implementation relies on an associative array to ensure the best performances.
  35200. * The value can be anything including 'null' but except 'undefined'
  35201. */
  35202. export class StringDictionary<T> {
  35203. /**
  35204. * This will clear this dictionary and copy the content from the 'source' one.
  35205. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35206. * @param source the dictionary to take the content from and copy to this dictionary
  35207. */
  35208. copyFrom(source: StringDictionary<T>): void;
  35209. /**
  35210. * Get a value based from its key
  35211. * @param key the given key to get the matching value from
  35212. * @return the value if found, otherwise undefined is returned
  35213. */
  35214. get(key: string): T | undefined;
  35215. /**
  35216. * Get a value from its key or add it if it doesn't exist.
  35217. * This method will ensure you that a given key/data will be present in the dictionary.
  35218. * @param key the given key to get the matching value from
  35219. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35220. * The factory will only be invoked if there's no data for the given key.
  35221. * @return the value corresponding to the key.
  35222. */
  35223. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35224. /**
  35225. * Get a value from its key if present in the dictionary otherwise add it
  35226. * @param key the key to get the value from
  35227. * @param val if there's no such key/value pair in the dictionary add it with this value
  35228. * @return the value corresponding to the key
  35229. */
  35230. getOrAdd(key: string, val: T): T;
  35231. /**
  35232. * Check if there's a given key in the dictionary
  35233. * @param key the key to check for
  35234. * @return true if the key is present, false otherwise
  35235. */
  35236. contains(key: string): boolean;
  35237. /**
  35238. * Add a new key and its corresponding value
  35239. * @param key the key to add
  35240. * @param value the value corresponding to the key
  35241. * @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
  35242. */
  35243. add(key: string, value: T): boolean;
  35244. /**
  35245. * Update a specific value associated to a key
  35246. * @param key defines the key to use
  35247. * @param value defines the value to store
  35248. * @returns true if the value was updated (or false if the key was not found)
  35249. */
  35250. set(key: string, value: T): boolean;
  35251. /**
  35252. * Get the element of the given key and remove it from the dictionary
  35253. * @param key defines the key to search
  35254. * @returns the value associated with the key or null if not found
  35255. */
  35256. getAndRemove(key: string): Nullable<T>;
  35257. /**
  35258. * Remove a key/value from the dictionary.
  35259. * @param key the key to remove
  35260. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35261. */
  35262. remove(key: string): boolean;
  35263. /**
  35264. * Clear the whole content of the dictionary
  35265. */
  35266. clear(): void;
  35267. /**
  35268. * Gets the current count
  35269. */
  35270. get count(): number;
  35271. /**
  35272. * Execute a callback on each key/val of the dictionary.
  35273. * Note that you can remove any element in this dictionary in the callback implementation
  35274. * @param callback the callback to execute on a given key/value pair
  35275. */
  35276. forEach(callback: (key: string, val: T) => void): void;
  35277. /**
  35278. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35279. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35280. * Note that you can remove any element in this dictionary in the callback implementation
  35281. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35282. * @returns the first item
  35283. */
  35284. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35285. private _count;
  35286. private _data;
  35287. }
  35288. }
  35289. declare module BABYLON {
  35290. /** @hidden */
  35291. export interface ICollisionCoordinator {
  35292. createCollider(): Collider;
  35293. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35294. init(scene: Scene): void;
  35295. }
  35296. /** @hidden */
  35297. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35298. private _scene;
  35299. private _scaledPosition;
  35300. private _scaledVelocity;
  35301. private _finalPosition;
  35302. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35303. createCollider(): Collider;
  35304. init(scene: Scene): void;
  35305. private _collideWithWorld;
  35306. }
  35307. }
  35308. declare module BABYLON {
  35309. /**
  35310. * Class used to manage all inputs for the scene.
  35311. */
  35312. export class InputManager {
  35313. /** The distance in pixel that you have to move to prevent some events */
  35314. static DragMovementThreshold: number;
  35315. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35316. static LongPressDelay: number;
  35317. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35318. static DoubleClickDelay: number;
  35319. /** If you need to check double click without raising a single click at first click, enable this flag */
  35320. static ExclusiveDoubleClickMode: boolean;
  35321. private _wheelEventName;
  35322. private _onPointerMove;
  35323. private _onPointerDown;
  35324. private _onPointerUp;
  35325. private _initClickEvent;
  35326. private _initActionManager;
  35327. private _delayedSimpleClick;
  35328. private _delayedSimpleClickTimeout;
  35329. private _previousDelayedSimpleClickTimeout;
  35330. private _meshPickProceed;
  35331. private _previousButtonPressed;
  35332. private _currentPickResult;
  35333. private _previousPickResult;
  35334. private _totalPointersPressed;
  35335. private _doubleClickOccured;
  35336. private _pointerOverMesh;
  35337. private _pickedDownMesh;
  35338. private _pickedUpMesh;
  35339. private _pointerX;
  35340. private _pointerY;
  35341. private _unTranslatedPointerX;
  35342. private _unTranslatedPointerY;
  35343. private _startingPointerPosition;
  35344. private _previousStartingPointerPosition;
  35345. private _startingPointerTime;
  35346. private _previousStartingPointerTime;
  35347. private _pointerCaptures;
  35348. private _onKeyDown;
  35349. private _onKeyUp;
  35350. private _onCanvasFocusObserver;
  35351. private _onCanvasBlurObserver;
  35352. private _scene;
  35353. /**
  35354. * Creates a new InputManager
  35355. * @param scene defines the hosting scene
  35356. */
  35357. constructor(scene: Scene);
  35358. /**
  35359. * Gets the mesh that is currently under the pointer
  35360. */
  35361. get meshUnderPointer(): Nullable<AbstractMesh>;
  35362. /**
  35363. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35364. */
  35365. get unTranslatedPointer(): Vector2;
  35366. /**
  35367. * Gets or sets the current on-screen X position of the pointer
  35368. */
  35369. get pointerX(): number;
  35370. set pointerX(value: number);
  35371. /**
  35372. * Gets or sets the current on-screen Y position of the pointer
  35373. */
  35374. get pointerY(): number;
  35375. set pointerY(value: number);
  35376. private _updatePointerPosition;
  35377. private _processPointerMove;
  35378. private _setRayOnPointerInfo;
  35379. private _checkPrePointerObservable;
  35380. /**
  35381. * Use this method to simulate a pointer move on a mesh
  35382. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35383. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35384. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35385. */
  35386. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35387. /**
  35388. * Use this method to simulate a pointer down on a mesh
  35389. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35390. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35391. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35392. */
  35393. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35394. private _processPointerDown;
  35395. /** @hidden */
  35396. _isPointerSwiping(): boolean;
  35397. /**
  35398. * Use this method to simulate a pointer up on a mesh
  35399. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35400. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35401. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35402. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35403. */
  35404. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35405. private _processPointerUp;
  35406. /**
  35407. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35408. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35409. * @returns true if the pointer was captured
  35410. */
  35411. isPointerCaptured(pointerId?: number): boolean;
  35412. /**
  35413. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35414. * @param attachUp defines if you want to attach events to pointerup
  35415. * @param attachDown defines if you want to attach events to pointerdown
  35416. * @param attachMove defines if you want to attach events to pointermove
  35417. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35418. */
  35419. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35420. /**
  35421. * Detaches all event handlers
  35422. */
  35423. detachControl(): void;
  35424. /**
  35425. * Force the value of meshUnderPointer
  35426. * @param mesh defines the mesh to use
  35427. */
  35428. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35429. /**
  35430. * Gets the mesh under the pointer
  35431. * @returns a Mesh or null if no mesh is under the pointer
  35432. */
  35433. getPointerOverMesh(): Nullable<AbstractMesh>;
  35434. }
  35435. }
  35436. declare module BABYLON {
  35437. /**
  35438. * Helper class used to generate session unique ID
  35439. */
  35440. export class UniqueIdGenerator {
  35441. private static _UniqueIdCounter;
  35442. /**
  35443. * Gets an unique (relatively to the current scene) Id
  35444. */
  35445. static get UniqueId(): number;
  35446. }
  35447. }
  35448. declare module BABYLON {
  35449. /**
  35450. * This class defines the direct association between an animation and a target
  35451. */
  35452. export class TargetedAnimation {
  35453. /**
  35454. * Animation to perform
  35455. */
  35456. animation: Animation;
  35457. /**
  35458. * Target to animate
  35459. */
  35460. target: any;
  35461. /**
  35462. * Serialize the object
  35463. * @returns the JSON object representing the current entity
  35464. */
  35465. serialize(): any;
  35466. }
  35467. /**
  35468. * Use this class to create coordinated animations on multiple targets
  35469. */
  35470. export class AnimationGroup implements IDisposable {
  35471. /** The name of the animation group */
  35472. name: string;
  35473. private _scene;
  35474. private _targetedAnimations;
  35475. private _animatables;
  35476. private _from;
  35477. private _to;
  35478. private _isStarted;
  35479. private _isPaused;
  35480. private _speedRatio;
  35481. private _loopAnimation;
  35482. private _isAdditive;
  35483. /**
  35484. * Gets or sets the unique id of the node
  35485. */
  35486. uniqueId: number;
  35487. /**
  35488. * This observable will notify when one animation have ended
  35489. */
  35490. onAnimationEndObservable: Observable<TargetedAnimation>;
  35491. /**
  35492. * Observer raised when one animation loops
  35493. */
  35494. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35495. /**
  35496. * Observer raised when all animations have looped
  35497. */
  35498. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35499. /**
  35500. * This observable will notify when all animations have ended.
  35501. */
  35502. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35503. /**
  35504. * This observable will notify when all animations have paused.
  35505. */
  35506. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35507. /**
  35508. * This observable will notify when all animations are playing.
  35509. */
  35510. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35511. /**
  35512. * Gets the first frame
  35513. */
  35514. get from(): number;
  35515. /**
  35516. * Gets the last frame
  35517. */
  35518. get to(): number;
  35519. /**
  35520. * Define if the animations are started
  35521. */
  35522. get isStarted(): boolean;
  35523. /**
  35524. * Gets a value indicating that the current group is playing
  35525. */
  35526. get isPlaying(): boolean;
  35527. /**
  35528. * Gets or sets the speed ratio to use for all animations
  35529. */
  35530. get speedRatio(): number;
  35531. /**
  35532. * Gets or sets the speed ratio to use for all animations
  35533. */
  35534. set speedRatio(value: number);
  35535. /**
  35536. * Gets or sets if all animations should loop or not
  35537. */
  35538. get loopAnimation(): boolean;
  35539. set loopAnimation(value: boolean);
  35540. /**
  35541. * Gets or sets if all animations should be evaluated additively
  35542. */
  35543. get isAdditive(): boolean;
  35544. set isAdditive(value: boolean);
  35545. /**
  35546. * Gets the targeted animations for this animation group
  35547. */
  35548. get targetedAnimations(): Array<TargetedAnimation>;
  35549. /**
  35550. * returning the list of animatables controlled by this animation group.
  35551. */
  35552. get animatables(): Array<Animatable>;
  35553. /**
  35554. * Instantiates a new Animation Group.
  35555. * This helps managing several animations at once.
  35556. * @see http://doc.babylonjs.com/how_to/group
  35557. * @param name Defines the name of the group
  35558. * @param scene Defines the scene the group belongs to
  35559. */
  35560. constructor(
  35561. /** The name of the animation group */
  35562. name: string, scene?: Nullable<Scene>);
  35563. /**
  35564. * Add an animation (with its target) in the group
  35565. * @param animation defines the animation we want to add
  35566. * @param target defines the target of the animation
  35567. * @returns the TargetedAnimation object
  35568. */
  35569. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35570. /**
  35571. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35572. * It can add constant keys at begin or end
  35573. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35574. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35575. * @returns the animation group
  35576. */
  35577. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35578. private _animationLoopCount;
  35579. private _animationLoopFlags;
  35580. private _processLoop;
  35581. /**
  35582. * Start all animations on given targets
  35583. * @param loop defines if animations must loop
  35584. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35585. * @param from defines the from key (optional)
  35586. * @param to defines the to key (optional)
  35587. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35588. * @returns the current animation group
  35589. */
  35590. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35591. /**
  35592. * Pause all animations
  35593. * @returns the animation group
  35594. */
  35595. pause(): AnimationGroup;
  35596. /**
  35597. * Play all animations to initial state
  35598. * This function will start() the animations if they were not started or will restart() them if they were paused
  35599. * @param loop defines if animations must loop
  35600. * @returns the animation group
  35601. */
  35602. play(loop?: boolean): AnimationGroup;
  35603. /**
  35604. * Reset all animations to initial state
  35605. * @returns the animation group
  35606. */
  35607. reset(): AnimationGroup;
  35608. /**
  35609. * Restart animations from key 0
  35610. * @returns the animation group
  35611. */
  35612. restart(): AnimationGroup;
  35613. /**
  35614. * Stop all animations
  35615. * @returns the animation group
  35616. */
  35617. stop(): AnimationGroup;
  35618. /**
  35619. * Set animation weight for all animatables
  35620. * @param weight defines the weight to use
  35621. * @return the animationGroup
  35622. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35623. */
  35624. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35625. /**
  35626. * Synchronize and normalize all animatables with a source animatable
  35627. * @param root defines the root animatable to synchronize with
  35628. * @return the animationGroup
  35629. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35630. */
  35631. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35632. /**
  35633. * Goes to a specific frame in this animation group
  35634. * @param frame the frame number to go to
  35635. * @return the animationGroup
  35636. */
  35637. goToFrame(frame: number): AnimationGroup;
  35638. /**
  35639. * Dispose all associated resources
  35640. */
  35641. dispose(): void;
  35642. private _checkAnimationGroupEnded;
  35643. /**
  35644. * Clone the current animation group and returns a copy
  35645. * @param newName defines the name of the new group
  35646. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35647. * @returns the new aniamtion group
  35648. */
  35649. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35650. /**
  35651. * Serializes the animationGroup to an object
  35652. * @returns Serialized object
  35653. */
  35654. serialize(): any;
  35655. /**
  35656. * Returns a new AnimationGroup object parsed from the source provided.
  35657. * @param parsedAnimationGroup defines the source
  35658. * @param scene defines the scene that will receive the animationGroup
  35659. * @returns a new AnimationGroup
  35660. */
  35661. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35662. /**
  35663. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35664. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35665. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35666. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35667. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35668. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35669. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35670. */
  35671. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35672. /**
  35673. * Returns the string "AnimationGroup"
  35674. * @returns "AnimationGroup"
  35675. */
  35676. getClassName(): string;
  35677. /**
  35678. * Creates a detailled string about the object
  35679. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35680. * @returns a string representing the object
  35681. */
  35682. toString(fullDetails?: boolean): string;
  35683. }
  35684. }
  35685. declare module BABYLON {
  35686. /**
  35687. * Define an interface for all classes that will hold resources
  35688. */
  35689. export interface IDisposable {
  35690. /**
  35691. * Releases all held resources
  35692. */
  35693. dispose(): void;
  35694. }
  35695. /** Interface defining initialization parameters for Scene class */
  35696. export interface SceneOptions {
  35697. /**
  35698. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35699. * It will improve performance when the number of geometries becomes important.
  35700. */
  35701. useGeometryUniqueIdsMap?: boolean;
  35702. /**
  35703. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35704. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35705. */
  35706. useMaterialMeshMap?: boolean;
  35707. /**
  35708. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35709. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35710. */
  35711. useClonedMeshMap?: boolean;
  35712. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35713. virtual?: boolean;
  35714. }
  35715. /**
  35716. * Represents a scene to be rendered by the engine.
  35717. * @see http://doc.babylonjs.com/features/scene
  35718. */
  35719. export class Scene extends AbstractScene implements IAnimatable {
  35720. /** The fog is deactivated */
  35721. static readonly FOGMODE_NONE: number;
  35722. /** The fog density is following an exponential function */
  35723. static readonly FOGMODE_EXP: number;
  35724. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35725. static readonly FOGMODE_EXP2: number;
  35726. /** The fog density is following a linear function. */
  35727. static readonly FOGMODE_LINEAR: number;
  35728. /**
  35729. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35731. */
  35732. static MinDeltaTime: number;
  35733. /**
  35734. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35736. */
  35737. static MaxDeltaTime: number;
  35738. /**
  35739. * Factory used to create the default material.
  35740. * @param name The name of the material to create
  35741. * @param scene The scene to create the material for
  35742. * @returns The default material
  35743. */
  35744. static DefaultMaterialFactory(scene: Scene): Material;
  35745. /**
  35746. * Factory used to create the a collision coordinator.
  35747. * @returns The collision coordinator
  35748. */
  35749. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35750. /** @hidden */
  35751. _inputManager: InputManager;
  35752. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35753. cameraToUseForPointers: Nullable<Camera>;
  35754. /** @hidden */
  35755. readonly _isScene: boolean;
  35756. /** @hidden */
  35757. _blockEntityCollection: boolean;
  35758. /**
  35759. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35760. */
  35761. autoClear: boolean;
  35762. /**
  35763. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35764. */
  35765. autoClearDepthAndStencil: boolean;
  35766. /**
  35767. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35768. */
  35769. clearColor: Color4;
  35770. /**
  35771. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35772. */
  35773. ambientColor: Color3;
  35774. /**
  35775. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35776. * It should only be one of the following (if not the default embedded one):
  35777. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35778. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35779. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35780. * The material properties need to be setup according to the type of texture in use.
  35781. */
  35782. environmentBRDFTexture: BaseTexture;
  35783. /** @hidden */
  35784. protected _environmentTexture: Nullable<BaseTexture>;
  35785. /**
  35786. * Texture used in all pbr material as the reflection texture.
  35787. * As in the majority of the scene they are the same (exception for multi room and so on),
  35788. * this is easier to reference from here than from all the materials.
  35789. */
  35790. get environmentTexture(): Nullable<BaseTexture>;
  35791. /**
  35792. * Texture used in all pbr material as the reflection texture.
  35793. * As in the majority of the scene they are the same (exception for multi room and so on),
  35794. * this is easier to set here than in all the materials.
  35795. */
  35796. set environmentTexture(value: Nullable<BaseTexture>);
  35797. /** @hidden */
  35798. protected _environmentIntensity: number;
  35799. /**
  35800. * Intensity of the environment in all pbr material.
  35801. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35802. * As in the majority of the scene they are the same (exception for multi room and so on),
  35803. * this is easier to reference from here than from all the materials.
  35804. */
  35805. get environmentIntensity(): number;
  35806. /**
  35807. * Intensity of the environment in all pbr material.
  35808. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35809. * As in the majority of the scene they are the same (exception for multi room and so on),
  35810. * this is easier to set here than in all the materials.
  35811. */
  35812. set environmentIntensity(value: number);
  35813. /** @hidden */
  35814. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35815. /**
  35816. * Default image processing configuration used either in the rendering
  35817. * Forward main pass or through the imageProcessingPostProcess if present.
  35818. * As in the majority of the scene they are the same (exception for multi camera),
  35819. * this is easier to reference from here than from all the materials and post process.
  35820. *
  35821. * No setter as we it is a shared configuration, you can set the values instead.
  35822. */
  35823. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35824. private _forceWireframe;
  35825. /**
  35826. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35827. */
  35828. set forceWireframe(value: boolean);
  35829. get forceWireframe(): boolean;
  35830. private _skipFrustumClipping;
  35831. /**
  35832. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35833. */
  35834. set skipFrustumClipping(value: boolean);
  35835. get skipFrustumClipping(): boolean;
  35836. private _forcePointsCloud;
  35837. /**
  35838. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35839. */
  35840. set forcePointsCloud(value: boolean);
  35841. get forcePointsCloud(): boolean;
  35842. /**
  35843. * Gets or sets the active clipplane 1
  35844. */
  35845. clipPlane: Nullable<Plane>;
  35846. /**
  35847. * Gets or sets the active clipplane 2
  35848. */
  35849. clipPlane2: Nullable<Plane>;
  35850. /**
  35851. * Gets or sets the active clipplane 3
  35852. */
  35853. clipPlane3: Nullable<Plane>;
  35854. /**
  35855. * Gets or sets the active clipplane 4
  35856. */
  35857. clipPlane4: Nullable<Plane>;
  35858. /**
  35859. * Gets or sets the active clipplane 5
  35860. */
  35861. clipPlane5: Nullable<Plane>;
  35862. /**
  35863. * Gets or sets the active clipplane 6
  35864. */
  35865. clipPlane6: Nullable<Plane>;
  35866. /**
  35867. * Gets or sets a boolean indicating if animations are enabled
  35868. */
  35869. animationsEnabled: boolean;
  35870. private _animationPropertiesOverride;
  35871. /**
  35872. * Gets or sets the animation properties override
  35873. */
  35874. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35875. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35876. /**
  35877. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35878. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35879. */
  35880. useConstantAnimationDeltaTime: boolean;
  35881. /**
  35882. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35883. * Please note that it requires to run a ray cast through the scene on every frame
  35884. */
  35885. constantlyUpdateMeshUnderPointer: boolean;
  35886. /**
  35887. * Defines the HTML cursor to use when hovering over interactive elements
  35888. */
  35889. hoverCursor: string;
  35890. /**
  35891. * Defines the HTML default cursor to use (empty by default)
  35892. */
  35893. defaultCursor: string;
  35894. /**
  35895. * Defines whether cursors are handled by the scene.
  35896. */
  35897. doNotHandleCursors: boolean;
  35898. /**
  35899. * This is used to call preventDefault() on pointer down
  35900. * in order to block unwanted artifacts like system double clicks
  35901. */
  35902. preventDefaultOnPointerDown: boolean;
  35903. /**
  35904. * This is used to call preventDefault() on pointer up
  35905. * in order to block unwanted artifacts like system double clicks
  35906. */
  35907. preventDefaultOnPointerUp: boolean;
  35908. /**
  35909. * Gets or sets user defined metadata
  35910. */
  35911. metadata: any;
  35912. /**
  35913. * For internal use only. Please do not use.
  35914. */
  35915. reservedDataStore: any;
  35916. /**
  35917. * Gets the name of the plugin used to load this scene (null by default)
  35918. */
  35919. loadingPluginName: string;
  35920. /**
  35921. * Use this array to add regular expressions used to disable offline support for specific urls
  35922. */
  35923. disableOfflineSupportExceptionRules: RegExp[];
  35924. /**
  35925. * An event triggered when the scene is disposed.
  35926. */
  35927. onDisposeObservable: Observable<Scene>;
  35928. private _onDisposeObserver;
  35929. /** Sets a function to be executed when this scene is disposed. */
  35930. set onDispose(callback: () => void);
  35931. /**
  35932. * An event triggered before rendering the scene (right after animations and physics)
  35933. */
  35934. onBeforeRenderObservable: Observable<Scene>;
  35935. private _onBeforeRenderObserver;
  35936. /** Sets a function to be executed before rendering this scene */
  35937. set beforeRender(callback: Nullable<() => void>);
  35938. /**
  35939. * An event triggered after rendering the scene
  35940. */
  35941. onAfterRenderObservable: Observable<Scene>;
  35942. /**
  35943. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35944. */
  35945. onAfterRenderCameraObservable: Observable<Camera>;
  35946. private _onAfterRenderObserver;
  35947. /** Sets a function to be executed after rendering this scene */
  35948. set afterRender(callback: Nullable<() => void>);
  35949. /**
  35950. * An event triggered before animating the scene
  35951. */
  35952. onBeforeAnimationsObservable: Observable<Scene>;
  35953. /**
  35954. * An event triggered after animations processing
  35955. */
  35956. onAfterAnimationsObservable: Observable<Scene>;
  35957. /**
  35958. * An event triggered before draw calls are ready to be sent
  35959. */
  35960. onBeforeDrawPhaseObservable: Observable<Scene>;
  35961. /**
  35962. * An event triggered after draw calls have been sent
  35963. */
  35964. onAfterDrawPhaseObservable: Observable<Scene>;
  35965. /**
  35966. * An event triggered when the scene is ready
  35967. */
  35968. onReadyObservable: Observable<Scene>;
  35969. /**
  35970. * An event triggered before rendering a camera
  35971. */
  35972. onBeforeCameraRenderObservable: Observable<Camera>;
  35973. private _onBeforeCameraRenderObserver;
  35974. /** Sets a function to be executed before rendering a camera*/
  35975. set beforeCameraRender(callback: () => void);
  35976. /**
  35977. * An event triggered after rendering a camera
  35978. */
  35979. onAfterCameraRenderObservable: Observable<Camera>;
  35980. private _onAfterCameraRenderObserver;
  35981. /** Sets a function to be executed after rendering a camera*/
  35982. set afterCameraRender(callback: () => void);
  35983. /**
  35984. * An event triggered when active meshes evaluation is about to start
  35985. */
  35986. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35987. /**
  35988. * An event triggered when active meshes evaluation is done
  35989. */
  35990. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35991. /**
  35992. * An event triggered when particles rendering is about to start
  35993. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35994. */
  35995. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35996. /**
  35997. * An event triggered when particles rendering is done
  35998. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35999. */
  36000. onAfterParticlesRenderingObservable: Observable<Scene>;
  36001. /**
  36002. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36003. */
  36004. onDataLoadedObservable: Observable<Scene>;
  36005. /**
  36006. * An event triggered when a camera is created
  36007. */
  36008. onNewCameraAddedObservable: Observable<Camera>;
  36009. /**
  36010. * An event triggered when a camera is removed
  36011. */
  36012. onCameraRemovedObservable: Observable<Camera>;
  36013. /**
  36014. * An event triggered when a light is created
  36015. */
  36016. onNewLightAddedObservable: Observable<Light>;
  36017. /**
  36018. * An event triggered when a light is removed
  36019. */
  36020. onLightRemovedObservable: Observable<Light>;
  36021. /**
  36022. * An event triggered when a geometry is created
  36023. */
  36024. onNewGeometryAddedObservable: Observable<Geometry>;
  36025. /**
  36026. * An event triggered when a geometry is removed
  36027. */
  36028. onGeometryRemovedObservable: Observable<Geometry>;
  36029. /**
  36030. * An event triggered when a transform node is created
  36031. */
  36032. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36033. /**
  36034. * An event triggered when a transform node is removed
  36035. */
  36036. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36037. /**
  36038. * An event triggered when a mesh is created
  36039. */
  36040. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36041. /**
  36042. * An event triggered when a mesh is removed
  36043. */
  36044. onMeshRemovedObservable: Observable<AbstractMesh>;
  36045. /**
  36046. * An event triggered when a skeleton is created
  36047. */
  36048. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36049. /**
  36050. * An event triggered when a skeleton is removed
  36051. */
  36052. onSkeletonRemovedObservable: Observable<Skeleton>;
  36053. /**
  36054. * An event triggered when a material is created
  36055. */
  36056. onNewMaterialAddedObservable: Observable<Material>;
  36057. /**
  36058. * An event triggered when a material is removed
  36059. */
  36060. onMaterialRemovedObservable: Observable<Material>;
  36061. /**
  36062. * An event triggered when a texture is created
  36063. */
  36064. onNewTextureAddedObservable: Observable<BaseTexture>;
  36065. /**
  36066. * An event triggered when a texture is removed
  36067. */
  36068. onTextureRemovedObservable: Observable<BaseTexture>;
  36069. /**
  36070. * An event triggered when render targets are about to be rendered
  36071. * Can happen multiple times per frame.
  36072. */
  36073. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36074. /**
  36075. * An event triggered when render targets were rendered.
  36076. * Can happen multiple times per frame.
  36077. */
  36078. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36079. /**
  36080. * An event triggered before calculating deterministic simulation step
  36081. */
  36082. onBeforeStepObservable: Observable<Scene>;
  36083. /**
  36084. * An event triggered after calculating deterministic simulation step
  36085. */
  36086. onAfterStepObservable: Observable<Scene>;
  36087. /**
  36088. * An event triggered when the activeCamera property is updated
  36089. */
  36090. onActiveCameraChanged: Observable<Scene>;
  36091. /**
  36092. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36093. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36094. * 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)
  36095. */
  36096. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36097. /**
  36098. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36099. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36100. * 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)
  36101. */
  36102. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36103. /**
  36104. * This Observable will when a mesh has been imported into the scene.
  36105. */
  36106. onMeshImportedObservable: Observable<AbstractMesh>;
  36107. /**
  36108. * This Observable will when an animation file has been imported into the scene.
  36109. */
  36110. onAnimationFileImportedObservable: Observable<Scene>;
  36111. /**
  36112. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36113. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36114. */
  36115. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36116. /** @hidden */
  36117. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36118. /**
  36119. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36120. */
  36121. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36122. /**
  36123. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36124. */
  36125. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36126. /**
  36127. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36128. */
  36129. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36130. /** Callback called when a pointer move is detected */
  36131. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36132. /** Callback called when a pointer down is detected */
  36133. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36134. /** Callback called when a pointer up is detected */
  36135. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36136. /** Callback called when a pointer pick is detected */
  36137. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36138. /**
  36139. * 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).
  36140. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36141. */
  36142. onPrePointerObservable: Observable<PointerInfoPre>;
  36143. /**
  36144. * Observable event triggered each time an input event is received from the rendering canvas
  36145. */
  36146. onPointerObservable: Observable<PointerInfo>;
  36147. /**
  36148. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36149. */
  36150. get unTranslatedPointer(): Vector2;
  36151. /**
  36152. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36153. */
  36154. static get DragMovementThreshold(): number;
  36155. static set DragMovementThreshold(value: number);
  36156. /**
  36157. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36158. */
  36159. static get LongPressDelay(): number;
  36160. static set LongPressDelay(value: number);
  36161. /**
  36162. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36163. */
  36164. static get DoubleClickDelay(): number;
  36165. static set DoubleClickDelay(value: number);
  36166. /** If you need to check double click without raising a single click at first click, enable this flag */
  36167. static get ExclusiveDoubleClickMode(): boolean;
  36168. static set ExclusiveDoubleClickMode(value: boolean);
  36169. /** @hidden */
  36170. _mirroredCameraPosition: Nullable<Vector3>;
  36171. /**
  36172. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36173. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36174. */
  36175. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36176. /**
  36177. * Observable event triggered each time an keyboard event is received from the hosting window
  36178. */
  36179. onKeyboardObservable: Observable<KeyboardInfo>;
  36180. private _useRightHandedSystem;
  36181. /**
  36182. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36183. */
  36184. set useRightHandedSystem(value: boolean);
  36185. get useRightHandedSystem(): boolean;
  36186. private _timeAccumulator;
  36187. private _currentStepId;
  36188. private _currentInternalStep;
  36189. /**
  36190. * Sets the step Id used by deterministic lock step
  36191. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36192. * @param newStepId defines the step Id
  36193. */
  36194. setStepId(newStepId: number): void;
  36195. /**
  36196. * Gets the step Id used by deterministic lock step
  36197. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36198. * @returns the step Id
  36199. */
  36200. getStepId(): number;
  36201. /**
  36202. * Gets the internal step used by deterministic lock step
  36203. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36204. * @returns the internal step
  36205. */
  36206. getInternalStep(): number;
  36207. private _fogEnabled;
  36208. /**
  36209. * Gets or sets a boolean indicating if fog is enabled on this scene
  36210. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36211. * (Default is true)
  36212. */
  36213. set fogEnabled(value: boolean);
  36214. get fogEnabled(): boolean;
  36215. private _fogMode;
  36216. /**
  36217. * Gets or sets the fog mode to use
  36218. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36219. * | mode | value |
  36220. * | --- | --- |
  36221. * | FOGMODE_NONE | 0 |
  36222. * | FOGMODE_EXP | 1 |
  36223. * | FOGMODE_EXP2 | 2 |
  36224. * | FOGMODE_LINEAR | 3 |
  36225. */
  36226. set fogMode(value: number);
  36227. get fogMode(): number;
  36228. /**
  36229. * Gets or sets the fog color to use
  36230. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36231. * (Default is Color3(0.2, 0.2, 0.3))
  36232. */
  36233. fogColor: Color3;
  36234. /**
  36235. * Gets or sets the fog density to use
  36236. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36237. * (Default is 0.1)
  36238. */
  36239. fogDensity: number;
  36240. /**
  36241. * Gets or sets the fog start distance to use
  36242. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36243. * (Default is 0)
  36244. */
  36245. fogStart: number;
  36246. /**
  36247. * Gets or sets the fog end distance to use
  36248. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36249. * (Default is 1000)
  36250. */
  36251. fogEnd: number;
  36252. private _shadowsEnabled;
  36253. /**
  36254. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36255. */
  36256. set shadowsEnabled(value: boolean);
  36257. get shadowsEnabled(): boolean;
  36258. private _lightsEnabled;
  36259. /**
  36260. * Gets or sets a boolean indicating if lights are enabled on this scene
  36261. */
  36262. set lightsEnabled(value: boolean);
  36263. get lightsEnabled(): boolean;
  36264. /** All of the active cameras added to this scene. */
  36265. activeCameras: Camera[];
  36266. /** @hidden */
  36267. _activeCamera: Nullable<Camera>;
  36268. /** Gets or sets the current active camera */
  36269. get activeCamera(): Nullable<Camera>;
  36270. set activeCamera(value: Nullable<Camera>);
  36271. private _defaultMaterial;
  36272. /** The default material used on meshes when no material is affected */
  36273. get defaultMaterial(): Material;
  36274. /** The default material used on meshes when no material is affected */
  36275. set defaultMaterial(value: Material);
  36276. private _texturesEnabled;
  36277. /**
  36278. * Gets or sets a boolean indicating if textures are enabled on this scene
  36279. */
  36280. set texturesEnabled(value: boolean);
  36281. get texturesEnabled(): boolean;
  36282. /**
  36283. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  36284. */
  36285. physicsEnabled: boolean;
  36286. /**
  36287. * Gets or sets a boolean indicating if particles are enabled on this scene
  36288. */
  36289. particlesEnabled: boolean;
  36290. /**
  36291. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36292. */
  36293. spritesEnabled: boolean;
  36294. private _skeletonsEnabled;
  36295. /**
  36296. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36297. */
  36298. set skeletonsEnabled(value: boolean);
  36299. get skeletonsEnabled(): boolean;
  36300. /**
  36301. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36302. */
  36303. lensFlaresEnabled: boolean;
  36304. /**
  36305. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36306. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36307. */
  36308. collisionsEnabled: boolean;
  36309. private _collisionCoordinator;
  36310. /** @hidden */
  36311. get collisionCoordinator(): ICollisionCoordinator;
  36312. /**
  36313. * Defines the gravity applied to this scene (used only for collisions)
  36314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36315. */
  36316. gravity: Vector3;
  36317. /**
  36318. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36319. */
  36320. postProcessesEnabled: boolean;
  36321. /**
  36322. * The list of postprocesses added to the scene
  36323. */
  36324. postProcesses: PostProcess[];
  36325. /**
  36326. * Gets the current postprocess manager
  36327. */
  36328. postProcessManager: PostProcessManager;
  36329. /**
  36330. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36331. */
  36332. renderTargetsEnabled: boolean;
  36333. /**
  36334. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36335. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36336. */
  36337. dumpNextRenderTargets: boolean;
  36338. /**
  36339. * The list of user defined render targets added to the scene
  36340. */
  36341. customRenderTargets: RenderTargetTexture[];
  36342. /**
  36343. * Defines if texture loading must be delayed
  36344. * If true, textures will only be loaded when they need to be rendered
  36345. */
  36346. useDelayedTextureLoading: boolean;
  36347. /**
  36348. * Gets the list of meshes imported to the scene through SceneLoader
  36349. */
  36350. importedMeshesFiles: String[];
  36351. /**
  36352. * Gets or sets a boolean indicating if probes are enabled on this scene
  36353. */
  36354. probesEnabled: boolean;
  36355. /**
  36356. * Gets or sets the current offline provider to use to store scene data
  36357. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36358. */
  36359. offlineProvider: IOfflineProvider;
  36360. /**
  36361. * Gets or sets the action manager associated with the scene
  36362. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36363. */
  36364. actionManager: AbstractActionManager;
  36365. private _meshesForIntersections;
  36366. /**
  36367. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36368. */
  36369. proceduralTexturesEnabled: boolean;
  36370. private _engine;
  36371. private _totalVertices;
  36372. /** @hidden */
  36373. _activeIndices: PerfCounter;
  36374. /** @hidden */
  36375. _activeParticles: PerfCounter;
  36376. /** @hidden */
  36377. _activeBones: PerfCounter;
  36378. private _animationRatio;
  36379. /** @hidden */
  36380. _animationTimeLast: number;
  36381. /** @hidden */
  36382. _animationTime: number;
  36383. /**
  36384. * Gets or sets a general scale for animation speed
  36385. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36386. */
  36387. animationTimeScale: number;
  36388. /** @hidden */
  36389. _cachedMaterial: Nullable<Material>;
  36390. /** @hidden */
  36391. _cachedEffect: Nullable<Effect>;
  36392. /** @hidden */
  36393. _cachedVisibility: Nullable<number>;
  36394. private _renderId;
  36395. private _frameId;
  36396. private _executeWhenReadyTimeoutId;
  36397. private _intermediateRendering;
  36398. private _viewUpdateFlag;
  36399. private _projectionUpdateFlag;
  36400. /** @hidden */
  36401. _toBeDisposed: Nullable<IDisposable>[];
  36402. private _activeRequests;
  36403. /** @hidden */
  36404. _pendingData: any[];
  36405. private _isDisposed;
  36406. /**
  36407. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36408. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36409. */
  36410. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36411. private _activeMeshes;
  36412. private _processedMaterials;
  36413. private _renderTargets;
  36414. /** @hidden */
  36415. _activeParticleSystems: SmartArray<IParticleSystem>;
  36416. private _activeSkeletons;
  36417. private _softwareSkinnedMeshes;
  36418. private _renderingManager;
  36419. /** @hidden */
  36420. _activeAnimatables: Animatable[];
  36421. private _transformMatrix;
  36422. private _sceneUbo;
  36423. /** @hidden */
  36424. _viewMatrix: Matrix;
  36425. private _projectionMatrix;
  36426. /** @hidden */
  36427. _forcedViewPosition: Nullable<Vector3>;
  36428. /** @hidden */
  36429. _frustumPlanes: Plane[];
  36430. /**
  36431. * Gets the list of frustum planes (built from the active camera)
  36432. */
  36433. get frustumPlanes(): Plane[];
  36434. /**
  36435. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36436. * This is useful if there are more lights that the maximum simulteanous authorized
  36437. */
  36438. requireLightSorting: boolean;
  36439. /** @hidden */
  36440. readonly useMaterialMeshMap: boolean;
  36441. /** @hidden */
  36442. readonly useClonedMeshMap: boolean;
  36443. private _externalData;
  36444. private _uid;
  36445. /**
  36446. * @hidden
  36447. * Backing store of defined scene components.
  36448. */
  36449. _components: ISceneComponent[];
  36450. /**
  36451. * @hidden
  36452. * Backing store of defined scene components.
  36453. */
  36454. _serializableComponents: ISceneSerializableComponent[];
  36455. /**
  36456. * List of components to register on the next registration step.
  36457. */
  36458. private _transientComponents;
  36459. /**
  36460. * Registers the transient components if needed.
  36461. */
  36462. private _registerTransientComponents;
  36463. /**
  36464. * @hidden
  36465. * Add a component to the scene.
  36466. * Note that the ccomponent could be registered on th next frame if this is called after
  36467. * the register component stage.
  36468. * @param component Defines the component to add to the scene
  36469. */
  36470. _addComponent(component: ISceneComponent): void;
  36471. /**
  36472. * @hidden
  36473. * Gets a component from the scene.
  36474. * @param name defines the name of the component to retrieve
  36475. * @returns the component or null if not present
  36476. */
  36477. _getComponent(name: string): Nullable<ISceneComponent>;
  36478. /**
  36479. * @hidden
  36480. * Defines the actions happening before camera updates.
  36481. */
  36482. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36483. /**
  36484. * @hidden
  36485. * Defines the actions happening before clear the canvas.
  36486. */
  36487. _beforeClearStage: Stage<SimpleStageAction>;
  36488. /**
  36489. * @hidden
  36490. * Defines the actions when collecting render targets for the frame.
  36491. */
  36492. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36493. /**
  36494. * @hidden
  36495. * Defines the actions happening for one camera in the frame.
  36496. */
  36497. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36498. /**
  36499. * @hidden
  36500. * Defines the actions happening during the per mesh ready checks.
  36501. */
  36502. _isReadyForMeshStage: Stage<MeshStageAction>;
  36503. /**
  36504. * @hidden
  36505. * Defines the actions happening before evaluate active mesh checks.
  36506. */
  36507. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36508. /**
  36509. * @hidden
  36510. * Defines the actions happening during the evaluate sub mesh checks.
  36511. */
  36512. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36513. /**
  36514. * @hidden
  36515. * Defines the actions happening during the active mesh stage.
  36516. */
  36517. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36518. /**
  36519. * @hidden
  36520. * Defines the actions happening during the per camera render target step.
  36521. */
  36522. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36523. /**
  36524. * @hidden
  36525. * Defines the actions happening just before the active camera is drawing.
  36526. */
  36527. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36528. /**
  36529. * @hidden
  36530. * Defines the actions happening just before a render target is drawing.
  36531. */
  36532. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36533. /**
  36534. * @hidden
  36535. * Defines the actions happening just before a rendering group is drawing.
  36536. */
  36537. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36538. /**
  36539. * @hidden
  36540. * Defines the actions happening just before a mesh is drawing.
  36541. */
  36542. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36543. /**
  36544. * @hidden
  36545. * Defines the actions happening just after a mesh has been drawn.
  36546. */
  36547. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36548. /**
  36549. * @hidden
  36550. * Defines the actions happening just after a rendering group has been drawn.
  36551. */
  36552. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36553. /**
  36554. * @hidden
  36555. * Defines the actions happening just after the active camera has been drawn.
  36556. */
  36557. _afterCameraDrawStage: Stage<CameraStageAction>;
  36558. /**
  36559. * @hidden
  36560. * Defines the actions happening just after a render target has been drawn.
  36561. */
  36562. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36563. /**
  36564. * @hidden
  36565. * Defines the actions happening just after rendering all cameras and computing intersections.
  36566. */
  36567. _afterRenderStage: Stage<SimpleStageAction>;
  36568. /**
  36569. * @hidden
  36570. * Defines the actions happening when a pointer move event happens.
  36571. */
  36572. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36573. /**
  36574. * @hidden
  36575. * Defines the actions happening when a pointer down event happens.
  36576. */
  36577. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36578. /**
  36579. * @hidden
  36580. * Defines the actions happening when a pointer up event happens.
  36581. */
  36582. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36583. /**
  36584. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36585. */
  36586. private geometriesByUniqueId;
  36587. /**
  36588. * Creates a new Scene
  36589. * @param engine defines the engine to use to render this scene
  36590. * @param options defines the scene options
  36591. */
  36592. constructor(engine: Engine, options?: SceneOptions);
  36593. /**
  36594. * Gets a string idenfifying the name of the class
  36595. * @returns "Scene" string
  36596. */
  36597. getClassName(): string;
  36598. private _defaultMeshCandidates;
  36599. /**
  36600. * @hidden
  36601. */
  36602. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36603. private _defaultSubMeshCandidates;
  36604. /**
  36605. * @hidden
  36606. */
  36607. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36608. /**
  36609. * Sets the default candidate providers for the scene.
  36610. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36611. * and getCollidingSubMeshCandidates to their default function
  36612. */
  36613. setDefaultCandidateProviders(): void;
  36614. /**
  36615. * Gets the mesh that is currently under the pointer
  36616. */
  36617. get meshUnderPointer(): Nullable<AbstractMesh>;
  36618. /**
  36619. * Gets or sets the current on-screen X position of the pointer
  36620. */
  36621. get pointerX(): number;
  36622. set pointerX(value: number);
  36623. /**
  36624. * Gets or sets the current on-screen Y position of the pointer
  36625. */
  36626. get pointerY(): number;
  36627. set pointerY(value: number);
  36628. /**
  36629. * Gets the cached material (ie. the latest rendered one)
  36630. * @returns the cached material
  36631. */
  36632. getCachedMaterial(): Nullable<Material>;
  36633. /**
  36634. * Gets the cached effect (ie. the latest rendered one)
  36635. * @returns the cached effect
  36636. */
  36637. getCachedEffect(): Nullable<Effect>;
  36638. /**
  36639. * Gets the cached visibility state (ie. the latest rendered one)
  36640. * @returns the cached visibility state
  36641. */
  36642. getCachedVisibility(): Nullable<number>;
  36643. /**
  36644. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36645. * @param material defines the current material
  36646. * @param effect defines the current effect
  36647. * @param visibility defines the current visibility state
  36648. * @returns true if one parameter is not cached
  36649. */
  36650. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36651. /**
  36652. * Gets the engine associated with the scene
  36653. * @returns an Engine
  36654. */
  36655. getEngine(): Engine;
  36656. /**
  36657. * Gets the total number of vertices rendered per frame
  36658. * @returns the total number of vertices rendered per frame
  36659. */
  36660. getTotalVertices(): number;
  36661. /**
  36662. * Gets the performance counter for total vertices
  36663. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36664. */
  36665. get totalVerticesPerfCounter(): PerfCounter;
  36666. /**
  36667. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36668. * @returns the total number of active indices rendered per frame
  36669. */
  36670. getActiveIndices(): number;
  36671. /**
  36672. * Gets the performance counter for active indices
  36673. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36674. */
  36675. get totalActiveIndicesPerfCounter(): PerfCounter;
  36676. /**
  36677. * Gets the total number of active particles rendered per frame
  36678. * @returns the total number of active particles rendered per frame
  36679. */
  36680. getActiveParticles(): number;
  36681. /**
  36682. * Gets the performance counter for active particles
  36683. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36684. */
  36685. get activeParticlesPerfCounter(): PerfCounter;
  36686. /**
  36687. * Gets the total number of active bones rendered per frame
  36688. * @returns the total number of active bones rendered per frame
  36689. */
  36690. getActiveBones(): number;
  36691. /**
  36692. * Gets the performance counter for active bones
  36693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36694. */
  36695. get activeBonesPerfCounter(): PerfCounter;
  36696. /**
  36697. * Gets the array of active meshes
  36698. * @returns an array of AbstractMesh
  36699. */
  36700. getActiveMeshes(): SmartArray<AbstractMesh>;
  36701. /**
  36702. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36703. * @returns a number
  36704. */
  36705. getAnimationRatio(): number;
  36706. /**
  36707. * Gets an unique Id for the current render phase
  36708. * @returns a number
  36709. */
  36710. getRenderId(): number;
  36711. /**
  36712. * Gets an unique Id for the current frame
  36713. * @returns a number
  36714. */
  36715. getFrameId(): number;
  36716. /** Call this function if you want to manually increment the render Id*/
  36717. incrementRenderId(): void;
  36718. private _createUbo;
  36719. /**
  36720. * Use this method to simulate a pointer move on a mesh
  36721. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36722. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36723. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36724. * @returns the current scene
  36725. */
  36726. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36727. /**
  36728. * Use this method to simulate a pointer down on a mesh
  36729. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36730. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36731. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36732. * @returns the current scene
  36733. */
  36734. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36735. /**
  36736. * Use this method to simulate a pointer up on a mesh
  36737. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36738. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36739. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36740. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36741. * @returns the current scene
  36742. */
  36743. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36744. /**
  36745. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36746. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36747. * @returns true if the pointer was captured
  36748. */
  36749. isPointerCaptured(pointerId?: number): boolean;
  36750. /**
  36751. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36752. * @param attachUp defines if you want to attach events to pointerup
  36753. * @param attachDown defines if you want to attach events to pointerdown
  36754. * @param attachMove defines if you want to attach events to pointermove
  36755. */
  36756. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36757. /** Detaches all event handlers*/
  36758. detachControl(): void;
  36759. /**
  36760. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36761. * Delay loaded resources are not taking in account
  36762. * @return true if all required resources are ready
  36763. */
  36764. isReady(): boolean;
  36765. /** Resets all cached information relative to material (including effect and visibility) */
  36766. resetCachedMaterial(): void;
  36767. /**
  36768. * Registers a function to be called before every frame render
  36769. * @param func defines the function to register
  36770. */
  36771. registerBeforeRender(func: () => void): void;
  36772. /**
  36773. * Unregisters a function called before every frame render
  36774. * @param func defines the function to unregister
  36775. */
  36776. unregisterBeforeRender(func: () => void): void;
  36777. /**
  36778. * Registers a function to be called after every frame render
  36779. * @param func defines the function to register
  36780. */
  36781. registerAfterRender(func: () => void): void;
  36782. /**
  36783. * Unregisters a function called after every frame render
  36784. * @param func defines the function to unregister
  36785. */
  36786. unregisterAfterRender(func: () => void): void;
  36787. private _executeOnceBeforeRender;
  36788. /**
  36789. * The provided function will run before render once and will be disposed afterwards.
  36790. * A timeout delay can be provided so that the function will be executed in N ms.
  36791. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36792. * @param func The function to be executed.
  36793. * @param timeout optional delay in ms
  36794. */
  36795. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36796. /** @hidden */
  36797. _addPendingData(data: any): void;
  36798. /** @hidden */
  36799. _removePendingData(data: any): void;
  36800. /**
  36801. * Returns the number of items waiting to be loaded
  36802. * @returns the number of items waiting to be loaded
  36803. */
  36804. getWaitingItemsCount(): number;
  36805. /**
  36806. * Returns a boolean indicating if the scene is still loading data
  36807. */
  36808. get isLoading(): boolean;
  36809. /**
  36810. * Registers a function to be executed when the scene is ready
  36811. * @param {Function} func - the function to be executed
  36812. */
  36813. executeWhenReady(func: () => void): void;
  36814. /**
  36815. * Returns a promise that resolves when the scene is ready
  36816. * @returns A promise that resolves when the scene is ready
  36817. */
  36818. whenReadyAsync(): Promise<void>;
  36819. /** @hidden */
  36820. _checkIsReady(): void;
  36821. /**
  36822. * Gets all animatable attached to the scene
  36823. */
  36824. get animatables(): Animatable[];
  36825. /**
  36826. * Resets the last animation time frame.
  36827. * Useful to override when animations start running when loading a scene for the first time.
  36828. */
  36829. resetLastAnimationTimeFrame(): void;
  36830. /**
  36831. * Gets the current view matrix
  36832. * @returns a Matrix
  36833. */
  36834. getViewMatrix(): Matrix;
  36835. /**
  36836. * Gets the current projection matrix
  36837. * @returns a Matrix
  36838. */
  36839. getProjectionMatrix(): Matrix;
  36840. /**
  36841. * Gets the current transform matrix
  36842. * @returns a Matrix made of View * Projection
  36843. */
  36844. getTransformMatrix(): Matrix;
  36845. /**
  36846. * Sets the current transform matrix
  36847. * @param viewL defines the View matrix to use
  36848. * @param projectionL defines the Projection matrix to use
  36849. * @param viewR defines the right View matrix to use (if provided)
  36850. * @param projectionR defines the right Projection matrix to use (if provided)
  36851. */
  36852. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36853. /**
  36854. * Gets the uniform buffer used to store scene data
  36855. * @returns a UniformBuffer
  36856. */
  36857. getSceneUniformBuffer(): UniformBuffer;
  36858. /**
  36859. * Gets an unique (relatively to the current scene) Id
  36860. * @returns an unique number for the scene
  36861. */
  36862. getUniqueId(): number;
  36863. /**
  36864. * Add a mesh to the list of scene's meshes
  36865. * @param newMesh defines the mesh to add
  36866. * @param recursive if all child meshes should also be added to the scene
  36867. */
  36868. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36869. /**
  36870. * Remove a mesh for the list of scene's meshes
  36871. * @param toRemove defines the mesh to remove
  36872. * @param recursive if all child meshes should also be removed from the scene
  36873. * @returns the index where the mesh was in the mesh list
  36874. */
  36875. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36876. /**
  36877. * Add a transform node to the list of scene's transform nodes
  36878. * @param newTransformNode defines the transform node to add
  36879. */
  36880. addTransformNode(newTransformNode: TransformNode): void;
  36881. /**
  36882. * Remove a transform node for the list of scene's transform nodes
  36883. * @param toRemove defines the transform node to remove
  36884. * @returns the index where the transform node was in the transform node list
  36885. */
  36886. removeTransformNode(toRemove: TransformNode): number;
  36887. /**
  36888. * Remove a skeleton for the list of scene's skeletons
  36889. * @param toRemove defines the skeleton to remove
  36890. * @returns the index where the skeleton was in the skeleton list
  36891. */
  36892. removeSkeleton(toRemove: Skeleton): number;
  36893. /**
  36894. * Remove a morph target for the list of scene's morph targets
  36895. * @param toRemove defines the morph target to remove
  36896. * @returns the index where the morph target was in the morph target list
  36897. */
  36898. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36899. /**
  36900. * Remove a light for the list of scene's lights
  36901. * @param toRemove defines the light to remove
  36902. * @returns the index where the light was in the light list
  36903. */
  36904. removeLight(toRemove: Light): number;
  36905. /**
  36906. * Remove a camera for the list of scene's cameras
  36907. * @param toRemove defines the camera to remove
  36908. * @returns the index where the camera was in the camera list
  36909. */
  36910. removeCamera(toRemove: Camera): number;
  36911. /**
  36912. * Remove a particle system for the list of scene's particle systems
  36913. * @param toRemove defines the particle system to remove
  36914. * @returns the index where the particle system was in the particle system list
  36915. */
  36916. removeParticleSystem(toRemove: IParticleSystem): number;
  36917. /**
  36918. * Remove a animation for the list of scene's animations
  36919. * @param toRemove defines the animation to remove
  36920. * @returns the index where the animation was in the animation list
  36921. */
  36922. removeAnimation(toRemove: Animation): number;
  36923. /**
  36924. * Will stop the animation of the given target
  36925. * @param target - the target
  36926. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36927. * @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)
  36928. */
  36929. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36930. /**
  36931. * Removes the given animation group from this scene.
  36932. * @param toRemove The animation group to remove
  36933. * @returns The index of the removed animation group
  36934. */
  36935. removeAnimationGroup(toRemove: AnimationGroup): number;
  36936. /**
  36937. * Removes the given multi-material from this scene.
  36938. * @param toRemove The multi-material to remove
  36939. * @returns The index of the removed multi-material
  36940. */
  36941. removeMultiMaterial(toRemove: MultiMaterial): number;
  36942. /**
  36943. * Removes the given material from this scene.
  36944. * @param toRemove The material to remove
  36945. * @returns The index of the removed material
  36946. */
  36947. removeMaterial(toRemove: Material): number;
  36948. /**
  36949. * Removes the given action manager from this scene.
  36950. * @param toRemove The action manager to remove
  36951. * @returns The index of the removed action manager
  36952. */
  36953. removeActionManager(toRemove: AbstractActionManager): number;
  36954. /**
  36955. * Removes the given texture from this scene.
  36956. * @param toRemove The texture to remove
  36957. * @returns The index of the removed texture
  36958. */
  36959. removeTexture(toRemove: BaseTexture): number;
  36960. /**
  36961. * Adds the given light to this scene
  36962. * @param newLight The light to add
  36963. */
  36964. addLight(newLight: Light): void;
  36965. /**
  36966. * Sorts the list list based on light priorities
  36967. */
  36968. sortLightsByPriority(): void;
  36969. /**
  36970. * Adds the given camera to this scene
  36971. * @param newCamera The camera to add
  36972. */
  36973. addCamera(newCamera: Camera): void;
  36974. /**
  36975. * Adds the given skeleton to this scene
  36976. * @param newSkeleton The skeleton to add
  36977. */
  36978. addSkeleton(newSkeleton: Skeleton): void;
  36979. /**
  36980. * Adds the given particle system to this scene
  36981. * @param newParticleSystem The particle system to add
  36982. */
  36983. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36984. /**
  36985. * Adds the given animation to this scene
  36986. * @param newAnimation The animation to add
  36987. */
  36988. addAnimation(newAnimation: Animation): void;
  36989. /**
  36990. * Adds the given animation group to this scene.
  36991. * @param newAnimationGroup The animation group to add
  36992. */
  36993. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36994. /**
  36995. * Adds the given multi-material to this scene
  36996. * @param newMultiMaterial The multi-material to add
  36997. */
  36998. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36999. /**
  37000. * Adds the given material to this scene
  37001. * @param newMaterial The material to add
  37002. */
  37003. addMaterial(newMaterial: Material): void;
  37004. /**
  37005. * Adds the given morph target to this scene
  37006. * @param newMorphTargetManager The morph target to add
  37007. */
  37008. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37009. /**
  37010. * Adds the given geometry to this scene
  37011. * @param newGeometry The geometry to add
  37012. */
  37013. addGeometry(newGeometry: Geometry): void;
  37014. /**
  37015. * Adds the given action manager to this scene
  37016. * @param newActionManager The action manager to add
  37017. */
  37018. addActionManager(newActionManager: AbstractActionManager): void;
  37019. /**
  37020. * Adds the given texture to this scene.
  37021. * @param newTexture The texture to add
  37022. */
  37023. addTexture(newTexture: BaseTexture): void;
  37024. /**
  37025. * Switch active camera
  37026. * @param newCamera defines the new active camera
  37027. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37028. */
  37029. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37030. /**
  37031. * sets the active camera of the scene using its ID
  37032. * @param id defines the camera's ID
  37033. * @return the new active camera or null if none found.
  37034. */
  37035. setActiveCameraByID(id: string): Nullable<Camera>;
  37036. /**
  37037. * sets the active camera of the scene using its name
  37038. * @param name defines the camera's name
  37039. * @returns the new active camera or null if none found.
  37040. */
  37041. setActiveCameraByName(name: string): Nullable<Camera>;
  37042. /**
  37043. * get an animation group using its name
  37044. * @param name defines the material's name
  37045. * @return the animation group or null if none found.
  37046. */
  37047. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37048. /**
  37049. * Get a material using its unique id
  37050. * @param uniqueId defines the material's unique id
  37051. * @return the material or null if none found.
  37052. */
  37053. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37054. /**
  37055. * get a material using its id
  37056. * @param id defines the material's ID
  37057. * @return the material or null if none found.
  37058. */
  37059. getMaterialByID(id: string): Nullable<Material>;
  37060. /**
  37061. * Gets a the last added material using a given id
  37062. * @param id defines the material's ID
  37063. * @return the last material with the given id or null if none found.
  37064. */
  37065. getLastMaterialByID(id: string): Nullable<Material>;
  37066. /**
  37067. * Gets a material using its name
  37068. * @param name defines the material's name
  37069. * @return the material or null if none found.
  37070. */
  37071. getMaterialByName(name: string): Nullable<Material>;
  37072. /**
  37073. * Get a texture using its unique id
  37074. * @param uniqueId defines the texture's unique id
  37075. * @return the texture or null if none found.
  37076. */
  37077. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37078. /**
  37079. * Gets a camera using its id
  37080. * @param id defines the id to look for
  37081. * @returns the camera or null if not found
  37082. */
  37083. getCameraByID(id: string): Nullable<Camera>;
  37084. /**
  37085. * Gets a camera using its unique id
  37086. * @param uniqueId defines the unique id to look for
  37087. * @returns the camera or null if not found
  37088. */
  37089. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37090. /**
  37091. * Gets a camera using its name
  37092. * @param name defines the camera's name
  37093. * @return the camera or null if none found.
  37094. */
  37095. getCameraByName(name: string): Nullable<Camera>;
  37096. /**
  37097. * Gets a bone using its id
  37098. * @param id defines the bone's id
  37099. * @return the bone or null if not found
  37100. */
  37101. getBoneByID(id: string): Nullable<Bone>;
  37102. /**
  37103. * Gets a bone using its id
  37104. * @param name defines the bone's name
  37105. * @return the bone or null if not found
  37106. */
  37107. getBoneByName(name: string): Nullable<Bone>;
  37108. /**
  37109. * Gets a light node using its name
  37110. * @param name defines the the light's name
  37111. * @return the light or null if none found.
  37112. */
  37113. getLightByName(name: string): Nullable<Light>;
  37114. /**
  37115. * Gets a light node using its id
  37116. * @param id defines the light's id
  37117. * @return the light or null if none found.
  37118. */
  37119. getLightByID(id: string): Nullable<Light>;
  37120. /**
  37121. * Gets a light node using its scene-generated unique ID
  37122. * @param uniqueId defines the light's unique id
  37123. * @return the light or null if none found.
  37124. */
  37125. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37126. /**
  37127. * Gets a particle system by id
  37128. * @param id defines the particle system id
  37129. * @return the corresponding system or null if none found
  37130. */
  37131. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37132. /**
  37133. * Gets a geometry using its ID
  37134. * @param id defines the geometry's id
  37135. * @return the geometry or null if none found.
  37136. */
  37137. getGeometryByID(id: string): Nullable<Geometry>;
  37138. private _getGeometryByUniqueID;
  37139. /**
  37140. * Add a new geometry to this scene
  37141. * @param geometry defines the geometry to be added to the scene.
  37142. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37143. * @return a boolean defining if the geometry was added or not
  37144. */
  37145. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37146. /**
  37147. * Removes an existing geometry
  37148. * @param geometry defines the geometry to be removed from the scene
  37149. * @return a boolean defining if the geometry was removed or not
  37150. */
  37151. removeGeometry(geometry: Geometry): boolean;
  37152. /**
  37153. * Gets the list of geometries attached to the scene
  37154. * @returns an array of Geometry
  37155. */
  37156. getGeometries(): Geometry[];
  37157. /**
  37158. * Gets the first added mesh found of a given ID
  37159. * @param id defines the id to search for
  37160. * @return the mesh found or null if not found at all
  37161. */
  37162. getMeshByID(id: string): Nullable<AbstractMesh>;
  37163. /**
  37164. * Gets a list of meshes using their id
  37165. * @param id defines the id to search for
  37166. * @returns a list of meshes
  37167. */
  37168. getMeshesByID(id: string): Array<AbstractMesh>;
  37169. /**
  37170. * Gets the first added transform node found of a given ID
  37171. * @param id defines the id to search for
  37172. * @return the found transform node or null if not found at all.
  37173. */
  37174. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37175. /**
  37176. * Gets a transform node with its auto-generated unique id
  37177. * @param uniqueId efines the unique id to search for
  37178. * @return the found transform node or null if not found at all.
  37179. */
  37180. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37181. /**
  37182. * Gets a list of transform nodes using their id
  37183. * @param id defines the id to search for
  37184. * @returns a list of transform nodes
  37185. */
  37186. getTransformNodesByID(id: string): Array<TransformNode>;
  37187. /**
  37188. * Gets a mesh with its auto-generated unique id
  37189. * @param uniqueId defines the unique id to search for
  37190. * @return the found mesh or null if not found at all.
  37191. */
  37192. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37193. /**
  37194. * Gets a the last added mesh using a given id
  37195. * @param id defines the id to search for
  37196. * @return the found mesh or null if not found at all.
  37197. */
  37198. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37199. /**
  37200. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37201. * @param id defines the id to search for
  37202. * @return the found node or null if not found at all
  37203. */
  37204. getLastEntryByID(id: string): Nullable<Node>;
  37205. /**
  37206. * Gets a node (Mesh, Camera, Light) using a given id
  37207. * @param id defines the id to search for
  37208. * @return the found node or null if not found at all
  37209. */
  37210. getNodeByID(id: string): Nullable<Node>;
  37211. /**
  37212. * Gets a node (Mesh, Camera, Light) using a given name
  37213. * @param name defines the name to search for
  37214. * @return the found node or null if not found at all.
  37215. */
  37216. getNodeByName(name: string): Nullable<Node>;
  37217. /**
  37218. * Gets a mesh using a given name
  37219. * @param name defines the name to search for
  37220. * @return the found mesh or null if not found at all.
  37221. */
  37222. getMeshByName(name: string): Nullable<AbstractMesh>;
  37223. /**
  37224. * Gets a transform node using a given name
  37225. * @param name defines the name to search for
  37226. * @return the found transform node or null if not found at all.
  37227. */
  37228. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37229. /**
  37230. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37231. * @param id defines the id to search for
  37232. * @return the found skeleton or null if not found at all.
  37233. */
  37234. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37235. /**
  37236. * Gets a skeleton using a given auto generated unique id
  37237. * @param uniqueId defines the unique id to search for
  37238. * @return the found skeleton or null if not found at all.
  37239. */
  37240. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37241. /**
  37242. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37243. * @param id defines the id to search for
  37244. * @return the found skeleton or null if not found at all.
  37245. */
  37246. getSkeletonById(id: string): Nullable<Skeleton>;
  37247. /**
  37248. * Gets a skeleton using a given name
  37249. * @param name defines the name to search for
  37250. * @return the found skeleton or null if not found at all.
  37251. */
  37252. getSkeletonByName(name: string): Nullable<Skeleton>;
  37253. /**
  37254. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37255. * @param id defines the id to search for
  37256. * @return the found morph target manager or null if not found at all.
  37257. */
  37258. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37259. /**
  37260. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37261. * @param id defines the id to search for
  37262. * @return the found morph target or null if not found at all.
  37263. */
  37264. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37265. /**
  37266. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  37267. * @param name defines the name to search for
  37268. * @return the found morph target or null if not found at all.
  37269. */
  37270. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  37271. /**
  37272. * Gets a boolean indicating if the given mesh is active
  37273. * @param mesh defines the mesh to look for
  37274. * @returns true if the mesh is in the active list
  37275. */
  37276. isActiveMesh(mesh: AbstractMesh): boolean;
  37277. /**
  37278. * Return a unique id as a string which can serve as an identifier for the scene
  37279. */
  37280. get uid(): string;
  37281. /**
  37282. * Add an externaly attached data from its key.
  37283. * This method call will fail and return false, if such key already exists.
  37284. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37285. * @param key the unique key that identifies the data
  37286. * @param data the data object to associate to the key for this Engine instance
  37287. * @return true if no such key were already present and the data was added successfully, false otherwise
  37288. */
  37289. addExternalData<T>(key: string, data: T): boolean;
  37290. /**
  37291. * Get an externaly attached data from its key
  37292. * @param key the unique key that identifies the data
  37293. * @return the associated data, if present (can be null), or undefined if not present
  37294. */
  37295. getExternalData<T>(key: string): Nullable<T>;
  37296. /**
  37297. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37298. * @param key the unique key that identifies the data
  37299. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37300. * @return the associated data, can be null if the factory returned null.
  37301. */
  37302. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37303. /**
  37304. * Remove an externaly attached data from the Engine instance
  37305. * @param key the unique key that identifies the data
  37306. * @return true if the data was successfully removed, false if it doesn't exist
  37307. */
  37308. removeExternalData(key: string): boolean;
  37309. private _evaluateSubMesh;
  37310. /**
  37311. * Clear the processed materials smart array preventing retention point in material dispose.
  37312. */
  37313. freeProcessedMaterials(): void;
  37314. private _preventFreeActiveMeshesAndRenderingGroups;
  37315. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37316. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37317. * when disposing several meshes in a row or a hierarchy of meshes.
  37318. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37319. */
  37320. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37321. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37322. /**
  37323. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37324. */
  37325. freeActiveMeshes(): void;
  37326. /**
  37327. * Clear the info related to rendering groups preventing retention points during dispose.
  37328. */
  37329. freeRenderingGroups(): void;
  37330. /** @hidden */
  37331. _isInIntermediateRendering(): boolean;
  37332. /**
  37333. * Lambda returning the list of potentially active meshes.
  37334. */
  37335. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37336. /**
  37337. * Lambda returning the list of potentially active sub meshes.
  37338. */
  37339. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37340. /**
  37341. * Lambda returning the list of potentially intersecting sub meshes.
  37342. */
  37343. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37344. /**
  37345. * Lambda returning the list of potentially colliding sub meshes.
  37346. */
  37347. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37348. private _activeMeshesFrozen;
  37349. private _skipEvaluateActiveMeshesCompletely;
  37350. /**
  37351. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37352. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37353. * @returns the current scene
  37354. */
  37355. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37356. /**
  37357. * Use this function to restart evaluating active meshes on every frame
  37358. * @returns the current scene
  37359. */
  37360. unfreezeActiveMeshes(): Scene;
  37361. private _evaluateActiveMeshes;
  37362. private _activeMesh;
  37363. /**
  37364. * Update the transform matrix to update from the current active camera
  37365. * @param force defines a boolean used to force the update even if cache is up to date
  37366. */
  37367. updateTransformMatrix(force?: boolean): void;
  37368. private _bindFrameBuffer;
  37369. /** @hidden */
  37370. _allowPostProcessClearColor: boolean;
  37371. /** @hidden */
  37372. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37373. private _processSubCameras;
  37374. private _checkIntersections;
  37375. /** @hidden */
  37376. _advancePhysicsEngineStep(step: number): void;
  37377. /**
  37378. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37379. */
  37380. getDeterministicFrameTime: () => number;
  37381. /** @hidden */
  37382. _animate(): void;
  37383. /** Execute all animations (for a frame) */
  37384. animate(): void;
  37385. /**
  37386. * Render the scene
  37387. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37388. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37389. */
  37390. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37391. /**
  37392. * Freeze all materials
  37393. * A frozen material will not be updatable but should be faster to render
  37394. */
  37395. freezeMaterials(): void;
  37396. /**
  37397. * Unfreeze all materials
  37398. * A frozen material will not be updatable but should be faster to render
  37399. */
  37400. unfreezeMaterials(): void;
  37401. /**
  37402. * Releases all held ressources
  37403. */
  37404. dispose(): void;
  37405. /**
  37406. * Gets if the scene is already disposed
  37407. */
  37408. get isDisposed(): boolean;
  37409. /**
  37410. * Call this function to reduce memory footprint of the scene.
  37411. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37412. */
  37413. clearCachedVertexData(): void;
  37414. /**
  37415. * This function will remove the local cached buffer data from texture.
  37416. * It will save memory but will prevent the texture from being rebuilt
  37417. */
  37418. cleanCachedTextureBuffer(): void;
  37419. /**
  37420. * Get the world extend vectors with an optional filter
  37421. *
  37422. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37423. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37424. */
  37425. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37426. min: Vector3;
  37427. max: Vector3;
  37428. };
  37429. /**
  37430. * Creates a ray that can be used to pick in the scene
  37431. * @param x defines the x coordinate of the origin (on-screen)
  37432. * @param y defines the y coordinate of the origin (on-screen)
  37433. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37434. * @param camera defines the camera to use for the picking
  37435. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37436. * @returns a Ray
  37437. */
  37438. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37439. /**
  37440. * Creates a ray that can be used to pick in the scene
  37441. * @param x defines the x coordinate of the origin (on-screen)
  37442. * @param y defines the y coordinate of the origin (on-screen)
  37443. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37444. * @param result defines the ray where to store the picking ray
  37445. * @param camera defines the camera to use for the picking
  37446. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37447. * @returns the current scene
  37448. */
  37449. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37450. /**
  37451. * Creates a ray that can be used to pick in the scene
  37452. * @param x defines the x coordinate of the origin (on-screen)
  37453. * @param y defines the y coordinate of the origin (on-screen)
  37454. * @param camera defines the camera to use for the picking
  37455. * @returns a Ray
  37456. */
  37457. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37458. /**
  37459. * Creates a ray that can be used to pick in the scene
  37460. * @param x defines the x coordinate of the origin (on-screen)
  37461. * @param y defines the y coordinate of the origin (on-screen)
  37462. * @param result defines the ray where to store the picking ray
  37463. * @param camera defines the camera to use for the picking
  37464. * @returns the current scene
  37465. */
  37466. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37467. /** Launch a ray to try to pick a mesh in the scene
  37468. * @param x position on screen
  37469. * @param y position on screen
  37470. * @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
  37471. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37472. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37473. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37474. * @returns a PickingInfo
  37475. */
  37476. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37477. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  37478. * @param x position on screen
  37479. * @param y position on screen
  37480. * @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
  37481. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37482. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37483. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  37484. */
  37485. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  37486. /** Use the given ray to pick a mesh in the scene
  37487. * @param ray The ray to use to pick meshes
  37488. * @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
  37489. * @param fastCheck defines if the first intersection will be used (and not the closest)
  37490. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37491. * @returns a PickingInfo
  37492. */
  37493. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37494. /**
  37495. * Launch a ray to try to pick a mesh in the scene
  37496. * @param x X position on screen
  37497. * @param y Y position on screen
  37498. * @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
  37499. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37500. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37501. * @returns an array of PickingInfo
  37502. */
  37503. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37504. /**
  37505. * Launch a ray to try to pick a mesh in the scene
  37506. * @param ray Ray to use
  37507. * @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
  37508. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37509. * @returns an array of PickingInfo
  37510. */
  37511. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37512. /**
  37513. * Force the value of meshUnderPointer
  37514. * @param mesh defines the mesh to use
  37515. */
  37516. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37517. /**
  37518. * Gets the mesh under the pointer
  37519. * @returns a Mesh or null if no mesh is under the pointer
  37520. */
  37521. getPointerOverMesh(): Nullable<AbstractMesh>;
  37522. /** @hidden */
  37523. _rebuildGeometries(): void;
  37524. /** @hidden */
  37525. _rebuildTextures(): void;
  37526. private _getByTags;
  37527. /**
  37528. * Get a list of meshes by tags
  37529. * @param tagsQuery defines the tags query to use
  37530. * @param forEach defines a predicate used to filter results
  37531. * @returns an array of Mesh
  37532. */
  37533. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37534. /**
  37535. * Get a list of cameras by tags
  37536. * @param tagsQuery defines the tags query to use
  37537. * @param forEach defines a predicate used to filter results
  37538. * @returns an array of Camera
  37539. */
  37540. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37541. /**
  37542. * Get a list of lights by tags
  37543. * @param tagsQuery defines the tags query to use
  37544. * @param forEach defines a predicate used to filter results
  37545. * @returns an array of Light
  37546. */
  37547. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37548. /**
  37549. * Get a list of materials by tags
  37550. * @param tagsQuery defines the tags query to use
  37551. * @param forEach defines a predicate used to filter results
  37552. * @returns an array of Material
  37553. */
  37554. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37555. /**
  37556. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37557. * This allowed control for front to back rendering or reversly depending of the special needs.
  37558. *
  37559. * @param renderingGroupId The rendering group id corresponding to its index
  37560. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37561. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37562. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37563. */
  37564. 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;
  37565. /**
  37566. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37567. *
  37568. * @param renderingGroupId The rendering group id corresponding to its index
  37569. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37570. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37571. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37572. */
  37573. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37574. /**
  37575. * Gets the current auto clear configuration for one rendering group of the rendering
  37576. * manager.
  37577. * @param index the rendering group index to get the information for
  37578. * @returns The auto clear setup for the requested rendering group
  37579. */
  37580. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37581. private _blockMaterialDirtyMechanism;
  37582. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37583. get blockMaterialDirtyMechanism(): boolean;
  37584. set blockMaterialDirtyMechanism(value: boolean);
  37585. /**
  37586. * Will flag all materials as dirty to trigger new shader compilation
  37587. * @param flag defines the flag used to specify which material part must be marked as dirty
  37588. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37589. */
  37590. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37591. /** @hidden */
  37592. _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;
  37593. /** @hidden */
  37594. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37595. /** @hidden */
  37596. _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;
  37597. /** @hidden */
  37598. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37599. /** @hidden */
  37600. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37601. /** @hidden */
  37602. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37603. }
  37604. }
  37605. declare module BABYLON {
  37606. /**
  37607. * Set of assets to keep when moving a scene into an asset container.
  37608. */
  37609. export class KeepAssets extends AbstractScene {
  37610. }
  37611. /**
  37612. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37613. */
  37614. export class InstantiatedEntries {
  37615. /**
  37616. * List of new root nodes (eg. nodes with no parent)
  37617. */
  37618. rootNodes: TransformNode[];
  37619. /**
  37620. * List of new skeletons
  37621. */
  37622. skeletons: Skeleton[];
  37623. /**
  37624. * List of new animation groups
  37625. */
  37626. animationGroups: AnimationGroup[];
  37627. }
  37628. /**
  37629. * Container with a set of assets that can be added or removed from a scene.
  37630. */
  37631. export class AssetContainer extends AbstractScene {
  37632. private _wasAddedToScene;
  37633. /**
  37634. * The scene the AssetContainer belongs to.
  37635. */
  37636. scene: Scene;
  37637. /**
  37638. * Instantiates an AssetContainer.
  37639. * @param scene The scene the AssetContainer belongs to.
  37640. */
  37641. constructor(scene: Scene);
  37642. /**
  37643. * Instantiate or clone all meshes and add the new ones to the scene.
  37644. * Skeletons and animation groups will all be cloned
  37645. * @param nameFunction defines an optional function used to get new names for clones
  37646. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37647. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37648. */
  37649. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37650. /**
  37651. * Adds all the assets from the container to the scene.
  37652. */
  37653. addAllToScene(): void;
  37654. /**
  37655. * Removes all the assets in the container from the scene
  37656. */
  37657. removeAllFromScene(): void;
  37658. /**
  37659. * Disposes all the assets in the container
  37660. */
  37661. dispose(): void;
  37662. private _moveAssets;
  37663. /**
  37664. * Removes all the assets contained in the scene and adds them to the container.
  37665. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37666. */
  37667. moveAllFromScene(keepAssets?: KeepAssets): void;
  37668. /**
  37669. * 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.
  37670. * @returns the root mesh
  37671. */
  37672. createRootMesh(): Mesh;
  37673. /**
  37674. * Merge animations (direct and animation groups) from this asset container into a scene
  37675. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37676. * @param animatables set of animatables to retarget to a node from the scene
  37677. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37678. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  37679. */
  37680. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  37681. }
  37682. }
  37683. declare module BABYLON {
  37684. /**
  37685. * Defines how the parser contract is defined.
  37686. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37687. */
  37688. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37689. /**
  37690. * Defines how the individual parser contract is defined.
  37691. * These parser can parse an individual asset
  37692. */
  37693. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37694. /**
  37695. * Base class of the scene acting as a container for the different elements composing a scene.
  37696. * This class is dynamically extended by the different components of the scene increasing
  37697. * flexibility and reducing coupling
  37698. */
  37699. export abstract class AbstractScene {
  37700. /**
  37701. * Stores the list of available parsers in the application.
  37702. */
  37703. private static _BabylonFileParsers;
  37704. /**
  37705. * Stores the list of available individual parsers in the application.
  37706. */
  37707. private static _IndividualBabylonFileParsers;
  37708. /**
  37709. * Adds a parser in the list of available ones
  37710. * @param name Defines the name of the parser
  37711. * @param parser Defines the parser to add
  37712. */
  37713. static AddParser(name: string, parser: BabylonFileParser): void;
  37714. /**
  37715. * Gets a general parser from the list of avaialble ones
  37716. * @param name Defines the name of the parser
  37717. * @returns the requested parser or null
  37718. */
  37719. static GetParser(name: string): Nullable<BabylonFileParser>;
  37720. /**
  37721. * Adds n individual parser in the list of available ones
  37722. * @param name Defines the name of the parser
  37723. * @param parser Defines the parser to add
  37724. */
  37725. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37726. /**
  37727. * Gets an individual parser from the list of avaialble ones
  37728. * @param name Defines the name of the parser
  37729. * @returns the requested parser or null
  37730. */
  37731. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37732. /**
  37733. * Parser json data and populate both a scene and its associated container object
  37734. * @param jsonData Defines the data to parse
  37735. * @param scene Defines the scene to parse the data for
  37736. * @param container Defines the container attached to the parsing sequence
  37737. * @param rootUrl Defines the root url of the data
  37738. */
  37739. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37740. /**
  37741. * Gets the list of root nodes (ie. nodes with no parent)
  37742. */
  37743. rootNodes: Node[];
  37744. /** All of the cameras added to this scene
  37745. * @see http://doc.babylonjs.com/babylon101/cameras
  37746. */
  37747. cameras: Camera[];
  37748. /**
  37749. * All of the lights added to this scene
  37750. * @see http://doc.babylonjs.com/babylon101/lights
  37751. */
  37752. lights: Light[];
  37753. /**
  37754. * All of the (abstract) meshes added to this scene
  37755. */
  37756. meshes: AbstractMesh[];
  37757. /**
  37758. * The list of skeletons added to the scene
  37759. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37760. */
  37761. skeletons: Skeleton[];
  37762. /**
  37763. * All of the particle systems added to this scene
  37764. * @see http://doc.babylonjs.com/babylon101/particles
  37765. */
  37766. particleSystems: IParticleSystem[];
  37767. /**
  37768. * Gets a list of Animations associated with the scene
  37769. */
  37770. animations: Animation[];
  37771. /**
  37772. * All of the animation groups added to this scene
  37773. * @see http://doc.babylonjs.com/how_to/group
  37774. */
  37775. animationGroups: AnimationGroup[];
  37776. /**
  37777. * All of the multi-materials added to this scene
  37778. * @see http://doc.babylonjs.com/how_to/multi_materials
  37779. */
  37780. multiMaterials: MultiMaterial[];
  37781. /**
  37782. * All of the materials added to this scene
  37783. * In the context of a Scene, it is not supposed to be modified manually.
  37784. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37785. * Note also that the order of the Material within the array is not significant and might change.
  37786. * @see http://doc.babylonjs.com/babylon101/materials
  37787. */
  37788. materials: Material[];
  37789. /**
  37790. * The list of morph target managers added to the scene
  37791. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37792. */
  37793. morphTargetManagers: MorphTargetManager[];
  37794. /**
  37795. * The list of geometries used in the scene.
  37796. */
  37797. geometries: Geometry[];
  37798. /**
  37799. * All of the tranform nodes added to this scene
  37800. * In the context of a Scene, it is not supposed to be modified manually.
  37801. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37802. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37803. * @see http://doc.babylonjs.com/how_to/transformnode
  37804. */
  37805. transformNodes: TransformNode[];
  37806. /**
  37807. * ActionManagers available on the scene.
  37808. */
  37809. actionManagers: AbstractActionManager[];
  37810. /**
  37811. * Textures to keep.
  37812. */
  37813. textures: BaseTexture[];
  37814. /**
  37815. * Environment texture for the scene
  37816. */
  37817. environmentTexture: Nullable<BaseTexture>;
  37818. /**
  37819. * @returns all meshes, lights, cameras, transformNodes and bones
  37820. */
  37821. getNodes(): Array<Node>;
  37822. }
  37823. }
  37824. declare module BABYLON {
  37825. /**
  37826. * Interface used to define options for Sound class
  37827. */
  37828. export interface ISoundOptions {
  37829. /**
  37830. * Does the sound autoplay once loaded.
  37831. */
  37832. autoplay?: boolean;
  37833. /**
  37834. * Does the sound loop after it finishes playing once.
  37835. */
  37836. loop?: boolean;
  37837. /**
  37838. * Sound's volume
  37839. */
  37840. volume?: number;
  37841. /**
  37842. * Is it a spatial sound?
  37843. */
  37844. spatialSound?: boolean;
  37845. /**
  37846. * Maximum distance to hear that sound
  37847. */
  37848. maxDistance?: number;
  37849. /**
  37850. * Uses user defined attenuation function
  37851. */
  37852. useCustomAttenuation?: boolean;
  37853. /**
  37854. * Define the roll off factor of spatial sounds.
  37855. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37856. */
  37857. rolloffFactor?: number;
  37858. /**
  37859. * Define the reference distance the sound should be heard perfectly.
  37860. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37861. */
  37862. refDistance?: number;
  37863. /**
  37864. * Define the distance attenuation model the sound will follow.
  37865. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37866. */
  37867. distanceModel?: string;
  37868. /**
  37869. * Defines the playback speed (1 by default)
  37870. */
  37871. playbackRate?: number;
  37872. /**
  37873. * Defines if the sound is from a streaming source
  37874. */
  37875. streaming?: boolean;
  37876. /**
  37877. * Defines an optional length (in seconds) inside the sound file
  37878. */
  37879. length?: number;
  37880. /**
  37881. * Defines an optional offset (in seconds) inside the sound file
  37882. */
  37883. offset?: number;
  37884. /**
  37885. * If true, URLs will not be required to state the audio file codec to use.
  37886. */
  37887. skipCodecCheck?: boolean;
  37888. }
  37889. /**
  37890. * Defines a sound that can be played in the application.
  37891. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37892. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37893. */
  37894. export class Sound {
  37895. /**
  37896. * The name of the sound in the scene.
  37897. */
  37898. name: string;
  37899. /**
  37900. * Does the sound autoplay once loaded.
  37901. */
  37902. autoplay: boolean;
  37903. /**
  37904. * Does the sound loop after it finishes playing once.
  37905. */
  37906. loop: boolean;
  37907. /**
  37908. * Does the sound use a custom attenuation curve to simulate the falloff
  37909. * happening when the source gets further away from the camera.
  37910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37911. */
  37912. useCustomAttenuation: boolean;
  37913. /**
  37914. * The sound track id this sound belongs to.
  37915. */
  37916. soundTrackId: number;
  37917. /**
  37918. * Is this sound currently played.
  37919. */
  37920. isPlaying: boolean;
  37921. /**
  37922. * Is this sound currently paused.
  37923. */
  37924. isPaused: boolean;
  37925. /**
  37926. * Does this sound enables spatial sound.
  37927. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37928. */
  37929. spatialSound: boolean;
  37930. /**
  37931. * Define the reference distance the sound should be heard perfectly.
  37932. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37933. */
  37934. refDistance: number;
  37935. /**
  37936. * Define the roll off factor of spatial sounds.
  37937. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37938. */
  37939. rolloffFactor: number;
  37940. /**
  37941. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37942. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37943. */
  37944. maxDistance: number;
  37945. /**
  37946. * Define the distance attenuation model the sound will follow.
  37947. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37948. */
  37949. distanceModel: string;
  37950. /**
  37951. * @hidden
  37952. * Back Compat
  37953. **/
  37954. onended: () => any;
  37955. /**
  37956. * Observable event when the current playing sound finishes.
  37957. */
  37958. onEndedObservable: Observable<Sound>;
  37959. private _panningModel;
  37960. private _playbackRate;
  37961. private _streaming;
  37962. private _startTime;
  37963. private _startOffset;
  37964. private _position;
  37965. /** @hidden */
  37966. _positionInEmitterSpace: boolean;
  37967. private _localDirection;
  37968. private _volume;
  37969. private _isReadyToPlay;
  37970. private _isDirectional;
  37971. private _readyToPlayCallback;
  37972. private _audioBuffer;
  37973. private _soundSource;
  37974. private _streamingSource;
  37975. private _soundPanner;
  37976. private _soundGain;
  37977. private _inputAudioNode;
  37978. private _outputAudioNode;
  37979. private _coneInnerAngle;
  37980. private _coneOuterAngle;
  37981. private _coneOuterGain;
  37982. private _scene;
  37983. private _connectedTransformNode;
  37984. private _customAttenuationFunction;
  37985. private _registerFunc;
  37986. private _isOutputConnected;
  37987. private _htmlAudioElement;
  37988. private _urlType;
  37989. private _length?;
  37990. private _offset?;
  37991. /** @hidden */
  37992. static _SceneComponentInitialization: (scene: Scene) => void;
  37993. /**
  37994. * Create a sound and attach it to a scene
  37995. * @param name Name of your sound
  37996. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37997. * @param scene defines the scene the sound belongs to
  37998. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37999. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38000. */
  38001. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38002. /**
  38003. * Release the sound and its associated resources
  38004. */
  38005. dispose(): void;
  38006. /**
  38007. * Gets if the sounds is ready to be played or not.
  38008. * @returns true if ready, otherwise false
  38009. */
  38010. isReady(): boolean;
  38011. private _soundLoaded;
  38012. /**
  38013. * Sets the data of the sound from an audiobuffer
  38014. * @param audioBuffer The audioBuffer containing the data
  38015. */
  38016. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38017. /**
  38018. * Updates the current sounds options such as maxdistance, loop...
  38019. * @param options A JSON object containing values named as the object properties
  38020. */
  38021. updateOptions(options: ISoundOptions): void;
  38022. private _createSpatialParameters;
  38023. private _updateSpatialParameters;
  38024. /**
  38025. * Switch the panning model to HRTF:
  38026. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38028. */
  38029. switchPanningModelToHRTF(): void;
  38030. /**
  38031. * Switch the panning model to Equal Power:
  38032. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38033. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38034. */
  38035. switchPanningModelToEqualPower(): void;
  38036. private _switchPanningModel;
  38037. /**
  38038. * Connect this sound to a sound track audio node like gain...
  38039. * @param soundTrackAudioNode the sound track audio node to connect to
  38040. */
  38041. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38042. /**
  38043. * Transform this sound into a directional source
  38044. * @param coneInnerAngle Size of the inner cone in degree
  38045. * @param coneOuterAngle Size of the outer cone in degree
  38046. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38047. */
  38048. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38049. /**
  38050. * Gets or sets the inner angle for the directional cone.
  38051. */
  38052. get directionalConeInnerAngle(): number;
  38053. /**
  38054. * Gets or sets the inner angle for the directional cone.
  38055. */
  38056. set directionalConeInnerAngle(value: number);
  38057. /**
  38058. * Gets or sets the outer angle for the directional cone.
  38059. */
  38060. get directionalConeOuterAngle(): number;
  38061. /**
  38062. * Gets or sets the outer angle for the directional cone.
  38063. */
  38064. set directionalConeOuterAngle(value: number);
  38065. /**
  38066. * Sets the position of the emitter if spatial sound is enabled
  38067. * @param newPosition Defines the new posisiton
  38068. */
  38069. setPosition(newPosition: Vector3): void;
  38070. /**
  38071. * Sets the local direction of the emitter if spatial sound is enabled
  38072. * @param newLocalDirection Defines the new local direction
  38073. */
  38074. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38075. private _updateDirection;
  38076. /** @hidden */
  38077. updateDistanceFromListener(): void;
  38078. /**
  38079. * Sets a new custom attenuation function for the sound.
  38080. * @param callback Defines the function used for the attenuation
  38081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38082. */
  38083. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38084. /**
  38085. * Play the sound
  38086. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38087. * @param offset (optional) Start the sound at a specific time in seconds
  38088. * @param length (optional) Sound duration (in seconds)
  38089. */
  38090. play(time?: number, offset?: number, length?: number): void;
  38091. private _onended;
  38092. /**
  38093. * Stop the sound
  38094. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38095. */
  38096. stop(time?: number): void;
  38097. /**
  38098. * Put the sound in pause
  38099. */
  38100. pause(): void;
  38101. /**
  38102. * Sets a dedicated volume for this sounds
  38103. * @param newVolume Define the new volume of the sound
  38104. * @param time Define time for gradual change to new volume
  38105. */
  38106. setVolume(newVolume: number, time?: number): void;
  38107. /**
  38108. * Set the sound play back rate
  38109. * @param newPlaybackRate Define the playback rate the sound should be played at
  38110. */
  38111. setPlaybackRate(newPlaybackRate: number): void;
  38112. /**
  38113. * Gets the volume of the sound.
  38114. * @returns the volume of the sound
  38115. */
  38116. getVolume(): number;
  38117. /**
  38118. * Attach the sound to a dedicated mesh
  38119. * @param transformNode The transform node to connect the sound with
  38120. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38121. */
  38122. attachToMesh(transformNode: TransformNode): void;
  38123. /**
  38124. * Detach the sound from the previously attached mesh
  38125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38126. */
  38127. detachFromMesh(): void;
  38128. private _onRegisterAfterWorldMatrixUpdate;
  38129. /**
  38130. * Clone the current sound in the scene.
  38131. * @returns the new sound clone
  38132. */
  38133. clone(): Nullable<Sound>;
  38134. /**
  38135. * Gets the current underlying audio buffer containing the data
  38136. * @returns the audio buffer
  38137. */
  38138. getAudioBuffer(): Nullable<AudioBuffer>;
  38139. /**
  38140. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38141. * @returns the source node
  38142. */
  38143. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38144. /**
  38145. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38146. * @returns the gain node
  38147. */
  38148. getSoundGain(): Nullable<GainNode>;
  38149. /**
  38150. * Serializes the Sound in a JSON representation
  38151. * @returns the JSON representation of the sound
  38152. */
  38153. serialize(): any;
  38154. /**
  38155. * Parse a JSON representation of a sound to innstantiate in a given scene
  38156. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38157. * @param scene Define the scene the new parsed sound should be created in
  38158. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38159. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38160. * @returns the newly parsed sound
  38161. */
  38162. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38163. }
  38164. }
  38165. declare module BABYLON {
  38166. /**
  38167. * This defines an action helpful to play a defined sound on a triggered action.
  38168. */
  38169. export class PlaySoundAction extends Action {
  38170. private _sound;
  38171. /**
  38172. * Instantiate the action
  38173. * @param triggerOptions defines the trigger options
  38174. * @param sound defines the sound to play
  38175. * @param condition defines the trigger related conditions
  38176. */
  38177. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38178. /** @hidden */
  38179. _prepare(): void;
  38180. /**
  38181. * Execute the action and play the sound.
  38182. */
  38183. execute(): void;
  38184. /**
  38185. * Serializes the actions and its related information.
  38186. * @param parent defines the object to serialize in
  38187. * @returns the serialized object
  38188. */
  38189. serialize(parent: any): any;
  38190. }
  38191. /**
  38192. * This defines an action helpful to stop a defined sound on a triggered action.
  38193. */
  38194. export class StopSoundAction extends Action {
  38195. private _sound;
  38196. /**
  38197. * Instantiate the action
  38198. * @param triggerOptions defines the trigger options
  38199. * @param sound defines the sound to stop
  38200. * @param condition defines the trigger related conditions
  38201. */
  38202. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38203. /** @hidden */
  38204. _prepare(): void;
  38205. /**
  38206. * Execute the action and stop the sound.
  38207. */
  38208. execute(): void;
  38209. /**
  38210. * Serializes the actions and its related information.
  38211. * @param parent defines the object to serialize in
  38212. * @returns the serialized object
  38213. */
  38214. serialize(parent: any): any;
  38215. }
  38216. }
  38217. declare module BABYLON {
  38218. /**
  38219. * This defines an action responsible to change the value of a property
  38220. * by interpolating between its current value and the newly set one once triggered.
  38221. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38222. */
  38223. export class InterpolateValueAction extends Action {
  38224. /**
  38225. * Defines the path of the property where the value should be interpolated
  38226. */
  38227. propertyPath: string;
  38228. /**
  38229. * Defines the target value at the end of the interpolation.
  38230. */
  38231. value: any;
  38232. /**
  38233. * Defines the time it will take for the property to interpolate to the value.
  38234. */
  38235. duration: number;
  38236. /**
  38237. * Defines if the other scene animations should be stopped when the action has been triggered
  38238. */
  38239. stopOtherAnimations?: boolean;
  38240. /**
  38241. * Defines a callback raised once the interpolation animation has been done.
  38242. */
  38243. onInterpolationDone?: () => void;
  38244. /**
  38245. * Observable triggered once the interpolation animation has been done.
  38246. */
  38247. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38248. private _target;
  38249. private _effectiveTarget;
  38250. private _property;
  38251. /**
  38252. * Instantiate the action
  38253. * @param triggerOptions defines the trigger options
  38254. * @param target defines the object containing the value to interpolate
  38255. * @param propertyPath defines the path to the property in the target object
  38256. * @param value defines the target value at the end of the interpolation
  38257. * @param duration deines the time it will take for the property to interpolate to the value.
  38258. * @param condition defines the trigger related conditions
  38259. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38260. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38261. */
  38262. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38263. /** @hidden */
  38264. _prepare(): void;
  38265. /**
  38266. * Execute the action starts the value interpolation.
  38267. */
  38268. execute(): void;
  38269. /**
  38270. * Serializes the actions and its related information.
  38271. * @param parent defines the object to serialize in
  38272. * @returns the serialized object
  38273. */
  38274. serialize(parent: any): any;
  38275. }
  38276. }
  38277. declare module BABYLON {
  38278. /**
  38279. * Options allowed during the creation of a sound track.
  38280. */
  38281. export interface ISoundTrackOptions {
  38282. /**
  38283. * The volume the sound track should take during creation
  38284. */
  38285. volume?: number;
  38286. /**
  38287. * Define if the sound track is the main sound track of the scene
  38288. */
  38289. mainTrack?: boolean;
  38290. }
  38291. /**
  38292. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38293. * It will be also used in a future release to apply effects on a specific track.
  38294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38295. */
  38296. export class SoundTrack {
  38297. /**
  38298. * The unique identifier of the sound track in the scene.
  38299. */
  38300. id: number;
  38301. /**
  38302. * The list of sounds included in the sound track.
  38303. */
  38304. soundCollection: Array<Sound>;
  38305. private _outputAudioNode;
  38306. private _scene;
  38307. private _connectedAnalyser;
  38308. private _options;
  38309. private _isInitialized;
  38310. /**
  38311. * Creates a new sound track.
  38312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38313. * @param scene Define the scene the sound track belongs to
  38314. * @param options
  38315. */
  38316. constructor(scene: Scene, options?: ISoundTrackOptions);
  38317. private _initializeSoundTrackAudioGraph;
  38318. /**
  38319. * Release the sound track and its associated resources
  38320. */
  38321. dispose(): void;
  38322. /**
  38323. * Adds a sound to this sound track
  38324. * @param sound define the cound to add
  38325. * @ignoreNaming
  38326. */
  38327. AddSound(sound: Sound): void;
  38328. /**
  38329. * Removes a sound to this sound track
  38330. * @param sound define the cound to remove
  38331. * @ignoreNaming
  38332. */
  38333. RemoveSound(sound: Sound): void;
  38334. /**
  38335. * Set a global volume for the full sound track.
  38336. * @param newVolume Define the new volume of the sound track
  38337. */
  38338. setVolume(newVolume: number): void;
  38339. /**
  38340. * Switch the panning model to HRTF:
  38341. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38342. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38343. */
  38344. switchPanningModelToHRTF(): void;
  38345. /**
  38346. * Switch the panning model to Equal Power:
  38347. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38349. */
  38350. switchPanningModelToEqualPower(): void;
  38351. /**
  38352. * Connect the sound track to an audio analyser allowing some amazing
  38353. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38354. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38355. * @param analyser The analyser to connect to the engine
  38356. */
  38357. connectToAnalyser(analyser: Analyser): void;
  38358. }
  38359. }
  38360. declare module BABYLON {
  38361. interface AbstractScene {
  38362. /**
  38363. * The list of sounds used in the scene.
  38364. */
  38365. sounds: Nullable<Array<Sound>>;
  38366. }
  38367. interface Scene {
  38368. /**
  38369. * @hidden
  38370. * Backing field
  38371. */
  38372. _mainSoundTrack: SoundTrack;
  38373. /**
  38374. * The main sound track played by the scene.
  38375. * It cotains your primary collection of sounds.
  38376. */
  38377. mainSoundTrack: SoundTrack;
  38378. /**
  38379. * The list of sound tracks added to the scene
  38380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38381. */
  38382. soundTracks: Nullable<Array<SoundTrack>>;
  38383. /**
  38384. * Gets a sound using a given name
  38385. * @param name defines the name to search for
  38386. * @return the found sound or null if not found at all.
  38387. */
  38388. getSoundByName(name: string): Nullable<Sound>;
  38389. /**
  38390. * Gets or sets if audio support is enabled
  38391. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38392. */
  38393. audioEnabled: boolean;
  38394. /**
  38395. * Gets or sets if audio will be output to headphones
  38396. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38397. */
  38398. headphone: boolean;
  38399. /**
  38400. * Gets or sets custom audio listener position provider
  38401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38402. */
  38403. audioListenerPositionProvider: Nullable<() => Vector3>;
  38404. /**
  38405. * Gets or sets a refresh rate when using 3D audio positioning
  38406. */
  38407. audioPositioningRefreshRate: number;
  38408. }
  38409. /**
  38410. * Defines the sound scene component responsible to manage any sounds
  38411. * in a given scene.
  38412. */
  38413. export class AudioSceneComponent implements ISceneSerializableComponent {
  38414. /**
  38415. * The component name helpfull to identify the component in the list of scene components.
  38416. */
  38417. readonly name: string;
  38418. /**
  38419. * The scene the component belongs to.
  38420. */
  38421. scene: Scene;
  38422. private _audioEnabled;
  38423. /**
  38424. * Gets whether audio is enabled or not.
  38425. * Please use related enable/disable method to switch state.
  38426. */
  38427. get audioEnabled(): boolean;
  38428. private _headphone;
  38429. /**
  38430. * Gets whether audio is outputing to headphone or not.
  38431. * Please use the according Switch methods to change output.
  38432. */
  38433. get headphone(): boolean;
  38434. /**
  38435. * Gets or sets a refresh rate when using 3D audio positioning
  38436. */
  38437. audioPositioningRefreshRate: number;
  38438. private _audioListenerPositionProvider;
  38439. /**
  38440. * Gets the current audio listener position provider
  38441. */
  38442. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38443. /**
  38444. * Sets a custom listener position for all sounds in the scene
  38445. * By default, this is the position of the first active camera
  38446. */
  38447. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38448. /**
  38449. * Creates a new instance of the component for the given scene
  38450. * @param scene Defines the scene to register the component in
  38451. */
  38452. constructor(scene: Scene);
  38453. /**
  38454. * Registers the component in a given scene
  38455. */
  38456. register(): void;
  38457. /**
  38458. * Rebuilds the elements related to this component in case of
  38459. * context lost for instance.
  38460. */
  38461. rebuild(): void;
  38462. /**
  38463. * Serializes the component data to the specified json object
  38464. * @param serializationObject The object to serialize to
  38465. */
  38466. serialize(serializationObject: any): void;
  38467. /**
  38468. * Adds all the elements from the container to the scene
  38469. * @param container the container holding the elements
  38470. */
  38471. addFromContainer(container: AbstractScene): void;
  38472. /**
  38473. * Removes all the elements in the container from the scene
  38474. * @param container contains the elements to remove
  38475. * @param dispose if the removed element should be disposed (default: false)
  38476. */
  38477. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38478. /**
  38479. * Disposes the component and the associated ressources.
  38480. */
  38481. dispose(): void;
  38482. /**
  38483. * Disables audio in the associated scene.
  38484. */
  38485. disableAudio(): void;
  38486. /**
  38487. * Enables audio in the associated scene.
  38488. */
  38489. enableAudio(): void;
  38490. /**
  38491. * Switch audio to headphone output.
  38492. */
  38493. switchAudioModeForHeadphones(): void;
  38494. /**
  38495. * Switch audio to normal speakers.
  38496. */
  38497. switchAudioModeForNormalSpeakers(): void;
  38498. private _cachedCameraDirection;
  38499. private _cachedCameraPosition;
  38500. private _lastCheck;
  38501. private _afterRender;
  38502. }
  38503. }
  38504. declare module BABYLON {
  38505. /**
  38506. * Wraps one or more Sound objects and selects one with random weight for playback.
  38507. */
  38508. export class WeightedSound {
  38509. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38510. loop: boolean;
  38511. private _coneInnerAngle;
  38512. private _coneOuterAngle;
  38513. private _volume;
  38514. /** A Sound is currently playing. */
  38515. isPlaying: boolean;
  38516. /** A Sound is currently paused. */
  38517. isPaused: boolean;
  38518. private _sounds;
  38519. private _weights;
  38520. private _currentIndex?;
  38521. /**
  38522. * Creates a new WeightedSound from the list of sounds given.
  38523. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38524. * @param sounds Array of Sounds that will be selected from.
  38525. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38526. */
  38527. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38528. /**
  38529. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38530. */
  38531. get directionalConeInnerAngle(): number;
  38532. /**
  38533. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38534. */
  38535. set directionalConeInnerAngle(value: number);
  38536. /**
  38537. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38538. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38539. */
  38540. get directionalConeOuterAngle(): number;
  38541. /**
  38542. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38543. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38544. */
  38545. set directionalConeOuterAngle(value: number);
  38546. /**
  38547. * Playback volume.
  38548. */
  38549. get volume(): number;
  38550. /**
  38551. * Playback volume.
  38552. */
  38553. set volume(value: number);
  38554. private _onended;
  38555. /**
  38556. * Suspend playback
  38557. */
  38558. pause(): void;
  38559. /**
  38560. * Stop playback
  38561. */
  38562. stop(): void;
  38563. /**
  38564. * Start playback.
  38565. * @param startOffset Position the clip head at a specific time in seconds.
  38566. */
  38567. play(startOffset?: number): void;
  38568. }
  38569. }
  38570. declare module BABYLON {
  38571. /**
  38572. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38573. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38574. */
  38575. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38576. /**
  38577. * Gets the name of the behavior.
  38578. */
  38579. get name(): string;
  38580. /**
  38581. * The easing function used by animations
  38582. */
  38583. static EasingFunction: BackEase;
  38584. /**
  38585. * The easing mode used by animations
  38586. */
  38587. static EasingMode: number;
  38588. /**
  38589. * The duration of the animation, in milliseconds
  38590. */
  38591. transitionDuration: number;
  38592. /**
  38593. * Length of the distance animated by the transition when lower radius is reached
  38594. */
  38595. lowerRadiusTransitionRange: number;
  38596. /**
  38597. * Length of the distance animated by the transition when upper radius is reached
  38598. */
  38599. upperRadiusTransitionRange: number;
  38600. private _autoTransitionRange;
  38601. /**
  38602. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38603. */
  38604. get autoTransitionRange(): boolean;
  38605. /**
  38606. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38607. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38608. */
  38609. set autoTransitionRange(value: boolean);
  38610. private _attachedCamera;
  38611. private _onAfterCheckInputsObserver;
  38612. private _onMeshTargetChangedObserver;
  38613. /**
  38614. * Initializes the behavior.
  38615. */
  38616. init(): void;
  38617. /**
  38618. * Attaches the behavior to its arc rotate camera.
  38619. * @param camera Defines the camera to attach the behavior to
  38620. */
  38621. attach(camera: ArcRotateCamera): void;
  38622. /**
  38623. * Detaches the behavior from its current arc rotate camera.
  38624. */
  38625. detach(): void;
  38626. private _radiusIsAnimating;
  38627. private _radiusBounceTransition;
  38628. private _animatables;
  38629. private _cachedWheelPrecision;
  38630. /**
  38631. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38632. * @param radiusLimit The limit to check against.
  38633. * @return Bool to indicate if at limit.
  38634. */
  38635. private _isRadiusAtLimit;
  38636. /**
  38637. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38638. * @param radiusDelta The delta by which to animate to. Can be negative.
  38639. */
  38640. private _applyBoundRadiusAnimation;
  38641. /**
  38642. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38643. */
  38644. protected _clearAnimationLocks(): void;
  38645. /**
  38646. * Stops and removes all animations that have been applied to the camera
  38647. */
  38648. stopAllAnimations(): void;
  38649. }
  38650. }
  38651. declare module BABYLON {
  38652. /**
  38653. * 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.
  38654. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38655. */
  38656. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38657. /**
  38658. * Gets the name of the behavior.
  38659. */
  38660. get name(): string;
  38661. private _mode;
  38662. private _radiusScale;
  38663. private _positionScale;
  38664. private _defaultElevation;
  38665. private _elevationReturnTime;
  38666. private _elevationReturnWaitTime;
  38667. private _zoomStopsAnimation;
  38668. private _framingTime;
  38669. /**
  38670. * The easing function used by animations
  38671. */
  38672. static EasingFunction: ExponentialEase;
  38673. /**
  38674. * The easing mode used by animations
  38675. */
  38676. static EasingMode: number;
  38677. /**
  38678. * Sets the current mode used by the behavior
  38679. */
  38680. set mode(mode: number);
  38681. /**
  38682. * Gets current mode used by the behavior.
  38683. */
  38684. get mode(): number;
  38685. /**
  38686. * Sets the scale applied to the radius (1 by default)
  38687. */
  38688. set radiusScale(radius: number);
  38689. /**
  38690. * Gets the scale applied to the radius
  38691. */
  38692. get radiusScale(): number;
  38693. /**
  38694. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38695. */
  38696. set positionScale(scale: number);
  38697. /**
  38698. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38699. */
  38700. get positionScale(): number;
  38701. /**
  38702. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38703. * behaviour is triggered, in radians.
  38704. */
  38705. set defaultElevation(elevation: number);
  38706. /**
  38707. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38708. * behaviour is triggered, in radians.
  38709. */
  38710. get defaultElevation(): number;
  38711. /**
  38712. * Sets the time (in milliseconds) taken to return to the default beta position.
  38713. * Negative value indicates camera should not return to default.
  38714. */
  38715. set elevationReturnTime(speed: number);
  38716. /**
  38717. * Gets the time (in milliseconds) taken to return to the default beta position.
  38718. * Negative value indicates camera should not return to default.
  38719. */
  38720. get elevationReturnTime(): number;
  38721. /**
  38722. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38723. */
  38724. set elevationReturnWaitTime(time: number);
  38725. /**
  38726. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38727. */
  38728. get elevationReturnWaitTime(): number;
  38729. /**
  38730. * Sets the flag that indicates if user zooming should stop animation.
  38731. */
  38732. set zoomStopsAnimation(flag: boolean);
  38733. /**
  38734. * Gets the flag that indicates if user zooming should stop animation.
  38735. */
  38736. get zoomStopsAnimation(): boolean;
  38737. /**
  38738. * Sets the transition time when framing the mesh, in milliseconds
  38739. */
  38740. set framingTime(time: number);
  38741. /**
  38742. * Gets the transition time when framing the mesh, in milliseconds
  38743. */
  38744. get framingTime(): number;
  38745. /**
  38746. * Define if the behavior should automatically change the configured
  38747. * camera limits and sensibilities.
  38748. */
  38749. autoCorrectCameraLimitsAndSensibility: boolean;
  38750. private _onPrePointerObservableObserver;
  38751. private _onAfterCheckInputsObserver;
  38752. private _onMeshTargetChangedObserver;
  38753. private _attachedCamera;
  38754. private _isPointerDown;
  38755. private _lastInteractionTime;
  38756. /**
  38757. * Initializes the behavior.
  38758. */
  38759. init(): void;
  38760. /**
  38761. * Attaches the behavior to its arc rotate camera.
  38762. * @param camera Defines the camera to attach the behavior to
  38763. */
  38764. attach(camera: ArcRotateCamera): void;
  38765. /**
  38766. * Detaches the behavior from its current arc rotate camera.
  38767. */
  38768. detach(): void;
  38769. private _animatables;
  38770. private _betaIsAnimating;
  38771. private _betaTransition;
  38772. private _radiusTransition;
  38773. private _vectorTransition;
  38774. /**
  38775. * Targets the given mesh and updates zoom level accordingly.
  38776. * @param mesh The mesh to target.
  38777. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38778. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38779. */
  38780. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38781. /**
  38782. * Targets the given mesh with its children and updates zoom level accordingly.
  38783. * @param mesh The mesh to target.
  38784. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38785. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38786. */
  38787. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38788. /**
  38789. * Targets the given meshes with their children and updates zoom level accordingly.
  38790. * @param meshes The mesh to target.
  38791. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38792. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38793. */
  38794. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38795. /**
  38796. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38797. * @param minimumWorld Determines the smaller position of the bounding box extend
  38798. * @param maximumWorld Determines the bigger position of the bounding box extend
  38799. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38800. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38801. */
  38802. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38803. /**
  38804. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38805. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38806. * frustum width.
  38807. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38808. * to fully enclose the mesh in the viewing frustum.
  38809. */
  38810. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38811. /**
  38812. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38813. * is automatically returned to its default position (expected to be above ground plane).
  38814. */
  38815. private _maintainCameraAboveGround;
  38816. /**
  38817. * Returns the frustum slope based on the canvas ratio and camera FOV
  38818. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38819. */
  38820. private _getFrustumSlope;
  38821. /**
  38822. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38823. */
  38824. private _clearAnimationLocks;
  38825. /**
  38826. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38827. */
  38828. private _applyUserInteraction;
  38829. /**
  38830. * Stops and removes all animations that have been applied to the camera
  38831. */
  38832. stopAllAnimations(): void;
  38833. /**
  38834. * Gets a value indicating if the user is moving the camera
  38835. */
  38836. get isUserIsMoving(): boolean;
  38837. /**
  38838. * The camera can move all the way towards the mesh.
  38839. */
  38840. static IgnoreBoundsSizeMode: number;
  38841. /**
  38842. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38843. */
  38844. static FitFrustumSidesMode: number;
  38845. }
  38846. }
  38847. declare module BABYLON {
  38848. /**
  38849. * Base class for Camera Pointer Inputs.
  38850. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38851. * for example usage.
  38852. */
  38853. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38854. /**
  38855. * Defines the camera the input is attached to.
  38856. */
  38857. abstract camera: Camera;
  38858. /**
  38859. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38860. */
  38861. protected _altKey: boolean;
  38862. protected _ctrlKey: boolean;
  38863. protected _metaKey: boolean;
  38864. protected _shiftKey: boolean;
  38865. /**
  38866. * Which mouse buttons were pressed at time of last mouse event.
  38867. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38868. */
  38869. protected _buttonsPressed: number;
  38870. /**
  38871. * Defines the buttons associated with the input to handle camera move.
  38872. */
  38873. buttons: number[];
  38874. /**
  38875. * Attach the input controls to a specific dom element to get the input from.
  38876. * @param element Defines the element the controls should be listened from
  38877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38878. */
  38879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38880. /**
  38881. * Detach the current controls from the specified dom element.
  38882. * @param element Defines the element to stop listening the inputs from
  38883. */
  38884. detachControl(element: Nullable<HTMLElement>): void;
  38885. /**
  38886. * Gets the class name of the current input.
  38887. * @returns the class name
  38888. */
  38889. getClassName(): string;
  38890. /**
  38891. * Get the friendly name associated with the input class.
  38892. * @returns the input friendly name
  38893. */
  38894. getSimpleName(): string;
  38895. /**
  38896. * Called on pointer POINTERDOUBLETAP event.
  38897. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38898. */
  38899. protected onDoubleTap(type: string): void;
  38900. /**
  38901. * Called on pointer POINTERMOVE event if only a single touch is active.
  38902. * Override this method to provide functionality.
  38903. */
  38904. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38905. /**
  38906. * Called on pointer POINTERMOVE event if multiple touches are active.
  38907. * Override this method to provide functionality.
  38908. */
  38909. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38910. /**
  38911. * Called on JS contextmenu event.
  38912. * Override this method to provide functionality.
  38913. */
  38914. protected onContextMenu(evt: PointerEvent): void;
  38915. /**
  38916. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38917. * press.
  38918. * Override this method to provide functionality.
  38919. */
  38920. protected onButtonDown(evt: PointerEvent): void;
  38921. /**
  38922. * Called each time a new POINTERUP event occurs. Ie, for each button
  38923. * release.
  38924. * Override this method to provide functionality.
  38925. */
  38926. protected onButtonUp(evt: PointerEvent): void;
  38927. /**
  38928. * Called when window becomes inactive.
  38929. * Override this method to provide functionality.
  38930. */
  38931. protected onLostFocus(): void;
  38932. private _pointerInput;
  38933. private _observer;
  38934. private _onLostFocus;
  38935. private pointA;
  38936. private pointB;
  38937. }
  38938. }
  38939. declare module BABYLON {
  38940. /**
  38941. * Manage the pointers inputs to control an arc rotate camera.
  38942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38943. */
  38944. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38945. /**
  38946. * Defines the camera the input is attached to.
  38947. */
  38948. camera: ArcRotateCamera;
  38949. /**
  38950. * Gets the class name of the current input.
  38951. * @returns the class name
  38952. */
  38953. getClassName(): string;
  38954. /**
  38955. * Defines the buttons associated with the input to handle camera move.
  38956. */
  38957. buttons: number[];
  38958. /**
  38959. * Defines the pointer angular sensibility along the X axis or how fast is
  38960. * the camera rotating.
  38961. */
  38962. angularSensibilityX: number;
  38963. /**
  38964. * Defines the pointer angular sensibility along the Y axis or how fast is
  38965. * the camera rotating.
  38966. */
  38967. angularSensibilityY: number;
  38968. /**
  38969. * Defines the pointer pinch precision or how fast is the camera zooming.
  38970. */
  38971. pinchPrecision: number;
  38972. /**
  38973. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38974. * from 0.
  38975. * It defines the percentage of current camera.radius to use as delta when
  38976. * pinch zoom is used.
  38977. */
  38978. pinchDeltaPercentage: number;
  38979. /**
  38980. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38981. * that any object in the plane at the camera's target point will scale
  38982. * perfectly with finger motion.
  38983. * Overrides pinchDeltaPercentage and pinchPrecision.
  38984. */
  38985. useNaturalPinchZoom: boolean;
  38986. /**
  38987. * Defines the pointer panning sensibility or how fast is the camera moving.
  38988. */
  38989. panningSensibility: number;
  38990. /**
  38991. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38992. */
  38993. multiTouchPanning: boolean;
  38994. /**
  38995. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38996. * zoom (pinch) through multitouch.
  38997. */
  38998. multiTouchPanAndZoom: boolean;
  38999. /**
  39000. * Revers pinch action direction.
  39001. */
  39002. pinchInwards: boolean;
  39003. private _isPanClick;
  39004. private _twoFingerActivityCount;
  39005. private _isPinching;
  39006. /**
  39007. * Called on pointer POINTERMOVE event if only a single touch is active.
  39008. */
  39009. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39010. /**
  39011. * Called on pointer POINTERDOUBLETAP event.
  39012. */
  39013. protected onDoubleTap(type: string): void;
  39014. /**
  39015. * Called on pointer POINTERMOVE event if multiple touches are active.
  39016. */
  39017. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39018. /**
  39019. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39020. * press.
  39021. */
  39022. protected onButtonDown(evt: PointerEvent): void;
  39023. /**
  39024. * Called each time a new POINTERUP event occurs. Ie, for each button
  39025. * release.
  39026. */
  39027. protected onButtonUp(evt: PointerEvent): void;
  39028. /**
  39029. * Called when window becomes inactive.
  39030. */
  39031. protected onLostFocus(): void;
  39032. }
  39033. }
  39034. declare module BABYLON {
  39035. /**
  39036. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39038. */
  39039. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39040. /**
  39041. * Defines the camera the input is attached to.
  39042. */
  39043. camera: ArcRotateCamera;
  39044. /**
  39045. * Defines the list of key codes associated with the up action (increase alpha)
  39046. */
  39047. keysUp: number[];
  39048. /**
  39049. * Defines the list of key codes associated with the down action (decrease alpha)
  39050. */
  39051. keysDown: number[];
  39052. /**
  39053. * Defines the list of key codes associated with the left action (increase beta)
  39054. */
  39055. keysLeft: number[];
  39056. /**
  39057. * Defines the list of key codes associated with the right action (decrease beta)
  39058. */
  39059. keysRight: number[];
  39060. /**
  39061. * Defines the list of key codes associated with the reset action.
  39062. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39063. */
  39064. keysReset: number[];
  39065. /**
  39066. * Defines the panning sensibility of the inputs.
  39067. * (How fast is the camera panning)
  39068. */
  39069. panningSensibility: number;
  39070. /**
  39071. * Defines the zooming sensibility of the inputs.
  39072. * (How fast is the camera zooming)
  39073. */
  39074. zoomingSensibility: number;
  39075. /**
  39076. * Defines whether maintaining the alt key down switch the movement mode from
  39077. * orientation to zoom.
  39078. */
  39079. useAltToZoom: boolean;
  39080. /**
  39081. * Rotation speed of the camera
  39082. */
  39083. angularSpeed: number;
  39084. private _keys;
  39085. private _ctrlPressed;
  39086. private _altPressed;
  39087. private _onCanvasBlurObserver;
  39088. private _onKeyboardObserver;
  39089. private _engine;
  39090. private _scene;
  39091. /**
  39092. * Attach the input controls to a specific dom element to get the input from.
  39093. * @param element Defines the element the controls should be listened from
  39094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39095. */
  39096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39097. /**
  39098. * Detach the current controls from the specified dom element.
  39099. * @param element Defines the element to stop listening the inputs from
  39100. */
  39101. detachControl(element: Nullable<HTMLElement>): void;
  39102. /**
  39103. * Update the current camera state depending on the inputs that have been used this frame.
  39104. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39105. */
  39106. checkInputs(): void;
  39107. /**
  39108. * Gets the class name of the current intput.
  39109. * @returns the class name
  39110. */
  39111. getClassName(): string;
  39112. /**
  39113. * Get the friendly name associated with the input class.
  39114. * @returns the input friendly name
  39115. */
  39116. getSimpleName(): string;
  39117. }
  39118. }
  39119. declare module BABYLON {
  39120. /**
  39121. * Manage the mouse wheel inputs to control an arc rotate camera.
  39122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39123. */
  39124. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39125. /**
  39126. * Defines the camera the input is attached to.
  39127. */
  39128. camera: ArcRotateCamera;
  39129. /**
  39130. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39131. */
  39132. wheelPrecision: number;
  39133. /**
  39134. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39135. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39136. */
  39137. wheelDeltaPercentage: number;
  39138. private _wheel;
  39139. private _observer;
  39140. private computeDeltaFromMouseWheelLegacyEvent;
  39141. /**
  39142. * Attach the input controls to a specific dom element to get the input from.
  39143. * @param element Defines the element the controls should be listened from
  39144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39145. */
  39146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39147. /**
  39148. * Detach the current controls from the specified dom element.
  39149. * @param element Defines the element to stop listening the inputs from
  39150. */
  39151. detachControl(element: Nullable<HTMLElement>): void;
  39152. /**
  39153. * Gets the class name of the current intput.
  39154. * @returns the class name
  39155. */
  39156. getClassName(): string;
  39157. /**
  39158. * Get the friendly name associated with the input class.
  39159. * @returns the input friendly name
  39160. */
  39161. getSimpleName(): string;
  39162. }
  39163. }
  39164. declare module BABYLON {
  39165. /**
  39166. * Default Inputs manager for the ArcRotateCamera.
  39167. * It groups all the default supported inputs for ease of use.
  39168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39169. */
  39170. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39171. /**
  39172. * Instantiates a new ArcRotateCameraInputsManager.
  39173. * @param camera Defines the camera the inputs belong to
  39174. */
  39175. constructor(camera: ArcRotateCamera);
  39176. /**
  39177. * Add mouse wheel input support to the input manager.
  39178. * @returns the current input manager
  39179. */
  39180. addMouseWheel(): ArcRotateCameraInputsManager;
  39181. /**
  39182. * Add pointers input support to the input manager.
  39183. * @returns the current input manager
  39184. */
  39185. addPointers(): ArcRotateCameraInputsManager;
  39186. /**
  39187. * Add keyboard input support to the input manager.
  39188. * @returns the current input manager
  39189. */
  39190. addKeyboard(): ArcRotateCameraInputsManager;
  39191. }
  39192. }
  39193. declare module BABYLON {
  39194. /**
  39195. * This represents an orbital type of camera.
  39196. *
  39197. * 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.
  39198. * 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.
  39199. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39200. */
  39201. export class ArcRotateCamera extends TargetCamera {
  39202. /**
  39203. * Defines the rotation angle of the camera along the longitudinal axis.
  39204. */
  39205. alpha: number;
  39206. /**
  39207. * Defines the rotation angle of the camera along the latitudinal axis.
  39208. */
  39209. beta: number;
  39210. /**
  39211. * Defines the radius of the camera from it s target point.
  39212. */
  39213. radius: number;
  39214. protected _target: Vector3;
  39215. protected _targetHost: Nullable<AbstractMesh>;
  39216. /**
  39217. * Defines the target point of the camera.
  39218. * The camera looks towards it form the radius distance.
  39219. */
  39220. get target(): Vector3;
  39221. set target(value: Vector3);
  39222. /**
  39223. * Define the current local position of the camera in the scene
  39224. */
  39225. get position(): Vector3;
  39226. set position(newPosition: Vector3);
  39227. protected _upVector: Vector3;
  39228. protected _upToYMatrix: Matrix;
  39229. protected _YToUpMatrix: Matrix;
  39230. /**
  39231. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39232. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39233. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39234. */
  39235. set upVector(vec: Vector3);
  39236. get upVector(): Vector3;
  39237. /**
  39238. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39239. */
  39240. setMatUp(): void;
  39241. /**
  39242. * Current inertia value on the longitudinal axis.
  39243. * The bigger this number the longer it will take for the camera to stop.
  39244. */
  39245. inertialAlphaOffset: number;
  39246. /**
  39247. * Current inertia value on the latitudinal axis.
  39248. * The bigger this number the longer it will take for the camera to stop.
  39249. */
  39250. inertialBetaOffset: number;
  39251. /**
  39252. * Current inertia value on the radius axis.
  39253. * The bigger this number the longer it will take for the camera to stop.
  39254. */
  39255. inertialRadiusOffset: number;
  39256. /**
  39257. * Minimum allowed angle on the longitudinal axis.
  39258. * This can help limiting how the Camera is able to move in the scene.
  39259. */
  39260. lowerAlphaLimit: Nullable<number>;
  39261. /**
  39262. * Maximum allowed angle on the longitudinal axis.
  39263. * This can help limiting how the Camera is able to move in the scene.
  39264. */
  39265. upperAlphaLimit: Nullable<number>;
  39266. /**
  39267. * Minimum allowed angle on the latitudinal axis.
  39268. * This can help limiting how the Camera is able to move in the scene.
  39269. */
  39270. lowerBetaLimit: number;
  39271. /**
  39272. * Maximum allowed angle on the latitudinal axis.
  39273. * This can help limiting how the Camera is able to move in the scene.
  39274. */
  39275. upperBetaLimit: number;
  39276. /**
  39277. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39278. * This can help limiting how the Camera is able to move in the scene.
  39279. */
  39280. lowerRadiusLimit: Nullable<number>;
  39281. /**
  39282. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39283. * This can help limiting how the Camera is able to move in the scene.
  39284. */
  39285. upperRadiusLimit: Nullable<number>;
  39286. /**
  39287. * Defines the current inertia value used during panning of the camera along the X axis.
  39288. */
  39289. inertialPanningX: number;
  39290. /**
  39291. * Defines the current inertia value used during panning of the camera along the Y axis.
  39292. */
  39293. inertialPanningY: number;
  39294. /**
  39295. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39296. * Basically if your fingers moves away from more than this distance you will be considered
  39297. * in pinch mode.
  39298. */
  39299. pinchToPanMaxDistance: number;
  39300. /**
  39301. * Defines the maximum distance the camera can pan.
  39302. * This could help keeping the cammera always in your scene.
  39303. */
  39304. panningDistanceLimit: Nullable<number>;
  39305. /**
  39306. * Defines the target of the camera before paning.
  39307. */
  39308. panningOriginTarget: Vector3;
  39309. /**
  39310. * Defines the value of the inertia used during panning.
  39311. * 0 would mean stop inertia and one would mean no decelleration at all.
  39312. */
  39313. panningInertia: number;
  39314. /**
  39315. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39316. */
  39317. get angularSensibilityX(): number;
  39318. set angularSensibilityX(value: number);
  39319. /**
  39320. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39321. */
  39322. get angularSensibilityY(): number;
  39323. set angularSensibilityY(value: number);
  39324. /**
  39325. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39326. */
  39327. get pinchPrecision(): number;
  39328. set pinchPrecision(value: number);
  39329. /**
  39330. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39331. * It will be used instead of pinchDeltaPrecision if different from 0.
  39332. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39333. */
  39334. get pinchDeltaPercentage(): number;
  39335. set pinchDeltaPercentage(value: number);
  39336. /**
  39337. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39338. * and pinch delta percentage.
  39339. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39340. * that any object in the plane at the camera's target point will scale
  39341. * perfectly with finger motion.
  39342. */
  39343. get useNaturalPinchZoom(): boolean;
  39344. set useNaturalPinchZoom(value: boolean);
  39345. /**
  39346. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39347. */
  39348. get panningSensibility(): number;
  39349. set panningSensibility(value: number);
  39350. /**
  39351. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39352. */
  39353. get keysUp(): number[];
  39354. set keysUp(value: number[]);
  39355. /**
  39356. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39357. */
  39358. get keysDown(): number[];
  39359. set keysDown(value: number[]);
  39360. /**
  39361. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39362. */
  39363. get keysLeft(): number[];
  39364. set keysLeft(value: number[]);
  39365. /**
  39366. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39367. */
  39368. get keysRight(): number[];
  39369. set keysRight(value: number[]);
  39370. /**
  39371. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39372. */
  39373. get wheelPrecision(): number;
  39374. set wheelPrecision(value: number);
  39375. /**
  39376. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39377. * It will be used instead of pinchDeltaPrecision if different from 0.
  39378. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39379. */
  39380. get wheelDeltaPercentage(): number;
  39381. set wheelDeltaPercentage(value: number);
  39382. /**
  39383. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39384. */
  39385. zoomOnFactor: number;
  39386. /**
  39387. * Defines a screen offset for the camera position.
  39388. */
  39389. targetScreenOffset: Vector2;
  39390. /**
  39391. * Allows the camera to be completely reversed.
  39392. * If false the camera can not arrive upside down.
  39393. */
  39394. allowUpsideDown: boolean;
  39395. /**
  39396. * Define if double tap/click is used to restore the previously saved state of the camera.
  39397. */
  39398. useInputToRestoreState: boolean;
  39399. /** @hidden */
  39400. _viewMatrix: Matrix;
  39401. /** @hidden */
  39402. _useCtrlForPanning: boolean;
  39403. /** @hidden */
  39404. _panningMouseButton: number;
  39405. /**
  39406. * Defines the input associated to the camera.
  39407. */
  39408. inputs: ArcRotateCameraInputsManager;
  39409. /** @hidden */
  39410. _reset: () => void;
  39411. /**
  39412. * Defines the allowed panning axis.
  39413. */
  39414. panningAxis: Vector3;
  39415. protected _localDirection: Vector3;
  39416. protected _transformedDirection: Vector3;
  39417. private _bouncingBehavior;
  39418. /**
  39419. * Gets the bouncing behavior of the camera if it has been enabled.
  39420. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39421. */
  39422. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39423. /**
  39424. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39425. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39426. */
  39427. get useBouncingBehavior(): boolean;
  39428. set useBouncingBehavior(value: boolean);
  39429. private _framingBehavior;
  39430. /**
  39431. * Gets the framing behavior of the camera if it has been enabled.
  39432. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39433. */
  39434. get framingBehavior(): Nullable<FramingBehavior>;
  39435. /**
  39436. * Defines if the framing behavior of the camera is enabled on the camera.
  39437. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39438. */
  39439. get useFramingBehavior(): boolean;
  39440. set useFramingBehavior(value: boolean);
  39441. private _autoRotationBehavior;
  39442. /**
  39443. * Gets the auto rotation behavior of the camera if it has been enabled.
  39444. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39445. */
  39446. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39447. /**
  39448. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39449. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39450. */
  39451. get useAutoRotationBehavior(): boolean;
  39452. set useAutoRotationBehavior(value: boolean);
  39453. /**
  39454. * Observable triggered when the mesh target has been changed on the camera.
  39455. */
  39456. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39457. /**
  39458. * Event raised when the camera is colliding with a mesh.
  39459. */
  39460. onCollide: (collidedMesh: AbstractMesh) => void;
  39461. /**
  39462. * Defines whether the camera should check collision with the objects oh the scene.
  39463. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39464. */
  39465. checkCollisions: boolean;
  39466. /**
  39467. * Defines the collision radius of the camera.
  39468. * This simulates a sphere around the camera.
  39469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39470. */
  39471. collisionRadius: Vector3;
  39472. protected _collider: Collider;
  39473. protected _previousPosition: Vector3;
  39474. protected _collisionVelocity: Vector3;
  39475. protected _newPosition: Vector3;
  39476. protected _previousAlpha: number;
  39477. protected _previousBeta: number;
  39478. protected _previousRadius: number;
  39479. protected _collisionTriggered: boolean;
  39480. protected _targetBoundingCenter: Nullable<Vector3>;
  39481. private _computationVector;
  39482. /**
  39483. * Instantiates a new ArcRotateCamera in a given scene
  39484. * @param name Defines the name of the camera
  39485. * @param alpha Defines the camera rotation along the logitudinal axis
  39486. * @param beta Defines the camera rotation along the latitudinal axis
  39487. * @param radius Defines the camera distance from its target
  39488. * @param target Defines the camera target
  39489. * @param scene Defines the scene the camera belongs to
  39490. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39491. */
  39492. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39493. /** @hidden */
  39494. _initCache(): void;
  39495. /** @hidden */
  39496. _updateCache(ignoreParentClass?: boolean): void;
  39497. protected _getTargetPosition(): Vector3;
  39498. private _storedAlpha;
  39499. private _storedBeta;
  39500. private _storedRadius;
  39501. private _storedTarget;
  39502. private _storedTargetScreenOffset;
  39503. /**
  39504. * Stores the current state of the camera (alpha, beta, radius and target)
  39505. * @returns the camera itself
  39506. */
  39507. storeState(): Camera;
  39508. /**
  39509. * @hidden
  39510. * Restored camera state. You must call storeState() first
  39511. */
  39512. _restoreStateValues(): boolean;
  39513. /** @hidden */
  39514. _isSynchronizedViewMatrix(): boolean;
  39515. /**
  39516. * Attached controls to the current camera.
  39517. * @param element Defines the element the controls should be listened from
  39518. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39519. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39520. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39521. */
  39522. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39523. /**
  39524. * Detach the current controls from the camera.
  39525. * The camera will stop reacting to inputs.
  39526. * @param element Defines the element to stop listening the inputs from
  39527. */
  39528. detachControl(element: HTMLElement): void;
  39529. /** @hidden */
  39530. _checkInputs(): void;
  39531. protected _checkLimits(): void;
  39532. /**
  39533. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39534. */
  39535. rebuildAnglesAndRadius(): void;
  39536. /**
  39537. * Use a position to define the current camera related information like alpha, beta and radius
  39538. * @param position Defines the position to set the camera at
  39539. */
  39540. setPosition(position: Vector3): void;
  39541. /**
  39542. * Defines the target the camera should look at.
  39543. * This will automatically adapt alpha beta and radius to fit within the new target.
  39544. * @param target Defines the new target as a Vector or a mesh
  39545. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39546. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39547. */
  39548. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39549. /** @hidden */
  39550. _getViewMatrix(): Matrix;
  39551. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39552. /**
  39553. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39554. * @param meshes Defines the mesh to zoom on
  39555. * @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)
  39556. */
  39557. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39558. /**
  39559. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39560. * The target will be changed but the radius
  39561. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39562. * @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)
  39563. */
  39564. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39565. min: Vector3;
  39566. max: Vector3;
  39567. distance: number;
  39568. }, doNotUpdateMaxZ?: boolean): void;
  39569. /**
  39570. * @override
  39571. * Override Camera.createRigCamera
  39572. */
  39573. createRigCamera(name: string, cameraIndex: number): Camera;
  39574. /**
  39575. * @hidden
  39576. * @override
  39577. * Override Camera._updateRigCameras
  39578. */
  39579. _updateRigCameras(): void;
  39580. /**
  39581. * Destroy the camera and release the current resources hold by it.
  39582. */
  39583. dispose(): void;
  39584. /**
  39585. * Gets the current object class name.
  39586. * @return the class name
  39587. */
  39588. getClassName(): string;
  39589. }
  39590. }
  39591. declare module BABYLON {
  39592. /**
  39593. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39594. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39595. */
  39596. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39597. /**
  39598. * Gets the name of the behavior.
  39599. */
  39600. get name(): string;
  39601. private _zoomStopsAnimation;
  39602. private _idleRotationSpeed;
  39603. private _idleRotationWaitTime;
  39604. private _idleRotationSpinupTime;
  39605. /**
  39606. * Sets the flag that indicates if user zooming should stop animation.
  39607. */
  39608. set zoomStopsAnimation(flag: boolean);
  39609. /**
  39610. * Gets the flag that indicates if user zooming should stop animation.
  39611. */
  39612. get zoomStopsAnimation(): boolean;
  39613. /**
  39614. * Sets the default speed at which the camera rotates around the model.
  39615. */
  39616. set idleRotationSpeed(speed: number);
  39617. /**
  39618. * Gets the default speed at which the camera rotates around the model.
  39619. */
  39620. get idleRotationSpeed(): number;
  39621. /**
  39622. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39623. */
  39624. set idleRotationWaitTime(time: number);
  39625. /**
  39626. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39627. */
  39628. get idleRotationWaitTime(): number;
  39629. /**
  39630. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39631. */
  39632. set idleRotationSpinupTime(time: number);
  39633. /**
  39634. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39635. */
  39636. get idleRotationSpinupTime(): number;
  39637. /**
  39638. * Gets a value indicating if the camera is currently rotating because of this behavior
  39639. */
  39640. get rotationInProgress(): boolean;
  39641. private _onPrePointerObservableObserver;
  39642. private _onAfterCheckInputsObserver;
  39643. private _attachedCamera;
  39644. private _isPointerDown;
  39645. private _lastFrameTime;
  39646. private _lastInteractionTime;
  39647. private _cameraRotationSpeed;
  39648. /**
  39649. * Initializes the behavior.
  39650. */
  39651. init(): void;
  39652. /**
  39653. * Attaches the behavior to its arc rotate camera.
  39654. * @param camera Defines the camera to attach the behavior to
  39655. */
  39656. attach(camera: ArcRotateCamera): void;
  39657. /**
  39658. * Detaches the behavior from its current arc rotate camera.
  39659. */
  39660. detach(): void;
  39661. /**
  39662. * Returns true if user is scrolling.
  39663. * @return true if user is scrolling.
  39664. */
  39665. private _userIsZooming;
  39666. private _lastFrameRadius;
  39667. private _shouldAnimationStopForInteraction;
  39668. /**
  39669. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39670. */
  39671. private _applyUserInteraction;
  39672. private _userIsMoving;
  39673. }
  39674. }
  39675. declare module BABYLON {
  39676. /**
  39677. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39678. */
  39679. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39680. private ui;
  39681. /**
  39682. * The name of the behavior
  39683. */
  39684. name: string;
  39685. /**
  39686. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39687. */
  39688. distanceAwayFromFace: number;
  39689. /**
  39690. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39691. */
  39692. distanceAwayFromBottomOfFace: number;
  39693. private _faceVectors;
  39694. private _target;
  39695. private _scene;
  39696. private _onRenderObserver;
  39697. private _tmpMatrix;
  39698. private _tmpVector;
  39699. /**
  39700. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39701. * @param ui The transform node that should be attched to the mesh
  39702. */
  39703. constructor(ui: TransformNode);
  39704. /**
  39705. * Initializes the behavior
  39706. */
  39707. init(): void;
  39708. private _closestFace;
  39709. private _zeroVector;
  39710. private _lookAtTmpMatrix;
  39711. private _lookAtToRef;
  39712. /**
  39713. * Attaches the AttachToBoxBehavior to the passed in mesh
  39714. * @param target The mesh that the specified node will be attached to
  39715. */
  39716. attach(target: Mesh): void;
  39717. /**
  39718. * Detaches the behavior from the mesh
  39719. */
  39720. detach(): void;
  39721. }
  39722. }
  39723. declare module BABYLON {
  39724. /**
  39725. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39726. */
  39727. export class FadeInOutBehavior implements Behavior<Mesh> {
  39728. /**
  39729. * Time in milliseconds to delay before fading in (Default: 0)
  39730. */
  39731. delay: number;
  39732. /**
  39733. * Time in milliseconds for the mesh to fade in (Default: 300)
  39734. */
  39735. fadeInTime: number;
  39736. private _millisecondsPerFrame;
  39737. private _hovered;
  39738. private _hoverValue;
  39739. private _ownerNode;
  39740. /**
  39741. * Instatiates the FadeInOutBehavior
  39742. */
  39743. constructor();
  39744. /**
  39745. * The name of the behavior
  39746. */
  39747. get name(): string;
  39748. /**
  39749. * Initializes the behavior
  39750. */
  39751. init(): void;
  39752. /**
  39753. * Attaches the fade behavior on the passed in mesh
  39754. * @param ownerNode The mesh that will be faded in/out once attached
  39755. */
  39756. attach(ownerNode: Mesh): void;
  39757. /**
  39758. * Detaches the behavior from the mesh
  39759. */
  39760. detach(): void;
  39761. /**
  39762. * Triggers the mesh to begin fading in or out
  39763. * @param value if the object should fade in or out (true to fade in)
  39764. */
  39765. fadeIn(value: boolean): void;
  39766. private _update;
  39767. private _setAllVisibility;
  39768. }
  39769. }
  39770. declare module BABYLON {
  39771. /**
  39772. * Class containing a set of static utilities functions for managing Pivots
  39773. * @hidden
  39774. */
  39775. export class PivotTools {
  39776. private static _PivotCached;
  39777. private static _OldPivotPoint;
  39778. private static _PivotTranslation;
  39779. private static _PivotTmpVector;
  39780. /** @hidden */
  39781. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39782. /** @hidden */
  39783. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39784. }
  39785. }
  39786. declare module BABYLON {
  39787. /**
  39788. * Class containing static functions to help procedurally build meshes
  39789. */
  39790. export class PlaneBuilder {
  39791. /**
  39792. * Creates a plane mesh
  39793. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39794. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39795. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39797. * * 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
  39798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39799. * @param name defines the name of the mesh
  39800. * @param options defines the options used to create the mesh
  39801. * @param scene defines the hosting scene
  39802. * @returns the plane mesh
  39803. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39804. */
  39805. static CreatePlane(name: string, options: {
  39806. size?: number;
  39807. width?: number;
  39808. height?: number;
  39809. sideOrientation?: number;
  39810. frontUVs?: Vector4;
  39811. backUVs?: Vector4;
  39812. updatable?: boolean;
  39813. sourcePlane?: Plane;
  39814. }, scene?: Nullable<Scene>): Mesh;
  39815. }
  39816. }
  39817. declare module BABYLON {
  39818. /**
  39819. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39820. */
  39821. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39822. private static _AnyMouseID;
  39823. /**
  39824. * Abstract mesh the behavior is set on
  39825. */
  39826. attachedNode: AbstractMesh;
  39827. private _dragPlane;
  39828. private _scene;
  39829. private _pointerObserver;
  39830. private _beforeRenderObserver;
  39831. private static _planeScene;
  39832. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39833. /**
  39834. * 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)
  39835. */
  39836. maxDragAngle: number;
  39837. /**
  39838. * @hidden
  39839. */
  39840. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39841. /**
  39842. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39843. */
  39844. currentDraggingPointerID: number;
  39845. /**
  39846. * The last position where the pointer hit the drag plane in world space
  39847. */
  39848. lastDragPosition: Vector3;
  39849. /**
  39850. * If the behavior is currently in a dragging state
  39851. */
  39852. dragging: boolean;
  39853. /**
  39854. * 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)
  39855. */
  39856. dragDeltaRatio: number;
  39857. /**
  39858. * If the drag plane orientation should be updated during the dragging (Default: true)
  39859. */
  39860. updateDragPlane: boolean;
  39861. private _debugMode;
  39862. private _moving;
  39863. /**
  39864. * Fires each time the attached mesh is dragged with the pointer
  39865. * * delta between last drag position and current drag position in world space
  39866. * * dragDistance along the drag axis
  39867. * * dragPlaneNormal normal of the current drag plane used during the drag
  39868. * * dragPlanePoint in world space where the drag intersects the drag plane
  39869. */
  39870. onDragObservable: Observable<{
  39871. delta: Vector3;
  39872. dragPlanePoint: Vector3;
  39873. dragPlaneNormal: Vector3;
  39874. dragDistance: number;
  39875. pointerId: number;
  39876. }>;
  39877. /**
  39878. * Fires each time a drag begins (eg. mouse down on mesh)
  39879. */
  39880. onDragStartObservable: Observable<{
  39881. dragPlanePoint: Vector3;
  39882. pointerId: number;
  39883. }>;
  39884. /**
  39885. * Fires each time a drag ends (eg. mouse release after drag)
  39886. */
  39887. onDragEndObservable: Observable<{
  39888. dragPlanePoint: Vector3;
  39889. pointerId: number;
  39890. }>;
  39891. /**
  39892. * If the attached mesh should be moved when dragged
  39893. */
  39894. moveAttached: boolean;
  39895. /**
  39896. * If the drag behavior will react to drag events (Default: true)
  39897. */
  39898. enabled: boolean;
  39899. /**
  39900. * If pointer events should start and release the drag (Default: true)
  39901. */
  39902. startAndReleaseDragOnPointerEvents: boolean;
  39903. /**
  39904. * If camera controls should be detached during the drag
  39905. */
  39906. detachCameraControls: boolean;
  39907. /**
  39908. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39909. */
  39910. useObjectOrientationForDragging: boolean;
  39911. private _options;
  39912. /**
  39913. * Gets the options used by the behavior
  39914. */
  39915. get options(): {
  39916. dragAxis?: Vector3;
  39917. dragPlaneNormal?: Vector3;
  39918. };
  39919. /**
  39920. * Sets the options used by the behavior
  39921. */
  39922. set options(options: {
  39923. dragAxis?: Vector3;
  39924. dragPlaneNormal?: Vector3;
  39925. });
  39926. /**
  39927. * Creates a pointer drag behavior that can be attached to a mesh
  39928. * @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)
  39929. */
  39930. constructor(options?: {
  39931. dragAxis?: Vector3;
  39932. dragPlaneNormal?: Vector3;
  39933. });
  39934. /**
  39935. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39936. */
  39937. validateDrag: (targetPosition: Vector3) => boolean;
  39938. /**
  39939. * The name of the behavior
  39940. */
  39941. get name(): string;
  39942. /**
  39943. * Initializes the behavior
  39944. */
  39945. init(): void;
  39946. private _tmpVector;
  39947. private _alternatePickedPoint;
  39948. private _worldDragAxis;
  39949. private _targetPosition;
  39950. private _attachedElement;
  39951. /**
  39952. * Attaches the drag behavior the passed in mesh
  39953. * @param ownerNode The mesh that will be dragged around once attached
  39954. * @param predicate Predicate to use for pick filtering
  39955. */
  39956. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39957. /**
  39958. * Force relase the drag action by code.
  39959. */
  39960. releaseDrag(): void;
  39961. private _startDragRay;
  39962. private _lastPointerRay;
  39963. /**
  39964. * Simulates the start of a pointer drag event on the behavior
  39965. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39966. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39967. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39968. */
  39969. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39970. private _startDrag;
  39971. private _dragDelta;
  39972. private _moveDrag;
  39973. private _pickWithRayOnDragPlane;
  39974. private _pointA;
  39975. private _pointB;
  39976. private _pointC;
  39977. private _lineA;
  39978. private _lineB;
  39979. private _localAxis;
  39980. private _lookAt;
  39981. private _updateDragPlanePosition;
  39982. /**
  39983. * Detaches the behavior from the mesh
  39984. */
  39985. detach(): void;
  39986. }
  39987. }
  39988. declare module BABYLON {
  39989. /**
  39990. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39991. */
  39992. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39993. private _dragBehaviorA;
  39994. private _dragBehaviorB;
  39995. private _startDistance;
  39996. private _initialScale;
  39997. private _targetScale;
  39998. private _ownerNode;
  39999. private _sceneRenderObserver;
  40000. /**
  40001. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40002. */
  40003. constructor();
  40004. /**
  40005. * The name of the behavior
  40006. */
  40007. get name(): string;
  40008. /**
  40009. * Initializes the behavior
  40010. */
  40011. init(): void;
  40012. private _getCurrentDistance;
  40013. /**
  40014. * Attaches the scale behavior the passed in mesh
  40015. * @param ownerNode The mesh that will be scaled around once attached
  40016. */
  40017. attach(ownerNode: Mesh): void;
  40018. /**
  40019. * Detaches the behavior from the mesh
  40020. */
  40021. detach(): void;
  40022. }
  40023. }
  40024. declare module BABYLON {
  40025. /**
  40026. * 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
  40027. */
  40028. export class SixDofDragBehavior implements Behavior<Mesh> {
  40029. private static _virtualScene;
  40030. private _ownerNode;
  40031. private _sceneRenderObserver;
  40032. private _scene;
  40033. private _targetPosition;
  40034. private _virtualOriginMesh;
  40035. private _virtualDragMesh;
  40036. private _pointerObserver;
  40037. private _moving;
  40038. private _startingOrientation;
  40039. private _attachedElement;
  40040. /**
  40041. * 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)
  40042. */
  40043. private zDragFactor;
  40044. /**
  40045. * If the object should rotate to face the drag origin
  40046. */
  40047. rotateDraggedObject: boolean;
  40048. /**
  40049. * If the behavior is currently in a dragging state
  40050. */
  40051. dragging: boolean;
  40052. /**
  40053. * 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)
  40054. */
  40055. dragDeltaRatio: number;
  40056. /**
  40057. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40058. */
  40059. currentDraggingPointerID: number;
  40060. /**
  40061. * If camera controls should be detached during the drag
  40062. */
  40063. detachCameraControls: boolean;
  40064. /**
  40065. * Fires each time a drag starts
  40066. */
  40067. onDragStartObservable: Observable<{}>;
  40068. /**
  40069. * Fires each time a drag ends (eg. mouse release after drag)
  40070. */
  40071. onDragEndObservable: Observable<{}>;
  40072. /**
  40073. * 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
  40074. */
  40075. constructor();
  40076. /**
  40077. * The name of the behavior
  40078. */
  40079. get name(): string;
  40080. /**
  40081. * Initializes the behavior
  40082. */
  40083. init(): void;
  40084. /**
  40085. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40086. */
  40087. private get _pointerCamera();
  40088. /**
  40089. * Attaches the scale behavior the passed in mesh
  40090. * @param ownerNode The mesh that will be scaled around once attached
  40091. */
  40092. attach(ownerNode: Mesh): void;
  40093. /**
  40094. * Detaches the behavior from the mesh
  40095. */
  40096. detach(): void;
  40097. }
  40098. }
  40099. declare module BABYLON {
  40100. /**
  40101. * Class used to apply inverse kinematics to bones
  40102. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40103. */
  40104. export class BoneIKController {
  40105. private static _tmpVecs;
  40106. private static _tmpQuat;
  40107. private static _tmpMats;
  40108. /**
  40109. * Gets or sets the target mesh
  40110. */
  40111. targetMesh: AbstractMesh;
  40112. /** Gets or sets the mesh used as pole */
  40113. poleTargetMesh: AbstractMesh;
  40114. /**
  40115. * Gets or sets the bone used as pole
  40116. */
  40117. poleTargetBone: Nullable<Bone>;
  40118. /**
  40119. * Gets or sets the target position
  40120. */
  40121. targetPosition: Vector3;
  40122. /**
  40123. * Gets or sets the pole target position
  40124. */
  40125. poleTargetPosition: Vector3;
  40126. /**
  40127. * Gets or sets the pole target local offset
  40128. */
  40129. poleTargetLocalOffset: Vector3;
  40130. /**
  40131. * Gets or sets the pole angle
  40132. */
  40133. poleAngle: number;
  40134. /**
  40135. * Gets or sets the mesh associated with the controller
  40136. */
  40137. mesh: AbstractMesh;
  40138. /**
  40139. * 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)
  40140. */
  40141. slerpAmount: number;
  40142. private _bone1Quat;
  40143. private _bone1Mat;
  40144. private _bone2Ang;
  40145. private _bone1;
  40146. private _bone2;
  40147. private _bone1Length;
  40148. private _bone2Length;
  40149. private _maxAngle;
  40150. private _maxReach;
  40151. private _rightHandedSystem;
  40152. private _bendAxis;
  40153. private _slerping;
  40154. private _adjustRoll;
  40155. /**
  40156. * Gets or sets maximum allowed angle
  40157. */
  40158. get maxAngle(): number;
  40159. set maxAngle(value: number);
  40160. /**
  40161. * Creates a new BoneIKController
  40162. * @param mesh defines the mesh to control
  40163. * @param bone defines the bone to control
  40164. * @param options defines options to set up the controller
  40165. */
  40166. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40167. targetMesh?: AbstractMesh;
  40168. poleTargetMesh?: AbstractMesh;
  40169. poleTargetBone?: Bone;
  40170. poleTargetLocalOffset?: Vector3;
  40171. poleAngle?: number;
  40172. bendAxis?: Vector3;
  40173. maxAngle?: number;
  40174. slerpAmount?: number;
  40175. });
  40176. private _setMaxAngle;
  40177. /**
  40178. * Force the controller to update the bones
  40179. */
  40180. update(): void;
  40181. }
  40182. }
  40183. declare module BABYLON {
  40184. /**
  40185. * Class used to make a bone look toward a point in space
  40186. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40187. */
  40188. export class BoneLookController {
  40189. private static _tmpVecs;
  40190. private static _tmpQuat;
  40191. private static _tmpMats;
  40192. /**
  40193. * The target Vector3 that the bone will look at
  40194. */
  40195. target: Vector3;
  40196. /**
  40197. * The mesh that the bone is attached to
  40198. */
  40199. mesh: AbstractMesh;
  40200. /**
  40201. * The bone that will be looking to the target
  40202. */
  40203. bone: Bone;
  40204. /**
  40205. * The up axis of the coordinate system that is used when the bone is rotated
  40206. */
  40207. upAxis: Vector3;
  40208. /**
  40209. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40210. */
  40211. upAxisSpace: Space;
  40212. /**
  40213. * Used to make an adjustment to the yaw of the bone
  40214. */
  40215. adjustYaw: number;
  40216. /**
  40217. * Used to make an adjustment to the pitch of the bone
  40218. */
  40219. adjustPitch: number;
  40220. /**
  40221. * Used to make an adjustment to the roll of the bone
  40222. */
  40223. adjustRoll: number;
  40224. /**
  40225. * 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)
  40226. */
  40227. slerpAmount: number;
  40228. private _minYaw;
  40229. private _maxYaw;
  40230. private _minPitch;
  40231. private _maxPitch;
  40232. private _minYawSin;
  40233. private _minYawCos;
  40234. private _maxYawSin;
  40235. private _maxYawCos;
  40236. private _midYawConstraint;
  40237. private _minPitchTan;
  40238. private _maxPitchTan;
  40239. private _boneQuat;
  40240. private _slerping;
  40241. private _transformYawPitch;
  40242. private _transformYawPitchInv;
  40243. private _firstFrameSkipped;
  40244. private _yawRange;
  40245. private _fowardAxis;
  40246. /**
  40247. * Gets or sets the minimum yaw angle that the bone can look to
  40248. */
  40249. get minYaw(): number;
  40250. set minYaw(value: number);
  40251. /**
  40252. * Gets or sets the maximum yaw angle that the bone can look to
  40253. */
  40254. get maxYaw(): number;
  40255. set maxYaw(value: number);
  40256. /**
  40257. * Gets or sets the minimum pitch angle that the bone can look to
  40258. */
  40259. get minPitch(): number;
  40260. set minPitch(value: number);
  40261. /**
  40262. * Gets or sets the maximum pitch angle that the bone can look to
  40263. */
  40264. get maxPitch(): number;
  40265. set maxPitch(value: number);
  40266. /**
  40267. * Create a BoneLookController
  40268. * @param mesh the mesh that the bone belongs to
  40269. * @param bone the bone that will be looking to the target
  40270. * @param target the target Vector3 to look at
  40271. * @param options optional settings:
  40272. * * maxYaw: the maximum angle the bone will yaw to
  40273. * * minYaw: the minimum angle the bone will yaw to
  40274. * * maxPitch: the maximum angle the bone will pitch to
  40275. * * minPitch: the minimum angle the bone will yaw to
  40276. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40277. * * upAxis: the up axis of the coordinate system
  40278. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40279. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40280. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40281. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40282. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40283. * * adjustRoll: used to make an adjustment to the roll of the bone
  40284. **/
  40285. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40286. maxYaw?: number;
  40287. minYaw?: number;
  40288. maxPitch?: number;
  40289. minPitch?: number;
  40290. slerpAmount?: number;
  40291. upAxis?: Vector3;
  40292. upAxisSpace?: Space;
  40293. yawAxis?: Vector3;
  40294. pitchAxis?: Vector3;
  40295. adjustYaw?: number;
  40296. adjustPitch?: number;
  40297. adjustRoll?: number;
  40298. });
  40299. /**
  40300. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40301. */
  40302. update(): void;
  40303. private _getAngleDiff;
  40304. private _getAngleBetween;
  40305. private _isAngleBetween;
  40306. }
  40307. }
  40308. declare module BABYLON {
  40309. /**
  40310. * Manage the gamepad inputs to control an arc rotate camera.
  40311. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40312. */
  40313. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40314. /**
  40315. * Defines the camera the input is attached to.
  40316. */
  40317. camera: ArcRotateCamera;
  40318. /**
  40319. * Defines the gamepad the input is gathering event from.
  40320. */
  40321. gamepad: Nullable<Gamepad>;
  40322. /**
  40323. * Defines the gamepad rotation sensiblity.
  40324. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40325. */
  40326. gamepadRotationSensibility: number;
  40327. /**
  40328. * Defines the gamepad move sensiblity.
  40329. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40330. */
  40331. gamepadMoveSensibility: number;
  40332. private _yAxisScale;
  40333. /**
  40334. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40335. */
  40336. get invertYAxis(): boolean;
  40337. set invertYAxis(value: boolean);
  40338. private _onGamepadConnectedObserver;
  40339. private _onGamepadDisconnectedObserver;
  40340. /**
  40341. * Attach the input controls to a specific dom element to get the input from.
  40342. * @param element Defines the element the controls should be listened from
  40343. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40344. */
  40345. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40346. /**
  40347. * Detach the current controls from the specified dom element.
  40348. * @param element Defines the element to stop listening the inputs from
  40349. */
  40350. detachControl(element: Nullable<HTMLElement>): void;
  40351. /**
  40352. * Update the current camera state depending on the inputs that have been used this frame.
  40353. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40354. */
  40355. checkInputs(): void;
  40356. /**
  40357. * Gets the class name of the current intput.
  40358. * @returns the class name
  40359. */
  40360. getClassName(): string;
  40361. /**
  40362. * Get the friendly name associated with the input class.
  40363. * @returns the input friendly name
  40364. */
  40365. getSimpleName(): string;
  40366. }
  40367. }
  40368. declare module BABYLON {
  40369. interface ArcRotateCameraInputsManager {
  40370. /**
  40371. * Add orientation input support to the input manager.
  40372. * @returns the current input manager
  40373. */
  40374. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40375. }
  40376. /**
  40377. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40379. */
  40380. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40381. /**
  40382. * Defines the camera the input is attached to.
  40383. */
  40384. camera: ArcRotateCamera;
  40385. /**
  40386. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40387. */
  40388. alphaCorrection: number;
  40389. /**
  40390. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40391. */
  40392. gammaCorrection: number;
  40393. private _alpha;
  40394. private _gamma;
  40395. private _dirty;
  40396. private _deviceOrientationHandler;
  40397. /**
  40398. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40399. */
  40400. constructor();
  40401. /**
  40402. * Attach the input controls to a specific dom element to get the input from.
  40403. * @param element Defines the element the controls should be listened from
  40404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40405. */
  40406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40407. /** @hidden */
  40408. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40409. /**
  40410. * Update the current camera state depending on the inputs that have been used this frame.
  40411. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40412. */
  40413. checkInputs(): void;
  40414. /**
  40415. * Detach the current controls from the specified dom element.
  40416. * @param element Defines the element to stop listening the inputs from
  40417. */
  40418. detachControl(element: Nullable<HTMLElement>): void;
  40419. /**
  40420. * Gets the class name of the current intput.
  40421. * @returns the class name
  40422. */
  40423. getClassName(): string;
  40424. /**
  40425. * Get the friendly name associated with the input class.
  40426. * @returns the input friendly name
  40427. */
  40428. getSimpleName(): string;
  40429. }
  40430. }
  40431. declare module BABYLON {
  40432. /**
  40433. * Listen to mouse events to control the camera.
  40434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40435. */
  40436. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40437. /**
  40438. * Defines the camera the input is attached to.
  40439. */
  40440. camera: FlyCamera;
  40441. /**
  40442. * Defines if touch is enabled. (Default is true.)
  40443. */
  40444. touchEnabled: boolean;
  40445. /**
  40446. * Defines the buttons associated with the input to handle camera rotation.
  40447. */
  40448. buttons: number[];
  40449. /**
  40450. * Assign buttons for Yaw control.
  40451. */
  40452. buttonsYaw: number[];
  40453. /**
  40454. * Assign buttons for Pitch control.
  40455. */
  40456. buttonsPitch: number[];
  40457. /**
  40458. * Assign buttons for Roll control.
  40459. */
  40460. buttonsRoll: number[];
  40461. /**
  40462. * Detect if any button is being pressed while mouse is moved.
  40463. * -1 = Mouse locked.
  40464. * 0 = Left button.
  40465. * 1 = Middle Button.
  40466. * 2 = Right Button.
  40467. */
  40468. activeButton: number;
  40469. /**
  40470. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40471. * Higher values reduce its sensitivity.
  40472. */
  40473. angularSensibility: number;
  40474. private _mousemoveCallback;
  40475. private _observer;
  40476. private _rollObserver;
  40477. private previousPosition;
  40478. private noPreventDefault;
  40479. private element;
  40480. /**
  40481. * Listen to mouse events to control the camera.
  40482. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40484. */
  40485. constructor(touchEnabled?: boolean);
  40486. /**
  40487. * Attach the mouse control to the HTML DOM element.
  40488. * @param element Defines the element that listens to the input events.
  40489. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40490. */
  40491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40492. /**
  40493. * Detach the current controls from the specified dom element.
  40494. * @param element Defines the element to stop listening the inputs from
  40495. */
  40496. detachControl(element: Nullable<HTMLElement>): void;
  40497. /**
  40498. * Gets the class name of the current input.
  40499. * @returns the class name.
  40500. */
  40501. getClassName(): string;
  40502. /**
  40503. * Get the friendly name associated with the input class.
  40504. * @returns the input's friendly name.
  40505. */
  40506. getSimpleName(): string;
  40507. private _pointerInput;
  40508. private _onMouseMove;
  40509. /**
  40510. * Rotate camera by mouse offset.
  40511. */
  40512. private rotateCamera;
  40513. }
  40514. }
  40515. declare module BABYLON {
  40516. /**
  40517. * Default Inputs manager for the FlyCamera.
  40518. * It groups all the default supported inputs for ease of use.
  40519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40520. */
  40521. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40522. /**
  40523. * Instantiates a new FlyCameraInputsManager.
  40524. * @param camera Defines the camera the inputs belong to.
  40525. */
  40526. constructor(camera: FlyCamera);
  40527. /**
  40528. * Add keyboard input support to the input manager.
  40529. * @returns the new FlyCameraKeyboardMoveInput().
  40530. */
  40531. addKeyboard(): FlyCameraInputsManager;
  40532. /**
  40533. * Add mouse input support to the input manager.
  40534. * @param touchEnabled Enable touch screen support.
  40535. * @returns the new FlyCameraMouseInput().
  40536. */
  40537. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40538. }
  40539. }
  40540. declare module BABYLON {
  40541. /**
  40542. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40543. * such as in a 3D Space Shooter or a Flight Simulator.
  40544. */
  40545. export class FlyCamera extends TargetCamera {
  40546. /**
  40547. * Define the collision ellipsoid of the camera.
  40548. * This is helpful for simulating a camera body, like a player's body.
  40549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40550. */
  40551. ellipsoid: Vector3;
  40552. /**
  40553. * Define an offset for the position of the ellipsoid around the camera.
  40554. * This can be helpful if the camera is attached away from the player's body center,
  40555. * such as at its head.
  40556. */
  40557. ellipsoidOffset: Vector3;
  40558. /**
  40559. * Enable or disable collisions of the camera with the rest of the scene objects.
  40560. */
  40561. checkCollisions: boolean;
  40562. /**
  40563. * Enable or disable gravity on the camera.
  40564. */
  40565. applyGravity: boolean;
  40566. /**
  40567. * Define the current direction the camera is moving to.
  40568. */
  40569. cameraDirection: Vector3;
  40570. /**
  40571. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40572. * This overrides and empties cameraRotation.
  40573. */
  40574. rotationQuaternion: Quaternion;
  40575. /**
  40576. * Track Roll to maintain the wanted Rolling when looking around.
  40577. */
  40578. _trackRoll: number;
  40579. /**
  40580. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40581. */
  40582. rollCorrect: number;
  40583. /**
  40584. * Mimic a banked turn, Rolling the camera when Yawing.
  40585. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40586. */
  40587. bankedTurn: boolean;
  40588. /**
  40589. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40590. */
  40591. bankedTurnLimit: number;
  40592. /**
  40593. * Value of 0 disables the banked Roll.
  40594. * Value of 1 is equal to the Yaw angle in radians.
  40595. */
  40596. bankedTurnMultiplier: number;
  40597. /**
  40598. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40599. */
  40600. inputs: FlyCameraInputsManager;
  40601. /**
  40602. * Gets the input sensibility for mouse input.
  40603. * Higher values reduce sensitivity.
  40604. */
  40605. get angularSensibility(): number;
  40606. /**
  40607. * Sets the input sensibility for a mouse input.
  40608. * Higher values reduce sensitivity.
  40609. */
  40610. set angularSensibility(value: number);
  40611. /**
  40612. * Get the keys for camera movement forward.
  40613. */
  40614. get keysForward(): number[];
  40615. /**
  40616. * Set the keys for camera movement forward.
  40617. */
  40618. set keysForward(value: number[]);
  40619. /**
  40620. * Get the keys for camera movement backward.
  40621. */
  40622. get keysBackward(): number[];
  40623. set keysBackward(value: number[]);
  40624. /**
  40625. * Get the keys for camera movement up.
  40626. */
  40627. get keysUp(): number[];
  40628. /**
  40629. * Set the keys for camera movement up.
  40630. */
  40631. set keysUp(value: number[]);
  40632. /**
  40633. * Get the keys for camera movement down.
  40634. */
  40635. get keysDown(): number[];
  40636. /**
  40637. * Set the keys for camera movement down.
  40638. */
  40639. set keysDown(value: number[]);
  40640. /**
  40641. * Get the keys for camera movement left.
  40642. */
  40643. get keysLeft(): number[];
  40644. /**
  40645. * Set the keys for camera movement left.
  40646. */
  40647. set keysLeft(value: number[]);
  40648. /**
  40649. * Set the keys for camera movement right.
  40650. */
  40651. get keysRight(): number[];
  40652. /**
  40653. * Set the keys for camera movement right.
  40654. */
  40655. set keysRight(value: number[]);
  40656. /**
  40657. * Event raised when the camera collides with a mesh in the scene.
  40658. */
  40659. onCollide: (collidedMesh: AbstractMesh) => void;
  40660. private _collider;
  40661. private _needMoveForGravity;
  40662. private _oldPosition;
  40663. private _diffPosition;
  40664. private _newPosition;
  40665. /** @hidden */
  40666. _localDirection: Vector3;
  40667. /** @hidden */
  40668. _transformedDirection: Vector3;
  40669. /**
  40670. * Instantiates a FlyCamera.
  40671. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40672. * such as in a 3D Space Shooter or a Flight Simulator.
  40673. * @param name Define the name of the camera in the scene.
  40674. * @param position Define the starting position of the camera in the scene.
  40675. * @param scene Define the scene the camera belongs to.
  40676. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40677. */
  40678. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40679. /**
  40680. * Attach a control to the HTML DOM element.
  40681. * @param element Defines the element that listens to the input events.
  40682. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40683. */
  40684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40685. /**
  40686. * Detach a control from the HTML DOM element.
  40687. * The camera will stop reacting to that input.
  40688. * @param element Defines the element that listens to the input events.
  40689. */
  40690. detachControl(element: HTMLElement): void;
  40691. private _collisionMask;
  40692. /**
  40693. * Get the mask that the camera ignores in collision events.
  40694. */
  40695. get collisionMask(): number;
  40696. /**
  40697. * Set the mask that the camera ignores in collision events.
  40698. */
  40699. set collisionMask(mask: number);
  40700. /** @hidden */
  40701. _collideWithWorld(displacement: Vector3): void;
  40702. /** @hidden */
  40703. private _onCollisionPositionChange;
  40704. /** @hidden */
  40705. _checkInputs(): void;
  40706. /** @hidden */
  40707. _decideIfNeedsToMove(): boolean;
  40708. /** @hidden */
  40709. _updatePosition(): void;
  40710. /**
  40711. * Restore the Roll to its target value at the rate specified.
  40712. * @param rate - Higher means slower restoring.
  40713. * @hidden
  40714. */
  40715. restoreRoll(rate: number): void;
  40716. /**
  40717. * Destroy the camera and release the current resources held by it.
  40718. */
  40719. dispose(): void;
  40720. /**
  40721. * Get the current object class name.
  40722. * @returns the class name.
  40723. */
  40724. getClassName(): string;
  40725. }
  40726. }
  40727. declare module BABYLON {
  40728. /**
  40729. * Listen to keyboard events to control the camera.
  40730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40731. */
  40732. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40733. /**
  40734. * Defines the camera the input is attached to.
  40735. */
  40736. camera: FlyCamera;
  40737. /**
  40738. * The list of keyboard keys used to control the forward move of the camera.
  40739. */
  40740. keysForward: number[];
  40741. /**
  40742. * The list of keyboard keys used to control the backward move of the camera.
  40743. */
  40744. keysBackward: number[];
  40745. /**
  40746. * The list of keyboard keys used to control the forward move of the camera.
  40747. */
  40748. keysUp: number[];
  40749. /**
  40750. * The list of keyboard keys used to control the backward move of the camera.
  40751. */
  40752. keysDown: number[];
  40753. /**
  40754. * The list of keyboard keys used to control the right strafe move of the camera.
  40755. */
  40756. keysRight: number[];
  40757. /**
  40758. * The list of keyboard keys used to control the left strafe move of the camera.
  40759. */
  40760. keysLeft: number[];
  40761. private _keys;
  40762. private _onCanvasBlurObserver;
  40763. private _onKeyboardObserver;
  40764. private _engine;
  40765. private _scene;
  40766. /**
  40767. * Attach the input controls to a specific dom element to get the input from.
  40768. * @param element Defines the element the controls should be listened from
  40769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40770. */
  40771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40772. /**
  40773. * Detach the current controls from the specified dom element.
  40774. * @param element Defines the element to stop listening the inputs from
  40775. */
  40776. detachControl(element: Nullable<HTMLElement>): void;
  40777. /**
  40778. * Gets the class name of the current intput.
  40779. * @returns the class name
  40780. */
  40781. getClassName(): string;
  40782. /** @hidden */
  40783. _onLostFocus(e: FocusEvent): void;
  40784. /**
  40785. * Get the friendly name associated with the input class.
  40786. * @returns the input friendly name
  40787. */
  40788. getSimpleName(): string;
  40789. /**
  40790. * Update the current camera state depending on the inputs that have been used this frame.
  40791. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40792. */
  40793. checkInputs(): void;
  40794. }
  40795. }
  40796. declare module BABYLON {
  40797. /**
  40798. * Manage the mouse wheel inputs to control a follow camera.
  40799. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40800. */
  40801. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40802. /**
  40803. * Defines the camera the input is attached to.
  40804. */
  40805. camera: FollowCamera;
  40806. /**
  40807. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40808. */
  40809. axisControlRadius: boolean;
  40810. /**
  40811. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40812. */
  40813. axisControlHeight: boolean;
  40814. /**
  40815. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40816. */
  40817. axisControlRotation: boolean;
  40818. /**
  40819. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40820. * relation to mouseWheel events.
  40821. */
  40822. wheelPrecision: number;
  40823. /**
  40824. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40825. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40826. */
  40827. wheelDeltaPercentage: number;
  40828. private _wheel;
  40829. private _observer;
  40830. /**
  40831. * Attach the input controls to a specific dom element to get the input from.
  40832. * @param element Defines the element the controls should be listened from
  40833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40834. */
  40835. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40836. /**
  40837. * Detach the current controls from the specified dom element.
  40838. * @param element Defines the element to stop listening the inputs from
  40839. */
  40840. detachControl(element: Nullable<HTMLElement>): void;
  40841. /**
  40842. * Gets the class name of the current intput.
  40843. * @returns the class name
  40844. */
  40845. getClassName(): string;
  40846. /**
  40847. * Get the friendly name associated with the input class.
  40848. * @returns the input friendly name
  40849. */
  40850. getSimpleName(): string;
  40851. }
  40852. }
  40853. declare module BABYLON {
  40854. /**
  40855. * Manage the pointers inputs to control an follow camera.
  40856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40857. */
  40858. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40859. /**
  40860. * Defines the camera the input is attached to.
  40861. */
  40862. camera: FollowCamera;
  40863. /**
  40864. * Gets the class name of the current input.
  40865. * @returns the class name
  40866. */
  40867. getClassName(): string;
  40868. /**
  40869. * Defines the pointer angular sensibility along the X axis or how fast is
  40870. * the camera rotating.
  40871. * A negative number will reverse the axis direction.
  40872. */
  40873. angularSensibilityX: number;
  40874. /**
  40875. * Defines the pointer angular sensibility along the Y axis or how fast is
  40876. * the camera rotating.
  40877. * A negative number will reverse the axis direction.
  40878. */
  40879. angularSensibilityY: number;
  40880. /**
  40881. * Defines the pointer pinch precision or how fast is the camera zooming.
  40882. * A negative number will reverse the axis direction.
  40883. */
  40884. pinchPrecision: number;
  40885. /**
  40886. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40887. * from 0.
  40888. * It defines the percentage of current camera.radius to use as delta when
  40889. * pinch zoom is used.
  40890. */
  40891. pinchDeltaPercentage: number;
  40892. /**
  40893. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40894. */
  40895. axisXControlRadius: boolean;
  40896. /**
  40897. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40898. */
  40899. axisXControlHeight: boolean;
  40900. /**
  40901. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40902. */
  40903. axisXControlRotation: boolean;
  40904. /**
  40905. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40906. */
  40907. axisYControlRadius: boolean;
  40908. /**
  40909. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40910. */
  40911. axisYControlHeight: boolean;
  40912. /**
  40913. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40914. */
  40915. axisYControlRotation: boolean;
  40916. /**
  40917. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40918. */
  40919. axisPinchControlRadius: boolean;
  40920. /**
  40921. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40922. */
  40923. axisPinchControlHeight: boolean;
  40924. /**
  40925. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40926. */
  40927. axisPinchControlRotation: boolean;
  40928. /**
  40929. * Log error messages if basic misconfiguration has occurred.
  40930. */
  40931. warningEnable: boolean;
  40932. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40933. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40934. private _warningCounter;
  40935. private _warning;
  40936. }
  40937. }
  40938. declare module BABYLON {
  40939. /**
  40940. * Default Inputs manager for the FollowCamera.
  40941. * It groups all the default supported inputs for ease of use.
  40942. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40943. */
  40944. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40945. /**
  40946. * Instantiates a new FollowCameraInputsManager.
  40947. * @param camera Defines the camera the inputs belong to
  40948. */
  40949. constructor(camera: FollowCamera);
  40950. /**
  40951. * Add keyboard input support to the input manager.
  40952. * @returns the current input manager
  40953. */
  40954. addKeyboard(): FollowCameraInputsManager;
  40955. /**
  40956. * Add mouse wheel input support to the input manager.
  40957. * @returns the current input manager
  40958. */
  40959. addMouseWheel(): FollowCameraInputsManager;
  40960. /**
  40961. * Add pointers input support to the input manager.
  40962. * @returns the current input manager
  40963. */
  40964. addPointers(): FollowCameraInputsManager;
  40965. /**
  40966. * Add orientation input support to the input manager.
  40967. * @returns the current input manager
  40968. */
  40969. addVRDeviceOrientation(): FollowCameraInputsManager;
  40970. }
  40971. }
  40972. declare module BABYLON {
  40973. /**
  40974. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40975. * an arc rotate version arcFollowCamera are available.
  40976. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40977. */
  40978. export class FollowCamera extends TargetCamera {
  40979. /**
  40980. * Distance the follow camera should follow an object at
  40981. */
  40982. radius: number;
  40983. /**
  40984. * Minimum allowed distance of the camera to the axis of rotation
  40985. * (The camera can not get closer).
  40986. * This can help limiting how the Camera is able to move in the scene.
  40987. */
  40988. lowerRadiusLimit: Nullable<number>;
  40989. /**
  40990. * Maximum allowed distance of the camera to the axis of rotation
  40991. * (The camera can not get further).
  40992. * This can help limiting how the Camera is able to move in the scene.
  40993. */
  40994. upperRadiusLimit: Nullable<number>;
  40995. /**
  40996. * Define a rotation offset between the camera and the object it follows
  40997. */
  40998. rotationOffset: number;
  40999. /**
  41000. * Minimum allowed angle to camera position relative to target object.
  41001. * This can help limiting how the Camera is able to move in the scene.
  41002. */
  41003. lowerRotationOffsetLimit: Nullable<number>;
  41004. /**
  41005. * Maximum allowed angle to camera position relative to target object.
  41006. * This can help limiting how the Camera is able to move in the scene.
  41007. */
  41008. upperRotationOffsetLimit: Nullable<number>;
  41009. /**
  41010. * Define a height offset between the camera and the object it follows.
  41011. * It can help following an object from the top (like a car chaing a plane)
  41012. */
  41013. heightOffset: number;
  41014. /**
  41015. * Minimum allowed height of camera position relative to target object.
  41016. * This can help limiting how the Camera is able to move in the scene.
  41017. */
  41018. lowerHeightOffsetLimit: Nullable<number>;
  41019. /**
  41020. * Maximum allowed height of camera position relative to target object.
  41021. * This can help limiting how the Camera is able to move in the scene.
  41022. */
  41023. upperHeightOffsetLimit: Nullable<number>;
  41024. /**
  41025. * Define how fast the camera can accelerate to follow it s target.
  41026. */
  41027. cameraAcceleration: number;
  41028. /**
  41029. * Define the speed limit of the camera following an object.
  41030. */
  41031. maxCameraSpeed: number;
  41032. /**
  41033. * Define the target of the camera.
  41034. */
  41035. lockedTarget: Nullable<AbstractMesh>;
  41036. /**
  41037. * Defines the input associated with the camera.
  41038. */
  41039. inputs: FollowCameraInputsManager;
  41040. /**
  41041. * Instantiates the follow camera.
  41042. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41043. * @param name Define the name of the camera in the scene
  41044. * @param position Define the position of the camera
  41045. * @param scene Define the scene the camera belong to
  41046. * @param lockedTarget Define the target of the camera
  41047. */
  41048. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41049. private _follow;
  41050. /**
  41051. * Attached controls to the current camera.
  41052. * @param element Defines the element the controls should be listened from
  41053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41054. */
  41055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41056. /**
  41057. * Detach the current controls from the camera.
  41058. * The camera will stop reacting to inputs.
  41059. * @param element Defines the element to stop listening the inputs from
  41060. */
  41061. detachControl(element: HTMLElement): void;
  41062. /** @hidden */
  41063. _checkInputs(): void;
  41064. private _checkLimits;
  41065. /**
  41066. * Gets the camera class name.
  41067. * @returns the class name
  41068. */
  41069. getClassName(): string;
  41070. }
  41071. /**
  41072. * Arc Rotate version of the follow camera.
  41073. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41074. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41075. */
  41076. export class ArcFollowCamera extends TargetCamera {
  41077. /** The longitudinal angle of the camera */
  41078. alpha: number;
  41079. /** The latitudinal angle of the camera */
  41080. beta: number;
  41081. /** The radius of the camera from its target */
  41082. radius: number;
  41083. /** Define the camera target (the messh it should follow) */
  41084. target: Nullable<AbstractMesh>;
  41085. private _cartesianCoordinates;
  41086. /**
  41087. * Instantiates a new ArcFollowCamera
  41088. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41089. * @param name Define the name of the camera
  41090. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41091. * @param beta Define the rotation angle of the camera around the elevation axis
  41092. * @param radius Define the radius of the camera from its target point
  41093. * @param target Define the target of the camera
  41094. * @param scene Define the scene the camera belongs to
  41095. */
  41096. constructor(name: string,
  41097. /** The longitudinal angle of the camera */
  41098. alpha: number,
  41099. /** The latitudinal angle of the camera */
  41100. beta: number,
  41101. /** The radius of the camera from its target */
  41102. radius: number,
  41103. /** Define the camera target (the messh it should follow) */
  41104. target: Nullable<AbstractMesh>, scene: Scene);
  41105. private _follow;
  41106. /** @hidden */
  41107. _checkInputs(): void;
  41108. /**
  41109. * Returns the class name of the object.
  41110. * It is mostly used internally for serialization purposes.
  41111. */
  41112. getClassName(): string;
  41113. }
  41114. }
  41115. declare module BABYLON {
  41116. /**
  41117. * Manage the keyboard inputs to control the movement of a follow camera.
  41118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41119. */
  41120. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41121. /**
  41122. * Defines the camera the input is attached to.
  41123. */
  41124. camera: FollowCamera;
  41125. /**
  41126. * Defines the list of key codes associated with the up action (increase heightOffset)
  41127. */
  41128. keysHeightOffsetIncr: number[];
  41129. /**
  41130. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41131. */
  41132. keysHeightOffsetDecr: number[];
  41133. /**
  41134. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41135. */
  41136. keysHeightOffsetModifierAlt: boolean;
  41137. /**
  41138. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41139. */
  41140. keysHeightOffsetModifierCtrl: boolean;
  41141. /**
  41142. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41143. */
  41144. keysHeightOffsetModifierShift: boolean;
  41145. /**
  41146. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41147. */
  41148. keysRotationOffsetIncr: number[];
  41149. /**
  41150. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41151. */
  41152. keysRotationOffsetDecr: number[];
  41153. /**
  41154. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41155. */
  41156. keysRotationOffsetModifierAlt: boolean;
  41157. /**
  41158. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41159. */
  41160. keysRotationOffsetModifierCtrl: boolean;
  41161. /**
  41162. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41163. */
  41164. keysRotationOffsetModifierShift: boolean;
  41165. /**
  41166. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41167. */
  41168. keysRadiusIncr: number[];
  41169. /**
  41170. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41171. */
  41172. keysRadiusDecr: number[];
  41173. /**
  41174. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41175. */
  41176. keysRadiusModifierAlt: boolean;
  41177. /**
  41178. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41179. */
  41180. keysRadiusModifierCtrl: boolean;
  41181. /**
  41182. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41183. */
  41184. keysRadiusModifierShift: boolean;
  41185. /**
  41186. * Defines the rate of change of heightOffset.
  41187. */
  41188. heightSensibility: number;
  41189. /**
  41190. * Defines the rate of change of rotationOffset.
  41191. */
  41192. rotationSensibility: number;
  41193. /**
  41194. * Defines the rate of change of radius.
  41195. */
  41196. radiusSensibility: number;
  41197. private _keys;
  41198. private _ctrlPressed;
  41199. private _altPressed;
  41200. private _shiftPressed;
  41201. private _onCanvasBlurObserver;
  41202. private _onKeyboardObserver;
  41203. private _engine;
  41204. private _scene;
  41205. /**
  41206. * Attach the input controls to a specific dom element to get the input from.
  41207. * @param element Defines the element the controls should be listened from
  41208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41209. */
  41210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41211. /**
  41212. * Detach the current controls from the specified dom element.
  41213. * @param element Defines the element to stop listening the inputs from
  41214. */
  41215. detachControl(element: Nullable<HTMLElement>): void;
  41216. /**
  41217. * Update the current camera state depending on the inputs that have been used this frame.
  41218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41219. */
  41220. checkInputs(): void;
  41221. /**
  41222. * Gets the class name of the current input.
  41223. * @returns the class name
  41224. */
  41225. getClassName(): string;
  41226. /**
  41227. * Get the friendly name associated with the input class.
  41228. * @returns the input friendly name
  41229. */
  41230. getSimpleName(): string;
  41231. /**
  41232. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41233. * allow modification of the heightOffset value.
  41234. */
  41235. private _modifierHeightOffset;
  41236. /**
  41237. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41238. * allow modification of the rotationOffset value.
  41239. */
  41240. private _modifierRotationOffset;
  41241. /**
  41242. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41243. * allow modification of the radius value.
  41244. */
  41245. private _modifierRadius;
  41246. }
  41247. }
  41248. declare module BABYLON {
  41249. interface FreeCameraInputsManager {
  41250. /**
  41251. * @hidden
  41252. */
  41253. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41254. /**
  41255. * Add orientation input support to the input manager.
  41256. * @returns the current input manager
  41257. */
  41258. addDeviceOrientation(): FreeCameraInputsManager;
  41259. }
  41260. /**
  41261. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41262. * Screen rotation is taken into account.
  41263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41264. */
  41265. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41266. private _camera;
  41267. private _screenOrientationAngle;
  41268. private _constantTranform;
  41269. private _screenQuaternion;
  41270. private _alpha;
  41271. private _beta;
  41272. private _gamma;
  41273. /**
  41274. * Can be used to detect if a device orientation sensor is available on a device
  41275. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41276. * @returns a promise that will resolve on orientation change
  41277. */
  41278. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41279. /**
  41280. * @hidden
  41281. */
  41282. _onDeviceOrientationChangedObservable: Observable<void>;
  41283. /**
  41284. * Instantiates a new input
  41285. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41286. */
  41287. constructor();
  41288. /**
  41289. * Define the camera controlled by the input.
  41290. */
  41291. get camera(): FreeCamera;
  41292. set camera(camera: FreeCamera);
  41293. /**
  41294. * Attach the input controls to a specific dom element to get the input from.
  41295. * @param element Defines the element the controls should be listened from
  41296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41297. */
  41298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41299. private _orientationChanged;
  41300. private _deviceOrientation;
  41301. /**
  41302. * Detach the current controls from the specified dom element.
  41303. * @param element Defines the element to stop listening the inputs from
  41304. */
  41305. detachControl(element: Nullable<HTMLElement>): void;
  41306. /**
  41307. * Update the current camera state depending on the inputs that have been used this frame.
  41308. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41309. */
  41310. checkInputs(): void;
  41311. /**
  41312. * Gets the class name of the current intput.
  41313. * @returns the class name
  41314. */
  41315. getClassName(): string;
  41316. /**
  41317. * Get the friendly name associated with the input class.
  41318. * @returns the input friendly name
  41319. */
  41320. getSimpleName(): string;
  41321. }
  41322. }
  41323. declare module BABYLON {
  41324. /**
  41325. * Manage the gamepad inputs to control a free camera.
  41326. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41327. */
  41328. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41329. /**
  41330. * Define the camera the input is attached to.
  41331. */
  41332. camera: FreeCamera;
  41333. /**
  41334. * Define the Gamepad controlling the input
  41335. */
  41336. gamepad: Nullable<Gamepad>;
  41337. /**
  41338. * Defines the gamepad rotation sensiblity.
  41339. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41340. */
  41341. gamepadAngularSensibility: number;
  41342. /**
  41343. * Defines the gamepad move sensiblity.
  41344. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41345. */
  41346. gamepadMoveSensibility: number;
  41347. private _yAxisScale;
  41348. /**
  41349. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41350. */
  41351. get invertYAxis(): boolean;
  41352. set invertYAxis(value: boolean);
  41353. private _onGamepadConnectedObserver;
  41354. private _onGamepadDisconnectedObserver;
  41355. private _cameraTransform;
  41356. private _deltaTransform;
  41357. private _vector3;
  41358. private _vector2;
  41359. /**
  41360. * Attach the input controls to a specific dom element to get the input from.
  41361. * @param element Defines the element the controls should be listened from
  41362. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41363. */
  41364. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41365. /**
  41366. * Detach the current controls from the specified dom element.
  41367. * @param element Defines the element to stop listening the inputs from
  41368. */
  41369. detachControl(element: Nullable<HTMLElement>): void;
  41370. /**
  41371. * Update the current camera state depending on the inputs that have been used this frame.
  41372. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41373. */
  41374. checkInputs(): void;
  41375. /**
  41376. * Gets the class name of the current intput.
  41377. * @returns the class name
  41378. */
  41379. getClassName(): string;
  41380. /**
  41381. * Get the friendly name associated with the input class.
  41382. * @returns the input friendly name
  41383. */
  41384. getSimpleName(): string;
  41385. }
  41386. }
  41387. declare module BABYLON {
  41388. /**
  41389. * Defines the potential axis of a Joystick
  41390. */
  41391. export enum JoystickAxis {
  41392. /** X axis */
  41393. X = 0,
  41394. /** Y axis */
  41395. Y = 1,
  41396. /** Z axis */
  41397. Z = 2
  41398. }
  41399. /**
  41400. * Class used to define virtual joystick (used in touch mode)
  41401. */
  41402. export class VirtualJoystick {
  41403. /**
  41404. * Gets or sets a boolean indicating that left and right values must be inverted
  41405. */
  41406. reverseLeftRight: boolean;
  41407. /**
  41408. * Gets or sets a boolean indicating that up and down values must be inverted
  41409. */
  41410. reverseUpDown: boolean;
  41411. /**
  41412. * Gets the offset value for the position (ie. the change of the position value)
  41413. */
  41414. deltaPosition: Vector3;
  41415. /**
  41416. * Gets a boolean indicating if the virtual joystick was pressed
  41417. */
  41418. pressed: boolean;
  41419. /**
  41420. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41421. */
  41422. static Canvas: Nullable<HTMLCanvasElement>;
  41423. private static _globalJoystickIndex;
  41424. private static vjCanvasContext;
  41425. private static vjCanvasWidth;
  41426. private static vjCanvasHeight;
  41427. private static halfWidth;
  41428. private _action;
  41429. private _axisTargetedByLeftAndRight;
  41430. private _axisTargetedByUpAndDown;
  41431. private _joystickSensibility;
  41432. private _inversedSensibility;
  41433. private _joystickPointerID;
  41434. private _joystickColor;
  41435. private _joystickPointerPos;
  41436. private _joystickPreviousPointerPos;
  41437. private _joystickPointerStartPos;
  41438. private _deltaJoystickVector;
  41439. private _leftJoystick;
  41440. private _touches;
  41441. private _onPointerDownHandlerRef;
  41442. private _onPointerMoveHandlerRef;
  41443. private _onPointerUpHandlerRef;
  41444. private _onResize;
  41445. /**
  41446. * Creates a new virtual joystick
  41447. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41448. */
  41449. constructor(leftJoystick?: boolean);
  41450. /**
  41451. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41452. * @param newJoystickSensibility defines the new sensibility
  41453. */
  41454. setJoystickSensibility(newJoystickSensibility: number): void;
  41455. private _onPointerDown;
  41456. private _onPointerMove;
  41457. private _onPointerUp;
  41458. /**
  41459. * Change the color of the virtual joystick
  41460. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41461. */
  41462. setJoystickColor(newColor: string): void;
  41463. /**
  41464. * Defines a callback to call when the joystick is touched
  41465. * @param action defines the callback
  41466. */
  41467. setActionOnTouch(action: () => any): void;
  41468. /**
  41469. * Defines which axis you'd like to control for left & right
  41470. * @param axis defines the axis to use
  41471. */
  41472. setAxisForLeftRight(axis: JoystickAxis): void;
  41473. /**
  41474. * Defines which axis you'd like to control for up & down
  41475. * @param axis defines the axis to use
  41476. */
  41477. setAxisForUpDown(axis: JoystickAxis): void;
  41478. private _drawVirtualJoystick;
  41479. /**
  41480. * Release internal HTML canvas
  41481. */
  41482. releaseCanvas(): void;
  41483. }
  41484. }
  41485. declare module BABYLON {
  41486. interface FreeCameraInputsManager {
  41487. /**
  41488. * Add virtual joystick input support to the input manager.
  41489. * @returns the current input manager
  41490. */
  41491. addVirtualJoystick(): FreeCameraInputsManager;
  41492. }
  41493. /**
  41494. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41496. */
  41497. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41498. /**
  41499. * Defines the camera the input is attached to.
  41500. */
  41501. camera: FreeCamera;
  41502. private _leftjoystick;
  41503. private _rightjoystick;
  41504. /**
  41505. * Gets the left stick of the virtual joystick.
  41506. * @returns The virtual Joystick
  41507. */
  41508. getLeftJoystick(): VirtualJoystick;
  41509. /**
  41510. * Gets the right stick of the virtual joystick.
  41511. * @returns The virtual Joystick
  41512. */
  41513. getRightJoystick(): VirtualJoystick;
  41514. /**
  41515. * Update the current camera state depending on the inputs that have been used this frame.
  41516. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41517. */
  41518. checkInputs(): void;
  41519. /**
  41520. * Attach the input controls to a specific dom element to get the input from.
  41521. * @param element Defines the element the controls should be listened from
  41522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41523. */
  41524. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41525. /**
  41526. * Detach the current controls from the specified dom element.
  41527. * @param element Defines the element to stop listening the inputs from
  41528. */
  41529. detachControl(element: Nullable<HTMLElement>): void;
  41530. /**
  41531. * Gets the class name of the current intput.
  41532. * @returns the class name
  41533. */
  41534. getClassName(): string;
  41535. /**
  41536. * Get the friendly name associated with the input class.
  41537. * @returns the input friendly name
  41538. */
  41539. getSimpleName(): string;
  41540. }
  41541. }
  41542. declare module BABYLON {
  41543. /**
  41544. * This represents a FPS type of camera controlled by touch.
  41545. * This is like a universal camera minus the Gamepad controls.
  41546. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41547. */
  41548. export class TouchCamera extends FreeCamera {
  41549. /**
  41550. * Defines the touch sensibility for rotation.
  41551. * The higher the faster.
  41552. */
  41553. get touchAngularSensibility(): number;
  41554. set touchAngularSensibility(value: number);
  41555. /**
  41556. * Defines the touch sensibility for move.
  41557. * The higher the faster.
  41558. */
  41559. get touchMoveSensibility(): number;
  41560. set touchMoveSensibility(value: number);
  41561. /**
  41562. * Instantiates a new touch camera.
  41563. * This represents a FPS type of camera controlled by touch.
  41564. * This is like a universal camera minus the Gamepad controls.
  41565. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41566. * @param name Define the name of the camera in the scene
  41567. * @param position Define the start position of the camera in the scene
  41568. * @param scene Define the scene the camera belongs to
  41569. */
  41570. constructor(name: string, position: Vector3, scene: Scene);
  41571. /**
  41572. * Gets the current object class name.
  41573. * @return the class name
  41574. */
  41575. getClassName(): string;
  41576. /** @hidden */
  41577. _setupInputs(): void;
  41578. }
  41579. }
  41580. declare module BABYLON {
  41581. /**
  41582. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41583. * being tilted forward or back and left or right.
  41584. */
  41585. export class DeviceOrientationCamera extends FreeCamera {
  41586. private _initialQuaternion;
  41587. private _quaternionCache;
  41588. private _tmpDragQuaternion;
  41589. private _disablePointerInputWhenUsingDeviceOrientation;
  41590. /**
  41591. * Creates a new device orientation camera
  41592. * @param name The name of the camera
  41593. * @param position The start position camera
  41594. * @param scene The scene the camera belongs to
  41595. */
  41596. constructor(name: string, position: Vector3, scene: Scene);
  41597. /**
  41598. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41599. */
  41600. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41601. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41602. private _dragFactor;
  41603. /**
  41604. * Enabled turning on the y axis when the orientation sensor is active
  41605. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41606. */
  41607. enableHorizontalDragging(dragFactor?: number): void;
  41608. /**
  41609. * Gets the current instance class name ("DeviceOrientationCamera").
  41610. * This helps avoiding instanceof at run time.
  41611. * @returns the class name
  41612. */
  41613. getClassName(): string;
  41614. /**
  41615. * @hidden
  41616. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41617. */
  41618. _checkInputs(): void;
  41619. /**
  41620. * Reset the camera to its default orientation on the specified axis only.
  41621. * @param axis The axis to reset
  41622. */
  41623. resetToCurrentRotation(axis?: Axis): void;
  41624. }
  41625. }
  41626. declare module BABYLON {
  41627. /**
  41628. * Defines supported buttons for XBox360 compatible gamepads
  41629. */
  41630. export enum Xbox360Button {
  41631. /** A */
  41632. A = 0,
  41633. /** B */
  41634. B = 1,
  41635. /** X */
  41636. X = 2,
  41637. /** Y */
  41638. Y = 3,
  41639. /** Left button */
  41640. LB = 4,
  41641. /** Right button */
  41642. RB = 5,
  41643. /** Back */
  41644. Back = 8,
  41645. /** Start */
  41646. Start = 9,
  41647. /** Left stick */
  41648. LeftStick = 10,
  41649. /** Right stick */
  41650. RightStick = 11
  41651. }
  41652. /** Defines values for XBox360 DPad */
  41653. export enum Xbox360Dpad {
  41654. /** Up */
  41655. Up = 12,
  41656. /** Down */
  41657. Down = 13,
  41658. /** Left */
  41659. Left = 14,
  41660. /** Right */
  41661. Right = 15
  41662. }
  41663. /**
  41664. * Defines a XBox360 gamepad
  41665. */
  41666. export class Xbox360Pad extends Gamepad {
  41667. private _leftTrigger;
  41668. private _rightTrigger;
  41669. private _onlefttriggerchanged;
  41670. private _onrighttriggerchanged;
  41671. private _onbuttondown;
  41672. private _onbuttonup;
  41673. private _ondpaddown;
  41674. private _ondpadup;
  41675. /** Observable raised when a button is pressed */
  41676. onButtonDownObservable: Observable<Xbox360Button>;
  41677. /** Observable raised when a button is released */
  41678. onButtonUpObservable: Observable<Xbox360Button>;
  41679. /** Observable raised when a pad is pressed */
  41680. onPadDownObservable: Observable<Xbox360Dpad>;
  41681. /** Observable raised when a pad is released */
  41682. onPadUpObservable: Observable<Xbox360Dpad>;
  41683. private _buttonA;
  41684. private _buttonB;
  41685. private _buttonX;
  41686. private _buttonY;
  41687. private _buttonBack;
  41688. private _buttonStart;
  41689. private _buttonLB;
  41690. private _buttonRB;
  41691. private _buttonLeftStick;
  41692. private _buttonRightStick;
  41693. private _dPadUp;
  41694. private _dPadDown;
  41695. private _dPadLeft;
  41696. private _dPadRight;
  41697. private _isXboxOnePad;
  41698. /**
  41699. * Creates a new XBox360 gamepad object
  41700. * @param id defines the id of this gamepad
  41701. * @param index defines its index
  41702. * @param gamepad defines the internal HTML gamepad object
  41703. * @param xboxOne defines if it is a XBox One gamepad
  41704. */
  41705. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41706. /**
  41707. * Defines the callback to call when left trigger is pressed
  41708. * @param callback defines the callback to use
  41709. */
  41710. onlefttriggerchanged(callback: (value: number) => void): void;
  41711. /**
  41712. * Defines the callback to call when right trigger is pressed
  41713. * @param callback defines the callback to use
  41714. */
  41715. onrighttriggerchanged(callback: (value: number) => void): void;
  41716. /**
  41717. * Gets the left trigger value
  41718. */
  41719. get leftTrigger(): number;
  41720. /**
  41721. * Sets the left trigger value
  41722. */
  41723. set leftTrigger(newValue: number);
  41724. /**
  41725. * Gets the right trigger value
  41726. */
  41727. get rightTrigger(): number;
  41728. /**
  41729. * Sets the right trigger value
  41730. */
  41731. set rightTrigger(newValue: number);
  41732. /**
  41733. * Defines the callback to call when a button is pressed
  41734. * @param callback defines the callback to use
  41735. */
  41736. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41737. /**
  41738. * Defines the callback to call when a button is released
  41739. * @param callback defines the callback to use
  41740. */
  41741. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41742. /**
  41743. * Defines the callback to call when a pad is pressed
  41744. * @param callback defines the callback to use
  41745. */
  41746. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41747. /**
  41748. * Defines the callback to call when a pad is released
  41749. * @param callback defines the callback to use
  41750. */
  41751. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41752. private _setButtonValue;
  41753. private _setDPadValue;
  41754. /**
  41755. * Gets the value of the `A` button
  41756. */
  41757. get buttonA(): number;
  41758. /**
  41759. * Sets the value of the `A` button
  41760. */
  41761. set buttonA(value: number);
  41762. /**
  41763. * Gets the value of the `B` button
  41764. */
  41765. get buttonB(): number;
  41766. /**
  41767. * Sets the value of the `B` button
  41768. */
  41769. set buttonB(value: number);
  41770. /**
  41771. * Gets the value of the `X` button
  41772. */
  41773. get buttonX(): number;
  41774. /**
  41775. * Sets the value of the `X` button
  41776. */
  41777. set buttonX(value: number);
  41778. /**
  41779. * Gets the value of the `Y` button
  41780. */
  41781. get buttonY(): number;
  41782. /**
  41783. * Sets the value of the `Y` button
  41784. */
  41785. set buttonY(value: number);
  41786. /**
  41787. * Gets the value of the `Start` button
  41788. */
  41789. get buttonStart(): number;
  41790. /**
  41791. * Sets the value of the `Start` button
  41792. */
  41793. set buttonStart(value: number);
  41794. /**
  41795. * Gets the value of the `Back` button
  41796. */
  41797. get buttonBack(): number;
  41798. /**
  41799. * Sets the value of the `Back` button
  41800. */
  41801. set buttonBack(value: number);
  41802. /**
  41803. * Gets the value of the `Left` button
  41804. */
  41805. get buttonLB(): number;
  41806. /**
  41807. * Sets the value of the `Left` button
  41808. */
  41809. set buttonLB(value: number);
  41810. /**
  41811. * Gets the value of the `Right` button
  41812. */
  41813. get buttonRB(): number;
  41814. /**
  41815. * Sets the value of the `Right` button
  41816. */
  41817. set buttonRB(value: number);
  41818. /**
  41819. * Gets the value of the Left joystick
  41820. */
  41821. get buttonLeftStick(): number;
  41822. /**
  41823. * Sets the value of the Left joystick
  41824. */
  41825. set buttonLeftStick(value: number);
  41826. /**
  41827. * Gets the value of the Right joystick
  41828. */
  41829. get buttonRightStick(): number;
  41830. /**
  41831. * Sets the value of the Right joystick
  41832. */
  41833. set buttonRightStick(value: number);
  41834. /**
  41835. * Gets the value of D-pad up
  41836. */
  41837. get dPadUp(): number;
  41838. /**
  41839. * Sets the value of D-pad up
  41840. */
  41841. set dPadUp(value: number);
  41842. /**
  41843. * Gets the value of D-pad down
  41844. */
  41845. get dPadDown(): number;
  41846. /**
  41847. * Sets the value of D-pad down
  41848. */
  41849. set dPadDown(value: number);
  41850. /**
  41851. * Gets the value of D-pad left
  41852. */
  41853. get dPadLeft(): number;
  41854. /**
  41855. * Sets the value of D-pad left
  41856. */
  41857. set dPadLeft(value: number);
  41858. /**
  41859. * Gets the value of D-pad right
  41860. */
  41861. get dPadRight(): number;
  41862. /**
  41863. * Sets the value of D-pad right
  41864. */
  41865. set dPadRight(value: number);
  41866. /**
  41867. * Force the gamepad to synchronize with device values
  41868. */
  41869. update(): void;
  41870. /**
  41871. * Disposes the gamepad
  41872. */
  41873. dispose(): void;
  41874. }
  41875. }
  41876. declare module BABYLON {
  41877. /**
  41878. * Defines supported buttons for DualShock compatible gamepads
  41879. */
  41880. export enum DualShockButton {
  41881. /** Cross */
  41882. Cross = 0,
  41883. /** Circle */
  41884. Circle = 1,
  41885. /** Square */
  41886. Square = 2,
  41887. /** Triangle */
  41888. Triangle = 3,
  41889. /** L1 */
  41890. L1 = 4,
  41891. /** R1 */
  41892. R1 = 5,
  41893. /** Share */
  41894. Share = 8,
  41895. /** Options */
  41896. Options = 9,
  41897. /** Left stick */
  41898. LeftStick = 10,
  41899. /** Right stick */
  41900. RightStick = 11
  41901. }
  41902. /** Defines values for DualShock DPad */
  41903. export enum DualShockDpad {
  41904. /** Up */
  41905. Up = 12,
  41906. /** Down */
  41907. Down = 13,
  41908. /** Left */
  41909. Left = 14,
  41910. /** Right */
  41911. Right = 15
  41912. }
  41913. /**
  41914. * Defines a DualShock gamepad
  41915. */
  41916. export class DualShockPad extends Gamepad {
  41917. private _leftTrigger;
  41918. private _rightTrigger;
  41919. private _onlefttriggerchanged;
  41920. private _onrighttriggerchanged;
  41921. private _onbuttondown;
  41922. private _onbuttonup;
  41923. private _ondpaddown;
  41924. private _ondpadup;
  41925. /** Observable raised when a button is pressed */
  41926. onButtonDownObservable: Observable<DualShockButton>;
  41927. /** Observable raised when a button is released */
  41928. onButtonUpObservable: Observable<DualShockButton>;
  41929. /** Observable raised when a pad is pressed */
  41930. onPadDownObservable: Observable<DualShockDpad>;
  41931. /** Observable raised when a pad is released */
  41932. onPadUpObservable: Observable<DualShockDpad>;
  41933. private _buttonCross;
  41934. private _buttonCircle;
  41935. private _buttonSquare;
  41936. private _buttonTriangle;
  41937. private _buttonShare;
  41938. private _buttonOptions;
  41939. private _buttonL1;
  41940. private _buttonR1;
  41941. private _buttonLeftStick;
  41942. private _buttonRightStick;
  41943. private _dPadUp;
  41944. private _dPadDown;
  41945. private _dPadLeft;
  41946. private _dPadRight;
  41947. /**
  41948. * Creates a new DualShock gamepad object
  41949. * @param id defines the id of this gamepad
  41950. * @param index defines its index
  41951. * @param gamepad defines the internal HTML gamepad object
  41952. */
  41953. constructor(id: string, index: number, gamepad: any);
  41954. /**
  41955. * Defines the callback to call when left trigger is pressed
  41956. * @param callback defines the callback to use
  41957. */
  41958. onlefttriggerchanged(callback: (value: number) => void): void;
  41959. /**
  41960. * Defines the callback to call when right trigger is pressed
  41961. * @param callback defines the callback to use
  41962. */
  41963. onrighttriggerchanged(callback: (value: number) => void): void;
  41964. /**
  41965. * Gets the left trigger value
  41966. */
  41967. get leftTrigger(): number;
  41968. /**
  41969. * Sets the left trigger value
  41970. */
  41971. set leftTrigger(newValue: number);
  41972. /**
  41973. * Gets the right trigger value
  41974. */
  41975. get rightTrigger(): number;
  41976. /**
  41977. * Sets the right trigger value
  41978. */
  41979. set rightTrigger(newValue: number);
  41980. /**
  41981. * Defines the callback to call when a button is pressed
  41982. * @param callback defines the callback to use
  41983. */
  41984. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41985. /**
  41986. * Defines the callback to call when a button is released
  41987. * @param callback defines the callback to use
  41988. */
  41989. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41990. /**
  41991. * Defines the callback to call when a pad is pressed
  41992. * @param callback defines the callback to use
  41993. */
  41994. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41995. /**
  41996. * Defines the callback to call when a pad is released
  41997. * @param callback defines the callback to use
  41998. */
  41999. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42000. private _setButtonValue;
  42001. private _setDPadValue;
  42002. /**
  42003. * Gets the value of the `Cross` button
  42004. */
  42005. get buttonCross(): number;
  42006. /**
  42007. * Sets the value of the `Cross` button
  42008. */
  42009. set buttonCross(value: number);
  42010. /**
  42011. * Gets the value of the `Circle` button
  42012. */
  42013. get buttonCircle(): number;
  42014. /**
  42015. * Sets the value of the `Circle` button
  42016. */
  42017. set buttonCircle(value: number);
  42018. /**
  42019. * Gets the value of the `Square` button
  42020. */
  42021. get buttonSquare(): number;
  42022. /**
  42023. * Sets the value of the `Square` button
  42024. */
  42025. set buttonSquare(value: number);
  42026. /**
  42027. * Gets the value of the `Triangle` button
  42028. */
  42029. get buttonTriangle(): number;
  42030. /**
  42031. * Sets the value of the `Triangle` button
  42032. */
  42033. set buttonTriangle(value: number);
  42034. /**
  42035. * Gets the value of the `Options` button
  42036. */
  42037. get buttonOptions(): number;
  42038. /**
  42039. * Sets the value of the `Options` button
  42040. */
  42041. set buttonOptions(value: number);
  42042. /**
  42043. * Gets the value of the `Share` button
  42044. */
  42045. get buttonShare(): number;
  42046. /**
  42047. * Sets the value of the `Share` button
  42048. */
  42049. set buttonShare(value: number);
  42050. /**
  42051. * Gets the value of the `L1` button
  42052. */
  42053. get buttonL1(): number;
  42054. /**
  42055. * Sets the value of the `L1` button
  42056. */
  42057. set buttonL1(value: number);
  42058. /**
  42059. * Gets the value of the `R1` button
  42060. */
  42061. get buttonR1(): number;
  42062. /**
  42063. * Sets the value of the `R1` button
  42064. */
  42065. set buttonR1(value: number);
  42066. /**
  42067. * Gets the value of the Left joystick
  42068. */
  42069. get buttonLeftStick(): number;
  42070. /**
  42071. * Sets the value of the Left joystick
  42072. */
  42073. set buttonLeftStick(value: number);
  42074. /**
  42075. * Gets the value of the Right joystick
  42076. */
  42077. get buttonRightStick(): number;
  42078. /**
  42079. * Sets the value of the Right joystick
  42080. */
  42081. set buttonRightStick(value: number);
  42082. /**
  42083. * Gets the value of D-pad up
  42084. */
  42085. get dPadUp(): number;
  42086. /**
  42087. * Sets the value of D-pad up
  42088. */
  42089. set dPadUp(value: number);
  42090. /**
  42091. * Gets the value of D-pad down
  42092. */
  42093. get dPadDown(): number;
  42094. /**
  42095. * Sets the value of D-pad down
  42096. */
  42097. set dPadDown(value: number);
  42098. /**
  42099. * Gets the value of D-pad left
  42100. */
  42101. get dPadLeft(): number;
  42102. /**
  42103. * Sets the value of D-pad left
  42104. */
  42105. set dPadLeft(value: number);
  42106. /**
  42107. * Gets the value of D-pad right
  42108. */
  42109. get dPadRight(): number;
  42110. /**
  42111. * Sets the value of D-pad right
  42112. */
  42113. set dPadRight(value: number);
  42114. /**
  42115. * Force the gamepad to synchronize with device values
  42116. */
  42117. update(): void;
  42118. /**
  42119. * Disposes the gamepad
  42120. */
  42121. dispose(): void;
  42122. }
  42123. }
  42124. declare module BABYLON {
  42125. /**
  42126. * Manager for handling gamepads
  42127. */
  42128. export class GamepadManager {
  42129. private _scene?;
  42130. private _babylonGamepads;
  42131. private _oneGamepadConnected;
  42132. /** @hidden */
  42133. _isMonitoring: boolean;
  42134. private _gamepadEventSupported;
  42135. private _gamepadSupport?;
  42136. /**
  42137. * observable to be triggered when the gamepad controller has been connected
  42138. */
  42139. onGamepadConnectedObservable: Observable<Gamepad>;
  42140. /**
  42141. * observable to be triggered when the gamepad controller has been disconnected
  42142. */
  42143. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42144. private _onGamepadConnectedEvent;
  42145. private _onGamepadDisconnectedEvent;
  42146. /**
  42147. * Initializes the gamepad manager
  42148. * @param _scene BabylonJS scene
  42149. */
  42150. constructor(_scene?: Scene | undefined);
  42151. /**
  42152. * The gamepads in the game pad manager
  42153. */
  42154. get gamepads(): Gamepad[];
  42155. /**
  42156. * Get the gamepad controllers based on type
  42157. * @param type The type of gamepad controller
  42158. * @returns Nullable gamepad
  42159. */
  42160. getGamepadByType(type?: number): Nullable<Gamepad>;
  42161. /**
  42162. * Disposes the gamepad manager
  42163. */
  42164. dispose(): void;
  42165. private _addNewGamepad;
  42166. private _startMonitoringGamepads;
  42167. private _stopMonitoringGamepads;
  42168. /** @hidden */
  42169. _checkGamepadsStatus(): void;
  42170. private _updateGamepadObjects;
  42171. }
  42172. }
  42173. declare module BABYLON {
  42174. interface Scene {
  42175. /** @hidden */
  42176. _gamepadManager: Nullable<GamepadManager>;
  42177. /**
  42178. * Gets the gamepad manager associated with the scene
  42179. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42180. */
  42181. gamepadManager: GamepadManager;
  42182. }
  42183. /**
  42184. * Interface representing a free camera inputs manager
  42185. */
  42186. interface FreeCameraInputsManager {
  42187. /**
  42188. * Adds gamepad input support to the FreeCameraInputsManager.
  42189. * @returns the FreeCameraInputsManager
  42190. */
  42191. addGamepad(): FreeCameraInputsManager;
  42192. }
  42193. /**
  42194. * Interface representing an arc rotate camera inputs manager
  42195. */
  42196. interface ArcRotateCameraInputsManager {
  42197. /**
  42198. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42199. * @returns the camera inputs manager
  42200. */
  42201. addGamepad(): ArcRotateCameraInputsManager;
  42202. }
  42203. /**
  42204. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42205. */
  42206. export class GamepadSystemSceneComponent implements ISceneComponent {
  42207. /**
  42208. * The component name helpfull to identify the component in the list of scene components.
  42209. */
  42210. readonly name: string;
  42211. /**
  42212. * The scene the component belongs to.
  42213. */
  42214. scene: Scene;
  42215. /**
  42216. * Creates a new instance of the component for the given scene
  42217. * @param scene Defines the scene to register the component in
  42218. */
  42219. constructor(scene: Scene);
  42220. /**
  42221. * Registers the component in a given scene
  42222. */
  42223. register(): void;
  42224. /**
  42225. * Rebuilds the elements related to this component in case of
  42226. * context lost for instance.
  42227. */
  42228. rebuild(): void;
  42229. /**
  42230. * Disposes the component and the associated ressources
  42231. */
  42232. dispose(): void;
  42233. private _beforeCameraUpdate;
  42234. }
  42235. }
  42236. declare module BABYLON {
  42237. /**
  42238. * 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,
  42239. * which still works and will still be found in many Playgrounds.
  42240. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42241. */
  42242. export class UniversalCamera extends TouchCamera {
  42243. /**
  42244. * Defines the gamepad rotation sensiblity.
  42245. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42246. */
  42247. get gamepadAngularSensibility(): number;
  42248. set gamepadAngularSensibility(value: number);
  42249. /**
  42250. * Defines the gamepad move sensiblity.
  42251. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42252. */
  42253. get gamepadMoveSensibility(): number;
  42254. set gamepadMoveSensibility(value: number);
  42255. /**
  42256. * 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,
  42257. * which still works and will still be found in many Playgrounds.
  42258. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42259. * @param name Define the name of the camera in the scene
  42260. * @param position Define the start position of the camera in the scene
  42261. * @param scene Define the scene the camera belongs to
  42262. */
  42263. constructor(name: string, position: Vector3, scene: Scene);
  42264. /**
  42265. * Gets the current object class name.
  42266. * @return the class name
  42267. */
  42268. getClassName(): string;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * This represents a FPS type of camera. This is only here for back compat purpose.
  42274. * Please use the UniversalCamera instead as both are identical.
  42275. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42276. */
  42277. export class GamepadCamera extends UniversalCamera {
  42278. /**
  42279. * Instantiates a new Gamepad Camera
  42280. * This represents a FPS type of camera. This is only here for back compat purpose.
  42281. * Please use the UniversalCamera instead as both are identical.
  42282. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42283. * @param name Define the name of the camera in the scene
  42284. * @param position Define the start position of the camera in the scene
  42285. * @param scene Define the scene the camera belongs to
  42286. */
  42287. constructor(name: string, position: Vector3, scene: Scene);
  42288. /**
  42289. * Gets the current object class name.
  42290. * @return the class name
  42291. */
  42292. getClassName(): string;
  42293. }
  42294. }
  42295. declare module BABYLON {
  42296. /** @hidden */
  42297. export var passPixelShader: {
  42298. name: string;
  42299. shader: string;
  42300. };
  42301. }
  42302. declare module BABYLON {
  42303. /** @hidden */
  42304. export var passCubePixelShader: {
  42305. name: string;
  42306. shader: string;
  42307. };
  42308. }
  42309. declare module BABYLON {
  42310. /**
  42311. * PassPostProcess which produces an output the same as it's input
  42312. */
  42313. export class PassPostProcess extends PostProcess {
  42314. /**
  42315. * Creates the PassPostProcess
  42316. * @param name The name of the effect.
  42317. * @param options The required width/height ratio to downsize to before computing the render pass.
  42318. * @param camera The camera to apply the render pass to.
  42319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42320. * @param engine The engine which the post process will be applied. (default: current engine)
  42321. * @param reusable If the post process can be reused on the same frame. (default: false)
  42322. * @param textureType The type of texture to be used when performing the post processing.
  42323. * @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)
  42324. */
  42325. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42326. }
  42327. /**
  42328. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42329. */
  42330. export class PassCubePostProcess extends PostProcess {
  42331. private _face;
  42332. /**
  42333. * Gets or sets the cube face to display.
  42334. * * 0 is +X
  42335. * * 1 is -X
  42336. * * 2 is +Y
  42337. * * 3 is -Y
  42338. * * 4 is +Z
  42339. * * 5 is -Z
  42340. */
  42341. get face(): number;
  42342. set face(value: number);
  42343. /**
  42344. * Creates the PassCubePostProcess
  42345. * @param name The name of the effect.
  42346. * @param options The required width/height ratio to downsize to before computing the render pass.
  42347. * @param camera The camera to apply the render pass to.
  42348. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42349. * @param engine The engine which the post process will be applied. (default: current engine)
  42350. * @param reusable If the post process can be reused on the same frame. (default: false)
  42351. * @param textureType The type of texture to be used when performing the post processing.
  42352. * @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)
  42353. */
  42354. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42355. }
  42356. }
  42357. declare module BABYLON {
  42358. /** @hidden */
  42359. export var anaglyphPixelShader: {
  42360. name: string;
  42361. shader: string;
  42362. };
  42363. }
  42364. declare module BABYLON {
  42365. /**
  42366. * Postprocess used to generate anaglyphic rendering
  42367. */
  42368. export class AnaglyphPostProcess extends PostProcess {
  42369. private _passedProcess;
  42370. /**
  42371. * Creates a new AnaglyphPostProcess
  42372. * @param name defines postprocess name
  42373. * @param options defines creation options or target ratio scale
  42374. * @param rigCameras defines cameras using this postprocess
  42375. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42376. * @param engine defines hosting engine
  42377. * @param reusable defines if the postprocess will be reused multiple times per frame
  42378. */
  42379. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42380. }
  42381. }
  42382. declare module BABYLON {
  42383. /**
  42384. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42385. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42386. */
  42387. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42388. /**
  42389. * Creates a new AnaglyphArcRotateCamera
  42390. * @param name defines camera name
  42391. * @param alpha defines alpha angle (in radians)
  42392. * @param beta defines beta angle (in radians)
  42393. * @param radius defines radius
  42394. * @param target defines camera target
  42395. * @param interaxialDistance defines distance between each color axis
  42396. * @param scene defines the hosting scene
  42397. */
  42398. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42399. /**
  42400. * Gets camera class name
  42401. * @returns AnaglyphArcRotateCamera
  42402. */
  42403. getClassName(): string;
  42404. }
  42405. }
  42406. declare module BABYLON {
  42407. /**
  42408. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42409. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42410. */
  42411. export class AnaglyphFreeCamera extends FreeCamera {
  42412. /**
  42413. * Creates a new AnaglyphFreeCamera
  42414. * @param name defines camera name
  42415. * @param position defines initial position
  42416. * @param interaxialDistance defines distance between each color axis
  42417. * @param scene defines the hosting scene
  42418. */
  42419. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42420. /**
  42421. * Gets camera class name
  42422. * @returns AnaglyphFreeCamera
  42423. */
  42424. getClassName(): string;
  42425. }
  42426. }
  42427. declare module BABYLON {
  42428. /**
  42429. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42430. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42431. */
  42432. export class AnaglyphGamepadCamera extends GamepadCamera {
  42433. /**
  42434. * Creates a new AnaglyphGamepadCamera
  42435. * @param name defines camera name
  42436. * @param position defines initial position
  42437. * @param interaxialDistance defines distance between each color axis
  42438. * @param scene defines the hosting scene
  42439. */
  42440. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42441. /**
  42442. * Gets camera class name
  42443. * @returns AnaglyphGamepadCamera
  42444. */
  42445. getClassName(): string;
  42446. }
  42447. }
  42448. declare module BABYLON {
  42449. /**
  42450. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42451. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42452. */
  42453. export class AnaglyphUniversalCamera extends UniversalCamera {
  42454. /**
  42455. * Creates a new AnaglyphUniversalCamera
  42456. * @param name defines camera name
  42457. * @param position defines initial position
  42458. * @param interaxialDistance defines distance between each color axis
  42459. * @param scene defines the hosting scene
  42460. */
  42461. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42462. /**
  42463. * Gets camera class name
  42464. * @returns AnaglyphUniversalCamera
  42465. */
  42466. getClassName(): string;
  42467. }
  42468. }
  42469. declare module BABYLON {
  42470. /**
  42471. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42472. * @see http://doc.babylonjs.com/features/cameras
  42473. */
  42474. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42475. /**
  42476. * Creates a new StereoscopicArcRotateCamera
  42477. * @param name defines camera name
  42478. * @param alpha defines alpha angle (in radians)
  42479. * @param beta defines beta angle (in radians)
  42480. * @param radius defines radius
  42481. * @param target defines camera target
  42482. * @param interaxialDistance defines distance between each color axis
  42483. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42484. * @param scene defines the hosting scene
  42485. */
  42486. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42487. /**
  42488. * Gets camera class name
  42489. * @returns StereoscopicArcRotateCamera
  42490. */
  42491. getClassName(): string;
  42492. }
  42493. }
  42494. declare module BABYLON {
  42495. /**
  42496. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42497. * @see http://doc.babylonjs.com/features/cameras
  42498. */
  42499. export class StereoscopicFreeCamera extends FreeCamera {
  42500. /**
  42501. * Creates a new StereoscopicFreeCamera
  42502. * @param name defines camera name
  42503. * @param position defines initial position
  42504. * @param interaxialDistance defines distance between each color axis
  42505. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42506. * @param scene defines the hosting scene
  42507. */
  42508. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42509. /**
  42510. * Gets camera class name
  42511. * @returns StereoscopicFreeCamera
  42512. */
  42513. getClassName(): string;
  42514. }
  42515. }
  42516. declare module BABYLON {
  42517. /**
  42518. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42519. * @see http://doc.babylonjs.com/features/cameras
  42520. */
  42521. export class StereoscopicGamepadCamera extends GamepadCamera {
  42522. /**
  42523. * Creates a new StereoscopicGamepadCamera
  42524. * @param name defines camera name
  42525. * @param position defines initial position
  42526. * @param interaxialDistance defines distance between each color axis
  42527. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42528. * @param scene defines the hosting scene
  42529. */
  42530. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42531. /**
  42532. * Gets camera class name
  42533. * @returns StereoscopicGamepadCamera
  42534. */
  42535. getClassName(): string;
  42536. }
  42537. }
  42538. declare module BABYLON {
  42539. /**
  42540. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42541. * @see http://doc.babylonjs.com/features/cameras
  42542. */
  42543. export class StereoscopicUniversalCamera extends UniversalCamera {
  42544. /**
  42545. * Creates a new StereoscopicUniversalCamera
  42546. * @param name defines camera name
  42547. * @param position defines initial position
  42548. * @param interaxialDistance defines distance between each color axis
  42549. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42550. * @param scene defines the hosting scene
  42551. */
  42552. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42553. /**
  42554. * Gets camera class name
  42555. * @returns StereoscopicUniversalCamera
  42556. */
  42557. getClassName(): string;
  42558. }
  42559. }
  42560. declare module BABYLON {
  42561. /**
  42562. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42563. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42564. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42565. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42566. */
  42567. export class VirtualJoysticksCamera extends FreeCamera {
  42568. /**
  42569. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42570. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42571. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42572. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42573. * @param name Define the name of the camera in the scene
  42574. * @param position Define the start position of the camera in the scene
  42575. * @param scene Define the scene the camera belongs to
  42576. */
  42577. constructor(name: string, position: Vector3, scene: Scene);
  42578. /**
  42579. * Gets the current object class name.
  42580. * @return the class name
  42581. */
  42582. getClassName(): string;
  42583. }
  42584. }
  42585. declare module BABYLON {
  42586. /**
  42587. * This represents all the required metrics to create a VR camera.
  42588. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42589. */
  42590. export class VRCameraMetrics {
  42591. /**
  42592. * Define the horizontal resolution off the screen.
  42593. */
  42594. hResolution: number;
  42595. /**
  42596. * Define the vertical resolution off the screen.
  42597. */
  42598. vResolution: number;
  42599. /**
  42600. * Define the horizontal screen size.
  42601. */
  42602. hScreenSize: number;
  42603. /**
  42604. * Define the vertical screen size.
  42605. */
  42606. vScreenSize: number;
  42607. /**
  42608. * Define the vertical screen center position.
  42609. */
  42610. vScreenCenter: number;
  42611. /**
  42612. * Define the distance of the eyes to the screen.
  42613. */
  42614. eyeToScreenDistance: number;
  42615. /**
  42616. * Define the distance between both lenses
  42617. */
  42618. lensSeparationDistance: number;
  42619. /**
  42620. * Define the distance between both viewer's eyes.
  42621. */
  42622. interpupillaryDistance: number;
  42623. /**
  42624. * Define the distortion factor of the VR postprocess.
  42625. * Please, touch with care.
  42626. */
  42627. distortionK: number[];
  42628. /**
  42629. * Define the chromatic aberration correction factors for the VR post process.
  42630. */
  42631. chromaAbCorrection: number[];
  42632. /**
  42633. * Define the scale factor of the post process.
  42634. * The smaller the better but the slower.
  42635. */
  42636. postProcessScaleFactor: number;
  42637. /**
  42638. * Define an offset for the lens center.
  42639. */
  42640. lensCenterOffset: number;
  42641. /**
  42642. * Define if the current vr camera should compensate the distortion of the lense or not.
  42643. */
  42644. compensateDistortion: boolean;
  42645. /**
  42646. * Defines if multiview should be enabled when rendering (Default: false)
  42647. */
  42648. multiviewEnabled: boolean;
  42649. /**
  42650. * Gets the rendering aspect ratio based on the provided resolutions.
  42651. */
  42652. get aspectRatio(): number;
  42653. /**
  42654. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42655. */
  42656. get aspectRatioFov(): number;
  42657. /**
  42658. * @hidden
  42659. */
  42660. get leftHMatrix(): Matrix;
  42661. /**
  42662. * @hidden
  42663. */
  42664. get rightHMatrix(): Matrix;
  42665. /**
  42666. * @hidden
  42667. */
  42668. get leftPreViewMatrix(): Matrix;
  42669. /**
  42670. * @hidden
  42671. */
  42672. get rightPreViewMatrix(): Matrix;
  42673. /**
  42674. * Get the default VRMetrics based on the most generic setup.
  42675. * @returns the default vr metrics
  42676. */
  42677. static GetDefault(): VRCameraMetrics;
  42678. }
  42679. }
  42680. declare module BABYLON {
  42681. /** @hidden */
  42682. export var vrDistortionCorrectionPixelShader: {
  42683. name: string;
  42684. shader: string;
  42685. };
  42686. }
  42687. declare module BABYLON {
  42688. /**
  42689. * VRDistortionCorrectionPostProcess used for mobile VR
  42690. */
  42691. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42692. private _isRightEye;
  42693. private _distortionFactors;
  42694. private _postProcessScaleFactor;
  42695. private _lensCenterOffset;
  42696. private _scaleIn;
  42697. private _scaleFactor;
  42698. private _lensCenter;
  42699. /**
  42700. * Initializes the VRDistortionCorrectionPostProcess
  42701. * @param name The name of the effect.
  42702. * @param camera The camera to apply the render pass to.
  42703. * @param isRightEye If this is for the right eye distortion
  42704. * @param vrMetrics All the required metrics for the VR camera
  42705. */
  42706. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42707. }
  42708. }
  42709. declare module BABYLON {
  42710. /**
  42711. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42712. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42713. */
  42714. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42715. /**
  42716. * Creates a new VRDeviceOrientationArcRotateCamera
  42717. * @param name defines camera name
  42718. * @param alpha defines the camera rotation along the logitudinal axis
  42719. * @param beta defines the camera rotation along the latitudinal axis
  42720. * @param radius defines the camera distance from its target
  42721. * @param target defines the camera target
  42722. * @param scene defines the scene the camera belongs to
  42723. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42724. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42725. */
  42726. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42727. /**
  42728. * Gets camera class name
  42729. * @returns VRDeviceOrientationArcRotateCamera
  42730. */
  42731. getClassName(): string;
  42732. }
  42733. }
  42734. declare module BABYLON {
  42735. /**
  42736. * Camera used to simulate VR rendering (based on FreeCamera)
  42737. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42738. */
  42739. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42740. /**
  42741. * Creates a new VRDeviceOrientationFreeCamera
  42742. * @param name defines camera name
  42743. * @param position defines the start position of the camera
  42744. * @param scene defines the scene the camera belongs to
  42745. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42746. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42747. */
  42748. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42749. /**
  42750. * Gets camera class name
  42751. * @returns VRDeviceOrientationFreeCamera
  42752. */
  42753. getClassName(): string;
  42754. }
  42755. }
  42756. declare module BABYLON {
  42757. /**
  42758. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42759. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42760. */
  42761. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42762. /**
  42763. * Creates a new VRDeviceOrientationGamepadCamera
  42764. * @param name defines camera name
  42765. * @param position defines the start position of the camera
  42766. * @param scene defines the scene the camera belongs to
  42767. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42768. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42769. */
  42770. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42771. /**
  42772. * Gets camera class name
  42773. * @returns VRDeviceOrientationGamepadCamera
  42774. */
  42775. getClassName(): string;
  42776. }
  42777. }
  42778. declare module BABYLON {
  42779. /** @hidden */
  42780. export var imageProcessingPixelShader: {
  42781. name: string;
  42782. shader: string;
  42783. };
  42784. }
  42785. declare module BABYLON {
  42786. /**
  42787. * ImageProcessingPostProcess
  42788. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42789. */
  42790. export class ImageProcessingPostProcess extends PostProcess {
  42791. /**
  42792. * Default configuration related to image processing available in the PBR Material.
  42793. */
  42794. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42795. /**
  42796. * Gets the image processing configuration used either in this material.
  42797. */
  42798. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42799. /**
  42800. * Sets the Default image processing configuration used either in the this material.
  42801. *
  42802. * If sets to null, the scene one is in use.
  42803. */
  42804. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42805. /**
  42806. * Keep track of the image processing observer to allow dispose and replace.
  42807. */
  42808. private _imageProcessingObserver;
  42809. /**
  42810. * Attaches a new image processing configuration to the PBR Material.
  42811. * @param configuration
  42812. */
  42813. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42814. /**
  42815. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42816. */
  42817. get colorCurves(): Nullable<ColorCurves>;
  42818. /**
  42819. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42820. */
  42821. set colorCurves(value: Nullable<ColorCurves>);
  42822. /**
  42823. * Gets wether the color curves effect is enabled.
  42824. */
  42825. get colorCurvesEnabled(): boolean;
  42826. /**
  42827. * Sets wether the color curves effect is enabled.
  42828. */
  42829. set colorCurvesEnabled(value: boolean);
  42830. /**
  42831. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42832. */
  42833. get colorGradingTexture(): Nullable<BaseTexture>;
  42834. /**
  42835. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42836. */
  42837. set colorGradingTexture(value: Nullable<BaseTexture>);
  42838. /**
  42839. * Gets wether the color grading effect is enabled.
  42840. */
  42841. get colorGradingEnabled(): boolean;
  42842. /**
  42843. * Gets wether the color grading effect is enabled.
  42844. */
  42845. set colorGradingEnabled(value: boolean);
  42846. /**
  42847. * Gets exposure used in the effect.
  42848. */
  42849. get exposure(): number;
  42850. /**
  42851. * Sets exposure used in the effect.
  42852. */
  42853. set exposure(value: number);
  42854. /**
  42855. * Gets wether tonemapping is enabled or not.
  42856. */
  42857. get toneMappingEnabled(): boolean;
  42858. /**
  42859. * Sets wether tonemapping is enabled or not
  42860. */
  42861. set toneMappingEnabled(value: boolean);
  42862. /**
  42863. * Gets the type of tone mapping effect.
  42864. */
  42865. get toneMappingType(): number;
  42866. /**
  42867. * Sets the type of tone mapping effect.
  42868. */
  42869. set toneMappingType(value: number);
  42870. /**
  42871. * Gets contrast used in the effect.
  42872. */
  42873. get contrast(): number;
  42874. /**
  42875. * Sets contrast used in the effect.
  42876. */
  42877. set contrast(value: number);
  42878. /**
  42879. * Gets Vignette stretch size.
  42880. */
  42881. get vignetteStretch(): number;
  42882. /**
  42883. * Sets Vignette stretch size.
  42884. */
  42885. set vignetteStretch(value: number);
  42886. /**
  42887. * Gets Vignette centre X Offset.
  42888. */
  42889. get vignetteCentreX(): number;
  42890. /**
  42891. * Sets Vignette centre X Offset.
  42892. */
  42893. set vignetteCentreX(value: number);
  42894. /**
  42895. * Gets Vignette centre Y Offset.
  42896. */
  42897. get vignetteCentreY(): number;
  42898. /**
  42899. * Sets Vignette centre Y Offset.
  42900. */
  42901. set vignetteCentreY(value: number);
  42902. /**
  42903. * Gets Vignette weight or intensity of the vignette effect.
  42904. */
  42905. get vignetteWeight(): number;
  42906. /**
  42907. * Sets Vignette weight or intensity of the vignette effect.
  42908. */
  42909. set vignetteWeight(value: number);
  42910. /**
  42911. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42912. * if vignetteEnabled is set to true.
  42913. */
  42914. get vignetteColor(): Color4;
  42915. /**
  42916. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42917. * if vignetteEnabled is set to true.
  42918. */
  42919. set vignetteColor(value: Color4);
  42920. /**
  42921. * Gets Camera field of view used by the Vignette effect.
  42922. */
  42923. get vignetteCameraFov(): number;
  42924. /**
  42925. * Sets Camera field of view used by the Vignette effect.
  42926. */
  42927. set vignetteCameraFov(value: number);
  42928. /**
  42929. * Gets the vignette blend mode allowing different kind of effect.
  42930. */
  42931. get vignetteBlendMode(): number;
  42932. /**
  42933. * Sets the vignette blend mode allowing different kind of effect.
  42934. */
  42935. set vignetteBlendMode(value: number);
  42936. /**
  42937. * Gets wether the vignette effect is enabled.
  42938. */
  42939. get vignetteEnabled(): boolean;
  42940. /**
  42941. * Sets wether the vignette effect is enabled.
  42942. */
  42943. set vignetteEnabled(value: boolean);
  42944. private _fromLinearSpace;
  42945. /**
  42946. * Gets wether the input of the processing is in Gamma or Linear Space.
  42947. */
  42948. get fromLinearSpace(): boolean;
  42949. /**
  42950. * Sets wether the input of the processing is in Gamma or Linear Space.
  42951. */
  42952. set fromLinearSpace(value: boolean);
  42953. /**
  42954. * Defines cache preventing GC.
  42955. */
  42956. private _defines;
  42957. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42958. /**
  42959. * "ImageProcessingPostProcess"
  42960. * @returns "ImageProcessingPostProcess"
  42961. */
  42962. getClassName(): string;
  42963. protected _updateParameters(): void;
  42964. dispose(camera?: Camera): void;
  42965. }
  42966. }
  42967. declare module BABYLON {
  42968. /**
  42969. * Class containing static functions to help procedurally build meshes
  42970. */
  42971. export class GroundBuilder {
  42972. /**
  42973. * Creates a ground mesh
  42974. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42975. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42977. * @param name defines the name of the mesh
  42978. * @param options defines the options used to create the mesh
  42979. * @param scene defines the hosting scene
  42980. * @returns the ground mesh
  42981. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42982. */
  42983. static CreateGround(name: string, options: {
  42984. width?: number;
  42985. height?: number;
  42986. subdivisions?: number;
  42987. subdivisionsX?: number;
  42988. subdivisionsY?: number;
  42989. updatable?: boolean;
  42990. }, scene: any): Mesh;
  42991. /**
  42992. * Creates a tiled ground mesh
  42993. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42994. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42995. * * 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
  42996. * * 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
  42997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42998. * @param name defines the name of the mesh
  42999. * @param options defines the options used to create the mesh
  43000. * @param scene defines the hosting scene
  43001. * @returns the tiled ground mesh
  43002. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43003. */
  43004. static CreateTiledGround(name: string, options: {
  43005. xmin: number;
  43006. zmin: number;
  43007. xmax: number;
  43008. zmax: number;
  43009. subdivisions?: {
  43010. w: number;
  43011. h: number;
  43012. };
  43013. precision?: {
  43014. w: number;
  43015. h: number;
  43016. };
  43017. updatable?: boolean;
  43018. }, scene?: Nullable<Scene>): Mesh;
  43019. /**
  43020. * Creates a ground mesh from a height map
  43021. * * The parameter `url` sets the URL of the height map image resource.
  43022. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43023. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43024. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43025. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43026. * * 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.
  43027. * * 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).
  43028. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43030. * @param name defines the name of the mesh
  43031. * @param url defines the url to the height map
  43032. * @param options defines the options used to create the mesh
  43033. * @param scene defines the hosting scene
  43034. * @returns the ground mesh
  43035. * @see https://doc.babylonjs.com/babylon101/height_map
  43036. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43037. */
  43038. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43039. width?: number;
  43040. height?: number;
  43041. subdivisions?: number;
  43042. minHeight?: number;
  43043. maxHeight?: number;
  43044. colorFilter?: Color3;
  43045. alphaFilter?: number;
  43046. updatable?: boolean;
  43047. onReady?: (mesh: GroundMesh) => void;
  43048. }, scene?: Nullable<Scene>): GroundMesh;
  43049. }
  43050. }
  43051. declare module BABYLON {
  43052. /**
  43053. * Class containing static functions to help procedurally build meshes
  43054. */
  43055. export class TorusBuilder {
  43056. /**
  43057. * Creates a torus mesh
  43058. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43059. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43060. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43062. * * 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
  43063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43064. * @param name defines the name of the mesh
  43065. * @param options defines the options used to create the mesh
  43066. * @param scene defines the hosting scene
  43067. * @returns the torus mesh
  43068. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43069. */
  43070. static CreateTorus(name: string, options: {
  43071. diameter?: number;
  43072. thickness?: number;
  43073. tessellation?: number;
  43074. updatable?: boolean;
  43075. sideOrientation?: number;
  43076. frontUVs?: Vector4;
  43077. backUVs?: Vector4;
  43078. }, scene: any): Mesh;
  43079. }
  43080. }
  43081. declare module BABYLON {
  43082. /**
  43083. * Class containing static functions to help procedurally build meshes
  43084. */
  43085. export class CylinderBuilder {
  43086. /**
  43087. * Creates a cylinder or a cone mesh
  43088. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43089. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43090. * * 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.
  43091. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43092. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43093. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43094. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43095. * * 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).
  43096. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43097. * * 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).
  43098. * * 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
  43099. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43100. * * 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
  43101. * * 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.
  43102. * * If `enclose` is false, a ring surface is one element.
  43103. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43104. * * 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
  43105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43106. * * 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
  43107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43108. * @param name defines the name of the mesh
  43109. * @param options defines the options used to create the mesh
  43110. * @param scene defines the hosting scene
  43111. * @returns the cylinder mesh
  43112. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43113. */
  43114. static CreateCylinder(name: string, options: {
  43115. height?: number;
  43116. diameterTop?: number;
  43117. diameterBottom?: number;
  43118. diameter?: number;
  43119. tessellation?: number;
  43120. subdivisions?: number;
  43121. arc?: number;
  43122. faceColors?: Color4[];
  43123. faceUV?: Vector4[];
  43124. updatable?: boolean;
  43125. hasRings?: boolean;
  43126. enclose?: boolean;
  43127. cap?: number;
  43128. sideOrientation?: number;
  43129. frontUVs?: Vector4;
  43130. backUVs?: Vector4;
  43131. }, scene: any): Mesh;
  43132. }
  43133. }
  43134. declare module BABYLON {
  43135. /**
  43136. * States of the webXR experience
  43137. */
  43138. export enum WebXRState {
  43139. /**
  43140. * Transitioning to being in XR mode
  43141. */
  43142. ENTERING_XR = 0,
  43143. /**
  43144. * Transitioning to non XR mode
  43145. */
  43146. EXITING_XR = 1,
  43147. /**
  43148. * In XR mode and presenting
  43149. */
  43150. IN_XR = 2,
  43151. /**
  43152. * Not entered XR mode
  43153. */
  43154. NOT_IN_XR = 3
  43155. }
  43156. /**
  43157. * Abstraction of the XR render target
  43158. */
  43159. export interface WebXRRenderTarget extends IDisposable {
  43160. /**
  43161. * xrpresent context of the canvas which can be used to display/mirror xr content
  43162. */
  43163. canvasContext: WebGLRenderingContext;
  43164. /**
  43165. * xr layer for the canvas
  43166. */
  43167. xrLayer: Nullable<XRWebGLLayer>;
  43168. /**
  43169. * Initializes the xr layer for the session
  43170. * @param xrSession xr session
  43171. * @returns a promise that will resolve once the XR Layer has been created
  43172. */
  43173. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43174. }
  43175. }
  43176. declare module BABYLON {
  43177. /**
  43178. * COnfiguration object for WebXR output canvas
  43179. */
  43180. export class WebXRManagedOutputCanvasOptions {
  43181. /**
  43182. * An optional canvas in case you wish to create it yourself and provide it here.
  43183. * If not provided, a new canvas will be created
  43184. */
  43185. canvasElement?: HTMLCanvasElement;
  43186. /**
  43187. * Options for this XR Layer output
  43188. */
  43189. canvasOptions?: XRWebGLLayerOptions;
  43190. /**
  43191. * CSS styling for a newly created canvas (if not provided)
  43192. */
  43193. newCanvasCssStyle?: string;
  43194. /**
  43195. * Get the default values of the configuration object
  43196. * @returns default values of this configuration object
  43197. */
  43198. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43199. }
  43200. /**
  43201. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43202. */
  43203. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43204. private _options;
  43205. private _canvas;
  43206. private _engine;
  43207. /**
  43208. * Rendering context of the canvas which can be used to display/mirror xr content
  43209. */
  43210. canvasContext: WebGLRenderingContext;
  43211. /**
  43212. * xr layer for the canvas
  43213. */
  43214. xrLayer: Nullable<XRWebGLLayer>;
  43215. /**
  43216. * Initializes the canvas to be added/removed upon entering/exiting xr
  43217. * @param _xrSessionManager The XR Session manager
  43218. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  43219. */
  43220. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  43221. /**
  43222. * Disposes of the object
  43223. */
  43224. dispose(): void;
  43225. /**
  43226. * Initializes the xr layer for the session
  43227. * @param xrSession xr session
  43228. * @returns a promise that will resolve once the XR Layer has been created
  43229. */
  43230. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43231. private _addCanvas;
  43232. private _removeCanvas;
  43233. private _setManagedOutputCanvas;
  43234. }
  43235. }
  43236. declare module BABYLON {
  43237. /**
  43238. * Manages an XRSession to work with Babylon's engine
  43239. * @see https://doc.babylonjs.com/how_to/webxr
  43240. */
  43241. export class WebXRSessionManager implements IDisposable {
  43242. /** The scene which the session should be created for */
  43243. scene: Scene;
  43244. private _referenceSpace;
  43245. private _rttProvider;
  43246. private _sessionEnded;
  43247. private _xrNavigator;
  43248. private baseLayer;
  43249. /**
  43250. * The base reference space from which the session started. good if you want to reset your
  43251. * reference space
  43252. */
  43253. baseReferenceSpace: XRReferenceSpace;
  43254. /**
  43255. * Current XR frame
  43256. */
  43257. currentFrame: Nullable<XRFrame>;
  43258. /** WebXR timestamp updated every frame */
  43259. currentTimestamp: number;
  43260. /**
  43261. * Used just in case of a failure to initialize an immersive session.
  43262. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43263. */
  43264. defaultHeightCompensation: number;
  43265. /**
  43266. * Fires every time a new xrFrame arrives which can be used to update the camera
  43267. */
  43268. onXRFrameObservable: Observable<XRFrame>;
  43269. /**
  43270. * Fires when the reference space changed
  43271. */
  43272. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43273. /**
  43274. * Fires when the xr session is ended either by the device or manually done
  43275. */
  43276. onXRSessionEnded: Observable<any>;
  43277. /**
  43278. * Fires when the xr session is ended either by the device or manually done
  43279. */
  43280. onXRSessionInit: Observable<XRSession>;
  43281. /**
  43282. * Underlying xr session
  43283. */
  43284. session: XRSession;
  43285. /**
  43286. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43287. * or get the offset the player is currently at.
  43288. */
  43289. viewerReferenceSpace: XRReferenceSpace;
  43290. /**
  43291. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43292. * @param scene The scene which the session should be created for
  43293. */
  43294. constructor(
  43295. /** The scene which the session should be created for */
  43296. scene: Scene);
  43297. /**
  43298. * The current reference space used in this session. This reference space can constantly change!
  43299. * It is mainly used to offset the camera's position.
  43300. */
  43301. get referenceSpace(): XRReferenceSpace;
  43302. /**
  43303. * Set a new reference space and triggers the observable
  43304. */
  43305. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43306. /**
  43307. * Disposes of the session manager
  43308. */
  43309. dispose(): void;
  43310. /**
  43311. * Stops the xrSession and restores the render loop
  43312. * @returns Promise which resolves after it exits XR
  43313. */
  43314. exitXRAsync(): Promise<void>;
  43315. /**
  43316. * Gets the correct render target texture to be rendered this frame for this eye
  43317. * @param eye the eye for which to get the render target
  43318. * @returns the render target for the specified eye
  43319. */
  43320. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43321. /**
  43322. * Creates a WebXRRenderTarget object for the XR session
  43323. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43324. * @param options optional options to provide when creating a new render target
  43325. * @returns a WebXR render target to which the session can render
  43326. */
  43327. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43328. /**
  43329. * Initializes the manager
  43330. * After initialization enterXR can be called to start an XR session
  43331. * @returns Promise which resolves after it is initialized
  43332. */
  43333. initializeAsync(): Promise<void>;
  43334. /**
  43335. * Initializes an xr session
  43336. * @param xrSessionMode mode to initialize
  43337. * @param xrSessionInit defines optional and required values to pass to the session builder
  43338. * @returns a promise which will resolve once the session has been initialized
  43339. */
  43340. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43341. /**
  43342. * Checks if a session would be supported for the creation options specified
  43343. * @param sessionMode session mode to check if supported eg. immersive-vr
  43344. * @returns A Promise that resolves to true if supported and false if not
  43345. */
  43346. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43347. /**
  43348. * Resets the reference space to the one started the session
  43349. */
  43350. resetReferenceSpace(): void;
  43351. /**
  43352. * Starts rendering to the xr layer
  43353. */
  43354. runXRRenderLoop(): void;
  43355. /**
  43356. * Sets the reference space on the xr session
  43357. * @param referenceSpaceType space to set
  43358. * @returns a promise that will resolve once the reference space has been set
  43359. */
  43360. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43361. /**
  43362. * Updates the render state of the session
  43363. * @param state state to set
  43364. * @returns a promise that resolves once the render state has been updated
  43365. */
  43366. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43367. /**
  43368. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43369. * @param sessionMode defines the session to test
  43370. * @returns a promise with boolean as final value
  43371. */
  43372. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43373. private _createRenderTargetTexture;
  43374. }
  43375. }
  43376. declare module BABYLON {
  43377. /**
  43378. * WebXR Camera which holds the views for the xrSession
  43379. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43380. */
  43381. export class WebXRCamera extends FreeCamera {
  43382. private _xrSessionManager;
  43383. private _firstFrame;
  43384. private _referenceQuaternion;
  43385. private _referencedPosition;
  43386. private _xrInvPositionCache;
  43387. private _xrInvQuaternionCache;
  43388. /**
  43389. * Should position compensation execute on first frame.
  43390. * This is used when copying the position from a native (non XR) camera
  43391. */
  43392. compensateOnFirstFrame: boolean;
  43393. /**
  43394. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43395. * @param name the name of the camera
  43396. * @param scene the scene to add the camera to
  43397. * @param _xrSessionManager a constructed xr session manager
  43398. */
  43399. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43400. /**
  43401. * Return the user's height, unrelated to the current ground.
  43402. * This will be the y position of this camera, when ground level is 0.
  43403. */
  43404. get realWorldHeight(): number;
  43405. /** @hidden */
  43406. _updateForDualEyeDebugging(): void;
  43407. /**
  43408. * Sets this camera's transformation based on a non-vr camera
  43409. * @param otherCamera the non-vr camera to copy the transformation from
  43410. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43411. */
  43412. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43413. /**
  43414. * Gets the current instance class name ("WebXRCamera").
  43415. * @returns the class name
  43416. */
  43417. getClassName(): string;
  43418. private _updateFromXRSession;
  43419. private _updateNumberOfRigCameras;
  43420. private _updateReferenceSpace;
  43421. private _updateReferenceSpaceOffset;
  43422. }
  43423. }
  43424. declare module BABYLON {
  43425. /**
  43426. * Defining the interface required for a (webxr) feature
  43427. */
  43428. export interface IWebXRFeature extends IDisposable {
  43429. /**
  43430. * Is this feature attached
  43431. */
  43432. attached: boolean;
  43433. /**
  43434. * Should auto-attach be disabled?
  43435. */
  43436. disableAutoAttach: boolean;
  43437. /**
  43438. * Attach the feature to the session
  43439. * Will usually be called by the features manager
  43440. *
  43441. * @param force should attachment be forced (even when already attached)
  43442. * @returns true if successful.
  43443. */
  43444. attach(force?: boolean): boolean;
  43445. /**
  43446. * Detach the feature from the session
  43447. * Will usually be called by the features manager
  43448. *
  43449. * @returns true if successful.
  43450. */
  43451. detach(): boolean;
  43452. }
  43453. /**
  43454. * A list of the currently available features without referencing them
  43455. */
  43456. export class WebXRFeatureName {
  43457. /**
  43458. * The name of the anchor system feature
  43459. */
  43460. static ANCHOR_SYSTEM: string;
  43461. /**
  43462. * The name of the background remover feature
  43463. */
  43464. static BACKGROUND_REMOVER: string;
  43465. /**
  43466. * The name of the hit test feature
  43467. */
  43468. static HIT_TEST: string;
  43469. /**
  43470. * physics impostors for xr controllers feature
  43471. */
  43472. static PHYSICS_CONTROLLERS: string;
  43473. /**
  43474. * The name of the plane detection feature
  43475. */
  43476. static PLANE_DETECTION: string;
  43477. /**
  43478. * The name of the pointer selection feature
  43479. */
  43480. static POINTER_SELECTION: string;
  43481. /**
  43482. * The name of the teleportation feature
  43483. */
  43484. static TELEPORTATION: string;
  43485. }
  43486. /**
  43487. * Defining the constructor of a feature. Used to register the modules.
  43488. */
  43489. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43490. /**
  43491. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43492. * It is mainly used in AR sessions.
  43493. *
  43494. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43495. */
  43496. export class WebXRFeaturesManager implements IDisposable {
  43497. private _xrSessionManager;
  43498. private static readonly _AvailableFeatures;
  43499. private _features;
  43500. /**
  43501. * constructs a new features manages.
  43502. *
  43503. * @param _xrSessionManager an instance of WebXRSessionManager
  43504. */
  43505. constructor(_xrSessionManager: WebXRSessionManager);
  43506. /**
  43507. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43508. * Mainly used internally.
  43509. *
  43510. * @param featureName the name of the feature to register
  43511. * @param constructorFunction the function used to construct the module
  43512. * @param version the (babylon) version of the module
  43513. * @param stable is that a stable version of this module
  43514. */
  43515. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43516. /**
  43517. * Returns a constructor of a specific feature.
  43518. *
  43519. * @param featureName the name of the feature to construct
  43520. * @param version the version of the feature to load
  43521. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43522. * @param options optional options provided to the module.
  43523. * @returns a function that, when called, will return a new instance of this feature
  43524. */
  43525. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43526. /**
  43527. * Can be used to return the list of features currently registered
  43528. *
  43529. * @returns an Array of available features
  43530. */
  43531. static GetAvailableFeatures(): string[];
  43532. /**
  43533. * Gets the versions available for a specific feature
  43534. * @param featureName the name of the feature
  43535. * @returns an array with the available versions
  43536. */
  43537. static GetAvailableVersions(featureName: string): string[];
  43538. /**
  43539. * Return the latest unstable version of this feature
  43540. * @param featureName the name of the feature to search
  43541. * @returns the version number. if not found will return -1
  43542. */
  43543. static GetLatestVersionOfFeature(featureName: string): number;
  43544. /**
  43545. * Return the latest stable version of this feature
  43546. * @param featureName the name of the feature to search
  43547. * @returns the version number. if not found will return -1
  43548. */
  43549. static GetStableVersionOfFeature(featureName: string): number;
  43550. /**
  43551. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43552. * Can be used during a session to start a feature
  43553. * @param featureName the name of feature to attach
  43554. */
  43555. attachFeature(featureName: string): void;
  43556. /**
  43557. * Can be used inside a session or when the session ends to detach a specific feature
  43558. * @param featureName the name of the feature to detach
  43559. */
  43560. detachFeature(featureName: string): void;
  43561. /**
  43562. * Used to disable an already-enabled feature
  43563. * The feature will be disposed and will be recreated once enabled.
  43564. * @param featureName the feature to disable
  43565. * @returns true if disable was successful
  43566. */
  43567. disableFeature(featureName: string | {
  43568. Name: string;
  43569. }): boolean;
  43570. /**
  43571. * dispose this features manager
  43572. */
  43573. dispose(): void;
  43574. /**
  43575. * 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.
  43576. * 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.
  43577. *
  43578. * @param featureName the name of the feature to load or the class of the feature
  43579. * @param version optional version to load. if not provided the latest version will be enabled
  43580. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43581. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43582. * @returns a new constructed feature or throws an error if feature not found.
  43583. */
  43584. enableFeature(featureName: string | {
  43585. Name: string;
  43586. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43587. /**
  43588. * get the implementation of an enabled feature.
  43589. * @param featureName the name of the feature to load
  43590. * @returns the feature class, if found
  43591. */
  43592. getEnabledFeature(featureName: string): IWebXRFeature;
  43593. /**
  43594. * Get the list of enabled features
  43595. * @returns an array of enabled features
  43596. */
  43597. getEnabledFeatures(): string[];
  43598. }
  43599. }
  43600. declare module BABYLON {
  43601. /**
  43602. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43603. * @see https://doc.babylonjs.com/how_to/webxr
  43604. */
  43605. export class WebXRExperienceHelper implements IDisposable {
  43606. private scene;
  43607. private _nonVRCamera;
  43608. private _originalSceneAutoClear;
  43609. private _supported;
  43610. /**
  43611. * Camera used to render xr content
  43612. */
  43613. camera: WebXRCamera;
  43614. /** A features manager for this xr session */
  43615. featuresManager: WebXRFeaturesManager;
  43616. /**
  43617. * Observers registered here will be triggered after the camera's initial transformation is set
  43618. * This can be used to set a different ground level or an extra rotation.
  43619. *
  43620. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43621. * to the position set after this observable is done executing.
  43622. */
  43623. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43624. /**
  43625. * Fires when the state of the experience helper has changed
  43626. */
  43627. onStateChangedObservable: Observable<WebXRState>;
  43628. /** Session manager used to keep track of xr session */
  43629. sessionManager: WebXRSessionManager;
  43630. /**
  43631. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43632. */
  43633. state: WebXRState;
  43634. /**
  43635. * Creates a WebXRExperienceHelper
  43636. * @param scene The scene the helper should be created in
  43637. */
  43638. private constructor();
  43639. /**
  43640. * Creates the experience helper
  43641. * @param scene the scene to attach the experience helper to
  43642. * @returns a promise for the experience helper
  43643. */
  43644. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43645. /**
  43646. * Disposes of the experience helper
  43647. */
  43648. dispose(): void;
  43649. /**
  43650. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43651. * @param sessionMode options for the XR session
  43652. * @param referenceSpaceType frame of reference of the XR session
  43653. * @param renderTarget the output canvas that will be used to enter XR mode
  43654. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  43655. * @returns promise that resolves after xr mode has entered
  43656. */
  43657. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  43658. /**
  43659. * Exits XR mode and returns the scene to its original state
  43660. * @returns promise that resolves after xr mode has exited
  43661. */
  43662. exitXRAsync(): Promise<void>;
  43663. private _nonXRToXRCamera;
  43664. private _setState;
  43665. }
  43666. }
  43667. declare module BABYLON {
  43668. /**
  43669. * X-Y values for axes in WebXR
  43670. */
  43671. export interface IWebXRMotionControllerAxesValue {
  43672. /**
  43673. * The value of the x axis
  43674. */
  43675. x: number;
  43676. /**
  43677. * The value of the y-axis
  43678. */
  43679. y: number;
  43680. }
  43681. /**
  43682. * changed / previous values for the values of this component
  43683. */
  43684. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43685. /**
  43686. * current (this frame) value
  43687. */
  43688. current: T;
  43689. /**
  43690. * previous (last change) value
  43691. */
  43692. previous: T;
  43693. }
  43694. /**
  43695. * Represents changes in the component between current frame and last values recorded
  43696. */
  43697. export interface IWebXRMotionControllerComponentChanges {
  43698. /**
  43699. * will be populated with previous and current values if axes changed
  43700. */
  43701. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43702. /**
  43703. * will be populated with previous and current values if pressed changed
  43704. */
  43705. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43706. /**
  43707. * will be populated with previous and current values if touched changed
  43708. */
  43709. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43710. /**
  43711. * will be populated with previous and current values if value changed
  43712. */
  43713. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43714. }
  43715. /**
  43716. * This class represents a single component (for example button or thumbstick) of a motion controller
  43717. */
  43718. export class WebXRControllerComponent implements IDisposable {
  43719. /**
  43720. * the id of this component
  43721. */
  43722. id: string;
  43723. /**
  43724. * the type of the component
  43725. */
  43726. type: MotionControllerComponentType;
  43727. private _buttonIndex;
  43728. private _axesIndices;
  43729. private _axes;
  43730. private _changes;
  43731. private _currentValue;
  43732. private _hasChanges;
  43733. private _pressed;
  43734. private _touched;
  43735. /**
  43736. * button component type
  43737. */
  43738. static BUTTON_TYPE: MotionControllerComponentType;
  43739. /**
  43740. * squeeze component type
  43741. */
  43742. static SQUEEZE_TYPE: MotionControllerComponentType;
  43743. /**
  43744. * Thumbstick component type
  43745. */
  43746. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43747. /**
  43748. * Touchpad component type
  43749. */
  43750. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43751. /**
  43752. * trigger component type
  43753. */
  43754. static TRIGGER_TYPE: MotionControllerComponentType;
  43755. /**
  43756. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43757. * the axes data changes
  43758. */
  43759. onAxisValueChangedObservable: Observable<{
  43760. x: number;
  43761. y: number;
  43762. }>;
  43763. /**
  43764. * Observers registered here will be triggered when the state of a button changes
  43765. * State change is either pressed / touched / value
  43766. */
  43767. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43768. /**
  43769. * Creates a new component for a motion controller.
  43770. * It is created by the motion controller itself
  43771. *
  43772. * @param id the id of this component
  43773. * @param type the type of the component
  43774. * @param _buttonIndex index in the buttons array of the gamepad
  43775. * @param _axesIndices indices of the values in the axes array of the gamepad
  43776. */
  43777. constructor(
  43778. /**
  43779. * the id of this component
  43780. */
  43781. id: string,
  43782. /**
  43783. * the type of the component
  43784. */
  43785. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43786. /**
  43787. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43788. */
  43789. get axes(): IWebXRMotionControllerAxesValue;
  43790. /**
  43791. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43792. */
  43793. get changes(): IWebXRMotionControllerComponentChanges;
  43794. /**
  43795. * Return whether or not the component changed the last frame
  43796. */
  43797. get hasChanges(): boolean;
  43798. /**
  43799. * is the button currently pressed
  43800. */
  43801. get pressed(): boolean;
  43802. /**
  43803. * is the button currently touched
  43804. */
  43805. get touched(): boolean;
  43806. /**
  43807. * Get the current value of this component
  43808. */
  43809. get value(): number;
  43810. /**
  43811. * Dispose this component
  43812. */
  43813. dispose(): void;
  43814. /**
  43815. * Are there axes correlating to this component
  43816. * @return true is axes data is available
  43817. */
  43818. isAxes(): boolean;
  43819. /**
  43820. * Is this component a button (hence - pressable)
  43821. * @returns true if can be pressed
  43822. */
  43823. isButton(): boolean;
  43824. /**
  43825. * update this component using the gamepad object it is in. Called on every frame
  43826. * @param nativeController the native gamepad controller object
  43827. */
  43828. update(nativeController: IMinimalMotionControllerObject): void;
  43829. }
  43830. }
  43831. declare module BABYLON {
  43832. /**
  43833. * Class used to represent data loading progression
  43834. */
  43835. export class SceneLoaderProgressEvent {
  43836. /** defines if data length to load can be evaluated */
  43837. readonly lengthComputable: boolean;
  43838. /** defines the loaded data length */
  43839. readonly loaded: number;
  43840. /** defines the data length to load */
  43841. readonly total: number;
  43842. /**
  43843. * Create a new progress event
  43844. * @param lengthComputable defines if data length to load can be evaluated
  43845. * @param loaded defines the loaded data length
  43846. * @param total defines the data length to load
  43847. */
  43848. constructor(
  43849. /** defines if data length to load can be evaluated */
  43850. lengthComputable: boolean,
  43851. /** defines the loaded data length */
  43852. loaded: number,
  43853. /** defines the data length to load */
  43854. total: number);
  43855. /**
  43856. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43857. * @param event defines the source event
  43858. * @returns a new SceneLoaderProgressEvent
  43859. */
  43860. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43861. }
  43862. /**
  43863. * Interface used by SceneLoader plugins to define supported file extensions
  43864. */
  43865. export interface ISceneLoaderPluginExtensions {
  43866. /**
  43867. * Defines the list of supported extensions
  43868. */
  43869. [extension: string]: {
  43870. isBinary: boolean;
  43871. };
  43872. }
  43873. /**
  43874. * Interface used by SceneLoader plugin factory
  43875. */
  43876. export interface ISceneLoaderPluginFactory {
  43877. /**
  43878. * Defines the name of the factory
  43879. */
  43880. name: string;
  43881. /**
  43882. * Function called to create a new plugin
  43883. * @return the new plugin
  43884. */
  43885. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43886. /**
  43887. * The callback that returns true if the data can be directly loaded.
  43888. * @param data string containing the file data
  43889. * @returns if the data can be loaded directly
  43890. */
  43891. canDirectLoad?(data: string): boolean;
  43892. }
  43893. /**
  43894. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43895. */
  43896. export interface ISceneLoaderPluginBase {
  43897. /**
  43898. * The friendly name of this plugin.
  43899. */
  43900. name: string;
  43901. /**
  43902. * The file extensions supported by this plugin.
  43903. */
  43904. extensions: string | ISceneLoaderPluginExtensions;
  43905. /**
  43906. * The callback called when loading from a url.
  43907. * @param scene scene loading this url
  43908. * @param url url to load
  43909. * @param onSuccess callback called when the file successfully loads
  43910. * @param onProgress callback called while file is loading (if the server supports this mode)
  43911. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43912. * @param onError callback called when the file fails to load
  43913. * @returns a file request object
  43914. */
  43915. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43916. /**
  43917. * The callback called when loading from a file object.
  43918. * @param scene scene loading this file
  43919. * @param file defines the file to load
  43920. * @param onSuccess defines the callback to call when data is loaded
  43921. * @param onProgress defines the callback to call during loading process
  43922. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43923. * @param onError defines the callback to call when an error occurs
  43924. * @returns a file request object
  43925. */
  43926. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43927. /**
  43928. * The callback that returns true if the data can be directly loaded.
  43929. * @param data string containing the file data
  43930. * @returns if the data can be loaded directly
  43931. */
  43932. canDirectLoad?(data: string): boolean;
  43933. /**
  43934. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43935. * @param scene scene loading this data
  43936. * @param data string containing the data
  43937. * @returns data to pass to the plugin
  43938. */
  43939. directLoad?(scene: Scene, data: string): any;
  43940. /**
  43941. * The callback that allows custom handling of the root url based on the response url.
  43942. * @param rootUrl the original root url
  43943. * @param responseURL the response url if available
  43944. * @returns the new root url
  43945. */
  43946. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43947. }
  43948. /**
  43949. * Interface used to define a SceneLoader plugin
  43950. */
  43951. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43952. /**
  43953. * Import meshes into a scene.
  43954. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43955. * @param scene The scene to import into
  43956. * @param data The data to import
  43957. * @param rootUrl The root url for scene and resources
  43958. * @param meshes The meshes array to import into
  43959. * @param particleSystems The particle systems array to import into
  43960. * @param skeletons The skeletons array to import into
  43961. * @param onError The callback when import fails
  43962. * @returns True if successful or false otherwise
  43963. */
  43964. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43965. /**
  43966. * Load into a scene.
  43967. * @param scene The scene to load into
  43968. * @param data The data to import
  43969. * @param rootUrl The root url for scene and resources
  43970. * @param onError The callback when import fails
  43971. * @returns True if successful or false otherwise
  43972. */
  43973. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43974. /**
  43975. * Load into an asset container.
  43976. * @param scene The scene to load into
  43977. * @param data The data to import
  43978. * @param rootUrl The root url for scene and resources
  43979. * @param onError The callback when import fails
  43980. * @returns The loaded asset container
  43981. */
  43982. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43983. }
  43984. /**
  43985. * Interface used to define an async SceneLoader plugin
  43986. */
  43987. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43988. /**
  43989. * Import meshes into a scene.
  43990. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43991. * @param scene The scene to import into
  43992. * @param data The data to import
  43993. * @param rootUrl The root url for scene and resources
  43994. * @param onProgress The callback when the load progresses
  43995. * @param fileName Defines the name of the file to load
  43996. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43997. */
  43998. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43999. meshes: AbstractMesh[];
  44000. particleSystems: IParticleSystem[];
  44001. skeletons: Skeleton[];
  44002. animationGroups: AnimationGroup[];
  44003. }>;
  44004. /**
  44005. * Load into a scene.
  44006. * @param scene The scene to load into
  44007. * @param data The data to import
  44008. * @param rootUrl The root url for scene and resources
  44009. * @param onProgress The callback when the load progresses
  44010. * @param fileName Defines the name of the file to load
  44011. * @returns Nothing
  44012. */
  44013. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44014. /**
  44015. * Load into an asset container.
  44016. * @param scene The scene to load into
  44017. * @param data The data to import
  44018. * @param rootUrl The root url for scene and resources
  44019. * @param onProgress The callback when the load progresses
  44020. * @param fileName Defines the name of the file to load
  44021. * @returns The loaded asset container
  44022. */
  44023. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44024. }
  44025. /**
  44026. * Mode that determines how to handle old animation groups before loading new ones.
  44027. */
  44028. export enum SceneLoaderAnimationGroupLoadingMode {
  44029. /**
  44030. * Reset all old animations to initial state then dispose them.
  44031. */
  44032. Clean = 0,
  44033. /**
  44034. * Stop all old animations.
  44035. */
  44036. Stop = 1,
  44037. /**
  44038. * Restart old animations from first frame.
  44039. */
  44040. Sync = 2,
  44041. /**
  44042. * Old animations remains untouched.
  44043. */
  44044. NoSync = 3
  44045. }
  44046. /**
  44047. * Class used to load scene from various file formats using registered plugins
  44048. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44049. */
  44050. export class SceneLoader {
  44051. /**
  44052. * No logging while loading
  44053. */
  44054. static readonly NO_LOGGING: number;
  44055. /**
  44056. * Minimal logging while loading
  44057. */
  44058. static readonly MINIMAL_LOGGING: number;
  44059. /**
  44060. * Summary logging while loading
  44061. */
  44062. static readonly SUMMARY_LOGGING: number;
  44063. /**
  44064. * Detailled logging while loading
  44065. */
  44066. static readonly DETAILED_LOGGING: number;
  44067. /**
  44068. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44069. */
  44070. static get ForceFullSceneLoadingForIncremental(): boolean;
  44071. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44072. /**
  44073. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44074. */
  44075. static get ShowLoadingScreen(): boolean;
  44076. static set ShowLoadingScreen(value: boolean);
  44077. /**
  44078. * Defines the current logging level (while loading the scene)
  44079. * @ignorenaming
  44080. */
  44081. static get loggingLevel(): number;
  44082. static set loggingLevel(value: number);
  44083. /**
  44084. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44085. */
  44086. static get CleanBoneMatrixWeights(): boolean;
  44087. static set CleanBoneMatrixWeights(value: boolean);
  44088. /**
  44089. * Event raised when a plugin is used to load a scene
  44090. */
  44091. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44092. private static _registeredPlugins;
  44093. private static _getDefaultPlugin;
  44094. private static _getPluginForExtension;
  44095. private static _getPluginForDirectLoad;
  44096. private static _getPluginForFilename;
  44097. private static _getDirectLoad;
  44098. private static _loadData;
  44099. private static _getFileInfo;
  44100. /**
  44101. * Gets a plugin that can load the given extension
  44102. * @param extension defines the extension to load
  44103. * @returns a plugin or null if none works
  44104. */
  44105. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44106. /**
  44107. * Gets a boolean indicating that the given extension can be loaded
  44108. * @param extension defines the extension to load
  44109. * @returns true if the extension is supported
  44110. */
  44111. static IsPluginForExtensionAvailable(extension: string): boolean;
  44112. /**
  44113. * Adds a new plugin to the list of registered plugins
  44114. * @param plugin defines the plugin to add
  44115. */
  44116. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44117. /**
  44118. * Import meshes into a scene
  44119. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44120. * @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)
  44121. * @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)
  44122. * @param scene the instance of BABYLON.Scene to append to
  44123. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44124. * @param onProgress a callback with a progress event for each file being loaded
  44125. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44126. * @param pluginExtension the extension used to determine the plugin
  44127. * @returns The loaded plugin
  44128. */
  44129. 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>;
  44130. /**
  44131. * Import meshes into a scene
  44132. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44133. * @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)
  44134. * @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)
  44135. * @param scene the instance of BABYLON.Scene to append to
  44136. * @param onProgress a callback with a progress event for each file being loaded
  44137. * @param pluginExtension the extension used to determine the plugin
  44138. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44139. */
  44140. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44141. meshes: AbstractMesh[];
  44142. particleSystems: IParticleSystem[];
  44143. skeletons: Skeleton[];
  44144. animationGroups: AnimationGroup[];
  44145. }>;
  44146. /**
  44147. * Load a scene
  44148. * @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)
  44149. * @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)
  44150. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44151. * @param onSuccess a callback with the scene when import succeeds
  44152. * @param onProgress a callback with a progress event for each file being loaded
  44153. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44154. * @param pluginExtension the extension used to determine the plugin
  44155. * @returns The loaded plugin
  44156. */
  44157. 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>;
  44158. /**
  44159. * Load a scene
  44160. * @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)
  44161. * @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)
  44162. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44163. * @param onProgress a callback with a progress event for each file being loaded
  44164. * @param pluginExtension the extension used to determine the plugin
  44165. * @returns The loaded scene
  44166. */
  44167. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44168. /**
  44169. * Append a scene
  44170. * @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)
  44171. * @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)
  44172. * @param scene is the instance of BABYLON.Scene to append to
  44173. * @param onSuccess a callback with the scene when import succeeds
  44174. * @param onProgress a callback with a progress event for each file being loaded
  44175. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44176. * @param pluginExtension the extension used to determine the plugin
  44177. * @returns The loaded plugin
  44178. */
  44179. 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>;
  44180. /**
  44181. * Append a scene
  44182. * @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)
  44183. * @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)
  44184. * @param scene is the instance of BABYLON.Scene to append to
  44185. * @param onProgress a callback with a progress event for each file being loaded
  44186. * @param pluginExtension the extension used to determine the plugin
  44187. * @returns The given scene
  44188. */
  44189. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44190. /**
  44191. * Load a scene into an asset container
  44192. * @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)
  44193. * @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)
  44194. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44195. * @param onSuccess a callback with the scene when import succeeds
  44196. * @param onProgress a callback with a progress event for each file being loaded
  44197. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44198. * @param pluginExtension the extension used to determine the plugin
  44199. * @returns The loaded plugin
  44200. */
  44201. 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>;
  44202. /**
  44203. * Load a scene into an asset container
  44204. * @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)
  44205. * @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)
  44206. * @param scene is the instance of Scene to append to
  44207. * @param onProgress a callback with a progress event for each file being loaded
  44208. * @param pluginExtension the extension used to determine the plugin
  44209. * @returns The loaded asset container
  44210. */
  44211. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44212. /**
  44213. * Import animations from a file into a scene
  44214. * @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)
  44215. * @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)
  44216. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44217. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44218. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44219. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44220. * @param onSuccess a callback with the scene when import succeeds
  44221. * @param onProgress a callback with a progress event for each file being loaded
  44222. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44223. */
  44224. 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;
  44225. /**
  44226. * Import animations from a file into a scene
  44227. * @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)
  44228. * @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)
  44229. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44230. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44231. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44232. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44233. * @param onSuccess a callback with the scene when import succeeds
  44234. * @param onProgress a callback with a progress event for each file being loaded
  44235. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44236. * @returns the updated scene with imported animations
  44237. */
  44238. 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>;
  44239. }
  44240. }
  44241. declare module BABYLON {
  44242. /**
  44243. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44244. */
  44245. export type MotionControllerHandedness = "none" | "left" | "right";
  44246. /**
  44247. * The type of components available in motion controllers.
  44248. * This is not the name of the component.
  44249. */
  44250. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44251. /**
  44252. * The state of a controller component
  44253. */
  44254. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44255. /**
  44256. * The schema of motion controller layout.
  44257. * No object will be initialized using this interface
  44258. * This is used just to define the profile.
  44259. */
  44260. export interface IMotionControllerLayout {
  44261. /**
  44262. * Path to load the assets. Usually relative to the base path
  44263. */
  44264. assetPath: string;
  44265. /**
  44266. * Available components (unsorted)
  44267. */
  44268. components: {
  44269. /**
  44270. * A map of component Ids
  44271. */
  44272. [componentId: string]: {
  44273. /**
  44274. * The type of input the component outputs
  44275. */
  44276. type: MotionControllerComponentType;
  44277. /**
  44278. * The indices of this component in the gamepad object
  44279. */
  44280. gamepadIndices: {
  44281. /**
  44282. * Index of button
  44283. */
  44284. button?: number;
  44285. /**
  44286. * If available, index of x-axis
  44287. */
  44288. xAxis?: number;
  44289. /**
  44290. * If available, index of y-axis
  44291. */
  44292. yAxis?: number;
  44293. };
  44294. /**
  44295. * The mesh's root node name
  44296. */
  44297. rootNodeName: string;
  44298. /**
  44299. * Animation definitions for this model
  44300. */
  44301. visualResponses: {
  44302. [stateKey: string]: {
  44303. /**
  44304. * What property will be animated
  44305. */
  44306. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44307. /**
  44308. * What states influence this visual response
  44309. */
  44310. states: MotionControllerComponentStateType[];
  44311. /**
  44312. * Type of animation - movement or visibility
  44313. */
  44314. valueNodeProperty: "transform" | "visibility";
  44315. /**
  44316. * Base node name to move. Its position will be calculated according to the min and max nodes
  44317. */
  44318. valueNodeName?: string;
  44319. /**
  44320. * Minimum movement node
  44321. */
  44322. minNodeName?: string;
  44323. /**
  44324. * Max movement node
  44325. */
  44326. maxNodeName?: string;
  44327. };
  44328. };
  44329. /**
  44330. * If touch enabled, what is the name of node to display user feedback
  44331. */
  44332. touchPointNodeName?: string;
  44333. };
  44334. };
  44335. /**
  44336. * Is it xr standard mapping or not
  44337. */
  44338. gamepadMapping: "" | "xr-standard";
  44339. /**
  44340. * Base root node of this entire model
  44341. */
  44342. rootNodeName: string;
  44343. /**
  44344. * Defines the main button component id
  44345. */
  44346. selectComponentId: string;
  44347. }
  44348. /**
  44349. * A definition for the layout map in the input profile
  44350. */
  44351. export interface IMotionControllerLayoutMap {
  44352. /**
  44353. * Layouts with handedness type as a key
  44354. */
  44355. [handedness: string]: IMotionControllerLayout;
  44356. }
  44357. /**
  44358. * The XR Input profile schema
  44359. * Profiles can be found here:
  44360. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44361. */
  44362. export interface IMotionControllerProfile {
  44363. /**
  44364. * fallback profiles for this profileId
  44365. */
  44366. fallbackProfileIds: string[];
  44367. /**
  44368. * The layout map, with handedness as key
  44369. */
  44370. layouts: IMotionControllerLayoutMap;
  44371. /**
  44372. * The id of this profile
  44373. * correlates to the profile(s) in the xrInput.profiles array
  44374. */
  44375. profileId: string;
  44376. }
  44377. /**
  44378. * A helper-interface for the 3 meshes needed for controller button animation
  44379. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44380. */
  44381. export interface IMotionControllerButtonMeshMap {
  44382. /**
  44383. * the mesh that defines the pressed value mesh position.
  44384. * This is used to find the max-position of this button
  44385. */
  44386. pressedMesh: AbstractMesh;
  44387. /**
  44388. * the mesh that defines the unpressed value mesh position.
  44389. * This is used to find the min (or initial) position of this button
  44390. */
  44391. unpressedMesh: AbstractMesh;
  44392. /**
  44393. * The mesh that will be changed when value changes
  44394. */
  44395. valueMesh: AbstractMesh;
  44396. }
  44397. /**
  44398. * A helper-interface for the 3 meshes needed for controller axis animation.
  44399. * This will be expanded when touchpad animations are fully supported
  44400. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44401. */
  44402. export interface IMotionControllerMeshMap {
  44403. /**
  44404. * the mesh that defines the maximum value mesh position.
  44405. */
  44406. maxMesh?: AbstractMesh;
  44407. /**
  44408. * the mesh that defines the minimum value mesh position.
  44409. */
  44410. minMesh?: AbstractMesh;
  44411. /**
  44412. * The mesh that will be changed when axis value changes
  44413. */
  44414. valueMesh: AbstractMesh;
  44415. }
  44416. /**
  44417. * The elements needed for change-detection of the gamepad objects in motion controllers
  44418. */
  44419. export interface IMinimalMotionControllerObject {
  44420. /**
  44421. * Available axes of this controller
  44422. */
  44423. axes: number[];
  44424. /**
  44425. * An array of available buttons
  44426. */
  44427. buttons: Array<{
  44428. /**
  44429. * Value of the button/trigger
  44430. */
  44431. value: number;
  44432. /**
  44433. * If the button/trigger is currently touched
  44434. */
  44435. touched: boolean;
  44436. /**
  44437. * If the button/trigger is currently pressed
  44438. */
  44439. pressed: boolean;
  44440. }>;
  44441. /**
  44442. * EXPERIMENTAL haptic support.
  44443. */
  44444. hapticActuators?: Array<{
  44445. pulse: (value: number, duration: number) => Promise<boolean>;
  44446. }>;
  44447. }
  44448. /**
  44449. * An Abstract Motion controller
  44450. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44451. * Each component has an observable to check for changes in value and state
  44452. */
  44453. export abstract class WebXRAbstractMotionController implements IDisposable {
  44454. protected scene: Scene;
  44455. protected layout: IMotionControllerLayout;
  44456. /**
  44457. * The gamepad object correlating to this controller
  44458. */
  44459. gamepadObject: IMinimalMotionControllerObject;
  44460. /**
  44461. * handedness (left/right/none) of this controller
  44462. */
  44463. handedness: MotionControllerHandedness;
  44464. private _initComponent;
  44465. private _modelReady;
  44466. /**
  44467. * A map of components (WebXRControllerComponent) in this motion controller
  44468. * Components have a ComponentType and can also have both button and axis definitions
  44469. */
  44470. readonly components: {
  44471. [id: string]: WebXRControllerComponent;
  44472. };
  44473. /**
  44474. * Disable the model's animation. Can be set at any time.
  44475. */
  44476. disableAnimation: boolean;
  44477. /**
  44478. * Observers registered here will be triggered when the model of this controller is done loading
  44479. */
  44480. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44481. /**
  44482. * The profile id of this motion controller
  44483. */
  44484. abstract profileId: string;
  44485. /**
  44486. * The root mesh of the model. It is null if the model was not yet initialized
  44487. */
  44488. rootMesh: Nullable<AbstractMesh>;
  44489. /**
  44490. * constructs a new abstract motion controller
  44491. * @param scene the scene to which the model of the controller will be added
  44492. * @param layout The profile layout to load
  44493. * @param gamepadObject The gamepad object correlating to this controller
  44494. * @param handedness handedness (left/right/none) of this controller
  44495. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44496. */
  44497. constructor(scene: Scene, layout: IMotionControllerLayout,
  44498. /**
  44499. * The gamepad object correlating to this controller
  44500. */
  44501. gamepadObject: IMinimalMotionControllerObject,
  44502. /**
  44503. * handedness (left/right/none) of this controller
  44504. */
  44505. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  44506. /**
  44507. * Dispose this controller, the model mesh and all its components
  44508. */
  44509. dispose(): void;
  44510. /**
  44511. * Returns all components of specific type
  44512. * @param type the type to search for
  44513. * @return an array of components with this type
  44514. */
  44515. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44516. /**
  44517. * get a component based an its component id as defined in layout.components
  44518. * @param id the id of the component
  44519. * @returns the component correlates to the id or undefined if not found
  44520. */
  44521. getComponent(id: string): WebXRControllerComponent;
  44522. /**
  44523. * Get the list of components available in this motion controller
  44524. * @returns an array of strings correlating to available components
  44525. */
  44526. getComponentIds(): string[];
  44527. /**
  44528. * Get the first component of specific type
  44529. * @param type type of component to find
  44530. * @return a controller component or null if not found
  44531. */
  44532. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44533. /**
  44534. * Get the main (Select) component of this controller as defined in the layout
  44535. * @returns the main component of this controller
  44536. */
  44537. getMainComponent(): WebXRControllerComponent;
  44538. /**
  44539. * Loads the model correlating to this controller
  44540. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44541. * @returns A promise fulfilled with the result of the model loading
  44542. */
  44543. loadModel(): Promise<boolean>;
  44544. /**
  44545. * Update this model using the current XRFrame
  44546. * @param xrFrame the current xr frame to use and update the model
  44547. */
  44548. updateFromXRFrame(xrFrame: XRFrame): void;
  44549. /**
  44550. * Backwards compatibility due to a deeply-integrated typo
  44551. */
  44552. get handness(): XREye;
  44553. /**
  44554. * Pulse (vibrate) this controller
  44555. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  44556. * Consecutive calls to this function will cancel the last pulse call
  44557. *
  44558. * @param value the strength of the pulse in 0.0...1.0 range
  44559. * @param duration Duration of the pulse in milliseconds
  44560. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  44561. * @returns a promise that will send true when the pulse has ended and false if the device doesn't support pulse or an error accrued
  44562. */
  44563. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  44564. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44565. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44566. /**
  44567. * Moves the axis on the controller mesh based on its current state
  44568. * @param axis the index of the axis
  44569. * @param axisValue the value of the axis which determines the meshes new position
  44570. * @hidden
  44571. */
  44572. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44573. /**
  44574. * Update the model itself with the current frame data
  44575. * @param xrFrame the frame to use for updating the model mesh
  44576. */
  44577. protected updateModel(xrFrame: XRFrame): void;
  44578. /**
  44579. * Get the filename and path for this controller's model
  44580. * @returns a map of filename and path
  44581. */
  44582. protected abstract _getFilenameAndPath(): {
  44583. filename: string;
  44584. path: string;
  44585. };
  44586. /**
  44587. * This function is called before the mesh is loaded. It checks for loading constraints.
  44588. * For example, this function can check if the GLB loader is available
  44589. * If this function returns false, the generic controller will be loaded instead
  44590. * @returns Is the client ready to load the mesh
  44591. */
  44592. protected abstract _getModelLoadingConstraints(): boolean;
  44593. /**
  44594. * This function will be called after the model was successfully loaded and can be used
  44595. * for mesh transformations before it is available for the user
  44596. * @param meshes the loaded meshes
  44597. */
  44598. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44599. /**
  44600. * Set the root mesh for this controller. Important for the WebXR controller class
  44601. * @param meshes the loaded meshes
  44602. */
  44603. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44604. /**
  44605. * A function executed each frame that updates the mesh (if needed)
  44606. * @param xrFrame the current xrFrame
  44607. */
  44608. protected abstract _updateModel(xrFrame: XRFrame): void;
  44609. private _getGenericFilenameAndPath;
  44610. private _getGenericParentMesh;
  44611. }
  44612. }
  44613. declare module BABYLON {
  44614. /**
  44615. * A generic trigger-only motion controller for WebXR
  44616. */
  44617. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44618. /**
  44619. * Static version of the profile id of this controller
  44620. */
  44621. static ProfileId: string;
  44622. profileId: string;
  44623. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  44624. protected _getFilenameAndPath(): {
  44625. filename: string;
  44626. path: string;
  44627. };
  44628. protected _getModelLoadingConstraints(): boolean;
  44629. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44630. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44631. protected _updateModel(): void;
  44632. }
  44633. }
  44634. declare module BABYLON {
  44635. /**
  44636. * Class containing static functions to help procedurally build meshes
  44637. */
  44638. export class SphereBuilder {
  44639. /**
  44640. * Creates a sphere mesh
  44641. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44642. * * 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`)
  44643. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44644. * * 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
  44645. * * 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)
  44646. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44647. * * 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
  44648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44649. * @param name defines the name of the mesh
  44650. * @param options defines the options used to create the mesh
  44651. * @param scene defines the hosting scene
  44652. * @returns the sphere mesh
  44653. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44654. */
  44655. static CreateSphere(name: string, options: {
  44656. segments?: number;
  44657. diameter?: number;
  44658. diameterX?: number;
  44659. diameterY?: number;
  44660. diameterZ?: number;
  44661. arc?: number;
  44662. slice?: number;
  44663. sideOrientation?: number;
  44664. frontUVs?: Vector4;
  44665. backUVs?: Vector4;
  44666. updatable?: boolean;
  44667. }, scene?: Nullable<Scene>): Mesh;
  44668. }
  44669. }
  44670. declare module BABYLON {
  44671. /**
  44672. * A profiled motion controller has its profile loaded from an online repository.
  44673. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44674. */
  44675. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44676. private _repositoryUrl;
  44677. private _buttonMeshMapping;
  44678. private _touchDots;
  44679. /**
  44680. * The profile ID of this controller. Will be populated when the controller initializes.
  44681. */
  44682. profileId: string;
  44683. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44684. dispose(): void;
  44685. protected _getFilenameAndPath(): {
  44686. filename: string;
  44687. path: string;
  44688. };
  44689. protected _getModelLoadingConstraints(): boolean;
  44690. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44691. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44692. protected _updateModel(_xrFrame: XRFrame): void;
  44693. }
  44694. }
  44695. declare module BABYLON {
  44696. /**
  44697. * A construction function type to create a new controller based on an xrInput object
  44698. */
  44699. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44700. /**
  44701. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44702. *
  44703. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44704. * it should be replaced with auto-loaded controllers.
  44705. *
  44706. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44707. */
  44708. export class WebXRMotionControllerManager {
  44709. private static _AvailableControllers;
  44710. private static _Fallbacks;
  44711. private static _ProfileLoadingPromises;
  44712. private static _ProfilesList;
  44713. /**
  44714. * The base URL of the online controller repository. Can be changed at any time.
  44715. */
  44716. static BaseRepositoryUrl: string;
  44717. /**
  44718. * Which repository gets priority - local or online
  44719. */
  44720. static PrioritizeOnlineRepository: boolean;
  44721. /**
  44722. * Use the online repository, or use only locally-defined controllers
  44723. */
  44724. static UseOnlineRepository: boolean;
  44725. /**
  44726. * Clear the cache used for profile loading and reload when requested again
  44727. */
  44728. static ClearProfilesCache(): void;
  44729. /**
  44730. * Register the default fallbacks.
  44731. * This function is called automatically when this file is imported.
  44732. */
  44733. static DefaultFallbacks(): void;
  44734. /**
  44735. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44736. * @param profileId the profile to which a fallback needs to be found
  44737. * @return an array with corresponding fallback profiles
  44738. */
  44739. static FindFallbackWithProfileId(profileId: string): string[];
  44740. /**
  44741. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44742. * The order of search:
  44743. *
  44744. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44745. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44746. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44747. * 4) return the generic trigger controller if none were found
  44748. *
  44749. * @param xrInput the xrInput to which a new controller is initialized
  44750. * @param scene the scene to which the model will be added
  44751. * @param forceProfile force a certain profile for this controller
  44752. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44753. */
  44754. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44755. /**
  44756. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44757. *
  44758. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44759. *
  44760. * @param type the profile type to register
  44761. * @param constructFunction the function to be called when loading this profile
  44762. */
  44763. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44764. /**
  44765. * Register a fallback to a specific profile.
  44766. * @param profileId the profileId that will receive the fallbacks
  44767. * @param fallbacks A list of fallback profiles
  44768. */
  44769. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44770. /**
  44771. * Will update the list of profiles available in the repository
  44772. * @return a promise that resolves to a map of profiles available online
  44773. */
  44774. static UpdateProfilesList(): Promise<{
  44775. [profile: string]: string;
  44776. }>;
  44777. private static _LoadProfileFromRepository;
  44778. private static _LoadProfilesFromAvailableControllers;
  44779. }
  44780. }
  44781. declare module BABYLON {
  44782. /**
  44783. * Configuration options for the WebXR controller creation
  44784. */
  44785. export interface IWebXRControllerOptions {
  44786. /**
  44787. * Should the controller mesh be animated when a user interacts with it
  44788. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44789. */
  44790. disableMotionControllerAnimation?: boolean;
  44791. /**
  44792. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44793. */
  44794. doNotLoadControllerMesh?: boolean;
  44795. /**
  44796. * Force a specific controller type for this controller.
  44797. * This can be used when creating your own profile or when testing different controllers
  44798. */
  44799. forceControllerProfile?: string;
  44800. /**
  44801. * Defines a rendering group ID for meshes that will be loaded.
  44802. * This is for the default controllers only.
  44803. */
  44804. renderingGroupId?: number;
  44805. }
  44806. /**
  44807. * Represents an XR controller
  44808. */
  44809. export class WebXRInputSource {
  44810. private _scene;
  44811. /** The underlying input source for the controller */
  44812. inputSource: XRInputSource;
  44813. private _options;
  44814. private _tmpQuaternion;
  44815. private _tmpVector;
  44816. private _uniqueId;
  44817. /**
  44818. * 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
  44819. */
  44820. grip?: AbstractMesh;
  44821. /**
  44822. * If available, this is the gamepad object related to this controller.
  44823. * Using this object it is possible to get click events and trackpad changes of the
  44824. * webxr controller that is currently being used.
  44825. */
  44826. motionController?: WebXRAbstractMotionController;
  44827. /**
  44828. * Event that fires when the controller is removed/disposed.
  44829. * The object provided as event data is this controller, after associated assets were disposed.
  44830. * uniqueId is still available.
  44831. */
  44832. onDisposeObservable: Observable<WebXRInputSource>;
  44833. /**
  44834. * Will be triggered when the mesh associated with the motion controller is done loading.
  44835. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44836. * A shortened version of controller -> motion controller -> on mesh loaded.
  44837. */
  44838. onMeshLoadedObservable: Observable<AbstractMesh>;
  44839. /**
  44840. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44841. */
  44842. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44843. /**
  44844. * Pointer which can be used to select objects or attach a visible laser to
  44845. */
  44846. pointer: AbstractMesh;
  44847. /**
  44848. * Creates the controller
  44849. * @see https://doc.babylonjs.com/how_to/webxr
  44850. * @param _scene the scene which the controller should be associated to
  44851. * @param inputSource the underlying input source for the controller
  44852. * @param _options options for this controller creation
  44853. */
  44854. constructor(_scene: Scene,
  44855. /** The underlying input source for the controller */
  44856. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44857. /**
  44858. * Get this controllers unique id
  44859. */
  44860. get uniqueId(): string;
  44861. /**
  44862. * Disposes of the object
  44863. */
  44864. dispose(): void;
  44865. /**
  44866. * Gets a world space ray coming from the pointer or grip
  44867. * @param result the resulting ray
  44868. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44869. */
  44870. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44871. /**
  44872. * Updates the controller pose based on the given XRFrame
  44873. * @param xrFrame xr frame to update the pose with
  44874. * @param referenceSpace reference space to use
  44875. */
  44876. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44877. }
  44878. }
  44879. declare module BABYLON {
  44880. /**
  44881. * The schema for initialization options of the XR Input class
  44882. */
  44883. export interface IWebXRInputOptions {
  44884. /**
  44885. * If set to true no model will be automatically loaded
  44886. */
  44887. doNotLoadControllerMeshes?: boolean;
  44888. /**
  44889. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44890. * If not found, the xr input profile data will be used.
  44891. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44892. */
  44893. forceInputProfile?: string;
  44894. /**
  44895. * Do not send a request to the controller repository to load the profile.
  44896. *
  44897. * Instead, use the controllers available in babylon itself.
  44898. */
  44899. disableOnlineControllerRepository?: boolean;
  44900. /**
  44901. * A custom URL for the controllers repository
  44902. */
  44903. customControllersRepositoryURL?: string;
  44904. /**
  44905. * Should the controller model's components not move according to the user input
  44906. */
  44907. disableControllerAnimation?: boolean;
  44908. /**
  44909. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  44910. */
  44911. controllerOptions?: IWebXRControllerOptions;
  44912. }
  44913. /**
  44914. * XR input used to track XR inputs such as controllers/rays
  44915. */
  44916. export class WebXRInput implements IDisposable {
  44917. /**
  44918. * the xr session manager for this session
  44919. */
  44920. xrSessionManager: WebXRSessionManager;
  44921. /**
  44922. * the WebXR camera for this session. Mainly used for teleportation
  44923. */
  44924. xrCamera: WebXRCamera;
  44925. private readonly options;
  44926. /**
  44927. * XR controllers being tracked
  44928. */
  44929. controllers: Array<WebXRInputSource>;
  44930. private _frameObserver;
  44931. private _sessionEndedObserver;
  44932. private _sessionInitObserver;
  44933. /**
  44934. * Event when a controller has been connected/added
  44935. */
  44936. onControllerAddedObservable: Observable<WebXRInputSource>;
  44937. /**
  44938. * Event when a controller has been removed/disconnected
  44939. */
  44940. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44941. /**
  44942. * Initializes the WebXRInput
  44943. * @param xrSessionManager the xr session manager for this session
  44944. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44945. * @param options = initialization options for this xr input
  44946. */
  44947. constructor(
  44948. /**
  44949. * the xr session manager for this session
  44950. */
  44951. xrSessionManager: WebXRSessionManager,
  44952. /**
  44953. * the WebXR camera for this session. Mainly used for teleportation
  44954. */
  44955. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44956. private _onInputSourcesChange;
  44957. private _addAndRemoveControllers;
  44958. /**
  44959. * Disposes of the object
  44960. */
  44961. dispose(): void;
  44962. }
  44963. }
  44964. declare module BABYLON {
  44965. /**
  44966. * This is the base class for all WebXR features.
  44967. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44968. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44969. */
  44970. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44971. protected _xrSessionManager: WebXRSessionManager;
  44972. private _attached;
  44973. private _removeOnDetach;
  44974. /**
  44975. * Should auto-attach be disabled?
  44976. */
  44977. disableAutoAttach: boolean;
  44978. /**
  44979. * Construct a new (abstract) WebXR feature
  44980. * @param _xrSessionManager the xr session manager for this feature
  44981. */
  44982. constructor(_xrSessionManager: WebXRSessionManager);
  44983. /**
  44984. * Is this feature attached
  44985. */
  44986. get attached(): boolean;
  44987. /**
  44988. * attach this feature
  44989. *
  44990. * @param force should attachment be forced (even when already attached)
  44991. * @returns true if successful, false is failed or already attached
  44992. */
  44993. attach(force?: boolean): boolean;
  44994. /**
  44995. * detach this feature.
  44996. *
  44997. * @returns true if successful, false if failed or already detached
  44998. */
  44999. detach(): boolean;
  45000. /**
  45001. * Dispose this feature and all of the resources attached
  45002. */
  45003. dispose(): void;
  45004. /**
  45005. * This is used to register callbacks that will automatically be removed when detach is called.
  45006. * @param observable the observable to which the observer will be attached
  45007. * @param callback the callback to register
  45008. */
  45009. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45010. /**
  45011. * Code in this function will be executed on each xrFrame received from the browser.
  45012. * This function will not execute after the feature is detached.
  45013. * @param _xrFrame the current frame
  45014. */
  45015. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45016. }
  45017. }
  45018. declare module BABYLON {
  45019. /**
  45020. * Renders a layer on top of an existing scene
  45021. */
  45022. export class UtilityLayerRenderer implements IDisposable {
  45023. /** the original scene that will be rendered on top of */
  45024. originalScene: Scene;
  45025. private _pointerCaptures;
  45026. private _lastPointerEvents;
  45027. private static _DefaultUtilityLayer;
  45028. private static _DefaultKeepDepthUtilityLayer;
  45029. private _sharedGizmoLight;
  45030. private _renderCamera;
  45031. /**
  45032. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45033. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  45034. * @returns the camera that is used when rendering the utility layer
  45035. */
  45036. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  45037. /**
  45038. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45039. * @param cam the camera that should be used when rendering the utility layer
  45040. */
  45041. setRenderCamera(cam: Nullable<Camera>): void;
  45042. /**
  45043. * @hidden
  45044. * Light which used by gizmos to get light shading
  45045. */
  45046. _getSharedGizmoLight(): HemisphericLight;
  45047. /**
  45048. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45049. */
  45050. pickUtilitySceneFirst: boolean;
  45051. /**
  45052. * 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)
  45053. */
  45054. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45055. /**
  45056. * 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)
  45057. */
  45058. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45059. /**
  45060. * The scene that is rendered on top of the original scene
  45061. */
  45062. utilityLayerScene: Scene;
  45063. /**
  45064. * If the utility layer should automatically be rendered on top of existing scene
  45065. */
  45066. shouldRender: boolean;
  45067. /**
  45068. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45069. */
  45070. onlyCheckPointerDownEvents: boolean;
  45071. /**
  45072. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45073. */
  45074. processAllEvents: boolean;
  45075. /**
  45076. * Observable raised when the pointer move from the utility layer scene to the main scene
  45077. */
  45078. onPointerOutObservable: Observable<number>;
  45079. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45080. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45081. private _afterRenderObserver;
  45082. private _sceneDisposeObserver;
  45083. private _originalPointerObserver;
  45084. /**
  45085. * Instantiates a UtilityLayerRenderer
  45086. * @param originalScene the original scene that will be rendered on top of
  45087. * @param handleEvents boolean indicating if the utility layer should handle events
  45088. */
  45089. constructor(
  45090. /** the original scene that will be rendered on top of */
  45091. originalScene: Scene, handleEvents?: boolean);
  45092. private _notifyObservers;
  45093. /**
  45094. * Renders the utility layers scene on top of the original scene
  45095. */
  45096. render(): void;
  45097. /**
  45098. * Disposes of the renderer
  45099. */
  45100. dispose(): void;
  45101. private _updateCamera;
  45102. }
  45103. }
  45104. declare module BABYLON {
  45105. /**
  45106. * Options interface for the pointer selection module
  45107. */
  45108. export interface IWebXRControllerPointerSelectionOptions {
  45109. /**
  45110. * if provided, this scene will be used to render meshes.
  45111. */
  45112. customUtilityLayerScene?: Scene;
  45113. /**
  45114. * 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)
  45115. * If not disabled, the last picked point will be used to execute a pointer up event
  45116. * If disabled, pointer up event will be triggered right after the pointer down event.
  45117. * Used in screen and gaze target ray mode only
  45118. */
  45119. disablePointerUpOnTouchOut: boolean;
  45120. /**
  45121. * For gaze mode (time to select instead of press)
  45122. */
  45123. forceGazeMode: boolean;
  45124. /**
  45125. * 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
  45126. * to start a new countdown to the pointer down event.
  45127. * Defaults to 1.
  45128. */
  45129. gazeModePointerMovedFactor?: number;
  45130. /**
  45131. * Different button type to use instead of the main component
  45132. */
  45133. overrideButtonId?: string;
  45134. /**
  45135. * use this rendering group id for the meshes (optional)
  45136. */
  45137. renderingGroupId?: number;
  45138. /**
  45139. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45140. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45141. * 3000 means 3 seconds between pointing at something and selecting it
  45142. */
  45143. timeToSelect?: number;
  45144. /**
  45145. * Should meshes created here be added to a utility layer or the main scene
  45146. */
  45147. useUtilityLayer?: boolean;
  45148. /**
  45149. * the xr input to use with this pointer selection
  45150. */
  45151. xrInput: WebXRInput;
  45152. }
  45153. /**
  45154. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45155. */
  45156. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45157. private readonly _options;
  45158. private static _idCounter;
  45159. private _attachController;
  45160. private _controllers;
  45161. private _scene;
  45162. private _tmpVectorForPickCompare;
  45163. /**
  45164. * The module's name
  45165. */
  45166. static readonly Name: string;
  45167. /**
  45168. * The (Babylon) version of this module.
  45169. * This is an integer representing the implementation version.
  45170. * This number does not correspond to the WebXR specs version
  45171. */
  45172. static readonly Version: number;
  45173. /**
  45174. * Disable lighting on the laser pointer (so it will always be visible)
  45175. */
  45176. disablePointerLighting: boolean;
  45177. /**
  45178. * Disable lighting on the selection mesh (so it will always be visible)
  45179. */
  45180. disableSelectionMeshLighting: boolean;
  45181. /**
  45182. * Should the laser pointer be displayed
  45183. */
  45184. displayLaserPointer: boolean;
  45185. /**
  45186. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  45187. */
  45188. displaySelectionMesh: boolean;
  45189. /**
  45190. * This color will be set to the laser pointer when selection is triggered
  45191. */
  45192. laserPointerPickedColor: Color3;
  45193. /**
  45194. * Default color of the laser pointer
  45195. */
  45196. lasterPointerDefaultColor: Color3;
  45197. /**
  45198. * default color of the selection ring
  45199. */
  45200. selectionMeshDefaultColor: Color3;
  45201. /**
  45202. * This color will be applied to the selection ring when selection is triggered
  45203. */
  45204. selectionMeshPickedColor: Color3;
  45205. /**
  45206. * Optional filter to be used for ray selection. This predicate shares behavior with
  45207. * scene.pointerMovePredicate which takes priority if it is also assigned.
  45208. */
  45209. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45210. /**
  45211. * constructs a new background remover module
  45212. * @param _xrSessionManager the session manager for this module
  45213. * @param _options read-only options to be used in this module
  45214. */
  45215. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  45216. /**
  45217. * attach this feature
  45218. * Will usually be called by the features manager
  45219. *
  45220. * @returns true if successful.
  45221. */
  45222. attach(): boolean;
  45223. /**
  45224. * detach this feature.
  45225. * Will usually be called by the features manager
  45226. *
  45227. * @returns true if successful.
  45228. */
  45229. detach(): boolean;
  45230. /**
  45231. * Will get the mesh under a specific pointer.
  45232. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  45233. * @param controllerId the controllerId to check
  45234. * @returns The mesh under pointer or null if no mesh is under the pointer
  45235. */
  45236. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  45237. /**
  45238. * Get the xr controller that correlates to the pointer id in the pointer event
  45239. *
  45240. * @param id the pointer id to search for
  45241. * @returns the controller that correlates to this id or null if not found
  45242. */
  45243. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  45244. protected _onXRFrame(_xrFrame: XRFrame): void;
  45245. private _attachGazeMode;
  45246. private _attachScreenRayMode;
  45247. private _attachTrackedPointerRayMode;
  45248. private _convertNormalToDirectionOfRay;
  45249. private _detachController;
  45250. private _generateNewMeshPair;
  45251. private _pickingMoved;
  45252. private _updatePointerDistance;
  45253. }
  45254. }
  45255. declare module BABYLON {
  45256. /**
  45257. * Button which can be used to enter a different mode of XR
  45258. */
  45259. export class WebXREnterExitUIButton {
  45260. /** button element */
  45261. element: HTMLElement;
  45262. /** XR initialization options for the button */
  45263. sessionMode: XRSessionMode;
  45264. /** Reference space type */
  45265. referenceSpaceType: XRReferenceSpaceType;
  45266. /**
  45267. * Creates a WebXREnterExitUIButton
  45268. * @param element button element
  45269. * @param sessionMode XR initialization session mode
  45270. * @param referenceSpaceType the type of reference space to be used
  45271. */
  45272. constructor(
  45273. /** button element */
  45274. element: HTMLElement,
  45275. /** XR initialization options for the button */
  45276. sessionMode: XRSessionMode,
  45277. /** Reference space type */
  45278. referenceSpaceType: XRReferenceSpaceType);
  45279. /**
  45280. * Extendable function which can be used to update the button's visuals when the state changes
  45281. * @param activeButton the current active button in the UI
  45282. */
  45283. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45284. }
  45285. /**
  45286. * Options to create the webXR UI
  45287. */
  45288. export class WebXREnterExitUIOptions {
  45289. /**
  45290. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45291. */
  45292. customButtons?: Array<WebXREnterExitUIButton>;
  45293. /**
  45294. * A reference space type to use when creating the default button.
  45295. * Default is local-floor
  45296. */
  45297. referenceSpaceType?: XRReferenceSpaceType;
  45298. /**
  45299. * Context to enter xr with
  45300. */
  45301. renderTarget?: Nullable<WebXRRenderTarget>;
  45302. /**
  45303. * A session mode to use when creating the default button.
  45304. * Default is immersive-vr
  45305. */
  45306. sessionMode?: XRSessionMode;
  45307. /**
  45308. * A list of optional features to init the session with
  45309. */
  45310. optionalFeatures?: string[];
  45311. }
  45312. /**
  45313. * UI to allow the user to enter/exit XR mode
  45314. */
  45315. export class WebXREnterExitUI implements IDisposable {
  45316. private scene;
  45317. /** version of the options passed to this UI */
  45318. options: WebXREnterExitUIOptions;
  45319. private _activeButton;
  45320. private _buttons;
  45321. private _overlay;
  45322. /**
  45323. * Fired every time the active button is changed.
  45324. *
  45325. * When xr is entered via a button that launches xr that button will be the callback parameter
  45326. *
  45327. * When exiting xr the callback parameter will be null)
  45328. */
  45329. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45330. /**
  45331. *
  45332. * @param scene babylon scene object to use
  45333. * @param options (read-only) version of the options passed to this UI
  45334. */
  45335. private constructor();
  45336. /**
  45337. * Creates UI to allow the user to enter/exit XR mode
  45338. * @param scene the scene to add the ui to
  45339. * @param helper the xr experience helper to enter/exit xr with
  45340. * @param options options to configure the UI
  45341. * @returns the created ui
  45342. */
  45343. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45344. /**
  45345. * Disposes of the XR UI component
  45346. */
  45347. dispose(): void;
  45348. private _updateButtons;
  45349. }
  45350. }
  45351. declare module BABYLON {
  45352. /**
  45353. * Class containing static functions to help procedurally build meshes
  45354. */
  45355. export class LinesBuilder {
  45356. /**
  45357. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45358. * * 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
  45359. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45360. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45361. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45362. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45363. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45364. * * 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
  45365. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45368. * @param name defines the name of the new line system
  45369. * @param options defines the options used to create the line system
  45370. * @param scene defines the hosting scene
  45371. * @returns a new line system mesh
  45372. */
  45373. static CreateLineSystem(name: string, options: {
  45374. lines: Vector3[][];
  45375. updatable?: boolean;
  45376. instance?: Nullable<LinesMesh>;
  45377. colors?: Nullable<Color4[][]>;
  45378. useVertexAlpha?: boolean;
  45379. }, scene: Nullable<Scene>): LinesMesh;
  45380. /**
  45381. * Creates a line mesh
  45382. * 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
  45383. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45384. * * The parameter `points` is an array successive Vector3
  45385. * * 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
  45386. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45387. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45388. * * When updating an instance, remember that only point positions can change, not the number of points
  45389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45391. * @param name defines the name of the new line system
  45392. * @param options defines the options used to create the line system
  45393. * @param scene defines the hosting scene
  45394. * @returns a new line mesh
  45395. */
  45396. static CreateLines(name: string, options: {
  45397. points: Vector3[];
  45398. updatable?: boolean;
  45399. instance?: Nullable<LinesMesh>;
  45400. colors?: Color4[];
  45401. useVertexAlpha?: boolean;
  45402. }, scene?: Nullable<Scene>): LinesMesh;
  45403. /**
  45404. * Creates a dashed line mesh
  45405. * * 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
  45406. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45407. * * The parameter `points` is an array successive Vector3
  45408. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45409. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45410. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45411. * * 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
  45412. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45413. * * When updating an instance, remember that only point positions can change, not the number of points
  45414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45415. * @param name defines the name of the mesh
  45416. * @param options defines the options used to create the mesh
  45417. * @param scene defines the hosting scene
  45418. * @returns the dashed line mesh
  45419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45420. */
  45421. static CreateDashedLines(name: string, options: {
  45422. points: Vector3[];
  45423. dashSize?: number;
  45424. gapSize?: number;
  45425. dashNb?: number;
  45426. updatable?: boolean;
  45427. instance?: LinesMesh;
  45428. useVertexAlpha?: boolean;
  45429. }, scene?: Nullable<Scene>): LinesMesh;
  45430. }
  45431. }
  45432. declare module BABYLON {
  45433. /**
  45434. * The options container for the teleportation module
  45435. */
  45436. export interface IWebXRTeleportationOptions {
  45437. /**
  45438. * if provided, this scene will be used to render meshes.
  45439. */
  45440. customUtilityLayerScene?: Scene;
  45441. /**
  45442. * Values to configure the default target mesh
  45443. */
  45444. defaultTargetMeshOptions?: {
  45445. /**
  45446. * Fill color of the teleportation area
  45447. */
  45448. teleportationFillColor?: string;
  45449. /**
  45450. * Border color for the teleportation area
  45451. */
  45452. teleportationBorderColor?: string;
  45453. /**
  45454. * Disable the mesh's animation sequence
  45455. */
  45456. disableAnimation?: boolean;
  45457. /**
  45458. * Disable lighting on the material or the ring and arrow
  45459. */
  45460. disableLighting?: boolean;
  45461. /**
  45462. * Override the default material of the torus and arrow
  45463. */
  45464. torusArrowMaterial?: Material;
  45465. };
  45466. /**
  45467. * A list of meshes to use as floor meshes.
  45468. * Meshes can be added and removed after initializing the feature using the
  45469. * addFloorMesh and removeFloorMesh functions
  45470. * If empty, rotation will still work
  45471. */
  45472. floorMeshes?: AbstractMesh[];
  45473. /**
  45474. * use this rendering group id for the meshes (optional)
  45475. */
  45476. renderingGroupId?: number;
  45477. /**
  45478. * Should teleportation move only to snap points
  45479. */
  45480. snapPointsOnly?: boolean;
  45481. /**
  45482. * An array of points to which the teleportation will snap to.
  45483. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45484. */
  45485. snapPositions?: Vector3[];
  45486. /**
  45487. * How close should the teleportation ray be in order to snap to position.
  45488. * Default to 0.8 units (meters)
  45489. */
  45490. snapToPositionRadius?: number;
  45491. /**
  45492. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45493. * If you want to support rotation, make sure your mesh has a direction indicator.
  45494. *
  45495. * When left untouched, the default mesh will be initialized.
  45496. */
  45497. teleportationTargetMesh?: AbstractMesh;
  45498. /**
  45499. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45500. */
  45501. timeToTeleport?: number;
  45502. /**
  45503. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45504. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45505. */
  45506. useMainComponentOnly?: boolean;
  45507. /**
  45508. * Should meshes created here be added to a utility layer or the main scene
  45509. */
  45510. useUtilityLayer?: boolean;
  45511. /**
  45512. * Babylon XR Input class for controller
  45513. */
  45514. xrInput: WebXRInput;
  45515. }
  45516. /**
  45517. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45518. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45519. * the input of the attached controllers.
  45520. */
  45521. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45522. private _options;
  45523. private _controllers;
  45524. private _currentTeleportationControllerId;
  45525. private _floorMeshes;
  45526. private _quadraticBezierCurve;
  45527. private _selectionFeature;
  45528. private _snapToPositions;
  45529. private _snappedToPoint;
  45530. private _teleportationRingMaterial?;
  45531. private _tmpRay;
  45532. private _tmpVector;
  45533. /**
  45534. * The module's name
  45535. */
  45536. static readonly Name: string;
  45537. /**
  45538. * The (Babylon) version of this module.
  45539. * This is an integer representing the implementation version.
  45540. * This number does not correspond to the webxr specs version
  45541. */
  45542. static readonly Version: number;
  45543. /**
  45544. * Is movement backwards enabled
  45545. */
  45546. backwardsMovementEnabled: boolean;
  45547. /**
  45548. * Distance to travel when moving backwards
  45549. */
  45550. backwardsTeleportationDistance: number;
  45551. /**
  45552. * The distance from the user to the inspection point in the direction of the controller
  45553. * A higher number will allow the user to move further
  45554. * defaults to 5 (meters, in xr units)
  45555. */
  45556. parabolicCheckRadius: number;
  45557. /**
  45558. * Should the module support parabolic ray on top of direct ray
  45559. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45560. * Very helpful when moving between floors / different heights
  45561. */
  45562. parabolicRayEnabled: boolean;
  45563. /**
  45564. * How much rotation should be applied when rotating right and left
  45565. */
  45566. rotationAngle: number;
  45567. /**
  45568. * Is rotation enabled when moving forward?
  45569. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45570. */
  45571. rotationEnabled: boolean;
  45572. /**
  45573. * constructs a new anchor system
  45574. * @param _xrSessionManager an instance of WebXRSessionManager
  45575. * @param _options configuration object for this feature
  45576. */
  45577. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45578. /**
  45579. * Get the snapPointsOnly flag
  45580. */
  45581. get snapPointsOnly(): boolean;
  45582. /**
  45583. * Sets the snapPointsOnly flag
  45584. * @param snapToPoints should teleportation be exclusively to snap points
  45585. */
  45586. set snapPointsOnly(snapToPoints: boolean);
  45587. /**
  45588. * Add a new mesh to the floor meshes array
  45589. * @param mesh the mesh to use as floor mesh
  45590. */
  45591. addFloorMesh(mesh: AbstractMesh): void;
  45592. /**
  45593. * Add a new snap-to point to fix teleportation to this position
  45594. * @param newSnapPoint The new Snap-To point
  45595. */
  45596. addSnapPoint(newSnapPoint: Vector3): void;
  45597. attach(): boolean;
  45598. detach(): boolean;
  45599. dispose(): void;
  45600. /**
  45601. * Remove a mesh from the floor meshes array
  45602. * @param mesh the mesh to remove
  45603. */
  45604. removeFloorMesh(mesh: AbstractMesh): void;
  45605. /**
  45606. * Remove a mesh from the floor meshes array using its name
  45607. * @param name the mesh name to remove
  45608. */
  45609. removeFloorMeshByName(name: string): void;
  45610. /**
  45611. * 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
  45612. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45613. * @returns was the point found and removed or not
  45614. */
  45615. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45616. /**
  45617. * This function sets a selection feature that will be disabled when
  45618. * the forward ray is shown and will be reattached when hidden.
  45619. * This is used to remove the selection rays when moving.
  45620. * @param selectionFeature the feature to disable when forward movement is enabled
  45621. */
  45622. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45623. protected _onXRFrame(_xrFrame: XRFrame): void;
  45624. private _attachController;
  45625. private _createDefaultTargetMesh;
  45626. private _detachController;
  45627. private _findClosestSnapPointWithRadius;
  45628. private _setTargetMeshPosition;
  45629. private _setTargetMeshVisibility;
  45630. private _showParabolicPath;
  45631. private _teleportForward;
  45632. }
  45633. }
  45634. declare module BABYLON {
  45635. /**
  45636. * Options for the default xr helper
  45637. */
  45638. export class WebXRDefaultExperienceOptions {
  45639. /**
  45640. * Enable or disable default UI to enter XR
  45641. */
  45642. disableDefaultUI?: boolean;
  45643. /**
  45644. * Should teleportation not initialize. defaults to false.
  45645. */
  45646. disableTeleportation?: boolean;
  45647. /**
  45648. * Floor meshes that will be used for teleport
  45649. */
  45650. floorMeshes?: Array<AbstractMesh>;
  45651. /**
  45652. * If set to true, the first frame will not be used to reset position
  45653. * The first frame is mainly used when copying transformation from the old camera
  45654. * Mainly used in AR
  45655. */
  45656. ignoreNativeCameraTransformation?: boolean;
  45657. /**
  45658. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45659. */
  45660. inputOptions?: IWebXRInputOptions;
  45661. /**
  45662. * optional configuration for the output canvas
  45663. */
  45664. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45665. /**
  45666. * optional UI options. This can be used among other to change session mode and reference space type
  45667. */
  45668. uiOptions?: WebXREnterExitUIOptions;
  45669. /**
  45670. * When loading teleportation and pointer select, use stable versions instead of latest.
  45671. */
  45672. useStablePlugins?: boolean;
  45673. /**
  45674. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  45675. */
  45676. renderingGroupId?: number;
  45677. /**
  45678. * A list of optional features to init the session with
  45679. * If set to true, all features we support will be added
  45680. */
  45681. optionalFeatures?: boolean | string[];
  45682. }
  45683. /**
  45684. * Default experience which provides a similar setup to the previous webVRExperience
  45685. */
  45686. export class WebXRDefaultExperience {
  45687. /**
  45688. * Base experience
  45689. */
  45690. baseExperience: WebXRExperienceHelper;
  45691. /**
  45692. * Enables ui for entering/exiting xr
  45693. */
  45694. enterExitUI: WebXREnterExitUI;
  45695. /**
  45696. * Input experience extension
  45697. */
  45698. input: WebXRInput;
  45699. /**
  45700. * Enables laser pointer and selection
  45701. */
  45702. pointerSelection: WebXRControllerPointerSelection;
  45703. /**
  45704. * Default target xr should render to
  45705. */
  45706. renderTarget: WebXRRenderTarget;
  45707. /**
  45708. * Enables teleportation
  45709. */
  45710. teleportation: WebXRMotionControllerTeleportation;
  45711. private constructor();
  45712. /**
  45713. * Creates the default xr experience
  45714. * @param scene scene
  45715. * @param options options for basic configuration
  45716. * @returns resulting WebXRDefaultExperience
  45717. */
  45718. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45719. /**
  45720. * DIsposes of the experience helper
  45721. */
  45722. dispose(): void;
  45723. }
  45724. }
  45725. declare module BABYLON {
  45726. /**
  45727. * Options to modify the vr teleportation behavior.
  45728. */
  45729. export interface VRTeleportationOptions {
  45730. /**
  45731. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45732. */
  45733. floorMeshName?: string;
  45734. /**
  45735. * A list of meshes to be used as the teleportation floor. (default: empty)
  45736. */
  45737. floorMeshes?: Mesh[];
  45738. /**
  45739. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45740. */
  45741. teleportationMode?: number;
  45742. /**
  45743. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45744. */
  45745. teleportationTime?: number;
  45746. /**
  45747. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45748. */
  45749. teleportationSpeed?: number;
  45750. /**
  45751. * The easing function used in the animation or null for Linear. (default CircleEase)
  45752. */
  45753. easingFunction?: EasingFunction;
  45754. }
  45755. /**
  45756. * Options to modify the vr experience helper's behavior.
  45757. */
  45758. export interface VRExperienceHelperOptions extends WebVROptions {
  45759. /**
  45760. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45761. */
  45762. createDeviceOrientationCamera?: boolean;
  45763. /**
  45764. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45765. */
  45766. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45767. /**
  45768. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45769. */
  45770. laserToggle?: boolean;
  45771. /**
  45772. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45773. */
  45774. floorMeshes?: Mesh[];
  45775. /**
  45776. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45777. */
  45778. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45779. /**
  45780. * Defines if WebXR should be used instead of WebVR (if available)
  45781. */
  45782. useXR?: boolean;
  45783. }
  45784. /**
  45785. * Event containing information after VR has been entered
  45786. */
  45787. export class OnAfterEnteringVRObservableEvent {
  45788. /**
  45789. * If entering vr was successful
  45790. */
  45791. success: boolean;
  45792. }
  45793. /**
  45794. * Helps to quickly add VR support to an existing scene.
  45795. * See http://doc.babylonjs.com/how_to/webvr_helper
  45796. */
  45797. export class VRExperienceHelper {
  45798. /** Options to modify the vr experience helper's behavior. */
  45799. webVROptions: VRExperienceHelperOptions;
  45800. private _scene;
  45801. private _position;
  45802. private _btnVR;
  45803. private _btnVRDisplayed;
  45804. private _webVRsupported;
  45805. private _webVRready;
  45806. private _webVRrequesting;
  45807. private _webVRpresenting;
  45808. private _hasEnteredVR;
  45809. private _fullscreenVRpresenting;
  45810. private _inputElement;
  45811. private _webVRCamera;
  45812. private _vrDeviceOrientationCamera;
  45813. private _deviceOrientationCamera;
  45814. private _existingCamera;
  45815. private _onKeyDown;
  45816. private _onVrDisplayPresentChange;
  45817. private _onVRDisplayChanged;
  45818. private _onVRRequestPresentStart;
  45819. private _onVRRequestPresentComplete;
  45820. /**
  45821. * 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)
  45822. */
  45823. enableGazeEvenWhenNoPointerLock: boolean;
  45824. /**
  45825. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45826. */
  45827. exitVROnDoubleTap: boolean;
  45828. /**
  45829. * Observable raised right before entering VR.
  45830. */
  45831. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45832. /**
  45833. * Observable raised when entering VR has completed.
  45834. */
  45835. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45836. /**
  45837. * Observable raised when exiting VR.
  45838. */
  45839. onExitingVRObservable: Observable<VRExperienceHelper>;
  45840. /**
  45841. * Observable raised when controller mesh is loaded.
  45842. */
  45843. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45844. /** Return this.onEnteringVRObservable
  45845. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45846. */
  45847. get onEnteringVR(): Observable<VRExperienceHelper>;
  45848. /** Return this.onExitingVRObservable
  45849. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45850. */
  45851. get onExitingVR(): Observable<VRExperienceHelper>;
  45852. /** Return this.onControllerMeshLoadedObservable
  45853. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45854. */
  45855. get onControllerMeshLoaded(): Observable<WebVRController>;
  45856. private _rayLength;
  45857. private _useCustomVRButton;
  45858. private _teleportationRequested;
  45859. private _teleportActive;
  45860. private _floorMeshName;
  45861. private _floorMeshesCollection;
  45862. private _teleportationMode;
  45863. private _teleportationTime;
  45864. private _teleportationSpeed;
  45865. private _teleportationEasing;
  45866. private _rotationAllowed;
  45867. private _teleportBackwardsVector;
  45868. private _teleportationTarget;
  45869. private _isDefaultTeleportationTarget;
  45870. private _postProcessMove;
  45871. private _teleportationFillColor;
  45872. private _teleportationBorderColor;
  45873. private _rotationAngle;
  45874. private _haloCenter;
  45875. private _cameraGazer;
  45876. private _padSensibilityUp;
  45877. private _padSensibilityDown;
  45878. private _leftController;
  45879. private _rightController;
  45880. private _gazeColor;
  45881. private _laserColor;
  45882. private _pickedLaserColor;
  45883. private _pickedGazeColor;
  45884. /**
  45885. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45886. */
  45887. onNewMeshSelected: Observable<AbstractMesh>;
  45888. /**
  45889. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45890. * This observable will provide the mesh and the controller used to select the mesh
  45891. */
  45892. onMeshSelectedWithController: Observable<{
  45893. mesh: AbstractMesh;
  45894. controller: WebVRController;
  45895. }>;
  45896. /**
  45897. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45898. */
  45899. onNewMeshPicked: Observable<PickingInfo>;
  45900. private _circleEase;
  45901. /**
  45902. * Observable raised before camera teleportation
  45903. */
  45904. onBeforeCameraTeleport: Observable<Vector3>;
  45905. /**
  45906. * Observable raised after camera teleportation
  45907. */
  45908. onAfterCameraTeleport: Observable<Vector3>;
  45909. /**
  45910. * Observable raised when current selected mesh gets unselected
  45911. */
  45912. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45913. private _raySelectionPredicate;
  45914. /**
  45915. * To be optionaly changed by user to define custom ray selection
  45916. */
  45917. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45918. /**
  45919. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45920. */
  45921. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45922. /**
  45923. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45924. */
  45925. teleportationEnabled: boolean;
  45926. private _defaultHeight;
  45927. private _teleportationInitialized;
  45928. private _interactionsEnabled;
  45929. private _interactionsRequested;
  45930. private _displayGaze;
  45931. private _displayLaserPointer;
  45932. /**
  45933. * The mesh used to display where the user is going to teleport.
  45934. */
  45935. get teleportationTarget(): Mesh;
  45936. /**
  45937. * Sets the mesh to be used to display where the user is going to teleport.
  45938. */
  45939. set teleportationTarget(value: Mesh);
  45940. /**
  45941. * 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
  45942. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45943. * See http://doc.babylonjs.com/resources/baking_transformations
  45944. */
  45945. get gazeTrackerMesh(): Mesh;
  45946. set gazeTrackerMesh(value: Mesh);
  45947. /**
  45948. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45949. */
  45950. updateGazeTrackerScale: boolean;
  45951. /**
  45952. * If the gaze trackers color should be updated when selecting meshes
  45953. */
  45954. updateGazeTrackerColor: boolean;
  45955. /**
  45956. * If the controller laser color should be updated when selecting meshes
  45957. */
  45958. updateControllerLaserColor: boolean;
  45959. /**
  45960. * The gaze tracking mesh corresponding to the left controller
  45961. */
  45962. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45963. /**
  45964. * The gaze tracking mesh corresponding to the right controller
  45965. */
  45966. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45967. /**
  45968. * If the ray of the gaze should be displayed.
  45969. */
  45970. get displayGaze(): boolean;
  45971. /**
  45972. * Sets if the ray of the gaze should be displayed.
  45973. */
  45974. set displayGaze(value: boolean);
  45975. /**
  45976. * If the ray of the LaserPointer should be displayed.
  45977. */
  45978. get displayLaserPointer(): boolean;
  45979. /**
  45980. * Sets if the ray of the LaserPointer should be displayed.
  45981. */
  45982. set displayLaserPointer(value: boolean);
  45983. /**
  45984. * The deviceOrientationCamera used as the camera when not in VR.
  45985. */
  45986. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45987. /**
  45988. * Based on the current WebVR support, returns the current VR camera used.
  45989. */
  45990. get currentVRCamera(): Nullable<Camera>;
  45991. /**
  45992. * The webVRCamera which is used when in VR.
  45993. */
  45994. get webVRCamera(): WebVRFreeCamera;
  45995. /**
  45996. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45997. */
  45998. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45999. /**
  46000. * The html button that is used to trigger entering into VR.
  46001. */
  46002. get vrButton(): Nullable<HTMLButtonElement>;
  46003. private get _teleportationRequestInitiated();
  46004. /**
  46005. * Defines whether or not Pointer lock should be requested when switching to
  46006. * full screen.
  46007. */
  46008. requestPointerLockOnFullScreen: boolean;
  46009. /**
  46010. * If asking to force XR, this will be populated with the default xr experience
  46011. */
  46012. xr: WebXRDefaultExperience;
  46013. /**
  46014. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46015. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46016. */
  46017. xrTestDone: boolean;
  46018. /**
  46019. * Instantiates a VRExperienceHelper.
  46020. * Helps to quickly add VR support to an existing scene.
  46021. * @param scene The scene the VRExperienceHelper belongs to.
  46022. * @param webVROptions Options to modify the vr experience helper's behavior.
  46023. */
  46024. constructor(scene: Scene,
  46025. /** Options to modify the vr experience helper's behavior. */
  46026. webVROptions?: VRExperienceHelperOptions);
  46027. private completeVRInit;
  46028. private _onDefaultMeshLoaded;
  46029. private _onResize;
  46030. private _onFullscreenChange;
  46031. /**
  46032. * Gets a value indicating if we are currently in VR mode.
  46033. */
  46034. get isInVRMode(): boolean;
  46035. private onVrDisplayPresentChange;
  46036. private onVRDisplayChanged;
  46037. private moveButtonToBottomRight;
  46038. private displayVRButton;
  46039. private updateButtonVisibility;
  46040. private _cachedAngularSensibility;
  46041. /**
  46042. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46043. * Otherwise, will use the fullscreen API.
  46044. */
  46045. enterVR(): void;
  46046. /**
  46047. * Attempt to exit VR, or fullscreen.
  46048. */
  46049. exitVR(): void;
  46050. /**
  46051. * The position of the vr experience helper.
  46052. */
  46053. get position(): Vector3;
  46054. /**
  46055. * Sets the position of the vr experience helper.
  46056. */
  46057. set position(value: Vector3);
  46058. /**
  46059. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46060. */
  46061. enableInteractions(): void;
  46062. private get _noControllerIsActive();
  46063. private beforeRender;
  46064. private _isTeleportationFloor;
  46065. /**
  46066. * Adds a floor mesh to be used for teleportation.
  46067. * @param floorMesh the mesh to be used for teleportation.
  46068. */
  46069. addFloorMesh(floorMesh: Mesh): void;
  46070. /**
  46071. * Removes a floor mesh from being used for teleportation.
  46072. * @param floorMesh the mesh to be removed.
  46073. */
  46074. removeFloorMesh(floorMesh: Mesh): void;
  46075. /**
  46076. * Enables interactions and teleportation using the VR controllers and gaze.
  46077. * @param vrTeleportationOptions options to modify teleportation behavior.
  46078. */
  46079. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46080. private _onNewGamepadConnected;
  46081. private _tryEnableInteractionOnController;
  46082. private _onNewGamepadDisconnected;
  46083. private _enableInteractionOnController;
  46084. private _checkTeleportWithRay;
  46085. private _checkRotate;
  46086. private _checkTeleportBackwards;
  46087. private _enableTeleportationOnController;
  46088. private _createTeleportationCircles;
  46089. private _displayTeleportationTarget;
  46090. private _hideTeleportationTarget;
  46091. private _rotateCamera;
  46092. private _moveTeleportationSelectorTo;
  46093. private _workingVector;
  46094. private _workingQuaternion;
  46095. private _workingMatrix;
  46096. /**
  46097. * Time Constant Teleportation Mode
  46098. */
  46099. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46100. /**
  46101. * Speed Constant Teleportation Mode
  46102. */
  46103. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46104. /**
  46105. * Teleports the users feet to the desired location
  46106. * @param location The location where the user's feet should be placed
  46107. */
  46108. teleportCamera(location: Vector3): void;
  46109. private _convertNormalToDirectionOfRay;
  46110. private _castRayAndSelectObject;
  46111. private _notifySelectedMeshUnselected;
  46112. /**
  46113. * Permanently set new colors for the laser pointer
  46114. * @param color the new laser color
  46115. * @param pickedColor the new laser color when picked mesh detected
  46116. */
  46117. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46118. /**
  46119. * Set lighting enabled / disabled on the laser pointer of both controllers
  46120. * @param enabled should the lighting be enabled on the laser pointer
  46121. */
  46122. setLaserLightingState(enabled?: boolean): void;
  46123. /**
  46124. * Permanently set new colors for the gaze pointer
  46125. * @param color the new gaze color
  46126. * @param pickedColor the new gaze color when picked mesh detected
  46127. */
  46128. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46129. /**
  46130. * Sets the color of the laser ray from the vr controllers.
  46131. * @param color new color for the ray.
  46132. */
  46133. changeLaserColor(color: Color3): void;
  46134. /**
  46135. * Sets the color of the ray from the vr headsets gaze.
  46136. * @param color new color for the ray.
  46137. */
  46138. changeGazeColor(color: Color3): void;
  46139. /**
  46140. * Exits VR and disposes of the vr experience helper
  46141. */
  46142. dispose(): void;
  46143. /**
  46144. * Gets the name of the VRExperienceHelper class
  46145. * @returns "VRExperienceHelper"
  46146. */
  46147. getClassName(): string;
  46148. }
  46149. }
  46150. declare module BABYLON {
  46151. /**
  46152. * Contains an array of blocks representing the octree
  46153. */
  46154. export interface IOctreeContainer<T> {
  46155. /**
  46156. * Blocks within the octree
  46157. */
  46158. blocks: Array<OctreeBlock<T>>;
  46159. }
  46160. /**
  46161. * Class used to store a cell in an octree
  46162. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46163. */
  46164. export class OctreeBlock<T> {
  46165. /**
  46166. * Gets the content of the current block
  46167. */
  46168. entries: T[];
  46169. /**
  46170. * Gets the list of block children
  46171. */
  46172. blocks: Array<OctreeBlock<T>>;
  46173. private _depth;
  46174. private _maxDepth;
  46175. private _capacity;
  46176. private _minPoint;
  46177. private _maxPoint;
  46178. private _boundingVectors;
  46179. private _creationFunc;
  46180. /**
  46181. * Creates a new block
  46182. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46183. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46184. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46185. * @param depth defines the current depth of this block in the octree
  46186. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46187. * @param creationFunc defines a callback to call when an element is added to the block
  46188. */
  46189. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46190. /**
  46191. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46192. */
  46193. get capacity(): number;
  46194. /**
  46195. * Gets the minimum vector (in world space) of the block's bounding box
  46196. */
  46197. get minPoint(): Vector3;
  46198. /**
  46199. * Gets the maximum vector (in world space) of the block's bounding box
  46200. */
  46201. get maxPoint(): Vector3;
  46202. /**
  46203. * Add a new element to this block
  46204. * @param entry defines the element to add
  46205. */
  46206. addEntry(entry: T): void;
  46207. /**
  46208. * Remove an element from this block
  46209. * @param entry defines the element to remove
  46210. */
  46211. removeEntry(entry: T): void;
  46212. /**
  46213. * Add an array of elements to this block
  46214. * @param entries defines the array of elements to add
  46215. */
  46216. addEntries(entries: T[]): void;
  46217. /**
  46218. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46219. * @param frustumPlanes defines the frustum planes to test
  46220. * @param selection defines the array to store current content if selection is positive
  46221. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46222. */
  46223. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46224. /**
  46225. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46226. * @param sphereCenter defines the bounding sphere center
  46227. * @param sphereRadius defines the bounding sphere radius
  46228. * @param selection defines the array to store current content if selection is positive
  46229. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46230. */
  46231. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46232. /**
  46233. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46234. * @param ray defines the ray to test with
  46235. * @param selection defines the array to store current content if selection is positive
  46236. */
  46237. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46238. /**
  46239. * Subdivide the content into child blocks (this block will then be empty)
  46240. */
  46241. createInnerBlocks(): void;
  46242. /**
  46243. * @hidden
  46244. */
  46245. 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;
  46246. }
  46247. }
  46248. declare module BABYLON {
  46249. /**
  46250. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46251. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46252. */
  46253. export class Octree<T> {
  46254. /** 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.) */
  46255. maxDepth: number;
  46256. /**
  46257. * Blocks within the octree containing objects
  46258. */
  46259. blocks: Array<OctreeBlock<T>>;
  46260. /**
  46261. * Content stored in the octree
  46262. */
  46263. dynamicContent: T[];
  46264. private _maxBlockCapacity;
  46265. private _selectionContent;
  46266. private _creationFunc;
  46267. /**
  46268. * Creates a octree
  46269. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46270. * @param creationFunc function to be used to instatiate the octree
  46271. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46272. * @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.)
  46273. */
  46274. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46275. /** 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.) */
  46276. maxDepth?: number);
  46277. /**
  46278. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46279. * @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);
  46280. * @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);
  46281. * @param entries meshes to be added to the octree blocks
  46282. */
  46283. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46284. /**
  46285. * Adds a mesh to the octree
  46286. * @param entry Mesh to add to the octree
  46287. */
  46288. addMesh(entry: T): void;
  46289. /**
  46290. * Remove an element from the octree
  46291. * @param entry defines the element to remove
  46292. */
  46293. removeMesh(entry: T): void;
  46294. /**
  46295. * Selects an array of meshes within the frustum
  46296. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46297. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46298. * @returns array of meshes within the frustum
  46299. */
  46300. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46301. /**
  46302. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46303. * @param sphereCenter defines the bounding sphere center
  46304. * @param sphereRadius defines the bounding sphere radius
  46305. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46306. * @returns an array of objects that intersect the sphere
  46307. */
  46308. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46309. /**
  46310. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46311. * @param ray defines the ray to test with
  46312. * @returns array of intersected objects
  46313. */
  46314. intersectsRay(ray: Ray): SmartArray<T>;
  46315. /**
  46316. * Adds a mesh into the octree block if it intersects the block
  46317. */
  46318. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46319. /**
  46320. * Adds a submesh into the octree block if it intersects the block
  46321. */
  46322. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46323. }
  46324. }
  46325. declare module BABYLON {
  46326. interface Scene {
  46327. /**
  46328. * @hidden
  46329. * Backing Filed
  46330. */
  46331. _selectionOctree: Octree<AbstractMesh>;
  46332. /**
  46333. * Gets the octree used to boost mesh selection (picking)
  46334. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46335. */
  46336. selectionOctree: Octree<AbstractMesh>;
  46337. /**
  46338. * Creates or updates the octree used to boost selection (picking)
  46339. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46340. * @param maxCapacity defines the maximum capacity per leaf
  46341. * @param maxDepth defines the maximum depth of the octree
  46342. * @returns an octree of AbstractMesh
  46343. */
  46344. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46345. }
  46346. interface AbstractMesh {
  46347. /**
  46348. * @hidden
  46349. * Backing Field
  46350. */
  46351. _submeshesOctree: Octree<SubMesh>;
  46352. /**
  46353. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46354. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46355. * @param maxCapacity defines the maximum size of each block (64 by default)
  46356. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46357. * @returns the new octree
  46358. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46360. */
  46361. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46362. }
  46363. /**
  46364. * Defines the octree scene component responsible to manage any octrees
  46365. * in a given scene.
  46366. */
  46367. export class OctreeSceneComponent {
  46368. /**
  46369. * The component name help to identify the component in the list of scene components.
  46370. */
  46371. readonly name: string;
  46372. /**
  46373. * The scene the component belongs to.
  46374. */
  46375. scene: Scene;
  46376. /**
  46377. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46378. */
  46379. readonly checksIsEnabled: boolean;
  46380. /**
  46381. * Creates a new instance of the component for the given scene
  46382. * @param scene Defines the scene to register the component in
  46383. */
  46384. constructor(scene: Scene);
  46385. /**
  46386. * Registers the component in a given scene
  46387. */
  46388. register(): void;
  46389. /**
  46390. * Return the list of active meshes
  46391. * @returns the list of active meshes
  46392. */
  46393. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46394. /**
  46395. * Return the list of active sub meshes
  46396. * @param mesh The mesh to get the candidates sub meshes from
  46397. * @returns the list of active sub meshes
  46398. */
  46399. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46400. private _tempRay;
  46401. /**
  46402. * Return the list of sub meshes intersecting with a given local ray
  46403. * @param mesh defines the mesh to find the submesh for
  46404. * @param localRay defines the ray in local space
  46405. * @returns the list of intersecting sub meshes
  46406. */
  46407. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46408. /**
  46409. * Return the list of sub meshes colliding with a collider
  46410. * @param mesh defines the mesh to find the submesh for
  46411. * @param collider defines the collider to evaluate the collision against
  46412. * @returns the list of colliding sub meshes
  46413. */
  46414. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46415. /**
  46416. * Rebuilds the elements related to this component in case of
  46417. * context lost for instance.
  46418. */
  46419. rebuild(): void;
  46420. /**
  46421. * Disposes the component and the associated ressources.
  46422. */
  46423. dispose(): void;
  46424. }
  46425. }
  46426. declare module BABYLON {
  46427. /**
  46428. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46429. */
  46430. export class Gizmo implements IDisposable {
  46431. /** The utility layer the gizmo will be added to */
  46432. gizmoLayer: UtilityLayerRenderer;
  46433. /**
  46434. * The root mesh of the gizmo
  46435. */
  46436. _rootMesh: Mesh;
  46437. private _attachedMesh;
  46438. /**
  46439. * Ratio for the scale of the gizmo (Default: 1)
  46440. */
  46441. scaleRatio: number;
  46442. /**
  46443. * If a custom mesh has been set (Default: false)
  46444. */
  46445. protected _customMeshSet: boolean;
  46446. /**
  46447. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46448. * * When set, interactions will be enabled
  46449. */
  46450. get attachedMesh(): Nullable<AbstractMesh>;
  46451. set attachedMesh(value: Nullable<AbstractMesh>);
  46452. /**
  46453. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46454. * @param mesh The mesh to replace the default mesh of the gizmo
  46455. */
  46456. setCustomMesh(mesh: Mesh): void;
  46457. /**
  46458. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46459. */
  46460. updateGizmoRotationToMatchAttachedMesh: boolean;
  46461. /**
  46462. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46463. */
  46464. updateGizmoPositionToMatchAttachedMesh: boolean;
  46465. /**
  46466. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46467. */
  46468. updateScale: boolean;
  46469. protected _interactionsEnabled: boolean;
  46470. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46471. private _beforeRenderObserver;
  46472. private _tempVector;
  46473. /**
  46474. * Creates a gizmo
  46475. * @param gizmoLayer The utility layer the gizmo will be added to
  46476. */
  46477. constructor(
  46478. /** The utility layer the gizmo will be added to */
  46479. gizmoLayer?: UtilityLayerRenderer);
  46480. /**
  46481. * Updates the gizmo to match the attached mesh's position/rotation
  46482. */
  46483. protected _update(): void;
  46484. /**
  46485. * Disposes of the gizmo
  46486. */
  46487. dispose(): void;
  46488. }
  46489. }
  46490. declare module BABYLON {
  46491. /**
  46492. * Single plane drag gizmo
  46493. */
  46494. export class PlaneDragGizmo extends Gizmo {
  46495. /**
  46496. * Drag behavior responsible for the gizmos dragging interactions
  46497. */
  46498. dragBehavior: PointerDragBehavior;
  46499. private _pointerObserver;
  46500. /**
  46501. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46502. */
  46503. snapDistance: number;
  46504. /**
  46505. * Event that fires each time the gizmo snaps to a new location.
  46506. * * snapDistance is the the change in distance
  46507. */
  46508. onSnapObservable: Observable<{
  46509. snapDistance: number;
  46510. }>;
  46511. private _plane;
  46512. private _coloredMaterial;
  46513. private _hoverMaterial;
  46514. private _isEnabled;
  46515. private _parent;
  46516. /** @hidden */
  46517. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46518. /** @hidden */
  46519. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46520. /**
  46521. * Creates a PlaneDragGizmo
  46522. * @param gizmoLayer The utility layer the gizmo will be added to
  46523. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46524. * @param color The color of the gizmo
  46525. */
  46526. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46527. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46528. /**
  46529. * If the gizmo is enabled
  46530. */
  46531. set isEnabled(value: boolean);
  46532. get isEnabled(): boolean;
  46533. /**
  46534. * Disposes of the gizmo
  46535. */
  46536. dispose(): void;
  46537. }
  46538. }
  46539. declare module BABYLON {
  46540. /**
  46541. * Gizmo that enables dragging a mesh along 3 axis
  46542. */
  46543. export class PositionGizmo extends Gizmo {
  46544. /**
  46545. * Internal gizmo used for interactions on the x axis
  46546. */
  46547. xGizmo: AxisDragGizmo;
  46548. /**
  46549. * Internal gizmo used for interactions on the y axis
  46550. */
  46551. yGizmo: AxisDragGizmo;
  46552. /**
  46553. * Internal gizmo used for interactions on the z axis
  46554. */
  46555. zGizmo: AxisDragGizmo;
  46556. /**
  46557. * Internal gizmo used for interactions on the yz plane
  46558. */
  46559. xPlaneGizmo: PlaneDragGizmo;
  46560. /**
  46561. * Internal gizmo used for interactions on the xz plane
  46562. */
  46563. yPlaneGizmo: PlaneDragGizmo;
  46564. /**
  46565. * Internal gizmo used for interactions on the xy plane
  46566. */
  46567. zPlaneGizmo: PlaneDragGizmo;
  46568. /**
  46569. * private variables
  46570. */
  46571. private _meshAttached;
  46572. private _updateGizmoRotationToMatchAttachedMesh;
  46573. private _snapDistance;
  46574. private _scaleRatio;
  46575. /** Fires an event when any of it's sub gizmos are dragged */
  46576. onDragStartObservable: Observable<unknown>;
  46577. /** Fires an event when any of it's sub gizmos are released from dragging */
  46578. onDragEndObservable: Observable<unknown>;
  46579. /**
  46580. * If set to true, planar drag is enabled
  46581. */
  46582. private _planarGizmoEnabled;
  46583. get attachedMesh(): Nullable<AbstractMesh>;
  46584. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46585. /**
  46586. * Creates a PositionGizmo
  46587. * @param gizmoLayer The utility layer the gizmo will be added to
  46588. */
  46589. constructor(gizmoLayer?: UtilityLayerRenderer);
  46590. /**
  46591. * If the planar drag gizmo is enabled
  46592. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46593. */
  46594. set planarGizmoEnabled(value: boolean);
  46595. get planarGizmoEnabled(): boolean;
  46596. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46597. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46598. /**
  46599. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46600. */
  46601. set snapDistance(value: number);
  46602. get snapDistance(): number;
  46603. /**
  46604. * Ratio for the scale of the gizmo (Default: 1)
  46605. */
  46606. set scaleRatio(value: number);
  46607. get scaleRatio(): number;
  46608. /**
  46609. * Disposes of the gizmo
  46610. */
  46611. dispose(): void;
  46612. /**
  46613. * CustomMeshes are not supported by this gizmo
  46614. * @param mesh The mesh to replace the default mesh of the gizmo
  46615. */
  46616. setCustomMesh(mesh: Mesh): void;
  46617. }
  46618. }
  46619. declare module BABYLON {
  46620. /**
  46621. * Single axis drag gizmo
  46622. */
  46623. export class AxisDragGizmo extends Gizmo {
  46624. /**
  46625. * Drag behavior responsible for the gizmos dragging interactions
  46626. */
  46627. dragBehavior: PointerDragBehavior;
  46628. private _pointerObserver;
  46629. /**
  46630. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46631. */
  46632. snapDistance: number;
  46633. /**
  46634. * Event that fires each time the gizmo snaps to a new location.
  46635. * * snapDistance is the the change in distance
  46636. */
  46637. onSnapObservable: Observable<{
  46638. snapDistance: number;
  46639. }>;
  46640. private _isEnabled;
  46641. private _parent;
  46642. private _arrow;
  46643. private _coloredMaterial;
  46644. private _hoverMaterial;
  46645. /** @hidden */
  46646. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46647. /** @hidden */
  46648. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46649. /**
  46650. * Creates an AxisDragGizmo
  46651. * @param gizmoLayer The utility layer the gizmo will be added to
  46652. * @param dragAxis The axis which the gizmo will be able to drag on
  46653. * @param color The color of the gizmo
  46654. */
  46655. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46656. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46657. /**
  46658. * If the gizmo is enabled
  46659. */
  46660. set isEnabled(value: boolean);
  46661. get isEnabled(): boolean;
  46662. /**
  46663. * Disposes of the gizmo
  46664. */
  46665. dispose(): void;
  46666. }
  46667. }
  46668. declare module BABYLON.Debug {
  46669. /**
  46670. * The Axes viewer will show 3 axes in a specific point in space
  46671. */
  46672. export class AxesViewer {
  46673. private _xAxis;
  46674. private _yAxis;
  46675. private _zAxis;
  46676. private _scaleLinesFactor;
  46677. private _instanced;
  46678. /**
  46679. * Gets the hosting scene
  46680. */
  46681. scene: Scene;
  46682. /**
  46683. * Gets or sets a number used to scale line length
  46684. */
  46685. scaleLines: number;
  46686. /** Gets the node hierarchy used to render x-axis */
  46687. get xAxis(): TransformNode;
  46688. /** Gets the node hierarchy used to render y-axis */
  46689. get yAxis(): TransformNode;
  46690. /** Gets the node hierarchy used to render z-axis */
  46691. get zAxis(): TransformNode;
  46692. /**
  46693. * Creates a new AxesViewer
  46694. * @param scene defines the hosting scene
  46695. * @param scaleLines defines a number used to scale line length (1 by default)
  46696. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46697. * @param xAxis defines the node hierarchy used to render the x-axis
  46698. * @param yAxis defines the node hierarchy used to render the y-axis
  46699. * @param zAxis defines the node hierarchy used to render the z-axis
  46700. */
  46701. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46702. /**
  46703. * Force the viewer to update
  46704. * @param position defines the position of the viewer
  46705. * @param xaxis defines the x axis of the viewer
  46706. * @param yaxis defines the y axis of the viewer
  46707. * @param zaxis defines the z axis of the viewer
  46708. */
  46709. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46710. /**
  46711. * Creates an instance of this axes viewer.
  46712. * @returns a new axes viewer with instanced meshes
  46713. */
  46714. createInstance(): AxesViewer;
  46715. /** Releases resources */
  46716. dispose(): void;
  46717. private static _SetRenderingGroupId;
  46718. }
  46719. }
  46720. declare module BABYLON.Debug {
  46721. /**
  46722. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46723. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46724. */
  46725. export class BoneAxesViewer extends AxesViewer {
  46726. /**
  46727. * Gets or sets the target mesh where to display the axes viewer
  46728. */
  46729. mesh: Nullable<Mesh>;
  46730. /**
  46731. * Gets or sets the target bone where to display the axes viewer
  46732. */
  46733. bone: Nullable<Bone>;
  46734. /** Gets current position */
  46735. pos: Vector3;
  46736. /** Gets direction of X axis */
  46737. xaxis: Vector3;
  46738. /** Gets direction of Y axis */
  46739. yaxis: Vector3;
  46740. /** Gets direction of Z axis */
  46741. zaxis: Vector3;
  46742. /**
  46743. * Creates a new BoneAxesViewer
  46744. * @param scene defines the hosting scene
  46745. * @param bone defines the target bone
  46746. * @param mesh defines the target mesh
  46747. * @param scaleLines defines a scaling factor for line length (1 by default)
  46748. */
  46749. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46750. /**
  46751. * Force the viewer to update
  46752. */
  46753. update(): void;
  46754. /** Releases resources */
  46755. dispose(): void;
  46756. }
  46757. }
  46758. declare module BABYLON {
  46759. /**
  46760. * Interface used to define scene explorer extensibility option
  46761. */
  46762. export interface IExplorerExtensibilityOption {
  46763. /**
  46764. * Define the option label
  46765. */
  46766. label: string;
  46767. /**
  46768. * Defines the action to execute on click
  46769. */
  46770. action: (entity: any) => void;
  46771. }
  46772. /**
  46773. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46774. */
  46775. export interface IExplorerExtensibilityGroup {
  46776. /**
  46777. * Defines a predicate to test if a given type mut be extended
  46778. */
  46779. predicate: (entity: any) => boolean;
  46780. /**
  46781. * Gets the list of options added to a type
  46782. */
  46783. entries: IExplorerExtensibilityOption[];
  46784. }
  46785. /**
  46786. * Interface used to define the options to use to create the Inspector
  46787. */
  46788. export interface IInspectorOptions {
  46789. /**
  46790. * Display in overlay mode (default: false)
  46791. */
  46792. overlay?: boolean;
  46793. /**
  46794. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46795. */
  46796. globalRoot?: HTMLElement;
  46797. /**
  46798. * Display the Scene explorer
  46799. */
  46800. showExplorer?: boolean;
  46801. /**
  46802. * Display the property inspector
  46803. */
  46804. showInspector?: boolean;
  46805. /**
  46806. * Display in embed mode (both panes on the right)
  46807. */
  46808. embedMode?: boolean;
  46809. /**
  46810. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46811. */
  46812. handleResize?: boolean;
  46813. /**
  46814. * Allow the panes to popup (default: true)
  46815. */
  46816. enablePopup?: boolean;
  46817. /**
  46818. * Allow the panes to be closed by users (default: true)
  46819. */
  46820. enableClose?: boolean;
  46821. /**
  46822. * Optional list of extensibility entries
  46823. */
  46824. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46825. /**
  46826. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46827. */
  46828. inspectorURL?: string;
  46829. /**
  46830. * Optional initial tab (default to DebugLayerTab.Properties)
  46831. */
  46832. initialTab?: DebugLayerTab;
  46833. }
  46834. interface Scene {
  46835. /**
  46836. * @hidden
  46837. * Backing field
  46838. */
  46839. _debugLayer: DebugLayer;
  46840. /**
  46841. * Gets the debug layer (aka Inspector) associated with the scene
  46842. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46843. */
  46844. debugLayer: DebugLayer;
  46845. }
  46846. /**
  46847. * Enum of inspector action tab
  46848. */
  46849. export enum DebugLayerTab {
  46850. /**
  46851. * Properties tag (default)
  46852. */
  46853. Properties = 0,
  46854. /**
  46855. * Debug tab
  46856. */
  46857. Debug = 1,
  46858. /**
  46859. * Statistics tab
  46860. */
  46861. Statistics = 2,
  46862. /**
  46863. * Tools tab
  46864. */
  46865. Tools = 3,
  46866. /**
  46867. * Settings tab
  46868. */
  46869. Settings = 4
  46870. }
  46871. /**
  46872. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46873. * what is happening in your scene
  46874. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46875. */
  46876. export class DebugLayer {
  46877. /**
  46878. * Define the url to get the inspector script from.
  46879. * By default it uses the babylonjs CDN.
  46880. * @ignoreNaming
  46881. */
  46882. static InspectorURL: string;
  46883. private _scene;
  46884. private BJSINSPECTOR;
  46885. private _onPropertyChangedObservable?;
  46886. /**
  46887. * Observable triggered when a property is changed through the inspector.
  46888. */
  46889. get onPropertyChangedObservable(): any;
  46890. /**
  46891. * Instantiates a new debug layer.
  46892. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46893. * what is happening in your scene
  46894. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46895. * @param scene Defines the scene to inspect
  46896. */
  46897. constructor(scene: Scene);
  46898. /** Creates the inspector window. */
  46899. private _createInspector;
  46900. /**
  46901. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46902. * @param entity defines the entity to select
  46903. * @param lineContainerTitle defines the specific block to highlight
  46904. */
  46905. select(entity: any, lineContainerTitle?: string): void;
  46906. /** Get the inspector from bundle or global */
  46907. private _getGlobalInspector;
  46908. /**
  46909. * Get if the inspector is visible or not.
  46910. * @returns true if visible otherwise, false
  46911. */
  46912. isVisible(): boolean;
  46913. /**
  46914. * Hide the inspector and close its window.
  46915. */
  46916. hide(): void;
  46917. /**
  46918. * Update the scene in the inspector
  46919. */
  46920. setAsActiveScene(): void;
  46921. /**
  46922. * Launch the debugLayer.
  46923. * @param config Define the configuration of the inspector
  46924. * @return a promise fulfilled when the debug layer is visible
  46925. */
  46926. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46927. }
  46928. }
  46929. declare module BABYLON {
  46930. /**
  46931. * Class containing static functions to help procedurally build meshes
  46932. */
  46933. export class BoxBuilder {
  46934. /**
  46935. * Creates a box mesh
  46936. * * The parameter `size` sets the size (float) of each box side (default 1)
  46937. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46938. * * 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)
  46939. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46941. * * 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
  46942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46943. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46944. * @param name defines the name of the mesh
  46945. * @param options defines the options used to create the mesh
  46946. * @param scene defines the hosting scene
  46947. * @returns the box mesh
  46948. */
  46949. static CreateBox(name: string, options: {
  46950. size?: number;
  46951. width?: number;
  46952. height?: number;
  46953. depth?: number;
  46954. faceUV?: Vector4[];
  46955. faceColors?: Color4[];
  46956. sideOrientation?: number;
  46957. frontUVs?: Vector4;
  46958. backUVs?: Vector4;
  46959. wrap?: boolean;
  46960. topBaseAt?: number;
  46961. bottomBaseAt?: number;
  46962. updatable?: boolean;
  46963. }, scene?: Nullable<Scene>): Mesh;
  46964. }
  46965. }
  46966. declare module BABYLON.Debug {
  46967. /**
  46968. * Used to show the physics impostor around the specific mesh
  46969. */
  46970. export class PhysicsViewer {
  46971. /** @hidden */
  46972. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46973. /** @hidden */
  46974. protected _meshes: Array<Nullable<AbstractMesh>>;
  46975. /** @hidden */
  46976. protected _scene: Nullable<Scene>;
  46977. /** @hidden */
  46978. protected _numMeshes: number;
  46979. /** @hidden */
  46980. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46981. private _renderFunction;
  46982. private _utilityLayer;
  46983. private _debugBoxMesh;
  46984. private _debugSphereMesh;
  46985. private _debugCylinderMesh;
  46986. private _debugMaterial;
  46987. private _debugMeshMeshes;
  46988. /**
  46989. * Creates a new PhysicsViewer
  46990. * @param scene defines the hosting scene
  46991. */
  46992. constructor(scene: Scene);
  46993. /** @hidden */
  46994. protected _updateDebugMeshes(): void;
  46995. /**
  46996. * Renders a specified physic impostor
  46997. * @param impostor defines the impostor to render
  46998. * @param targetMesh defines the mesh represented by the impostor
  46999. * @returns the new debug mesh used to render the impostor
  47000. */
  47001. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47002. /**
  47003. * Hides a specified physic impostor
  47004. * @param impostor defines the impostor to hide
  47005. */
  47006. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47007. private _getDebugMaterial;
  47008. private _getDebugBoxMesh;
  47009. private _getDebugSphereMesh;
  47010. private _getDebugCylinderMesh;
  47011. private _getDebugMeshMesh;
  47012. private _getDebugMesh;
  47013. /** Releases all resources */
  47014. dispose(): void;
  47015. }
  47016. }
  47017. declare module BABYLON {
  47018. /**
  47019. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47020. * in order to better appreciate the issue one might have.
  47021. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47022. */
  47023. export class RayHelper {
  47024. /**
  47025. * Defines the ray we are currently tryin to visualize.
  47026. */
  47027. ray: Nullable<Ray>;
  47028. private _renderPoints;
  47029. private _renderLine;
  47030. private _renderFunction;
  47031. private _scene;
  47032. private _updateToMeshFunction;
  47033. private _attachedToMesh;
  47034. private _meshSpaceDirection;
  47035. private _meshSpaceOrigin;
  47036. /**
  47037. * Helper function to create a colored helper in a scene in one line.
  47038. * @param ray Defines the ray we are currently tryin to visualize
  47039. * @param scene Defines the scene the ray is used in
  47040. * @param color Defines the color we want to see the ray in
  47041. * @returns The newly created ray helper.
  47042. */
  47043. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47044. /**
  47045. * Instantiate a new ray helper.
  47046. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47047. * in order to better appreciate the issue one might have.
  47048. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47049. * @param ray Defines the ray we are currently tryin to visualize
  47050. */
  47051. constructor(ray: Ray);
  47052. /**
  47053. * Shows the ray we are willing to debug.
  47054. * @param scene Defines the scene the ray needs to be rendered in
  47055. * @param color Defines the color the ray needs to be rendered in
  47056. */
  47057. show(scene: Scene, color?: Color3): void;
  47058. /**
  47059. * Hides the ray we are debugging.
  47060. */
  47061. hide(): void;
  47062. private _render;
  47063. /**
  47064. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47065. * @param mesh Defines the mesh we want the helper attached to
  47066. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47067. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47068. * @param length Defines the length of the ray
  47069. */
  47070. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47071. /**
  47072. * Detach the ray helper from the mesh it has previously been attached to.
  47073. */
  47074. detachFromMesh(): void;
  47075. private _updateToMesh;
  47076. /**
  47077. * Dispose the helper and release its associated resources.
  47078. */
  47079. dispose(): void;
  47080. }
  47081. }
  47082. declare module BABYLON.Debug {
  47083. /**
  47084. * Class used to render a debug view of a given skeleton
  47085. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47086. */
  47087. export class SkeletonViewer {
  47088. /** defines the skeleton to render */
  47089. skeleton: Skeleton;
  47090. /** defines the mesh attached to the skeleton */
  47091. mesh: AbstractMesh;
  47092. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47093. autoUpdateBonesMatrices: boolean;
  47094. /** defines the rendering group id to use with the viewer */
  47095. renderingGroupId: number;
  47096. /** Gets or sets the color used to render the skeleton */
  47097. color: Color3;
  47098. private _scene;
  47099. private _debugLines;
  47100. private _debugMesh;
  47101. private _isEnabled;
  47102. private _renderFunction;
  47103. private _utilityLayer;
  47104. /**
  47105. * Returns the mesh used to render the bones
  47106. */
  47107. get debugMesh(): Nullable<LinesMesh>;
  47108. /**
  47109. * Creates a new SkeletonViewer
  47110. * @param skeleton defines the skeleton to render
  47111. * @param mesh defines the mesh attached to the skeleton
  47112. * @param scene defines the hosting scene
  47113. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47114. * @param renderingGroupId defines the rendering group id to use with the viewer
  47115. */
  47116. constructor(
  47117. /** defines the skeleton to render */
  47118. skeleton: Skeleton,
  47119. /** defines the mesh attached to the skeleton */
  47120. mesh: AbstractMesh, scene: Scene,
  47121. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47122. autoUpdateBonesMatrices?: boolean,
  47123. /** defines the rendering group id to use with the viewer */
  47124. renderingGroupId?: number);
  47125. /** Gets or sets a boolean indicating if the viewer is enabled */
  47126. set isEnabled(value: boolean);
  47127. get isEnabled(): boolean;
  47128. private _getBonePosition;
  47129. private _getLinesForBonesWithLength;
  47130. private _getLinesForBonesNoLength;
  47131. /** Update the viewer to sync with current skeleton state */
  47132. update(): void;
  47133. /** Release associated resources */
  47134. dispose(): void;
  47135. }
  47136. }
  47137. declare module BABYLON {
  47138. /**
  47139. * This class will take all inputs from Keyboard, Pointer, and
  47140. * any Gamepads and provide a polling system that all devices
  47141. * will use. This class assumes that there will only be one
  47142. * pointer device and one keyboard.
  47143. */
  47144. export class DeviceInputSystem implements IDisposable {
  47145. /** POINTER_DEVICE */
  47146. static readonly POINTER_DEVICE: string;
  47147. /** KEYBOARD_DEVICE */
  47148. static readonly KEYBOARD_DEVICE: string;
  47149. /**
  47150. * Observable to be triggered when a device is connected
  47151. */
  47152. onDeviceConnectedObservable: Observable<string>;
  47153. /**
  47154. * Observable to be triggered when a device is disconnected
  47155. */
  47156. onDeviceDisconnectedObservable: Observable<string>;
  47157. private _inputs;
  47158. private _gamepads;
  47159. private _keyboardActive;
  47160. private _pointerActive;
  47161. private _elementToAttachTo;
  47162. private _keyboardDownEvent;
  47163. private _keyboardUpEvent;
  47164. private _pointerMoveEvent;
  47165. private _pointerDownEvent;
  47166. private _pointerUpEvent;
  47167. private _gamepadConnectedEvent;
  47168. private _gamepadDisconnectedEvent;
  47169. private static _MAX_KEYCODES;
  47170. private static _MAX_POINTER_INPUTS;
  47171. /**
  47172. * Default Constructor
  47173. * @param engine - engine to pull input element from
  47174. */
  47175. constructor(engine: Engine);
  47176. /**
  47177. * Checks for current device input value, given an id and input index
  47178. * @param deviceName Id of connected device
  47179. * @param inputIndex Index of device input
  47180. * @returns Current value of input
  47181. */
  47182. pollInput(deviceName: string, inputIndex: number): Nullable<number>;
  47183. /**
  47184. * Dispose of all the eventlisteners and clears the observables
  47185. */
  47186. dispose(): void;
  47187. /**
  47188. * Add device and inputs to device map
  47189. * @param deviceName Assigned name of device (may be SN)
  47190. * @param numberOfInputs Number of input entries to create for given device
  47191. */
  47192. private _registerDevice;
  47193. /**
  47194. * Given a specific device name, remove that device from the device map
  47195. * @param deviceName Name of device to be removed
  47196. */
  47197. private _unregisterDevice;
  47198. /**
  47199. * Handle all actions that come from keyboard interaction
  47200. */
  47201. private _handleKeyActions;
  47202. /**
  47203. * Handle all actions that come from pointer interaction
  47204. */
  47205. private _handlePointerActions;
  47206. /**
  47207. * Handle all actions that come from gamepad interaction
  47208. */
  47209. private _handleGamepadActions;
  47210. /**
  47211. * Update all non-event based devices with each frame
  47212. */
  47213. private _updateDevice;
  47214. }
  47215. }
  47216. declare module BABYLON {
  47217. /**
  47218. * Options to create the null engine
  47219. */
  47220. export class NullEngineOptions {
  47221. /**
  47222. * Render width (Default: 512)
  47223. */
  47224. renderWidth: number;
  47225. /**
  47226. * Render height (Default: 256)
  47227. */
  47228. renderHeight: number;
  47229. /**
  47230. * Texture size (Default: 512)
  47231. */
  47232. textureSize: number;
  47233. /**
  47234. * If delta time between frames should be constant
  47235. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47236. */
  47237. deterministicLockstep: boolean;
  47238. /**
  47239. * Maximum about of steps between frames (Default: 4)
  47240. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47241. */
  47242. lockstepMaxSteps: number;
  47243. }
  47244. /**
  47245. * The null engine class provides support for headless version of babylon.js.
  47246. * This can be used in server side scenario or for testing purposes
  47247. */
  47248. export class NullEngine extends Engine {
  47249. private _options;
  47250. /**
  47251. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47253. * @returns true if engine is in deterministic lock step mode
  47254. */
  47255. isDeterministicLockStep(): boolean;
  47256. /**
  47257. * Gets the max steps when engine is running in deterministic lock step
  47258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47259. * @returns the max steps
  47260. */
  47261. getLockstepMaxSteps(): number;
  47262. /**
  47263. * Gets the current hardware scaling level.
  47264. * By default the hardware scaling level is computed from the window device ratio.
  47265. * 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.
  47266. * @returns a number indicating the current hardware scaling level
  47267. */
  47268. getHardwareScalingLevel(): number;
  47269. constructor(options?: NullEngineOptions);
  47270. /**
  47271. * Creates a vertex buffer
  47272. * @param vertices the data for the vertex buffer
  47273. * @returns the new WebGL static buffer
  47274. */
  47275. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47276. /**
  47277. * Creates a new index buffer
  47278. * @param indices defines the content of the index buffer
  47279. * @param updatable defines if the index buffer must be updatable
  47280. * @returns a new webGL buffer
  47281. */
  47282. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47283. /**
  47284. * Clear the current render buffer or the current render target (if any is set up)
  47285. * @param color defines the color to use
  47286. * @param backBuffer defines if the back buffer must be cleared
  47287. * @param depth defines if the depth buffer must be cleared
  47288. * @param stencil defines if the stencil buffer must be cleared
  47289. */
  47290. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47291. /**
  47292. * Gets the current render width
  47293. * @param useScreen defines if screen size must be used (or the current render target if any)
  47294. * @returns a number defining the current render width
  47295. */
  47296. getRenderWidth(useScreen?: boolean): number;
  47297. /**
  47298. * Gets the current render height
  47299. * @param useScreen defines if screen size must be used (or the current render target if any)
  47300. * @returns a number defining the current render height
  47301. */
  47302. getRenderHeight(useScreen?: boolean): number;
  47303. /**
  47304. * Set the WebGL's viewport
  47305. * @param viewport defines the viewport element to be used
  47306. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  47307. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  47308. */
  47309. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  47310. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  47311. /**
  47312. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  47313. * @param pipelineContext defines the pipeline context to use
  47314. * @param uniformsNames defines the list of uniform names
  47315. * @returns an array of webGL uniform locations
  47316. */
  47317. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  47318. /**
  47319. * Gets the lsit of active attributes for a given webGL program
  47320. * @param pipelineContext defines the pipeline context to use
  47321. * @param attributesNames defines the list of attribute names to get
  47322. * @returns an array of indices indicating the offset of each attribute
  47323. */
  47324. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47325. /**
  47326. * Binds an effect to the webGL context
  47327. * @param effect defines the effect to bind
  47328. */
  47329. bindSamplers(effect: Effect): void;
  47330. /**
  47331. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  47332. * @param effect defines the effect to activate
  47333. */
  47334. enableEffect(effect: Effect): void;
  47335. /**
  47336. * Set various states to the webGL context
  47337. * @param culling defines backface culling state
  47338. * @param zOffset defines the value to apply to zOffset (0 by default)
  47339. * @param force defines if states must be applied even if cache is up to date
  47340. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  47341. */
  47342. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47343. /**
  47344. * Set the value of an uniform to an array of int32
  47345. * @param uniform defines the webGL uniform location where to store the value
  47346. * @param array defines the array of int32 to store
  47347. */
  47348. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47349. /**
  47350. * Set the value of an uniform to an array of int32 (stored as vec2)
  47351. * @param uniform defines the webGL uniform location where to store the value
  47352. * @param array defines the array of int32 to store
  47353. */
  47354. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47355. /**
  47356. * Set the value of an uniform to an array of int32 (stored as vec3)
  47357. * @param uniform defines the webGL uniform location where to store the value
  47358. * @param array defines the array of int32 to store
  47359. */
  47360. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47361. /**
  47362. * Set the value of an uniform to an array of int32 (stored as vec4)
  47363. * @param uniform defines the webGL uniform location where to store the value
  47364. * @param array defines the array of int32 to store
  47365. */
  47366. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47367. /**
  47368. * Set the value of an uniform to an array of float32
  47369. * @param uniform defines the webGL uniform location where to store the value
  47370. * @param array defines the array of float32 to store
  47371. */
  47372. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47373. /**
  47374. * Set the value of an uniform to an array of float32 (stored as vec2)
  47375. * @param uniform defines the webGL uniform location where to store the value
  47376. * @param array defines the array of float32 to store
  47377. */
  47378. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47379. /**
  47380. * Set the value of an uniform to an array of float32 (stored as vec3)
  47381. * @param uniform defines the webGL uniform location where to store the value
  47382. * @param array defines the array of float32 to store
  47383. */
  47384. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47385. /**
  47386. * Set the value of an uniform to an array of float32 (stored as vec4)
  47387. * @param uniform defines the webGL uniform location where to store the value
  47388. * @param array defines the array of float32 to store
  47389. */
  47390. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47391. /**
  47392. * Set the value of an uniform to an array of number
  47393. * @param uniform defines the webGL uniform location where to store the value
  47394. * @param array defines the array of number to store
  47395. */
  47396. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47397. /**
  47398. * Set the value of an uniform to an array of number (stored as vec2)
  47399. * @param uniform defines the webGL uniform location where to store the value
  47400. * @param array defines the array of number to store
  47401. */
  47402. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47403. /**
  47404. * Set the value of an uniform to an array of number (stored as vec3)
  47405. * @param uniform defines the webGL uniform location where to store the value
  47406. * @param array defines the array of number to store
  47407. */
  47408. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47409. /**
  47410. * Set the value of an uniform to an array of number (stored as vec4)
  47411. * @param uniform defines the webGL uniform location where to store the value
  47412. * @param array defines the array of number to store
  47413. */
  47414. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47415. /**
  47416. * Set the value of an uniform to an array of float32 (stored as matrices)
  47417. * @param uniform defines the webGL uniform location where to store the value
  47418. * @param matrices defines the array of float32 to store
  47419. */
  47420. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47421. /**
  47422. * Set the value of an uniform to a matrix (3x3)
  47423. * @param uniform defines the webGL uniform location where to store the value
  47424. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47425. */
  47426. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47427. /**
  47428. * Set the value of an uniform to a matrix (2x2)
  47429. * @param uniform defines the webGL uniform location where to store the value
  47430. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47431. */
  47432. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47433. /**
  47434. * Set the value of an uniform to a number (float)
  47435. * @param uniform defines the webGL uniform location where to store the value
  47436. * @param value defines the float number to store
  47437. */
  47438. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47439. /**
  47440. * Set the value of an uniform to a vec2
  47441. * @param uniform defines the webGL uniform location where to store the value
  47442. * @param x defines the 1st component of the value
  47443. * @param y defines the 2nd component of the value
  47444. */
  47445. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47446. /**
  47447. * Set the value of an uniform to a vec3
  47448. * @param uniform defines the webGL uniform location where to store the value
  47449. * @param x defines the 1st component of the value
  47450. * @param y defines the 2nd component of the value
  47451. * @param z defines the 3rd component of the value
  47452. */
  47453. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47454. /**
  47455. * Set the value of an uniform to a boolean
  47456. * @param uniform defines the webGL uniform location where to store the value
  47457. * @param bool defines the boolean to store
  47458. */
  47459. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47460. /**
  47461. * Set the value of an uniform to a vec4
  47462. * @param uniform defines the webGL uniform location where to store the value
  47463. * @param x defines the 1st component of the value
  47464. * @param y defines the 2nd component of the value
  47465. * @param z defines the 3rd component of the value
  47466. * @param w defines the 4th component of the value
  47467. */
  47468. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47469. /**
  47470. * Sets the current alpha mode
  47471. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47472. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47473. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47474. */
  47475. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47476. /**
  47477. * Bind webGl buffers directly to the webGL context
  47478. * @param vertexBuffers defines the vertex buffer to bind
  47479. * @param indexBuffer defines the index buffer to bind
  47480. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47481. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47482. * @param effect defines the effect associated with the vertex buffer
  47483. */
  47484. bindBuffers(vertexBuffers: {
  47485. [key: string]: VertexBuffer;
  47486. }, indexBuffer: DataBuffer, effect: Effect): void;
  47487. /**
  47488. * Force the entire cache to be cleared
  47489. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47490. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47491. */
  47492. wipeCaches(bruteForce?: boolean): void;
  47493. /**
  47494. * Send a draw order
  47495. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47496. * @param indexStart defines the starting index
  47497. * @param indexCount defines the number of index to draw
  47498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47499. */
  47500. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47501. /**
  47502. * Draw a list of indexed primitives
  47503. * @param fillMode defines the primitive to use
  47504. * @param indexStart defines the starting index
  47505. * @param indexCount defines the number of index to draw
  47506. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47507. */
  47508. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47509. /**
  47510. * Draw a list of unindexed primitives
  47511. * @param fillMode defines the primitive to use
  47512. * @param verticesStart defines the index of first vertex to draw
  47513. * @param verticesCount defines the count of vertices to draw
  47514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47515. */
  47516. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47517. /** @hidden */
  47518. _createTexture(): WebGLTexture;
  47519. /** @hidden */
  47520. _releaseTexture(texture: InternalTexture): void;
  47521. /**
  47522. * Usually called from Texture.ts.
  47523. * Passed information to create a WebGLTexture
  47524. * @param urlArg defines a value which contains one of the following:
  47525. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47526. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47527. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47528. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47529. * @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)
  47530. * @param scene needed for loading to the correct scene
  47531. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47532. * @param onLoad optional callback to be called upon successful completion
  47533. * @param onError optional callback to be called upon failure
  47534. * @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
  47535. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47536. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47537. * @param forcedExtension defines the extension to use to pick the right loader
  47538. * @param mimeType defines an optional mime type
  47539. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47540. */
  47541. 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;
  47542. /**
  47543. * Creates a new render target texture
  47544. * @param size defines the size of the texture
  47545. * @param options defines the options used to create the texture
  47546. * @returns a new render target texture stored in an InternalTexture
  47547. */
  47548. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47549. /**
  47550. * Update the sampling mode of a given texture
  47551. * @param samplingMode defines the required sampling mode
  47552. * @param texture defines the texture to update
  47553. */
  47554. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47555. /**
  47556. * Binds the frame buffer to the specified texture.
  47557. * @param texture The texture to render to or null for the default canvas
  47558. * @param faceIndex The face of the texture to render to in case of cube texture
  47559. * @param requiredWidth The width of the target to render to
  47560. * @param requiredHeight The height of the target to render to
  47561. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47562. * @param lodLevel defines le lod level to bind to the frame buffer
  47563. */
  47564. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47565. /**
  47566. * Unbind the current render target texture from the webGL context
  47567. * @param texture defines the render target texture to unbind
  47568. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47569. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47570. */
  47571. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47572. /**
  47573. * Creates a dynamic vertex buffer
  47574. * @param vertices the data for the dynamic vertex buffer
  47575. * @returns the new WebGL dynamic buffer
  47576. */
  47577. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47578. /**
  47579. * Update the content of a dynamic texture
  47580. * @param texture defines the texture to update
  47581. * @param canvas defines the canvas containing the source
  47582. * @param invertY defines if data must be stored with Y axis inverted
  47583. * @param premulAlpha defines if alpha is stored as premultiplied
  47584. * @param format defines the format of the data
  47585. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47586. */
  47587. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47588. /**
  47589. * Gets a boolean indicating if all created effects are ready
  47590. * @returns true if all effects are ready
  47591. */
  47592. areAllEffectsReady(): boolean;
  47593. /**
  47594. * @hidden
  47595. * Get the current error code of the webGL context
  47596. * @returns the error code
  47597. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47598. */
  47599. getError(): number;
  47600. /** @hidden */
  47601. _getUnpackAlignement(): number;
  47602. /** @hidden */
  47603. _unpackFlipY(value: boolean): void;
  47604. /**
  47605. * Update a dynamic index buffer
  47606. * @param indexBuffer defines the target index buffer
  47607. * @param indices defines the data to update
  47608. * @param offset defines the offset in the target index buffer where update should start
  47609. */
  47610. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47611. /**
  47612. * Updates a dynamic vertex buffer.
  47613. * @param vertexBuffer the vertex buffer to update
  47614. * @param vertices the data used to update the vertex buffer
  47615. * @param byteOffset the byte offset of the data (optional)
  47616. * @param byteLength the byte length of the data (optional)
  47617. */
  47618. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47619. /** @hidden */
  47620. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47621. /** @hidden */
  47622. _bindTexture(channel: number, texture: InternalTexture): void;
  47623. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47624. /**
  47625. * 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
  47626. */
  47627. releaseEffects(): void;
  47628. displayLoadingUI(): void;
  47629. hideLoadingUI(): void;
  47630. /** @hidden */
  47631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47632. /** @hidden */
  47633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47634. /** @hidden */
  47635. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47636. /** @hidden */
  47637. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47638. }
  47639. }
  47640. declare module BABYLON {
  47641. /**
  47642. * @hidden
  47643. **/
  47644. export class _TimeToken {
  47645. _startTimeQuery: Nullable<WebGLQuery>;
  47646. _endTimeQuery: Nullable<WebGLQuery>;
  47647. _timeElapsedQuery: Nullable<WebGLQuery>;
  47648. _timeElapsedQueryEnded: boolean;
  47649. }
  47650. }
  47651. declare module BABYLON {
  47652. /** @hidden */
  47653. export class _OcclusionDataStorage {
  47654. /** @hidden */
  47655. occlusionInternalRetryCounter: number;
  47656. /** @hidden */
  47657. isOcclusionQueryInProgress: boolean;
  47658. /** @hidden */
  47659. isOccluded: boolean;
  47660. /** @hidden */
  47661. occlusionRetryCount: number;
  47662. /** @hidden */
  47663. occlusionType: number;
  47664. /** @hidden */
  47665. occlusionQueryAlgorithmType: number;
  47666. }
  47667. interface Engine {
  47668. /**
  47669. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47670. * @return the new query
  47671. */
  47672. createQuery(): WebGLQuery;
  47673. /**
  47674. * Delete and release a webGL query
  47675. * @param query defines the query to delete
  47676. * @return the current engine
  47677. */
  47678. deleteQuery(query: WebGLQuery): Engine;
  47679. /**
  47680. * Check if a given query has resolved and got its value
  47681. * @param query defines the query to check
  47682. * @returns true if the query got its value
  47683. */
  47684. isQueryResultAvailable(query: WebGLQuery): boolean;
  47685. /**
  47686. * Gets the value of a given query
  47687. * @param query defines the query to check
  47688. * @returns the value of the query
  47689. */
  47690. getQueryResult(query: WebGLQuery): number;
  47691. /**
  47692. * Initiates an occlusion query
  47693. * @param algorithmType defines the algorithm to use
  47694. * @param query defines the query to use
  47695. * @returns the current engine
  47696. * @see http://doc.babylonjs.com/features/occlusionquery
  47697. */
  47698. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47699. /**
  47700. * Ends an occlusion query
  47701. * @see http://doc.babylonjs.com/features/occlusionquery
  47702. * @param algorithmType defines the algorithm to use
  47703. * @returns the current engine
  47704. */
  47705. endOcclusionQuery(algorithmType: number): Engine;
  47706. /**
  47707. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47708. * Please note that only one query can be issued at a time
  47709. * @returns a time token used to track the time span
  47710. */
  47711. startTimeQuery(): Nullable<_TimeToken>;
  47712. /**
  47713. * Ends a time query
  47714. * @param token defines the token used to measure the time span
  47715. * @returns the time spent (in ns)
  47716. */
  47717. endTimeQuery(token: _TimeToken): int;
  47718. /** @hidden */
  47719. _currentNonTimestampToken: Nullable<_TimeToken>;
  47720. /** @hidden */
  47721. _createTimeQuery(): WebGLQuery;
  47722. /** @hidden */
  47723. _deleteTimeQuery(query: WebGLQuery): void;
  47724. /** @hidden */
  47725. _getGlAlgorithmType(algorithmType: number): number;
  47726. /** @hidden */
  47727. _getTimeQueryResult(query: WebGLQuery): any;
  47728. /** @hidden */
  47729. _getTimeQueryAvailability(query: WebGLQuery): any;
  47730. }
  47731. interface AbstractMesh {
  47732. /**
  47733. * Backing filed
  47734. * @hidden
  47735. */
  47736. __occlusionDataStorage: _OcclusionDataStorage;
  47737. /**
  47738. * Access property
  47739. * @hidden
  47740. */
  47741. _occlusionDataStorage: _OcclusionDataStorage;
  47742. /**
  47743. * 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.
  47744. * The default value is -1 which means don't break the query and wait till the result
  47745. * @see http://doc.babylonjs.com/features/occlusionquery
  47746. */
  47747. occlusionRetryCount: number;
  47748. /**
  47749. * 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:
  47750. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47751. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47752. * * 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.
  47753. * @see http://doc.babylonjs.com/features/occlusionquery
  47754. */
  47755. occlusionType: number;
  47756. /**
  47757. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47758. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47759. * * 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.
  47760. * @see http://doc.babylonjs.com/features/occlusionquery
  47761. */
  47762. occlusionQueryAlgorithmType: number;
  47763. /**
  47764. * 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
  47765. * @see http://doc.babylonjs.com/features/occlusionquery
  47766. */
  47767. isOccluded: boolean;
  47768. /**
  47769. * Flag to check the progress status of the query
  47770. * @see http://doc.babylonjs.com/features/occlusionquery
  47771. */
  47772. isOcclusionQueryInProgress: boolean;
  47773. }
  47774. }
  47775. declare module BABYLON {
  47776. /** @hidden */
  47777. export var _forceTransformFeedbackToBundle: boolean;
  47778. interface Engine {
  47779. /**
  47780. * Creates a webGL transform feedback object
  47781. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47782. * @returns the webGL transform feedback object
  47783. */
  47784. createTransformFeedback(): WebGLTransformFeedback;
  47785. /**
  47786. * Delete a webGL transform feedback object
  47787. * @param value defines the webGL transform feedback object to delete
  47788. */
  47789. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47790. /**
  47791. * Bind a webGL transform feedback object to the webgl context
  47792. * @param value defines the webGL transform feedback object to bind
  47793. */
  47794. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47795. /**
  47796. * Begins a transform feedback operation
  47797. * @param usePoints defines if points or triangles must be used
  47798. */
  47799. beginTransformFeedback(usePoints: boolean): void;
  47800. /**
  47801. * Ends a transform feedback operation
  47802. */
  47803. endTransformFeedback(): void;
  47804. /**
  47805. * Specify the varyings to use with transform feedback
  47806. * @param program defines the associated webGL program
  47807. * @param value defines the list of strings representing the varying names
  47808. */
  47809. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47810. /**
  47811. * Bind a webGL buffer for a transform feedback operation
  47812. * @param value defines the webGL buffer to bind
  47813. */
  47814. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47815. }
  47816. }
  47817. declare module BABYLON {
  47818. /**
  47819. * Creation options of the multi render target texture.
  47820. */
  47821. export interface IMultiRenderTargetOptions {
  47822. /**
  47823. * Define if the texture needs to create mip maps after render.
  47824. */
  47825. generateMipMaps?: boolean;
  47826. /**
  47827. * Define the types of all the draw buffers we want to create
  47828. */
  47829. types?: number[];
  47830. /**
  47831. * Define the sampling modes of all the draw buffers we want to create
  47832. */
  47833. samplingModes?: number[];
  47834. /**
  47835. * Define if a depth buffer is required
  47836. */
  47837. generateDepthBuffer?: boolean;
  47838. /**
  47839. * Define if a stencil buffer is required
  47840. */
  47841. generateStencilBuffer?: boolean;
  47842. /**
  47843. * Define if a depth texture is required instead of a depth buffer
  47844. */
  47845. generateDepthTexture?: boolean;
  47846. /**
  47847. * Define the number of desired draw buffers
  47848. */
  47849. textureCount?: number;
  47850. /**
  47851. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47852. */
  47853. doNotChangeAspectRatio?: boolean;
  47854. /**
  47855. * Define the default type of the buffers we are creating
  47856. */
  47857. defaultType?: number;
  47858. }
  47859. /**
  47860. * A multi render target, like a render target provides the ability to render to a texture.
  47861. * Unlike the render target, it can render to several draw buffers in one draw.
  47862. * This is specially interesting in deferred rendering or for any effects requiring more than
  47863. * just one color from a single pass.
  47864. */
  47865. export class MultiRenderTarget extends RenderTargetTexture {
  47866. private _internalTextures;
  47867. private _textures;
  47868. private _multiRenderTargetOptions;
  47869. /**
  47870. * Get if draw buffers are currently supported by the used hardware and browser.
  47871. */
  47872. get isSupported(): boolean;
  47873. /**
  47874. * Get the list of textures generated by the multi render target.
  47875. */
  47876. get textures(): Texture[];
  47877. /**
  47878. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47879. */
  47880. get depthTexture(): Texture;
  47881. /**
  47882. * Set the wrapping mode on U of all the textures we are rendering to.
  47883. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47884. */
  47885. set wrapU(wrap: number);
  47886. /**
  47887. * Set the wrapping mode on V of all the textures we are rendering to.
  47888. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47889. */
  47890. set wrapV(wrap: number);
  47891. /**
  47892. * Instantiate a new multi render target texture.
  47893. * A multi render target, like a render target provides the ability to render to a texture.
  47894. * Unlike the render target, it can render to several draw buffers in one draw.
  47895. * This is specially interesting in deferred rendering or for any effects requiring more than
  47896. * just one color from a single pass.
  47897. * @param name Define the name of the texture
  47898. * @param size Define the size of the buffers to render to
  47899. * @param count Define the number of target we are rendering into
  47900. * @param scene Define the scene the texture belongs to
  47901. * @param options Define the options used to create the multi render target
  47902. */
  47903. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47904. /** @hidden */
  47905. _rebuild(): void;
  47906. private _createInternalTextures;
  47907. private _createTextures;
  47908. /**
  47909. * Define the number of samples used if MSAA is enabled.
  47910. */
  47911. get samples(): number;
  47912. set samples(value: number);
  47913. /**
  47914. * Resize all the textures in the multi render target.
  47915. * Be carrefull as it will recreate all the data in the new texture.
  47916. * @param size Define the new size
  47917. */
  47918. resize(size: any): void;
  47919. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47920. /**
  47921. * Dispose the render targets and their associated resources
  47922. */
  47923. dispose(): void;
  47924. /**
  47925. * Release all the underlying texture used as draw buffers.
  47926. */
  47927. releaseInternalTextures(): void;
  47928. }
  47929. }
  47930. declare module BABYLON {
  47931. interface ThinEngine {
  47932. /**
  47933. * Unbind a list of render target textures from the webGL context
  47934. * This is used only when drawBuffer extension or webGL2 are active
  47935. * @param textures defines the render target textures to unbind
  47936. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47937. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47938. */
  47939. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47940. /**
  47941. * Create a multi render target texture
  47942. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47943. * @param size defines the size of the texture
  47944. * @param options defines the creation options
  47945. * @returns the cube texture as an InternalTexture
  47946. */
  47947. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47948. /**
  47949. * Update the sample count for a given multiple render target texture
  47950. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47951. * @param textures defines the textures to update
  47952. * @param samples defines the sample count to set
  47953. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47954. */
  47955. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47956. }
  47957. }
  47958. declare module BABYLON {
  47959. /**
  47960. * Class used to define an additional view for the engine
  47961. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47962. */
  47963. export class EngineView {
  47964. /** Defines the canvas where to render the view */
  47965. target: HTMLCanvasElement;
  47966. /** Defines an optional camera used to render the view (will use active camera else) */
  47967. camera?: Camera;
  47968. }
  47969. interface Engine {
  47970. /**
  47971. * Gets or sets the HTML element to use for attaching events
  47972. */
  47973. inputElement: Nullable<HTMLElement>;
  47974. /**
  47975. * Gets the current engine view
  47976. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47977. */
  47978. activeView: Nullable<EngineView>;
  47979. /** Gets or sets the list of views */
  47980. views: EngineView[];
  47981. /**
  47982. * Register a new child canvas
  47983. * @param canvas defines the canvas to register
  47984. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47985. * @returns the associated view
  47986. */
  47987. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47988. /**
  47989. * Remove a registered child canvas
  47990. * @param canvas defines the canvas to remove
  47991. * @returns the current engine
  47992. */
  47993. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47994. }
  47995. }
  47996. declare module BABYLON {
  47997. interface Engine {
  47998. /** @hidden */
  47999. _excludedCompressedTextures: string[];
  48000. /** @hidden */
  48001. _textureFormatInUse: string;
  48002. /**
  48003. * Gets the list of texture formats supported
  48004. */
  48005. readonly texturesSupported: Array<string>;
  48006. /**
  48007. * Gets the texture format in use
  48008. */
  48009. readonly textureFormatInUse: Nullable<string>;
  48010. /**
  48011. * Set the compressed texture extensions or file names to skip.
  48012. *
  48013. * @param skippedFiles defines the list of those texture files you want to skip
  48014. * Example: [".dds", ".env", "myfile.png"]
  48015. */
  48016. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  48017. /**
  48018. * Set the compressed texture format to use, based on the formats you have, and the formats
  48019. * supported by the hardware / browser.
  48020. *
  48021. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  48022. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  48023. * to API arguments needed to compressed textures. This puts the burden on the container
  48024. * generator to house the arcane code for determining these for current & future formats.
  48025. *
  48026. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48027. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48028. *
  48029. * Note: The result of this call is not taken into account when a texture is base64.
  48030. *
  48031. * @param formatsAvailable defines the list of those format families you have created
  48032. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  48033. *
  48034. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  48035. * @returns The extension selected.
  48036. */
  48037. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  48038. }
  48039. }
  48040. declare module BABYLON {
  48041. /**
  48042. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48043. */
  48044. export interface CubeMapInfo {
  48045. /**
  48046. * The pixel array for the front face.
  48047. * This is stored in format, left to right, up to down format.
  48048. */
  48049. front: Nullable<ArrayBufferView>;
  48050. /**
  48051. * The pixel array for the back face.
  48052. * This is stored in format, left to right, up to down format.
  48053. */
  48054. back: Nullable<ArrayBufferView>;
  48055. /**
  48056. * The pixel array for the left face.
  48057. * This is stored in format, left to right, up to down format.
  48058. */
  48059. left: Nullable<ArrayBufferView>;
  48060. /**
  48061. * The pixel array for the right face.
  48062. * This is stored in format, left to right, up to down format.
  48063. */
  48064. right: Nullable<ArrayBufferView>;
  48065. /**
  48066. * The pixel array for the up face.
  48067. * This is stored in format, left to right, up to down format.
  48068. */
  48069. up: Nullable<ArrayBufferView>;
  48070. /**
  48071. * The pixel array for the down face.
  48072. * This is stored in format, left to right, up to down format.
  48073. */
  48074. down: Nullable<ArrayBufferView>;
  48075. /**
  48076. * The size of the cubemap stored.
  48077. *
  48078. * Each faces will be size * size pixels.
  48079. */
  48080. size: number;
  48081. /**
  48082. * The format of the texture.
  48083. *
  48084. * RGBA, RGB.
  48085. */
  48086. format: number;
  48087. /**
  48088. * The type of the texture data.
  48089. *
  48090. * UNSIGNED_INT, FLOAT.
  48091. */
  48092. type: number;
  48093. /**
  48094. * Specifies whether the texture is in gamma space.
  48095. */
  48096. gammaSpace: boolean;
  48097. }
  48098. /**
  48099. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48100. */
  48101. export class PanoramaToCubeMapTools {
  48102. private static FACE_LEFT;
  48103. private static FACE_RIGHT;
  48104. private static FACE_FRONT;
  48105. private static FACE_BACK;
  48106. private static FACE_DOWN;
  48107. private static FACE_UP;
  48108. /**
  48109. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48110. *
  48111. * @param float32Array The source data.
  48112. * @param inputWidth The width of the input panorama.
  48113. * @param inputHeight The height of the input panorama.
  48114. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48115. * @return The cubemap data
  48116. */
  48117. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48118. private static CreateCubemapTexture;
  48119. private static CalcProjectionSpherical;
  48120. }
  48121. }
  48122. declare module BABYLON {
  48123. /**
  48124. * Helper class dealing with the extraction of spherical polynomial dataArray
  48125. * from a cube map.
  48126. */
  48127. export class CubeMapToSphericalPolynomialTools {
  48128. private static FileFaces;
  48129. /**
  48130. * Converts a texture to the according Spherical Polynomial data.
  48131. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48132. *
  48133. * @param texture The texture to extract the information from.
  48134. * @return The Spherical Polynomial data.
  48135. */
  48136. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48137. /**
  48138. * Converts a cubemap to the according Spherical Polynomial data.
  48139. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48140. *
  48141. * @param cubeInfo The Cube map to extract the information from.
  48142. * @return The Spherical Polynomial data.
  48143. */
  48144. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48145. }
  48146. }
  48147. declare module BABYLON {
  48148. interface BaseTexture {
  48149. /**
  48150. * Get the polynomial representation of the texture data.
  48151. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48152. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48153. */
  48154. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48155. }
  48156. }
  48157. declare module BABYLON {
  48158. /** @hidden */
  48159. export var rgbdEncodePixelShader: {
  48160. name: string;
  48161. shader: string;
  48162. };
  48163. }
  48164. declare module BABYLON {
  48165. /** @hidden */
  48166. export var rgbdDecodePixelShader: {
  48167. name: string;
  48168. shader: string;
  48169. };
  48170. }
  48171. declare module BABYLON {
  48172. /**
  48173. * Raw texture data and descriptor sufficient for WebGL texture upload
  48174. */
  48175. export interface EnvironmentTextureInfo {
  48176. /**
  48177. * Version of the environment map
  48178. */
  48179. version: number;
  48180. /**
  48181. * Width of image
  48182. */
  48183. width: number;
  48184. /**
  48185. * Irradiance information stored in the file.
  48186. */
  48187. irradiance: any;
  48188. /**
  48189. * Specular information stored in the file.
  48190. */
  48191. specular: any;
  48192. }
  48193. /**
  48194. * Defines One Image in the file. It requires only the position in the file
  48195. * as well as the length.
  48196. */
  48197. interface BufferImageData {
  48198. /**
  48199. * Length of the image data.
  48200. */
  48201. length: number;
  48202. /**
  48203. * Position of the data from the null terminator delimiting the end of the JSON.
  48204. */
  48205. position: number;
  48206. }
  48207. /**
  48208. * Defines the specular data enclosed in the file.
  48209. * This corresponds to the version 1 of the data.
  48210. */
  48211. export interface EnvironmentTextureSpecularInfoV1 {
  48212. /**
  48213. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48214. */
  48215. specularDataPosition?: number;
  48216. /**
  48217. * This contains all the images data needed to reconstruct the cubemap.
  48218. */
  48219. mipmaps: Array<BufferImageData>;
  48220. /**
  48221. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48222. */
  48223. lodGenerationScale: number;
  48224. }
  48225. /**
  48226. * Sets of helpers addressing the serialization and deserialization of environment texture
  48227. * stored in a BabylonJS env file.
  48228. * Those files are usually stored as .env files.
  48229. */
  48230. export class EnvironmentTextureTools {
  48231. /**
  48232. * Magic number identifying the env file.
  48233. */
  48234. private static _MagicBytes;
  48235. /**
  48236. * Gets the environment info from an env file.
  48237. * @param data The array buffer containing the .env bytes.
  48238. * @returns the environment file info (the json header) if successfully parsed.
  48239. */
  48240. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  48241. /**
  48242. * Creates an environment texture from a loaded cube texture.
  48243. * @param texture defines the cube texture to convert in env file
  48244. * @return a promise containing the environment data if succesfull.
  48245. */
  48246. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  48247. /**
  48248. * Creates a JSON representation of the spherical data.
  48249. * @param texture defines the texture containing the polynomials
  48250. * @return the JSON representation of the spherical info
  48251. */
  48252. private static _CreateEnvTextureIrradiance;
  48253. /**
  48254. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48255. * @param data the image data
  48256. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48257. * @return the views described by info providing access to the underlying buffer
  48258. */
  48259. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48260. /**
  48261. * Uploads the texture info contained in the env file to the GPU.
  48262. * @param texture defines the internal texture to upload to
  48263. * @param data defines the data to load
  48264. * @param info defines the texture info retrieved through the GetEnvInfo method
  48265. * @returns a promise
  48266. */
  48267. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  48268. private static _OnImageReadyAsync;
  48269. /**
  48270. * Uploads the levels of image data to the GPU.
  48271. * @param texture defines the internal texture to upload to
  48272. * @param imageData defines the array buffer views of image data [mipmap][face]
  48273. * @returns a promise
  48274. */
  48275. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48276. /**
  48277. * Uploads spherical polynomials information to the texture.
  48278. * @param texture defines the texture we are trying to upload the information to
  48279. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48280. */
  48281. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48282. /** @hidden */
  48283. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48284. }
  48285. }
  48286. declare module BABYLON {
  48287. /**
  48288. * Contains position and normal vectors for a vertex
  48289. */
  48290. export class PositionNormalVertex {
  48291. /** the position of the vertex (defaut: 0,0,0) */
  48292. position: Vector3;
  48293. /** the normal of the vertex (defaut: 0,1,0) */
  48294. normal: Vector3;
  48295. /**
  48296. * Creates a PositionNormalVertex
  48297. * @param position the position of the vertex (defaut: 0,0,0)
  48298. * @param normal the normal of the vertex (defaut: 0,1,0)
  48299. */
  48300. constructor(
  48301. /** the position of the vertex (defaut: 0,0,0) */
  48302. position?: Vector3,
  48303. /** the normal of the vertex (defaut: 0,1,0) */
  48304. normal?: Vector3);
  48305. /**
  48306. * Clones the PositionNormalVertex
  48307. * @returns the cloned PositionNormalVertex
  48308. */
  48309. clone(): PositionNormalVertex;
  48310. }
  48311. /**
  48312. * Contains position, normal and uv vectors for a vertex
  48313. */
  48314. export class PositionNormalTextureVertex {
  48315. /** the position of the vertex (defaut: 0,0,0) */
  48316. position: Vector3;
  48317. /** the normal of the vertex (defaut: 0,1,0) */
  48318. normal: Vector3;
  48319. /** the uv of the vertex (default: 0,0) */
  48320. uv: Vector2;
  48321. /**
  48322. * Creates a PositionNormalTextureVertex
  48323. * @param position the position of the vertex (defaut: 0,0,0)
  48324. * @param normal the normal of the vertex (defaut: 0,1,0)
  48325. * @param uv the uv of the vertex (default: 0,0)
  48326. */
  48327. constructor(
  48328. /** the position of the vertex (defaut: 0,0,0) */
  48329. position?: Vector3,
  48330. /** the normal of the vertex (defaut: 0,1,0) */
  48331. normal?: Vector3,
  48332. /** the uv of the vertex (default: 0,0) */
  48333. uv?: Vector2);
  48334. /**
  48335. * Clones the PositionNormalTextureVertex
  48336. * @returns the cloned PositionNormalTextureVertex
  48337. */
  48338. clone(): PositionNormalTextureVertex;
  48339. }
  48340. }
  48341. declare module BABYLON {
  48342. /** @hidden */
  48343. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  48344. private _genericAttributeLocation;
  48345. private _varyingLocationCount;
  48346. private _varyingLocationMap;
  48347. private _replacements;
  48348. private _textureCount;
  48349. private _uniforms;
  48350. lineProcessor(line: string): string;
  48351. attributeProcessor(attribute: string): string;
  48352. varyingProcessor(varying: string, isFragment: boolean): string;
  48353. uniformProcessor(uniform: string): string;
  48354. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  48355. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  48356. }
  48357. }
  48358. declare module BABYLON {
  48359. /**
  48360. * Container for accessors for natively-stored mesh data buffers.
  48361. */
  48362. class NativeDataBuffer extends DataBuffer {
  48363. /**
  48364. * Accessor value used to identify/retrieve a natively-stored index buffer.
  48365. */
  48366. nativeIndexBuffer?: any;
  48367. /**
  48368. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  48369. */
  48370. nativeVertexBuffer?: any;
  48371. }
  48372. /** @hidden */
  48373. class NativeTexture extends InternalTexture {
  48374. getInternalTexture(): InternalTexture;
  48375. getViewCount(): number;
  48376. }
  48377. /** @hidden */
  48378. export class NativeEngine extends Engine {
  48379. private readonly _native;
  48380. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48381. private readonly INVALID_HANDLE;
  48382. getHardwareScalingLevel(): number;
  48383. constructor();
  48384. dispose(): void;
  48385. /**
  48386. * Can be used to override the current requestAnimationFrame requester.
  48387. * @hidden
  48388. */
  48389. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48390. /**
  48391. * Override default engine behavior.
  48392. * @param color
  48393. * @param backBuffer
  48394. * @param depth
  48395. * @param stencil
  48396. */
  48397. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48398. /**
  48399. * Gets host document
  48400. * @returns the host document object
  48401. */
  48402. getHostDocument(): Nullable<Document>;
  48403. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48404. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48405. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48406. recordVertexArrayObject(vertexBuffers: {
  48407. [key: string]: VertexBuffer;
  48408. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48409. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48410. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48411. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48412. /**
  48413. * Draw a list of indexed primitives
  48414. * @param fillMode defines the primitive to use
  48415. * @param indexStart defines the starting index
  48416. * @param indexCount defines the number of index to draw
  48417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48418. */
  48419. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48420. /**
  48421. * Draw a list of unindexed primitives
  48422. * @param fillMode defines the primitive to use
  48423. * @param verticesStart defines the index of first vertex to draw
  48424. * @param verticesCount defines the count of vertices to draw
  48425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48426. */
  48427. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48428. createPipelineContext(): IPipelineContext;
  48429. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48430. /** @hidden */
  48431. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48432. /** @hidden */
  48433. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48434. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48435. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48436. protected _setProgram(program: WebGLProgram): void;
  48437. _releaseEffect(effect: Effect): void;
  48438. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48439. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48440. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48441. bindSamplers(effect: Effect): void;
  48442. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48443. getRenderWidth(useScreen?: boolean): number;
  48444. getRenderHeight(useScreen?: boolean): number;
  48445. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48447. /**
  48448. * Set the z offset to apply to current rendering
  48449. * @param value defines the offset to apply
  48450. */
  48451. setZOffset(value: number): void;
  48452. /**
  48453. * Gets the current value of the zOffset
  48454. * @returns the current zOffset state
  48455. */
  48456. getZOffset(): number;
  48457. /**
  48458. * Enable or disable depth buffering
  48459. * @param enable defines the state to set
  48460. */
  48461. setDepthBuffer(enable: boolean): void;
  48462. /**
  48463. * Gets a boolean indicating if depth writing is enabled
  48464. * @returns the current depth writing state
  48465. */
  48466. getDepthWrite(): boolean;
  48467. /**
  48468. * Enable or disable depth writing
  48469. * @param enable defines the state to set
  48470. */
  48471. setDepthWrite(enable: boolean): void;
  48472. /**
  48473. * Enable or disable color writing
  48474. * @param enable defines the state to set
  48475. */
  48476. setColorWrite(enable: boolean): void;
  48477. /**
  48478. * Gets a boolean indicating if color writing is enabled
  48479. * @returns the current color writing state
  48480. */
  48481. getColorWrite(): boolean;
  48482. /**
  48483. * Sets alpha constants used by some alpha blending modes
  48484. * @param r defines the red component
  48485. * @param g defines the green component
  48486. * @param b defines the blue component
  48487. * @param a defines the alpha component
  48488. */
  48489. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48490. /**
  48491. * Sets the current alpha mode
  48492. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48493. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48494. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48495. */
  48496. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48497. /**
  48498. * Gets the current alpha mode
  48499. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48500. * @returns the current alpha mode
  48501. */
  48502. getAlphaMode(): number;
  48503. setInt(uniform: WebGLUniformLocation, int: number): void;
  48504. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48505. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48506. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48507. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48508. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48509. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48510. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48511. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48512. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48513. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48514. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48515. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48516. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48517. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48518. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48519. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48520. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48521. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48522. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48523. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48524. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48525. wipeCaches(bruteForce?: boolean): void;
  48526. _createTexture(): WebGLTexture;
  48527. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48528. /**
  48529. * Usually called from Texture.ts.
  48530. * Passed information to create a WebGLTexture
  48531. * @param url defines a value which contains one of the following:
  48532. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48533. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48534. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48535. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48536. * @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)
  48537. * @param scene needed for loading to the correct scene
  48538. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48539. * @param onLoad optional callback to be called upon successful completion
  48540. * @param onError optional callback to be called upon failure
  48541. * @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
  48542. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48543. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48544. * @param forcedExtension defines the extension to use to pick the right loader
  48545. * @param mimeType defines an optional mime type
  48546. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48547. */
  48548. createTexture(url: 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;
  48549. /**
  48550. * Creates a cube texture
  48551. * @param rootUrl defines the url where the files to load is located
  48552. * @param scene defines the current scene
  48553. * @param files defines the list of files to load (1 per face)
  48554. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48555. * @param onLoad defines an optional callback raised when the texture is loaded
  48556. * @param onError defines an optional callback raised if there is an issue to load the texture
  48557. * @param format defines the format of the data
  48558. * @param forcedExtension defines the extension to use to pick the right loader
  48559. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48560. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48561. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48562. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48563. * @returns the cube texture as an InternalTexture
  48564. */
  48565. 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;
  48566. private _getSamplingFilter;
  48567. private static _GetNativeTextureFormat;
  48568. createRenderTargetTexture(size: number | {
  48569. width: number;
  48570. height: number;
  48571. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48572. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48573. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48574. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48575. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48576. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48577. /**
  48578. * Updates a dynamic vertex buffer.
  48579. * @param vertexBuffer the vertex buffer to update
  48580. * @param data the data used to update the vertex buffer
  48581. * @param byteOffset the byte offset of the data (optional)
  48582. * @param byteLength the byte length of the data (optional)
  48583. */
  48584. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48585. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48586. private _updateAnisotropicLevel;
  48587. private _getAddressMode;
  48588. /** @hidden */
  48589. _bindTexture(channel: number, texture: InternalTexture): void;
  48590. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48591. releaseEffects(): void;
  48592. /** @hidden */
  48593. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48594. /** @hidden */
  48595. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48596. /** @hidden */
  48597. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48598. /** @hidden */
  48599. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48600. }
  48601. }
  48602. declare module BABYLON {
  48603. /**
  48604. * Gather the list of clipboard event types as constants.
  48605. */
  48606. export class ClipboardEventTypes {
  48607. /**
  48608. * The clipboard event is fired when a copy command is active (pressed).
  48609. */
  48610. static readonly COPY: number;
  48611. /**
  48612. * The clipboard event is fired when a cut command is active (pressed).
  48613. */
  48614. static readonly CUT: number;
  48615. /**
  48616. * The clipboard event is fired when a paste command is active (pressed).
  48617. */
  48618. static readonly PASTE: number;
  48619. }
  48620. /**
  48621. * This class is used to store clipboard related info for the onClipboardObservable event.
  48622. */
  48623. export class ClipboardInfo {
  48624. /**
  48625. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48626. */
  48627. type: number;
  48628. /**
  48629. * Defines the related dom event
  48630. */
  48631. event: ClipboardEvent;
  48632. /**
  48633. *Creates an instance of ClipboardInfo.
  48634. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48635. * @param event Defines the related dom event
  48636. */
  48637. constructor(
  48638. /**
  48639. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48640. */
  48641. type: number,
  48642. /**
  48643. * Defines the related dom event
  48644. */
  48645. event: ClipboardEvent);
  48646. /**
  48647. * Get the clipboard event's type from the keycode.
  48648. * @param keyCode Defines the keyCode for the current keyboard event.
  48649. * @return {number}
  48650. */
  48651. static GetTypeFromCharacter(keyCode: number): number;
  48652. }
  48653. }
  48654. declare module BABYLON {
  48655. /**
  48656. * Google Daydream controller
  48657. */
  48658. export class DaydreamController extends WebVRController {
  48659. /**
  48660. * Base Url for the controller model.
  48661. */
  48662. static MODEL_BASE_URL: string;
  48663. /**
  48664. * File name for the controller model.
  48665. */
  48666. static MODEL_FILENAME: string;
  48667. /**
  48668. * Gamepad Id prefix used to identify Daydream Controller.
  48669. */
  48670. static readonly GAMEPAD_ID_PREFIX: string;
  48671. /**
  48672. * Creates a new DaydreamController from a gamepad
  48673. * @param vrGamepad the gamepad that the controller should be created from
  48674. */
  48675. constructor(vrGamepad: any);
  48676. /**
  48677. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48678. * @param scene scene in which to add meshes
  48679. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48680. */
  48681. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48682. /**
  48683. * Called once for each button that changed state since the last frame
  48684. * @param buttonIdx Which button index changed
  48685. * @param state New state of the button
  48686. * @param changes Which properties on the state changed since last frame
  48687. */
  48688. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48689. }
  48690. }
  48691. declare module BABYLON {
  48692. /**
  48693. * Gear VR Controller
  48694. */
  48695. export class GearVRController extends WebVRController {
  48696. /**
  48697. * Base Url for the controller model.
  48698. */
  48699. static MODEL_BASE_URL: string;
  48700. /**
  48701. * File name for the controller model.
  48702. */
  48703. static MODEL_FILENAME: string;
  48704. /**
  48705. * Gamepad Id prefix used to identify this controller.
  48706. */
  48707. static readonly GAMEPAD_ID_PREFIX: string;
  48708. private readonly _buttonIndexToObservableNameMap;
  48709. /**
  48710. * Creates a new GearVRController from a gamepad
  48711. * @param vrGamepad the gamepad that the controller should be created from
  48712. */
  48713. constructor(vrGamepad: any);
  48714. /**
  48715. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48716. * @param scene scene in which to add meshes
  48717. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48718. */
  48719. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48720. /**
  48721. * Called once for each button that changed state since the last frame
  48722. * @param buttonIdx Which button index changed
  48723. * @param state New state of the button
  48724. * @param changes Which properties on the state changed since last frame
  48725. */
  48726. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48727. }
  48728. }
  48729. declare module BABYLON {
  48730. /**
  48731. * Generic Controller
  48732. */
  48733. export class GenericController extends WebVRController {
  48734. /**
  48735. * Base Url for the controller model.
  48736. */
  48737. static readonly MODEL_BASE_URL: string;
  48738. /**
  48739. * File name for the controller model.
  48740. */
  48741. static readonly MODEL_FILENAME: string;
  48742. /**
  48743. * Creates a new GenericController from a gamepad
  48744. * @param vrGamepad the gamepad that the controller should be created from
  48745. */
  48746. constructor(vrGamepad: any);
  48747. /**
  48748. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48749. * @param scene scene in which to add meshes
  48750. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48751. */
  48752. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48753. /**
  48754. * Called once for each button that changed state since the last frame
  48755. * @param buttonIdx Which button index changed
  48756. * @param state New state of the button
  48757. * @param changes Which properties on the state changed since last frame
  48758. */
  48759. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48760. }
  48761. }
  48762. declare module BABYLON {
  48763. /**
  48764. * Oculus Touch Controller
  48765. */
  48766. export class OculusTouchController extends WebVRController {
  48767. /**
  48768. * Base Url for the controller model.
  48769. */
  48770. static MODEL_BASE_URL: string;
  48771. /**
  48772. * File name for the left controller model.
  48773. */
  48774. static MODEL_LEFT_FILENAME: string;
  48775. /**
  48776. * File name for the right controller model.
  48777. */
  48778. static MODEL_RIGHT_FILENAME: string;
  48779. /**
  48780. * Base Url for the Quest controller model.
  48781. */
  48782. static QUEST_MODEL_BASE_URL: string;
  48783. /**
  48784. * @hidden
  48785. * If the controllers are running on a device that needs the updated Quest controller models
  48786. */
  48787. static _IsQuest: boolean;
  48788. /**
  48789. * Fired when the secondary trigger on this controller is modified
  48790. */
  48791. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48792. /**
  48793. * Fired when the thumb rest on this controller is modified
  48794. */
  48795. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48796. /**
  48797. * Creates a new OculusTouchController from a gamepad
  48798. * @param vrGamepad the gamepad that the controller should be created from
  48799. */
  48800. constructor(vrGamepad: any);
  48801. /**
  48802. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48803. * @param scene scene in which to add meshes
  48804. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48805. */
  48806. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48807. /**
  48808. * Fired when the A button on this controller is modified
  48809. */
  48810. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48811. /**
  48812. * Fired when the B button on this controller is modified
  48813. */
  48814. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48815. /**
  48816. * Fired when the X button on this controller is modified
  48817. */
  48818. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48819. /**
  48820. * Fired when the Y button on this controller is modified
  48821. */
  48822. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48823. /**
  48824. * Called once for each button that changed state since the last frame
  48825. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48826. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48827. * 2) secondary trigger (same)
  48828. * 3) A (right) X (left), touch, pressed = value
  48829. * 4) B / Y
  48830. * 5) thumb rest
  48831. * @param buttonIdx Which button index changed
  48832. * @param state New state of the button
  48833. * @param changes Which properties on the state changed since last frame
  48834. */
  48835. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48836. }
  48837. }
  48838. declare module BABYLON {
  48839. /**
  48840. * Vive Controller
  48841. */
  48842. export class ViveController extends WebVRController {
  48843. /**
  48844. * Base Url for the controller model.
  48845. */
  48846. static MODEL_BASE_URL: string;
  48847. /**
  48848. * File name for the controller model.
  48849. */
  48850. static MODEL_FILENAME: string;
  48851. /**
  48852. * Creates a new ViveController from a gamepad
  48853. * @param vrGamepad the gamepad that the controller should be created from
  48854. */
  48855. constructor(vrGamepad: any);
  48856. /**
  48857. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48858. * @param scene scene in which to add meshes
  48859. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48860. */
  48861. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48862. /**
  48863. * Fired when the left button on this controller is modified
  48864. */
  48865. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48866. /**
  48867. * Fired when the right button on this controller is modified
  48868. */
  48869. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48870. /**
  48871. * Fired when the menu button on this controller is modified
  48872. */
  48873. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48874. /**
  48875. * Called once for each button that changed state since the last frame
  48876. * Vive mapping:
  48877. * 0: touchpad
  48878. * 1: trigger
  48879. * 2: left AND right buttons
  48880. * 3: menu button
  48881. * @param buttonIdx Which button index changed
  48882. * @param state New state of the button
  48883. * @param changes Which properties on the state changed since last frame
  48884. */
  48885. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48886. }
  48887. }
  48888. declare module BABYLON {
  48889. /**
  48890. * Defines the WindowsMotionController object that the state of the windows motion controller
  48891. */
  48892. export class WindowsMotionController extends WebVRController {
  48893. /**
  48894. * The base url used to load the left and right controller models
  48895. */
  48896. static MODEL_BASE_URL: string;
  48897. /**
  48898. * The name of the left controller model file
  48899. */
  48900. static MODEL_LEFT_FILENAME: string;
  48901. /**
  48902. * The name of the right controller model file
  48903. */
  48904. static MODEL_RIGHT_FILENAME: string;
  48905. /**
  48906. * The controller name prefix for this controller type
  48907. */
  48908. static readonly GAMEPAD_ID_PREFIX: string;
  48909. /**
  48910. * The controller id pattern for this controller type
  48911. */
  48912. private static readonly GAMEPAD_ID_PATTERN;
  48913. private _loadedMeshInfo;
  48914. protected readonly _mapping: {
  48915. buttons: string[];
  48916. buttonMeshNames: {
  48917. trigger: string;
  48918. menu: string;
  48919. grip: string;
  48920. thumbstick: string;
  48921. trackpad: string;
  48922. };
  48923. buttonObservableNames: {
  48924. trigger: string;
  48925. menu: string;
  48926. grip: string;
  48927. thumbstick: string;
  48928. trackpad: string;
  48929. };
  48930. axisMeshNames: string[];
  48931. pointingPoseMeshName: string;
  48932. };
  48933. /**
  48934. * Fired when the trackpad on this controller is clicked
  48935. */
  48936. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48937. /**
  48938. * Fired when the trackpad on this controller is modified
  48939. */
  48940. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48941. /**
  48942. * The current x and y values of this controller's trackpad
  48943. */
  48944. trackpad: StickValues;
  48945. /**
  48946. * Creates a new WindowsMotionController from a gamepad
  48947. * @param vrGamepad the gamepad that the controller should be created from
  48948. */
  48949. constructor(vrGamepad: any);
  48950. /**
  48951. * Fired when the trigger on this controller is modified
  48952. */
  48953. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48954. /**
  48955. * Fired when the menu button on this controller is modified
  48956. */
  48957. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48958. /**
  48959. * Fired when the grip button on this controller is modified
  48960. */
  48961. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48962. /**
  48963. * Fired when the thumbstick button on this controller is modified
  48964. */
  48965. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48966. /**
  48967. * Fired when the touchpad button on this controller is modified
  48968. */
  48969. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48970. /**
  48971. * Fired when the touchpad values on this controller are modified
  48972. */
  48973. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48974. protected _updateTrackpad(): void;
  48975. /**
  48976. * Called once per frame by the engine.
  48977. */
  48978. update(): void;
  48979. /**
  48980. * Called once for each button that changed state since the last frame
  48981. * @param buttonIdx Which button index changed
  48982. * @param state New state of the button
  48983. * @param changes Which properties on the state changed since last frame
  48984. */
  48985. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48986. /**
  48987. * Moves the buttons on the controller mesh based on their current state
  48988. * @param buttonName the name of the button to move
  48989. * @param buttonValue the value of the button which determines the buttons new position
  48990. */
  48991. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48992. /**
  48993. * Moves the axis on the controller mesh based on its current state
  48994. * @param axis the index of the axis
  48995. * @param axisValue the value of the axis which determines the meshes new position
  48996. * @hidden
  48997. */
  48998. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48999. /**
  49000. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49001. * @param scene scene in which to add meshes
  49002. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49003. */
  49004. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  49005. /**
  49006. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  49007. * can be transformed by button presses and axes values, based on this._mapping.
  49008. *
  49009. * @param scene scene in which the meshes exist
  49010. * @param meshes list of meshes that make up the controller model to process
  49011. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  49012. */
  49013. private processModel;
  49014. private createMeshInfo;
  49015. /**
  49016. * Gets the ray of the controller in the direction the controller is pointing
  49017. * @param length the length the resulting ray should be
  49018. * @returns a ray in the direction the controller is pointing
  49019. */
  49020. getForwardRay(length?: number): Ray;
  49021. /**
  49022. * Disposes of the controller
  49023. */
  49024. dispose(): void;
  49025. }
  49026. /**
  49027. * This class represents a new windows motion controller in XR.
  49028. */
  49029. export class XRWindowsMotionController extends WindowsMotionController {
  49030. /**
  49031. * Changing the original WIndowsMotionController mapping to fir the new mapping
  49032. */
  49033. protected readonly _mapping: {
  49034. buttons: string[];
  49035. buttonMeshNames: {
  49036. trigger: string;
  49037. menu: string;
  49038. grip: string;
  49039. thumbstick: string;
  49040. trackpad: string;
  49041. };
  49042. buttonObservableNames: {
  49043. trigger: string;
  49044. menu: string;
  49045. grip: string;
  49046. thumbstick: string;
  49047. trackpad: string;
  49048. };
  49049. axisMeshNames: string[];
  49050. pointingPoseMeshName: string;
  49051. };
  49052. /**
  49053. * Construct a new XR-Based windows motion controller
  49054. *
  49055. * @param gamepadInfo the gamepad object from the browser
  49056. */
  49057. constructor(gamepadInfo: any);
  49058. /**
  49059. * holds the thumbstick values (X,Y)
  49060. */
  49061. thumbstickValues: StickValues;
  49062. /**
  49063. * Fired when the thumbstick on this controller is clicked
  49064. */
  49065. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  49066. /**
  49067. * Fired when the thumbstick on this controller is modified
  49068. */
  49069. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49070. /**
  49071. * Fired when the touchpad button on this controller is modified
  49072. */
  49073. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49074. /**
  49075. * Fired when the touchpad values on this controller are modified
  49076. */
  49077. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49078. /**
  49079. * Fired when the thumbstick button on this controller is modified
  49080. * here to prevent breaking changes
  49081. */
  49082. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49083. /**
  49084. * updating the thumbstick(!) and not the trackpad.
  49085. * This is named this way due to the difference between WebVR and XR and to avoid
  49086. * changing the parent class.
  49087. */
  49088. protected _updateTrackpad(): void;
  49089. /**
  49090. * Disposes the class with joy
  49091. */
  49092. dispose(): void;
  49093. }
  49094. }
  49095. declare module BABYLON {
  49096. /**
  49097. * Class containing static functions to help procedurally build meshes
  49098. */
  49099. export class PolyhedronBuilder {
  49100. /**
  49101. * Creates a polyhedron mesh
  49102. * * 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
  49103. * * The parameter `size` (positive float, default 1) sets the polygon size
  49104. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49105. * * 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`
  49106. * * 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
  49107. * * 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)`)
  49108. * * 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
  49109. * * 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
  49110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49111. * * 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
  49112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49113. * @param name defines the name of the mesh
  49114. * @param options defines the options used to create the mesh
  49115. * @param scene defines the hosting scene
  49116. * @returns the polyhedron mesh
  49117. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49118. */
  49119. static CreatePolyhedron(name: string, options: {
  49120. type?: number;
  49121. size?: number;
  49122. sizeX?: number;
  49123. sizeY?: number;
  49124. sizeZ?: number;
  49125. custom?: any;
  49126. faceUV?: Vector4[];
  49127. faceColors?: Color4[];
  49128. flat?: boolean;
  49129. updatable?: boolean;
  49130. sideOrientation?: number;
  49131. frontUVs?: Vector4;
  49132. backUVs?: Vector4;
  49133. }, scene?: Nullable<Scene>): Mesh;
  49134. }
  49135. }
  49136. declare module BABYLON {
  49137. /**
  49138. * Gizmo that enables scaling a mesh along 3 axis
  49139. */
  49140. export class ScaleGizmo extends Gizmo {
  49141. /**
  49142. * Internal gizmo used for interactions on the x axis
  49143. */
  49144. xGizmo: AxisScaleGizmo;
  49145. /**
  49146. * Internal gizmo used for interactions on the y axis
  49147. */
  49148. yGizmo: AxisScaleGizmo;
  49149. /**
  49150. * Internal gizmo used for interactions on the z axis
  49151. */
  49152. zGizmo: AxisScaleGizmo;
  49153. /**
  49154. * Internal gizmo used to scale all axis equally
  49155. */
  49156. uniformScaleGizmo: AxisScaleGizmo;
  49157. private _meshAttached;
  49158. private _updateGizmoRotationToMatchAttachedMesh;
  49159. private _snapDistance;
  49160. private _scaleRatio;
  49161. private _uniformScalingMesh;
  49162. private _octahedron;
  49163. private _sensitivity;
  49164. /** Fires an event when any of it's sub gizmos are dragged */
  49165. onDragStartObservable: Observable<unknown>;
  49166. /** Fires an event when any of it's sub gizmos are released from dragging */
  49167. onDragEndObservable: Observable<unknown>;
  49168. get attachedMesh(): Nullable<AbstractMesh>;
  49169. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49170. /**
  49171. * Creates a ScaleGizmo
  49172. * @param gizmoLayer The utility layer the gizmo will be added to
  49173. */
  49174. constructor(gizmoLayer?: UtilityLayerRenderer);
  49175. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49176. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49177. /**
  49178. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49179. */
  49180. set snapDistance(value: number);
  49181. get snapDistance(): number;
  49182. /**
  49183. * Ratio for the scale of the gizmo (Default: 1)
  49184. */
  49185. set scaleRatio(value: number);
  49186. get scaleRatio(): number;
  49187. /**
  49188. * Sensitivity factor for dragging (Default: 1)
  49189. */
  49190. set sensitivity(value: number);
  49191. get sensitivity(): number;
  49192. /**
  49193. * Disposes of the gizmo
  49194. */
  49195. dispose(): void;
  49196. }
  49197. }
  49198. declare module BABYLON {
  49199. /**
  49200. * Single axis scale gizmo
  49201. */
  49202. export class AxisScaleGizmo extends Gizmo {
  49203. /**
  49204. * Drag behavior responsible for the gizmos dragging interactions
  49205. */
  49206. dragBehavior: PointerDragBehavior;
  49207. private _pointerObserver;
  49208. /**
  49209. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49210. */
  49211. snapDistance: number;
  49212. /**
  49213. * Event that fires each time the gizmo snaps to a new location.
  49214. * * snapDistance is the the change in distance
  49215. */
  49216. onSnapObservable: Observable<{
  49217. snapDistance: number;
  49218. }>;
  49219. /**
  49220. * If the scaling operation should be done on all axis (default: false)
  49221. */
  49222. uniformScaling: boolean;
  49223. /**
  49224. * Custom sensitivity value for the drag strength
  49225. */
  49226. sensitivity: number;
  49227. private _isEnabled;
  49228. private _parent;
  49229. private _arrow;
  49230. private _coloredMaterial;
  49231. private _hoverMaterial;
  49232. /**
  49233. * Creates an AxisScaleGizmo
  49234. * @param gizmoLayer The utility layer the gizmo will be added to
  49235. * @param dragAxis The axis which the gizmo will be able to scale on
  49236. * @param color The color of the gizmo
  49237. */
  49238. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  49239. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49240. /**
  49241. * If the gizmo is enabled
  49242. */
  49243. set isEnabled(value: boolean);
  49244. get isEnabled(): boolean;
  49245. /**
  49246. * Disposes of the gizmo
  49247. */
  49248. dispose(): void;
  49249. /**
  49250. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  49251. * @param mesh The mesh to replace the default mesh of the gizmo
  49252. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  49253. */
  49254. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  49255. }
  49256. }
  49257. declare module BABYLON {
  49258. /**
  49259. * Bounding box gizmo
  49260. */
  49261. export class BoundingBoxGizmo extends Gizmo {
  49262. private _lineBoundingBox;
  49263. private _rotateSpheresParent;
  49264. private _scaleBoxesParent;
  49265. private _boundingDimensions;
  49266. private _renderObserver;
  49267. private _pointerObserver;
  49268. private _scaleDragSpeed;
  49269. private _tmpQuaternion;
  49270. private _tmpVector;
  49271. private _tmpRotationMatrix;
  49272. /**
  49273. * 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)
  49274. */
  49275. ignoreChildren: boolean;
  49276. /**
  49277. * 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)
  49278. */
  49279. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  49280. /**
  49281. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  49282. */
  49283. rotationSphereSize: number;
  49284. /**
  49285. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  49286. */
  49287. scaleBoxSize: number;
  49288. /**
  49289. * 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)
  49290. */
  49291. fixedDragMeshScreenSize: boolean;
  49292. /**
  49293. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  49294. */
  49295. fixedDragMeshScreenSizeDistanceFactor: number;
  49296. /**
  49297. * Fired when a rotation sphere or scale box is dragged
  49298. */
  49299. onDragStartObservable: Observable<{}>;
  49300. /**
  49301. * Fired when a scale box is dragged
  49302. */
  49303. onScaleBoxDragObservable: Observable<{}>;
  49304. /**
  49305. * Fired when a scale box drag is ended
  49306. */
  49307. onScaleBoxDragEndObservable: Observable<{}>;
  49308. /**
  49309. * Fired when a rotation sphere is dragged
  49310. */
  49311. onRotationSphereDragObservable: Observable<{}>;
  49312. /**
  49313. * Fired when a rotation sphere drag is ended
  49314. */
  49315. onRotationSphereDragEndObservable: Observable<{}>;
  49316. /**
  49317. * 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)
  49318. */
  49319. scalePivot: Nullable<Vector3>;
  49320. /**
  49321. * Mesh used as a pivot to rotate the attached mesh
  49322. */
  49323. private _anchorMesh;
  49324. private _existingMeshScale;
  49325. private _dragMesh;
  49326. private pointerDragBehavior;
  49327. private coloredMaterial;
  49328. private hoverColoredMaterial;
  49329. /**
  49330. * Sets the color of the bounding box gizmo
  49331. * @param color the color to set
  49332. */
  49333. setColor(color: Color3): void;
  49334. /**
  49335. * Creates an BoundingBoxGizmo
  49336. * @param gizmoLayer The utility layer the gizmo will be added to
  49337. * @param color The color of the gizmo
  49338. */
  49339. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  49340. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49341. private _selectNode;
  49342. /**
  49343. * Updates the bounding box information for the Gizmo
  49344. */
  49345. updateBoundingBox(): void;
  49346. private _updateRotationSpheres;
  49347. private _updateScaleBoxes;
  49348. /**
  49349. * Enables rotation on the specified axis and disables rotation on the others
  49350. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  49351. */
  49352. setEnabledRotationAxis(axis: string): void;
  49353. /**
  49354. * Enables/disables scaling
  49355. * @param enable if scaling should be enabled
  49356. * @param homogeneousScaling defines if scaling should only be homogeneous
  49357. */
  49358. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  49359. private _updateDummy;
  49360. /**
  49361. * Enables a pointer drag behavior on the bounding box of the gizmo
  49362. */
  49363. enableDragBehavior(): void;
  49364. /**
  49365. * Disposes of the gizmo
  49366. */
  49367. dispose(): void;
  49368. /**
  49369. * 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)
  49370. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  49371. * @returns the bounding box mesh with the passed in mesh as a child
  49372. */
  49373. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  49374. /**
  49375. * CustomMeshes are not supported by this gizmo
  49376. * @param mesh The mesh to replace the default mesh of the gizmo
  49377. */
  49378. setCustomMesh(mesh: Mesh): void;
  49379. }
  49380. }
  49381. declare module BABYLON {
  49382. /**
  49383. * Single plane rotation gizmo
  49384. */
  49385. export class PlaneRotationGizmo extends Gizmo {
  49386. /**
  49387. * Drag behavior responsible for the gizmos dragging interactions
  49388. */
  49389. dragBehavior: PointerDragBehavior;
  49390. private _pointerObserver;
  49391. /**
  49392. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49393. */
  49394. snapDistance: number;
  49395. /**
  49396. * Event that fires each time the gizmo snaps to a new location.
  49397. * * snapDistance is the the change in distance
  49398. */
  49399. onSnapObservable: Observable<{
  49400. snapDistance: number;
  49401. }>;
  49402. private _isEnabled;
  49403. private _parent;
  49404. /**
  49405. * Creates a PlaneRotationGizmo
  49406. * @param gizmoLayer The utility layer the gizmo will be added to
  49407. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49408. * @param color The color of the gizmo
  49409. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49410. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49411. */
  49412. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49413. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49414. /**
  49415. * If the gizmo is enabled
  49416. */
  49417. set isEnabled(value: boolean);
  49418. get isEnabled(): boolean;
  49419. /**
  49420. * Disposes of the gizmo
  49421. */
  49422. dispose(): void;
  49423. }
  49424. }
  49425. declare module BABYLON {
  49426. /**
  49427. * Gizmo that enables rotating a mesh along 3 axis
  49428. */
  49429. export class RotationGizmo extends Gizmo {
  49430. /**
  49431. * Internal gizmo used for interactions on the x axis
  49432. */
  49433. xGizmo: PlaneRotationGizmo;
  49434. /**
  49435. * Internal gizmo used for interactions on the y axis
  49436. */
  49437. yGizmo: PlaneRotationGizmo;
  49438. /**
  49439. * Internal gizmo used for interactions on the z axis
  49440. */
  49441. zGizmo: PlaneRotationGizmo;
  49442. /** Fires an event when any of it's sub gizmos are dragged */
  49443. onDragStartObservable: Observable<unknown>;
  49444. /** Fires an event when any of it's sub gizmos are released from dragging */
  49445. onDragEndObservable: Observable<unknown>;
  49446. private _meshAttached;
  49447. get attachedMesh(): Nullable<AbstractMesh>;
  49448. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49449. /**
  49450. * Creates a RotationGizmo
  49451. * @param gizmoLayer The utility layer the gizmo will be added to
  49452. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49453. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49454. */
  49455. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49456. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49457. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49458. /**
  49459. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49460. */
  49461. set snapDistance(value: number);
  49462. get snapDistance(): number;
  49463. /**
  49464. * Ratio for the scale of the gizmo (Default: 1)
  49465. */
  49466. set scaleRatio(value: number);
  49467. get scaleRatio(): number;
  49468. /**
  49469. * Disposes of the gizmo
  49470. */
  49471. dispose(): void;
  49472. /**
  49473. * CustomMeshes are not supported by this gizmo
  49474. * @param mesh The mesh to replace the default mesh of the gizmo
  49475. */
  49476. setCustomMesh(mesh: Mesh): void;
  49477. }
  49478. }
  49479. declare module BABYLON {
  49480. /**
  49481. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49482. */
  49483. export class GizmoManager implements IDisposable {
  49484. private scene;
  49485. /**
  49486. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49487. */
  49488. gizmos: {
  49489. positionGizmo: Nullable<PositionGizmo>;
  49490. rotationGizmo: Nullable<RotationGizmo>;
  49491. scaleGizmo: Nullable<ScaleGizmo>;
  49492. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49493. };
  49494. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49495. clearGizmoOnEmptyPointerEvent: boolean;
  49496. /** Fires an event when the manager is attached to a mesh */
  49497. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49498. private _gizmosEnabled;
  49499. private _pointerObserver;
  49500. private _attachedMesh;
  49501. private _boundingBoxColor;
  49502. private _defaultUtilityLayer;
  49503. private _defaultKeepDepthUtilityLayer;
  49504. /**
  49505. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49506. */
  49507. boundingBoxDragBehavior: SixDofDragBehavior;
  49508. /**
  49509. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49510. */
  49511. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49512. /**
  49513. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49514. */
  49515. usePointerToAttachGizmos: boolean;
  49516. /**
  49517. * Utility layer that the bounding box gizmo belongs to
  49518. */
  49519. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49520. /**
  49521. * Utility layer that all gizmos besides bounding box belong to
  49522. */
  49523. get utilityLayer(): UtilityLayerRenderer;
  49524. /**
  49525. * Instatiates a gizmo manager
  49526. * @param scene the scene to overlay the gizmos on top of
  49527. */
  49528. constructor(scene: Scene);
  49529. /**
  49530. * Attaches a set of gizmos to the specified mesh
  49531. * @param mesh The mesh the gizmo's should be attached to
  49532. */
  49533. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49534. /**
  49535. * If the position gizmo is enabled
  49536. */
  49537. set positionGizmoEnabled(value: boolean);
  49538. get positionGizmoEnabled(): boolean;
  49539. /**
  49540. * If the rotation gizmo is enabled
  49541. */
  49542. set rotationGizmoEnabled(value: boolean);
  49543. get rotationGizmoEnabled(): boolean;
  49544. /**
  49545. * If the scale gizmo is enabled
  49546. */
  49547. set scaleGizmoEnabled(value: boolean);
  49548. get scaleGizmoEnabled(): boolean;
  49549. /**
  49550. * If the boundingBox gizmo is enabled
  49551. */
  49552. set boundingBoxGizmoEnabled(value: boolean);
  49553. get boundingBoxGizmoEnabled(): boolean;
  49554. /**
  49555. * Disposes of the gizmo manager
  49556. */
  49557. dispose(): void;
  49558. }
  49559. }
  49560. declare module BABYLON {
  49561. /**
  49562. * A directional light is defined by a direction (what a surprise!).
  49563. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49564. * 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.
  49565. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49566. */
  49567. export class DirectionalLight extends ShadowLight {
  49568. private _shadowFrustumSize;
  49569. /**
  49570. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49571. */
  49572. get shadowFrustumSize(): number;
  49573. /**
  49574. * Specifies a fix frustum size for the shadow generation.
  49575. */
  49576. set shadowFrustumSize(value: number);
  49577. private _shadowOrthoScale;
  49578. /**
  49579. * Gets the shadow projection scale against the optimal computed one.
  49580. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49581. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49582. */
  49583. get shadowOrthoScale(): number;
  49584. /**
  49585. * Sets the shadow projection scale against the optimal computed one.
  49586. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49587. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49588. */
  49589. set shadowOrthoScale(value: number);
  49590. /**
  49591. * Automatically compute the projection matrix to best fit (including all the casters)
  49592. * on each frame.
  49593. */
  49594. autoUpdateExtends: boolean;
  49595. /**
  49596. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49597. * on each frame. autoUpdateExtends must be set to true for this to work
  49598. */
  49599. autoCalcShadowZBounds: boolean;
  49600. private _orthoLeft;
  49601. private _orthoRight;
  49602. private _orthoTop;
  49603. private _orthoBottom;
  49604. /**
  49605. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49606. * The directional light is emitted from everywhere in the given direction.
  49607. * It can cast shadows.
  49608. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49609. * @param name The friendly name of the light
  49610. * @param direction The direction of the light
  49611. * @param scene The scene the light belongs to
  49612. */
  49613. constructor(name: string, direction: Vector3, scene: Scene);
  49614. /**
  49615. * Returns the string "DirectionalLight".
  49616. * @return The class name
  49617. */
  49618. getClassName(): string;
  49619. /**
  49620. * Returns the integer 1.
  49621. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49622. */
  49623. getTypeID(): number;
  49624. /**
  49625. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49626. * Returns the DirectionalLight Shadow projection matrix.
  49627. */
  49628. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49629. /**
  49630. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49631. * Returns the DirectionalLight Shadow projection matrix.
  49632. */
  49633. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49634. /**
  49635. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49636. * Returns the DirectionalLight Shadow projection matrix.
  49637. */
  49638. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49639. protected _buildUniformLayout(): void;
  49640. /**
  49641. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49642. * @param effect The effect to update
  49643. * @param lightIndex The index of the light in the effect to update
  49644. * @returns The directional light
  49645. */
  49646. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49647. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49648. /**
  49649. * Gets the minZ used for shadow according to both the scene and the light.
  49650. *
  49651. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49652. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49653. * @param activeCamera The camera we are returning the min for
  49654. * @returns the depth min z
  49655. */
  49656. getDepthMinZ(activeCamera: Camera): number;
  49657. /**
  49658. * Gets the maxZ used for shadow according to both the scene and the light.
  49659. *
  49660. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49661. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49662. * @param activeCamera The camera we are returning the max for
  49663. * @returns the depth max z
  49664. */
  49665. getDepthMaxZ(activeCamera: Camera): number;
  49666. /**
  49667. * Prepares the list of defines specific to the light type.
  49668. * @param defines the list of defines
  49669. * @param lightIndex defines the index of the light for the effect
  49670. */
  49671. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49672. }
  49673. }
  49674. declare module BABYLON {
  49675. /**
  49676. * Class containing static functions to help procedurally build meshes
  49677. */
  49678. export class HemisphereBuilder {
  49679. /**
  49680. * Creates a hemisphere mesh
  49681. * @param name defines the name of the mesh
  49682. * @param options defines the options used to create the mesh
  49683. * @param scene defines the hosting scene
  49684. * @returns the hemisphere mesh
  49685. */
  49686. static CreateHemisphere(name: string, options: {
  49687. segments?: number;
  49688. diameter?: number;
  49689. sideOrientation?: number;
  49690. }, scene: any): Mesh;
  49691. }
  49692. }
  49693. declare module BABYLON {
  49694. /**
  49695. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49696. * These values define a cone of light starting from the position, emitting toward the direction.
  49697. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49698. * and the exponent defines the speed of the decay of the light with distance (reach).
  49699. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49700. */
  49701. export class SpotLight extends ShadowLight {
  49702. private _angle;
  49703. private _innerAngle;
  49704. private _cosHalfAngle;
  49705. private _lightAngleScale;
  49706. private _lightAngleOffset;
  49707. /**
  49708. * Gets the cone angle of the spot light in Radians.
  49709. */
  49710. get angle(): number;
  49711. /**
  49712. * Sets the cone angle of the spot light in Radians.
  49713. */
  49714. set angle(value: number);
  49715. /**
  49716. * Only used in gltf falloff mode, this defines the angle where
  49717. * the directional falloff will start before cutting at angle which could be seen
  49718. * as outer angle.
  49719. */
  49720. get innerAngle(): number;
  49721. /**
  49722. * Only used in gltf falloff mode, this defines the angle where
  49723. * the directional falloff will start before cutting at angle which could be seen
  49724. * as outer angle.
  49725. */
  49726. set innerAngle(value: number);
  49727. private _shadowAngleScale;
  49728. /**
  49729. * Allows scaling the angle of the light for shadow generation only.
  49730. */
  49731. get shadowAngleScale(): number;
  49732. /**
  49733. * Allows scaling the angle of the light for shadow generation only.
  49734. */
  49735. set shadowAngleScale(value: number);
  49736. /**
  49737. * The light decay speed with the distance from the emission spot.
  49738. */
  49739. exponent: number;
  49740. private _projectionTextureMatrix;
  49741. /**
  49742. * Allows reading the projecton texture
  49743. */
  49744. get projectionTextureMatrix(): Matrix;
  49745. protected _projectionTextureLightNear: number;
  49746. /**
  49747. * Gets the near clip of the Spotlight for texture projection.
  49748. */
  49749. get projectionTextureLightNear(): number;
  49750. /**
  49751. * Sets the near clip of the Spotlight for texture projection.
  49752. */
  49753. set projectionTextureLightNear(value: number);
  49754. protected _projectionTextureLightFar: number;
  49755. /**
  49756. * Gets the far clip of the Spotlight for texture projection.
  49757. */
  49758. get projectionTextureLightFar(): number;
  49759. /**
  49760. * Sets the far clip of the Spotlight for texture projection.
  49761. */
  49762. set projectionTextureLightFar(value: number);
  49763. protected _projectionTextureUpDirection: Vector3;
  49764. /**
  49765. * Gets the Up vector of the Spotlight for texture projection.
  49766. */
  49767. get projectionTextureUpDirection(): Vector3;
  49768. /**
  49769. * Sets the Up vector of the Spotlight for texture projection.
  49770. */
  49771. set projectionTextureUpDirection(value: Vector3);
  49772. private _projectionTexture;
  49773. /**
  49774. * Gets the projection texture of the light.
  49775. */
  49776. get projectionTexture(): Nullable<BaseTexture>;
  49777. /**
  49778. * Sets the projection texture of the light.
  49779. */
  49780. set projectionTexture(value: Nullable<BaseTexture>);
  49781. private _projectionTextureViewLightDirty;
  49782. private _projectionTextureProjectionLightDirty;
  49783. private _projectionTextureDirty;
  49784. private _projectionTextureViewTargetVector;
  49785. private _projectionTextureViewLightMatrix;
  49786. private _projectionTextureProjectionLightMatrix;
  49787. private _projectionTextureScalingMatrix;
  49788. /**
  49789. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49790. * It can cast shadows.
  49791. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49792. * @param name The light friendly name
  49793. * @param position The position of the spot light in the scene
  49794. * @param direction The direction of the light in the scene
  49795. * @param angle The cone angle of the light in Radians
  49796. * @param exponent The light decay speed with the distance from the emission spot
  49797. * @param scene The scene the lights belongs to
  49798. */
  49799. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49800. /**
  49801. * Returns the string "SpotLight".
  49802. * @returns the class name
  49803. */
  49804. getClassName(): string;
  49805. /**
  49806. * Returns the integer 2.
  49807. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49808. */
  49809. getTypeID(): number;
  49810. /**
  49811. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49812. */
  49813. protected _setDirection(value: Vector3): void;
  49814. /**
  49815. * Overrides the position setter to recompute the projection texture view light Matrix.
  49816. */
  49817. protected _setPosition(value: Vector3): void;
  49818. /**
  49819. * 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.
  49820. * Returns the SpotLight.
  49821. */
  49822. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49823. protected _computeProjectionTextureViewLightMatrix(): void;
  49824. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49825. /**
  49826. * Main function for light texture projection matrix computing.
  49827. */
  49828. protected _computeProjectionTextureMatrix(): void;
  49829. protected _buildUniformLayout(): void;
  49830. private _computeAngleValues;
  49831. /**
  49832. * Sets the passed Effect "effect" with the Light textures.
  49833. * @param effect The effect to update
  49834. * @param lightIndex The index of the light in the effect to update
  49835. * @returns The light
  49836. */
  49837. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49838. /**
  49839. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49840. * @param effect The effect to update
  49841. * @param lightIndex The index of the light in the effect to update
  49842. * @returns The spot light
  49843. */
  49844. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49845. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49846. /**
  49847. * Disposes the light and the associated resources.
  49848. */
  49849. dispose(): void;
  49850. /**
  49851. * Prepares the list of defines specific to the light type.
  49852. * @param defines the list of defines
  49853. * @param lightIndex defines the index of the light for the effect
  49854. */
  49855. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49856. }
  49857. }
  49858. declare module BABYLON {
  49859. /**
  49860. * Gizmo that enables viewing a light
  49861. */
  49862. export class LightGizmo extends Gizmo {
  49863. private _lightMesh;
  49864. private _material;
  49865. private _cachedPosition;
  49866. private _cachedForward;
  49867. private _attachedMeshParent;
  49868. /**
  49869. * Creates a LightGizmo
  49870. * @param gizmoLayer The utility layer the gizmo will be added to
  49871. */
  49872. constructor(gizmoLayer?: UtilityLayerRenderer);
  49873. private _light;
  49874. /**
  49875. * The light that the gizmo is attached to
  49876. */
  49877. set light(light: Nullable<Light>);
  49878. get light(): Nullable<Light>;
  49879. /**
  49880. * Gets the material used to render the light gizmo
  49881. */
  49882. get material(): StandardMaterial;
  49883. /**
  49884. * @hidden
  49885. * Updates the gizmo to match the attached mesh's position/rotation
  49886. */
  49887. protected _update(): void;
  49888. private static _Scale;
  49889. /**
  49890. * Creates the lines for a light mesh
  49891. */
  49892. private static _CreateLightLines;
  49893. /**
  49894. * Disposes of the light gizmo
  49895. */
  49896. dispose(): void;
  49897. private static _CreateHemisphericLightMesh;
  49898. private static _CreatePointLightMesh;
  49899. private static _CreateSpotLightMesh;
  49900. private static _CreateDirectionalLightMesh;
  49901. }
  49902. }
  49903. declare module BABYLON {
  49904. /** @hidden */
  49905. export var backgroundFragmentDeclaration: {
  49906. name: string;
  49907. shader: string;
  49908. };
  49909. }
  49910. declare module BABYLON {
  49911. /** @hidden */
  49912. export var backgroundUboDeclaration: {
  49913. name: string;
  49914. shader: string;
  49915. };
  49916. }
  49917. declare module BABYLON {
  49918. /** @hidden */
  49919. export var backgroundPixelShader: {
  49920. name: string;
  49921. shader: string;
  49922. };
  49923. }
  49924. declare module BABYLON {
  49925. /** @hidden */
  49926. export var backgroundVertexDeclaration: {
  49927. name: string;
  49928. shader: string;
  49929. };
  49930. }
  49931. declare module BABYLON {
  49932. /** @hidden */
  49933. export var backgroundVertexShader: {
  49934. name: string;
  49935. shader: string;
  49936. };
  49937. }
  49938. declare module BABYLON {
  49939. /**
  49940. * Background material used to create an efficient environement around your scene.
  49941. */
  49942. export class BackgroundMaterial extends PushMaterial {
  49943. /**
  49944. * Standard reflectance value at parallel view angle.
  49945. */
  49946. static StandardReflectance0: number;
  49947. /**
  49948. * Standard reflectance value at grazing angle.
  49949. */
  49950. static StandardReflectance90: number;
  49951. protected _primaryColor: Color3;
  49952. /**
  49953. * Key light Color (multiply against the environement texture)
  49954. */
  49955. primaryColor: Color3;
  49956. protected __perceptualColor: Nullable<Color3>;
  49957. /**
  49958. * Experimental Internal Use Only.
  49959. *
  49960. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49961. * This acts as a helper to set the primary color to a more "human friendly" value.
  49962. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49963. * output color as close as possible from the chosen value.
  49964. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49965. * part of lighting setup.)
  49966. */
  49967. get _perceptualColor(): Nullable<Color3>;
  49968. set _perceptualColor(value: Nullable<Color3>);
  49969. protected _primaryColorShadowLevel: float;
  49970. /**
  49971. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49972. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49973. */
  49974. get primaryColorShadowLevel(): float;
  49975. set primaryColorShadowLevel(value: float);
  49976. protected _primaryColorHighlightLevel: float;
  49977. /**
  49978. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49979. * The primary color is used at the level chosen to define what the white area would look.
  49980. */
  49981. get primaryColorHighlightLevel(): float;
  49982. set primaryColorHighlightLevel(value: float);
  49983. protected _reflectionTexture: Nullable<BaseTexture>;
  49984. /**
  49985. * Reflection Texture used in the material.
  49986. * Should be author in a specific way for the best result (refer to the documentation).
  49987. */
  49988. reflectionTexture: Nullable<BaseTexture>;
  49989. protected _reflectionBlur: float;
  49990. /**
  49991. * Reflection Texture level of blur.
  49992. *
  49993. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49994. * texture twice.
  49995. */
  49996. reflectionBlur: float;
  49997. protected _diffuseTexture: Nullable<BaseTexture>;
  49998. /**
  49999. * Diffuse Texture used in the material.
  50000. * Should be author in a specific way for the best result (refer to the documentation).
  50001. */
  50002. diffuseTexture: Nullable<BaseTexture>;
  50003. protected _shadowLights: Nullable<IShadowLight[]>;
  50004. /**
  50005. * Specify the list of lights casting shadow on the material.
  50006. * All scene shadow lights will be included if null.
  50007. */
  50008. shadowLights: Nullable<IShadowLight[]>;
  50009. protected _shadowLevel: float;
  50010. /**
  50011. * Helps adjusting the shadow to a softer level if required.
  50012. * 0 means black shadows and 1 means no shadows.
  50013. */
  50014. shadowLevel: float;
  50015. protected _sceneCenter: Vector3;
  50016. /**
  50017. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50018. * It is usually zero but might be interesting to modify according to your setup.
  50019. */
  50020. sceneCenter: Vector3;
  50021. protected _opacityFresnel: boolean;
  50022. /**
  50023. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50024. * This helps ensuring a nice transition when the camera goes under the ground.
  50025. */
  50026. opacityFresnel: boolean;
  50027. protected _reflectionFresnel: boolean;
  50028. /**
  50029. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50030. * This helps adding a mirror texture on the ground.
  50031. */
  50032. reflectionFresnel: boolean;
  50033. protected _reflectionFalloffDistance: number;
  50034. /**
  50035. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50036. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50037. */
  50038. reflectionFalloffDistance: number;
  50039. protected _reflectionAmount: number;
  50040. /**
  50041. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50042. */
  50043. reflectionAmount: number;
  50044. protected _reflectionReflectance0: number;
  50045. /**
  50046. * This specifies the weight of the reflection at grazing angle.
  50047. */
  50048. reflectionReflectance0: number;
  50049. protected _reflectionReflectance90: number;
  50050. /**
  50051. * This specifies the weight of the reflection at a perpendicular point of view.
  50052. */
  50053. reflectionReflectance90: number;
  50054. /**
  50055. * Sets the reflection reflectance fresnel values according to the default standard
  50056. * empirically know to work well :-)
  50057. */
  50058. set reflectionStandardFresnelWeight(value: number);
  50059. protected _useRGBColor: boolean;
  50060. /**
  50061. * Helps to directly use the maps channels instead of their level.
  50062. */
  50063. useRGBColor: boolean;
  50064. protected _enableNoise: boolean;
  50065. /**
  50066. * This helps reducing the banding effect that could occur on the background.
  50067. */
  50068. enableNoise: boolean;
  50069. /**
  50070. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50071. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  50072. * Recommended to be keep at 1.0 except for special cases.
  50073. */
  50074. get fovMultiplier(): number;
  50075. set fovMultiplier(value: number);
  50076. private _fovMultiplier;
  50077. /**
  50078. * Enable the FOV adjustment feature controlled by fovMultiplier.
  50079. */
  50080. useEquirectangularFOV: boolean;
  50081. private _maxSimultaneousLights;
  50082. /**
  50083. * Number of Simultaneous lights allowed on the material.
  50084. */
  50085. maxSimultaneousLights: int;
  50086. /**
  50087. * Default configuration related to image processing available in the Background Material.
  50088. */
  50089. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  50090. /**
  50091. * Keep track of the image processing observer to allow dispose and replace.
  50092. */
  50093. private _imageProcessingObserver;
  50094. /**
  50095. * Attaches a new image processing configuration to the PBR Material.
  50096. * @param configuration (if null the scene configuration will be use)
  50097. */
  50098. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  50099. /**
  50100. * Gets the image processing configuration used either in this material.
  50101. */
  50102. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  50103. /**
  50104. * Sets the Default image processing configuration used either in the this material.
  50105. *
  50106. * If sets to null, the scene one is in use.
  50107. */
  50108. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  50109. /**
  50110. * Gets wether the color curves effect is enabled.
  50111. */
  50112. get cameraColorCurvesEnabled(): boolean;
  50113. /**
  50114. * Sets wether the color curves effect is enabled.
  50115. */
  50116. set cameraColorCurvesEnabled(value: boolean);
  50117. /**
  50118. * Gets wether the color grading effect is enabled.
  50119. */
  50120. get cameraColorGradingEnabled(): boolean;
  50121. /**
  50122. * Gets wether the color grading effect is enabled.
  50123. */
  50124. set cameraColorGradingEnabled(value: boolean);
  50125. /**
  50126. * Gets wether tonemapping is enabled or not.
  50127. */
  50128. get cameraToneMappingEnabled(): boolean;
  50129. /**
  50130. * Sets wether tonemapping is enabled or not
  50131. */
  50132. set cameraToneMappingEnabled(value: boolean);
  50133. /**
  50134. * The camera exposure used on this material.
  50135. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50136. * This corresponds to a photographic exposure.
  50137. */
  50138. get cameraExposure(): float;
  50139. /**
  50140. * The camera exposure used on this material.
  50141. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50142. * This corresponds to a photographic exposure.
  50143. */
  50144. set cameraExposure(value: float);
  50145. /**
  50146. * Gets The camera contrast used on this material.
  50147. */
  50148. get cameraContrast(): float;
  50149. /**
  50150. * Sets The camera contrast used on this material.
  50151. */
  50152. set cameraContrast(value: float);
  50153. /**
  50154. * Gets the Color Grading 2D Lookup Texture.
  50155. */
  50156. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  50157. /**
  50158. * Sets the Color Grading 2D Lookup Texture.
  50159. */
  50160. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  50161. /**
  50162. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50163. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50164. * 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;
  50165. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50166. */
  50167. get cameraColorCurves(): Nullable<ColorCurves>;
  50168. /**
  50169. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50170. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50171. * 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;
  50172. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50173. */
  50174. set cameraColorCurves(value: Nullable<ColorCurves>);
  50175. /**
  50176. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  50177. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  50178. */
  50179. switchToBGR: boolean;
  50180. private _renderTargets;
  50181. private _reflectionControls;
  50182. private _white;
  50183. private _primaryShadowColor;
  50184. private _primaryHighlightColor;
  50185. /**
  50186. * Instantiates a Background Material in the given scene
  50187. * @param name The friendly name of the material
  50188. * @param scene The scene to add the material to
  50189. */
  50190. constructor(name: string, scene: Scene);
  50191. /**
  50192. * Gets a boolean indicating that current material needs to register RTT
  50193. */
  50194. get hasRenderTargetTextures(): boolean;
  50195. /**
  50196. * The entire material has been created in order to prevent overdraw.
  50197. * @returns false
  50198. */
  50199. needAlphaTesting(): boolean;
  50200. /**
  50201. * The entire material has been created in order to prevent overdraw.
  50202. * @returns true if blending is enable
  50203. */
  50204. needAlphaBlending(): boolean;
  50205. /**
  50206. * Checks wether the material is ready to be rendered for a given mesh.
  50207. * @param mesh The mesh to render
  50208. * @param subMesh The submesh to check against
  50209. * @param useInstances Specify wether or not the material is used with instances
  50210. * @returns true if all the dependencies are ready (Textures, Effects...)
  50211. */
  50212. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50213. /**
  50214. * Compute the primary color according to the chosen perceptual color.
  50215. */
  50216. private _computePrimaryColorFromPerceptualColor;
  50217. /**
  50218. * Compute the highlights and shadow colors according to their chosen levels.
  50219. */
  50220. private _computePrimaryColors;
  50221. /**
  50222. * Build the uniform buffer used in the material.
  50223. */
  50224. buildUniformLayout(): void;
  50225. /**
  50226. * Unbind the material.
  50227. */
  50228. unbind(): void;
  50229. /**
  50230. * Bind only the world matrix to the material.
  50231. * @param world The world matrix to bind.
  50232. */
  50233. bindOnlyWorldMatrix(world: Matrix): void;
  50234. /**
  50235. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50236. * @param world The world matrix to bind.
  50237. * @param subMesh The submesh to bind for.
  50238. */
  50239. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50240. /**
  50241. * Checks to see if a texture is used in the material.
  50242. * @param texture - Base texture to use.
  50243. * @returns - Boolean specifying if a texture is used in the material.
  50244. */
  50245. hasTexture(texture: BaseTexture): boolean;
  50246. /**
  50247. * Dispose the material.
  50248. * @param forceDisposeEffect Force disposal of the associated effect.
  50249. * @param forceDisposeTextures Force disposal of the associated textures.
  50250. */
  50251. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50252. /**
  50253. * Clones the material.
  50254. * @param name The cloned name.
  50255. * @returns The cloned material.
  50256. */
  50257. clone(name: string): BackgroundMaterial;
  50258. /**
  50259. * Serializes the current material to its JSON representation.
  50260. * @returns The JSON representation.
  50261. */
  50262. serialize(): any;
  50263. /**
  50264. * Gets the class name of the material
  50265. * @returns "BackgroundMaterial"
  50266. */
  50267. getClassName(): string;
  50268. /**
  50269. * Parse a JSON input to create back a background material.
  50270. * @param source The JSON data to parse
  50271. * @param scene The scene to create the parsed material in
  50272. * @param rootUrl The root url of the assets the material depends upon
  50273. * @returns the instantiated BackgroundMaterial.
  50274. */
  50275. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  50276. }
  50277. }
  50278. declare module BABYLON {
  50279. /**
  50280. * Represents the different options available during the creation of
  50281. * a Environment helper.
  50282. *
  50283. * This can control the default ground, skybox and image processing setup of your scene.
  50284. */
  50285. export interface IEnvironmentHelperOptions {
  50286. /**
  50287. * Specifies whether or not to create a ground.
  50288. * True by default.
  50289. */
  50290. createGround: boolean;
  50291. /**
  50292. * Specifies the ground size.
  50293. * 15 by default.
  50294. */
  50295. groundSize: number;
  50296. /**
  50297. * The texture used on the ground for the main color.
  50298. * Comes from the BabylonJS CDN by default.
  50299. *
  50300. * Remarks: Can be either a texture or a url.
  50301. */
  50302. groundTexture: string | BaseTexture;
  50303. /**
  50304. * The color mixed in the ground texture by default.
  50305. * BabylonJS clearColor by default.
  50306. */
  50307. groundColor: Color3;
  50308. /**
  50309. * Specifies the ground opacity.
  50310. * 1 by default.
  50311. */
  50312. groundOpacity: number;
  50313. /**
  50314. * Enables the ground to receive shadows.
  50315. * True by default.
  50316. */
  50317. enableGroundShadow: boolean;
  50318. /**
  50319. * Helps preventing the shadow to be fully black on the ground.
  50320. * 0.5 by default.
  50321. */
  50322. groundShadowLevel: number;
  50323. /**
  50324. * Creates a mirror texture attach to the ground.
  50325. * false by default.
  50326. */
  50327. enableGroundMirror: boolean;
  50328. /**
  50329. * Specifies the ground mirror size ratio.
  50330. * 0.3 by default as the default kernel is 64.
  50331. */
  50332. groundMirrorSizeRatio: number;
  50333. /**
  50334. * Specifies the ground mirror blur kernel size.
  50335. * 64 by default.
  50336. */
  50337. groundMirrorBlurKernel: number;
  50338. /**
  50339. * Specifies the ground mirror visibility amount.
  50340. * 1 by default
  50341. */
  50342. groundMirrorAmount: number;
  50343. /**
  50344. * Specifies the ground mirror reflectance weight.
  50345. * This uses the standard weight of the background material to setup the fresnel effect
  50346. * of the mirror.
  50347. * 1 by default.
  50348. */
  50349. groundMirrorFresnelWeight: number;
  50350. /**
  50351. * Specifies the ground mirror Falloff distance.
  50352. * This can helps reducing the size of the reflection.
  50353. * 0 by Default.
  50354. */
  50355. groundMirrorFallOffDistance: number;
  50356. /**
  50357. * Specifies the ground mirror texture type.
  50358. * Unsigned Int by Default.
  50359. */
  50360. groundMirrorTextureType: number;
  50361. /**
  50362. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  50363. * the shown objects.
  50364. */
  50365. groundYBias: number;
  50366. /**
  50367. * Specifies whether or not to create a skybox.
  50368. * True by default.
  50369. */
  50370. createSkybox: boolean;
  50371. /**
  50372. * Specifies the skybox size.
  50373. * 20 by default.
  50374. */
  50375. skyboxSize: number;
  50376. /**
  50377. * The texture used on the skybox for the main color.
  50378. * Comes from the BabylonJS CDN by default.
  50379. *
  50380. * Remarks: Can be either a texture or a url.
  50381. */
  50382. skyboxTexture: string | BaseTexture;
  50383. /**
  50384. * The color mixed in the skybox texture by default.
  50385. * BabylonJS clearColor by default.
  50386. */
  50387. skyboxColor: Color3;
  50388. /**
  50389. * The background rotation around the Y axis of the scene.
  50390. * This helps aligning the key lights of your scene with the background.
  50391. * 0 by default.
  50392. */
  50393. backgroundYRotation: number;
  50394. /**
  50395. * Compute automatically the size of the elements to best fit with the scene.
  50396. */
  50397. sizeAuto: boolean;
  50398. /**
  50399. * Default position of the rootMesh if autoSize is not true.
  50400. */
  50401. rootPosition: Vector3;
  50402. /**
  50403. * Sets up the image processing in the scene.
  50404. * true by default.
  50405. */
  50406. setupImageProcessing: boolean;
  50407. /**
  50408. * The texture used as your environment texture in the scene.
  50409. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50410. *
  50411. * Remarks: Can be either a texture or a url.
  50412. */
  50413. environmentTexture: string | BaseTexture;
  50414. /**
  50415. * The value of the exposure to apply to the scene.
  50416. * 0.6 by default if setupImageProcessing is true.
  50417. */
  50418. cameraExposure: number;
  50419. /**
  50420. * The value of the contrast to apply to the scene.
  50421. * 1.6 by default if setupImageProcessing is true.
  50422. */
  50423. cameraContrast: number;
  50424. /**
  50425. * Specifies whether or not tonemapping should be enabled in the scene.
  50426. * true by default if setupImageProcessing is true.
  50427. */
  50428. toneMappingEnabled: boolean;
  50429. }
  50430. /**
  50431. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50432. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50433. * It also helps with the default setup of your imageProcessing configuration.
  50434. */
  50435. export class EnvironmentHelper {
  50436. /**
  50437. * Default ground texture URL.
  50438. */
  50439. private static _groundTextureCDNUrl;
  50440. /**
  50441. * Default skybox texture URL.
  50442. */
  50443. private static _skyboxTextureCDNUrl;
  50444. /**
  50445. * Default environment texture URL.
  50446. */
  50447. private static _environmentTextureCDNUrl;
  50448. /**
  50449. * Creates the default options for the helper.
  50450. */
  50451. private static _getDefaultOptions;
  50452. private _rootMesh;
  50453. /**
  50454. * Gets the root mesh created by the helper.
  50455. */
  50456. get rootMesh(): Mesh;
  50457. private _skybox;
  50458. /**
  50459. * Gets the skybox created by the helper.
  50460. */
  50461. get skybox(): Nullable<Mesh>;
  50462. private _skyboxTexture;
  50463. /**
  50464. * Gets the skybox texture created by the helper.
  50465. */
  50466. get skyboxTexture(): Nullable<BaseTexture>;
  50467. private _skyboxMaterial;
  50468. /**
  50469. * Gets the skybox material created by the helper.
  50470. */
  50471. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50472. private _ground;
  50473. /**
  50474. * Gets the ground mesh created by the helper.
  50475. */
  50476. get ground(): Nullable<Mesh>;
  50477. private _groundTexture;
  50478. /**
  50479. * Gets the ground texture created by the helper.
  50480. */
  50481. get groundTexture(): Nullable<BaseTexture>;
  50482. private _groundMirror;
  50483. /**
  50484. * Gets the ground mirror created by the helper.
  50485. */
  50486. get groundMirror(): Nullable<MirrorTexture>;
  50487. /**
  50488. * Gets the ground mirror render list to helps pushing the meshes
  50489. * you wish in the ground reflection.
  50490. */
  50491. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50492. private _groundMaterial;
  50493. /**
  50494. * Gets the ground material created by the helper.
  50495. */
  50496. get groundMaterial(): Nullable<BackgroundMaterial>;
  50497. /**
  50498. * Stores the creation options.
  50499. */
  50500. private readonly _scene;
  50501. private _options;
  50502. /**
  50503. * This observable will be notified with any error during the creation of the environment,
  50504. * mainly texture creation errors.
  50505. */
  50506. onErrorObservable: Observable<{
  50507. message?: string;
  50508. exception?: any;
  50509. }>;
  50510. /**
  50511. * constructor
  50512. * @param options Defines the options we want to customize the helper
  50513. * @param scene The scene to add the material to
  50514. */
  50515. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50516. /**
  50517. * Updates the background according to the new options
  50518. * @param options
  50519. */
  50520. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50521. /**
  50522. * Sets the primary color of all the available elements.
  50523. * @param color the main color to affect to the ground and the background
  50524. */
  50525. setMainColor(color: Color3): void;
  50526. /**
  50527. * Setup the image processing according to the specified options.
  50528. */
  50529. private _setupImageProcessing;
  50530. /**
  50531. * Setup the environment texture according to the specified options.
  50532. */
  50533. private _setupEnvironmentTexture;
  50534. /**
  50535. * Setup the background according to the specified options.
  50536. */
  50537. private _setupBackground;
  50538. /**
  50539. * Get the scene sizes according to the setup.
  50540. */
  50541. private _getSceneSize;
  50542. /**
  50543. * Setup the ground according to the specified options.
  50544. */
  50545. private _setupGround;
  50546. /**
  50547. * Setup the ground material according to the specified options.
  50548. */
  50549. private _setupGroundMaterial;
  50550. /**
  50551. * Setup the ground diffuse texture according to the specified options.
  50552. */
  50553. private _setupGroundDiffuseTexture;
  50554. /**
  50555. * Setup the ground mirror texture according to the specified options.
  50556. */
  50557. private _setupGroundMirrorTexture;
  50558. /**
  50559. * Setup the ground to receive the mirror texture.
  50560. */
  50561. private _setupMirrorInGroundMaterial;
  50562. /**
  50563. * Setup the skybox according to the specified options.
  50564. */
  50565. private _setupSkybox;
  50566. /**
  50567. * Setup the skybox material according to the specified options.
  50568. */
  50569. private _setupSkyboxMaterial;
  50570. /**
  50571. * Setup the skybox reflection texture according to the specified options.
  50572. */
  50573. private _setupSkyboxReflectionTexture;
  50574. private _errorHandler;
  50575. /**
  50576. * Dispose all the elements created by the Helper.
  50577. */
  50578. dispose(): void;
  50579. }
  50580. }
  50581. declare module BABYLON {
  50582. /**
  50583. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50584. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50585. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50586. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50587. */
  50588. export class PhotoDome extends TransformNode {
  50589. /**
  50590. * Define the image as a Monoscopic panoramic 360 image.
  50591. */
  50592. static readonly MODE_MONOSCOPIC: number;
  50593. /**
  50594. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50595. */
  50596. static readonly MODE_TOPBOTTOM: number;
  50597. /**
  50598. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50599. */
  50600. static readonly MODE_SIDEBYSIDE: number;
  50601. private _useDirectMapping;
  50602. /**
  50603. * The texture being displayed on the sphere
  50604. */
  50605. protected _photoTexture: Texture;
  50606. /**
  50607. * Gets or sets the texture being displayed on the sphere
  50608. */
  50609. get photoTexture(): Texture;
  50610. set photoTexture(value: Texture);
  50611. /**
  50612. * Observable raised when an error occured while loading the 360 image
  50613. */
  50614. onLoadErrorObservable: Observable<string>;
  50615. /**
  50616. * The skybox material
  50617. */
  50618. protected _material: BackgroundMaterial;
  50619. /**
  50620. * The surface used for the skybox
  50621. */
  50622. protected _mesh: Mesh;
  50623. /**
  50624. * Gets the mesh used for the skybox.
  50625. */
  50626. get mesh(): Mesh;
  50627. /**
  50628. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50629. * Also see the options.resolution property.
  50630. */
  50631. get fovMultiplier(): number;
  50632. set fovMultiplier(value: number);
  50633. private _imageMode;
  50634. /**
  50635. * Gets or set the current video mode for the video. It can be:
  50636. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50637. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50638. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50639. */
  50640. get imageMode(): number;
  50641. set imageMode(value: number);
  50642. /**
  50643. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50644. * @param name Element's name, child elements will append suffixes for their own names.
  50645. * @param urlsOfPhoto defines the url of the photo to display
  50646. * @param options defines an object containing optional or exposed sub element properties
  50647. * @param onError defines a callback called when an error occured while loading the texture
  50648. */
  50649. constructor(name: string, urlOfPhoto: string, options: {
  50650. resolution?: number;
  50651. size?: number;
  50652. useDirectMapping?: boolean;
  50653. faceForward?: boolean;
  50654. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50655. private _onBeforeCameraRenderObserver;
  50656. private _changeImageMode;
  50657. /**
  50658. * Releases resources associated with this node.
  50659. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50660. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50661. */
  50662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50663. }
  50664. }
  50665. declare module BABYLON {
  50666. /**
  50667. * Class used to host RGBD texture specific utilities
  50668. */
  50669. export class RGBDTextureTools {
  50670. /**
  50671. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50672. * @param texture the texture to expand.
  50673. */
  50674. static ExpandRGBDTexture(texture: Texture): void;
  50675. }
  50676. }
  50677. declare module BABYLON {
  50678. /**
  50679. * Class used to host texture specific utilities
  50680. */
  50681. export class BRDFTextureTools {
  50682. /**
  50683. * Prevents texture cache collision
  50684. */
  50685. private static _instanceNumber;
  50686. /**
  50687. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50688. * @param scene defines the hosting scene
  50689. * @returns the environment BRDF texture
  50690. */
  50691. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50692. private static _environmentBRDFBase64Texture;
  50693. }
  50694. }
  50695. declare module BABYLON {
  50696. /**
  50697. * @hidden
  50698. */
  50699. export interface IMaterialClearCoatDefines {
  50700. CLEARCOAT: boolean;
  50701. CLEARCOAT_DEFAULTIOR: boolean;
  50702. CLEARCOAT_TEXTURE: boolean;
  50703. CLEARCOAT_TEXTUREDIRECTUV: number;
  50704. CLEARCOAT_BUMP: boolean;
  50705. CLEARCOAT_BUMPDIRECTUV: number;
  50706. CLEARCOAT_TINT: boolean;
  50707. CLEARCOAT_TINT_TEXTURE: boolean;
  50708. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50709. /** @hidden */
  50710. _areTexturesDirty: boolean;
  50711. }
  50712. /**
  50713. * Define the code related to the clear coat parameters of the pbr material.
  50714. */
  50715. export class PBRClearCoatConfiguration {
  50716. /**
  50717. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50718. * The default fits with a polyurethane material.
  50719. */
  50720. private static readonly _DefaultIndexOfRefraction;
  50721. private _isEnabled;
  50722. /**
  50723. * Defines if the clear coat is enabled in the material.
  50724. */
  50725. isEnabled: boolean;
  50726. /**
  50727. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50728. */
  50729. intensity: number;
  50730. /**
  50731. * Defines the clear coat layer roughness.
  50732. */
  50733. roughness: number;
  50734. private _indexOfRefraction;
  50735. /**
  50736. * Defines the index of refraction of the clear coat.
  50737. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50738. * The default fits with a polyurethane material.
  50739. * Changing the default value is more performance intensive.
  50740. */
  50741. indexOfRefraction: number;
  50742. private _texture;
  50743. /**
  50744. * Stores the clear coat values in a texture.
  50745. */
  50746. texture: Nullable<BaseTexture>;
  50747. private _bumpTexture;
  50748. /**
  50749. * Define the clear coat specific bump texture.
  50750. */
  50751. bumpTexture: Nullable<BaseTexture>;
  50752. private _isTintEnabled;
  50753. /**
  50754. * Defines if the clear coat tint is enabled in the material.
  50755. */
  50756. isTintEnabled: boolean;
  50757. /**
  50758. * Defines the clear coat tint of the material.
  50759. * This is only use if tint is enabled
  50760. */
  50761. tintColor: Color3;
  50762. /**
  50763. * Defines the distance at which the tint color should be found in the
  50764. * clear coat media.
  50765. * This is only use if tint is enabled
  50766. */
  50767. tintColorAtDistance: number;
  50768. /**
  50769. * Defines the clear coat layer thickness.
  50770. * This is only use if tint is enabled
  50771. */
  50772. tintThickness: number;
  50773. private _tintTexture;
  50774. /**
  50775. * Stores the clear tint values in a texture.
  50776. * rgb is tint
  50777. * a is a thickness factor
  50778. */
  50779. tintTexture: Nullable<BaseTexture>;
  50780. /** @hidden */
  50781. private _internalMarkAllSubMeshesAsTexturesDirty;
  50782. /** @hidden */
  50783. _markAllSubMeshesAsTexturesDirty(): void;
  50784. /**
  50785. * Instantiate a new istance of clear coat configuration.
  50786. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50787. */
  50788. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50789. /**
  50790. * Gets wehter the submesh is ready to be used or not.
  50791. * @param defines the list of "defines" to update.
  50792. * @param scene defines the scene the material belongs to.
  50793. * @param engine defines the engine the material belongs to.
  50794. * @param disableBumpMap defines wether the material disables bump or not.
  50795. * @returns - boolean indicating that the submesh is ready or not.
  50796. */
  50797. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50798. /**
  50799. * Checks to see if a texture is used in the material.
  50800. * @param defines the list of "defines" to update.
  50801. * @param scene defines the scene to the material belongs to.
  50802. */
  50803. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50804. /**
  50805. * Binds the material data.
  50806. * @param uniformBuffer defines the Uniform buffer to fill in.
  50807. * @param scene defines the scene the material belongs to.
  50808. * @param engine defines the engine the material belongs to.
  50809. * @param disableBumpMap defines wether the material disables bump or not.
  50810. * @param isFrozen defines wether the material is frozen or not.
  50811. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50812. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50813. */
  50814. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50815. /**
  50816. * Checks to see if a texture is used in the material.
  50817. * @param texture - Base texture to use.
  50818. * @returns - Boolean specifying if a texture is used in the material.
  50819. */
  50820. hasTexture(texture: BaseTexture): boolean;
  50821. /**
  50822. * Returns an array of the actively used textures.
  50823. * @param activeTextures Array of BaseTextures
  50824. */
  50825. getActiveTextures(activeTextures: BaseTexture[]): void;
  50826. /**
  50827. * Returns the animatable textures.
  50828. * @param animatables Array of animatable textures.
  50829. */
  50830. getAnimatables(animatables: IAnimatable[]): void;
  50831. /**
  50832. * Disposes the resources of the material.
  50833. * @param forceDisposeTextures - Forces the disposal of all textures.
  50834. */
  50835. dispose(forceDisposeTextures?: boolean): void;
  50836. /**
  50837. * Get the current class name of the texture useful for serialization or dynamic coding.
  50838. * @returns "PBRClearCoatConfiguration"
  50839. */
  50840. getClassName(): string;
  50841. /**
  50842. * Add fallbacks to the effect fallbacks list.
  50843. * @param defines defines the Base texture to use.
  50844. * @param fallbacks defines the current fallback list.
  50845. * @param currentRank defines the current fallback rank.
  50846. * @returns the new fallback rank.
  50847. */
  50848. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50849. /**
  50850. * Add the required uniforms to the current list.
  50851. * @param uniforms defines the current uniform list.
  50852. */
  50853. static AddUniforms(uniforms: string[]): void;
  50854. /**
  50855. * Add the required samplers to the current list.
  50856. * @param samplers defines the current sampler list.
  50857. */
  50858. static AddSamplers(samplers: string[]): void;
  50859. /**
  50860. * Add the required uniforms to the current buffer.
  50861. * @param uniformBuffer defines the current uniform buffer.
  50862. */
  50863. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50864. /**
  50865. * Makes a duplicate of the current configuration into another one.
  50866. * @param clearCoatConfiguration define the config where to copy the info
  50867. */
  50868. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50869. /**
  50870. * Serializes this clear coat configuration.
  50871. * @returns - An object with the serialized config.
  50872. */
  50873. serialize(): any;
  50874. /**
  50875. * Parses a anisotropy Configuration from a serialized object.
  50876. * @param source - Serialized object.
  50877. * @param scene Defines the scene we are parsing for
  50878. * @param rootUrl Defines the rootUrl to load from
  50879. */
  50880. parse(source: any, scene: Scene, rootUrl: string): void;
  50881. }
  50882. }
  50883. declare module BABYLON {
  50884. /**
  50885. * @hidden
  50886. */
  50887. export interface IMaterialAnisotropicDefines {
  50888. ANISOTROPIC: boolean;
  50889. ANISOTROPIC_TEXTURE: boolean;
  50890. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50891. MAINUV1: boolean;
  50892. _areTexturesDirty: boolean;
  50893. _needUVs: boolean;
  50894. }
  50895. /**
  50896. * Define the code related to the anisotropic parameters of the pbr material.
  50897. */
  50898. export class PBRAnisotropicConfiguration {
  50899. private _isEnabled;
  50900. /**
  50901. * Defines if the anisotropy is enabled in the material.
  50902. */
  50903. isEnabled: boolean;
  50904. /**
  50905. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50906. */
  50907. intensity: number;
  50908. /**
  50909. * Defines if the effect is along the tangents, bitangents or in between.
  50910. * By default, the effect is "strectching" the highlights along the tangents.
  50911. */
  50912. direction: Vector2;
  50913. private _texture;
  50914. /**
  50915. * Stores the anisotropy values in a texture.
  50916. * rg is direction (like normal from -1 to 1)
  50917. * b is a intensity
  50918. */
  50919. texture: Nullable<BaseTexture>;
  50920. /** @hidden */
  50921. private _internalMarkAllSubMeshesAsTexturesDirty;
  50922. /** @hidden */
  50923. _markAllSubMeshesAsTexturesDirty(): void;
  50924. /**
  50925. * Instantiate a new istance of anisotropy configuration.
  50926. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50927. */
  50928. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50929. /**
  50930. * Specifies that the submesh is ready to be used.
  50931. * @param defines the list of "defines" to update.
  50932. * @param scene defines the scene the material belongs to.
  50933. * @returns - boolean indicating that the submesh is ready or not.
  50934. */
  50935. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50936. /**
  50937. * Checks to see if a texture is used in the material.
  50938. * @param defines the list of "defines" to update.
  50939. * @param mesh the mesh we are preparing the defines for.
  50940. * @param scene defines the scene the material belongs to.
  50941. */
  50942. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50943. /**
  50944. * Binds the material data.
  50945. * @param uniformBuffer defines the Uniform buffer to fill in.
  50946. * @param scene defines the scene the material belongs to.
  50947. * @param isFrozen defines wether the material is frozen or not.
  50948. */
  50949. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50950. /**
  50951. * Checks to see if a texture is used in the material.
  50952. * @param texture - Base texture to use.
  50953. * @returns - Boolean specifying if a texture is used in the material.
  50954. */
  50955. hasTexture(texture: BaseTexture): boolean;
  50956. /**
  50957. * Returns an array of the actively used textures.
  50958. * @param activeTextures Array of BaseTextures
  50959. */
  50960. getActiveTextures(activeTextures: BaseTexture[]): void;
  50961. /**
  50962. * Returns the animatable textures.
  50963. * @param animatables Array of animatable textures.
  50964. */
  50965. getAnimatables(animatables: IAnimatable[]): void;
  50966. /**
  50967. * Disposes the resources of the material.
  50968. * @param forceDisposeTextures - Forces the disposal of all textures.
  50969. */
  50970. dispose(forceDisposeTextures?: boolean): void;
  50971. /**
  50972. * Get the current class name of the texture useful for serialization or dynamic coding.
  50973. * @returns "PBRAnisotropicConfiguration"
  50974. */
  50975. getClassName(): string;
  50976. /**
  50977. * Add fallbacks to the effect fallbacks list.
  50978. * @param defines defines the Base texture to use.
  50979. * @param fallbacks defines the current fallback list.
  50980. * @param currentRank defines the current fallback rank.
  50981. * @returns the new fallback rank.
  50982. */
  50983. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50984. /**
  50985. * Add the required uniforms to the current list.
  50986. * @param uniforms defines the current uniform list.
  50987. */
  50988. static AddUniforms(uniforms: string[]): void;
  50989. /**
  50990. * Add the required uniforms to the current buffer.
  50991. * @param uniformBuffer defines the current uniform buffer.
  50992. */
  50993. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50994. /**
  50995. * Add the required samplers to the current list.
  50996. * @param samplers defines the current sampler list.
  50997. */
  50998. static AddSamplers(samplers: string[]): void;
  50999. /**
  51000. * Makes a duplicate of the current configuration into another one.
  51001. * @param anisotropicConfiguration define the config where to copy the info
  51002. */
  51003. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51004. /**
  51005. * Serializes this anisotropy configuration.
  51006. * @returns - An object with the serialized config.
  51007. */
  51008. serialize(): any;
  51009. /**
  51010. * Parses a anisotropy Configuration from a serialized object.
  51011. * @param source - Serialized object.
  51012. * @param scene Defines the scene we are parsing for
  51013. * @param rootUrl Defines the rootUrl to load from
  51014. */
  51015. parse(source: any, scene: Scene, rootUrl: string): void;
  51016. }
  51017. }
  51018. declare module BABYLON {
  51019. /**
  51020. * @hidden
  51021. */
  51022. export interface IMaterialBRDFDefines {
  51023. BRDF_V_HEIGHT_CORRELATED: boolean;
  51024. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51025. SPHERICAL_HARMONICS: boolean;
  51026. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51027. /** @hidden */
  51028. _areMiscDirty: boolean;
  51029. }
  51030. /**
  51031. * Define the code related to the BRDF parameters of the pbr material.
  51032. */
  51033. export class PBRBRDFConfiguration {
  51034. /**
  51035. * Default value used for the energy conservation.
  51036. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51037. */
  51038. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  51039. /**
  51040. * Default value used for the Smith Visibility Height Correlated mode.
  51041. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  51042. */
  51043. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  51044. /**
  51045. * Default value used for the IBL diffuse part.
  51046. * This can help switching back to the polynomials mode globally which is a tiny bit
  51047. * less GPU intensive at the drawback of a lower quality.
  51048. */
  51049. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  51050. /**
  51051. * Default value used for activating energy conservation for the specular workflow.
  51052. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51053. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51054. */
  51055. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  51056. private _useEnergyConservation;
  51057. /**
  51058. * Defines if the material uses energy conservation.
  51059. */
  51060. useEnergyConservation: boolean;
  51061. private _useSmithVisibilityHeightCorrelated;
  51062. /**
  51063. * LEGACY Mode set to false
  51064. * Defines if the material uses height smith correlated visibility term.
  51065. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  51066. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  51067. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  51068. * Not relying on height correlated will also disable energy conservation.
  51069. */
  51070. useSmithVisibilityHeightCorrelated: boolean;
  51071. private _useSphericalHarmonics;
  51072. /**
  51073. * LEGACY Mode set to false
  51074. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  51075. * diffuse part of the IBL.
  51076. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  51077. * to the ground truth.
  51078. */
  51079. useSphericalHarmonics: boolean;
  51080. private _useSpecularGlossinessInputEnergyConservation;
  51081. /**
  51082. * Defines if the material uses energy conservation, when the specular workflow is active.
  51083. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  51084. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  51085. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  51086. */
  51087. useSpecularGlossinessInputEnergyConservation: boolean;
  51088. /** @hidden */
  51089. private _internalMarkAllSubMeshesAsMiscDirty;
  51090. /** @hidden */
  51091. _markAllSubMeshesAsMiscDirty(): void;
  51092. /**
  51093. * Instantiate a new istance of clear coat configuration.
  51094. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  51095. */
  51096. constructor(markAllSubMeshesAsMiscDirty: () => void);
  51097. /**
  51098. * Checks to see if a texture is used in the material.
  51099. * @param defines the list of "defines" to update.
  51100. */
  51101. prepareDefines(defines: IMaterialBRDFDefines): void;
  51102. /**
  51103. * Get the current class name of the texture useful for serialization or dynamic coding.
  51104. * @returns "PBRClearCoatConfiguration"
  51105. */
  51106. getClassName(): string;
  51107. /**
  51108. * Makes a duplicate of the current configuration into another one.
  51109. * @param brdfConfiguration define the config where to copy the info
  51110. */
  51111. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  51112. /**
  51113. * Serializes this BRDF configuration.
  51114. * @returns - An object with the serialized config.
  51115. */
  51116. serialize(): any;
  51117. /**
  51118. * Parses a anisotropy Configuration from a serialized object.
  51119. * @param source - Serialized object.
  51120. * @param scene Defines the scene we are parsing for
  51121. * @param rootUrl Defines the rootUrl to load from
  51122. */
  51123. parse(source: any, scene: Scene, rootUrl: string): void;
  51124. }
  51125. }
  51126. declare module BABYLON {
  51127. /**
  51128. * @hidden
  51129. */
  51130. export interface IMaterialSheenDefines {
  51131. SHEEN: boolean;
  51132. SHEEN_TEXTURE: boolean;
  51133. SHEEN_TEXTUREDIRECTUV: number;
  51134. SHEEN_LINKWITHALBEDO: boolean;
  51135. SHEEN_ROUGHNESS: boolean;
  51136. SHEEN_ALBEDOSCALING: boolean;
  51137. /** @hidden */
  51138. _areTexturesDirty: boolean;
  51139. }
  51140. /**
  51141. * Define the code related to the Sheen parameters of the pbr material.
  51142. */
  51143. export class PBRSheenConfiguration {
  51144. private _isEnabled;
  51145. /**
  51146. * Defines if the material uses sheen.
  51147. */
  51148. isEnabled: boolean;
  51149. private _linkSheenWithAlbedo;
  51150. /**
  51151. * Defines if the sheen is linked to the sheen color.
  51152. */
  51153. linkSheenWithAlbedo: boolean;
  51154. /**
  51155. * Defines the sheen intensity.
  51156. */
  51157. intensity: number;
  51158. /**
  51159. * Defines the sheen color.
  51160. */
  51161. color: Color3;
  51162. private _texture;
  51163. /**
  51164. * Stores the sheen tint values in a texture.
  51165. * rgb is tint
  51166. * a is a intensity
  51167. */
  51168. texture: Nullable<BaseTexture>;
  51169. private _roughness;
  51170. /**
  51171. * Defines the sheen roughness.
  51172. * It is not taken into account if linkSheenWithAlbedo is true.
  51173. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  51174. */
  51175. roughness: Nullable<number>;
  51176. private _albedoScaling;
  51177. /**
  51178. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  51179. * It allows the strength of the sheen effect to not depend on the base color of the material,
  51180. * making it easier to setup and tweak the effect
  51181. */
  51182. albedoScaling: boolean;
  51183. /** @hidden */
  51184. private _internalMarkAllSubMeshesAsTexturesDirty;
  51185. /** @hidden */
  51186. _markAllSubMeshesAsTexturesDirty(): void;
  51187. /**
  51188. * Instantiate a new istance of clear coat configuration.
  51189. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51190. */
  51191. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51192. /**
  51193. * Specifies that the submesh is ready to be used.
  51194. * @param defines the list of "defines" to update.
  51195. * @param scene defines the scene the material belongs to.
  51196. * @returns - boolean indicating that the submesh is ready or not.
  51197. */
  51198. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  51199. /**
  51200. * Checks to see if a texture is used in the material.
  51201. * @param defines the list of "defines" to update.
  51202. * @param scene defines the scene the material belongs to.
  51203. */
  51204. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  51205. /**
  51206. * Binds the material data.
  51207. * @param uniformBuffer defines the Uniform buffer to fill in.
  51208. * @param scene defines the scene the material belongs to.
  51209. * @param isFrozen defines wether the material is frozen or not.
  51210. */
  51211. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51212. /**
  51213. * Checks to see if a texture is used in the material.
  51214. * @param texture - Base texture to use.
  51215. * @returns - Boolean specifying if a texture is used in the material.
  51216. */
  51217. hasTexture(texture: BaseTexture): boolean;
  51218. /**
  51219. * Returns an array of the actively used textures.
  51220. * @param activeTextures Array of BaseTextures
  51221. */
  51222. getActiveTextures(activeTextures: BaseTexture[]): void;
  51223. /**
  51224. * Returns the animatable textures.
  51225. * @param animatables Array of animatable textures.
  51226. */
  51227. getAnimatables(animatables: IAnimatable[]): void;
  51228. /**
  51229. * Disposes the resources of the material.
  51230. * @param forceDisposeTextures - Forces the disposal of all textures.
  51231. */
  51232. dispose(forceDisposeTextures?: boolean): void;
  51233. /**
  51234. * Get the current class name of the texture useful for serialization or dynamic coding.
  51235. * @returns "PBRSheenConfiguration"
  51236. */
  51237. getClassName(): string;
  51238. /**
  51239. * Add fallbacks to the effect fallbacks list.
  51240. * @param defines defines the Base texture to use.
  51241. * @param fallbacks defines the current fallback list.
  51242. * @param currentRank defines the current fallback rank.
  51243. * @returns the new fallback rank.
  51244. */
  51245. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51246. /**
  51247. * Add the required uniforms to the current list.
  51248. * @param uniforms defines the current uniform list.
  51249. */
  51250. static AddUniforms(uniforms: string[]): void;
  51251. /**
  51252. * Add the required uniforms to the current buffer.
  51253. * @param uniformBuffer defines the current uniform buffer.
  51254. */
  51255. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51256. /**
  51257. * Add the required samplers to the current list.
  51258. * @param samplers defines the current sampler list.
  51259. */
  51260. static AddSamplers(samplers: string[]): void;
  51261. /**
  51262. * Makes a duplicate of the current configuration into another one.
  51263. * @param sheenConfiguration define the config where to copy the info
  51264. */
  51265. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  51266. /**
  51267. * Serializes this BRDF configuration.
  51268. * @returns - An object with the serialized config.
  51269. */
  51270. serialize(): any;
  51271. /**
  51272. * Parses a anisotropy Configuration from a serialized object.
  51273. * @param source - Serialized object.
  51274. * @param scene Defines the scene we are parsing for
  51275. * @param rootUrl Defines the rootUrl to load from
  51276. */
  51277. parse(source: any, scene: Scene, rootUrl: string): void;
  51278. }
  51279. }
  51280. declare module BABYLON {
  51281. /**
  51282. * @hidden
  51283. */
  51284. export interface IMaterialSubSurfaceDefines {
  51285. SUBSURFACE: boolean;
  51286. SS_REFRACTION: boolean;
  51287. SS_TRANSLUCENCY: boolean;
  51288. SS_SCATERRING: boolean;
  51289. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51290. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51291. SS_REFRACTIONMAP_3D: boolean;
  51292. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51293. SS_LODINREFRACTIONALPHA: boolean;
  51294. SS_GAMMAREFRACTION: boolean;
  51295. SS_RGBDREFRACTION: boolean;
  51296. SS_LINEARSPECULARREFRACTION: boolean;
  51297. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51298. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51299. /** @hidden */
  51300. _areTexturesDirty: boolean;
  51301. }
  51302. /**
  51303. * Define the code related to the sub surface parameters of the pbr material.
  51304. */
  51305. export class PBRSubSurfaceConfiguration {
  51306. private _isRefractionEnabled;
  51307. /**
  51308. * Defines if the refraction is enabled in the material.
  51309. */
  51310. isRefractionEnabled: boolean;
  51311. private _isTranslucencyEnabled;
  51312. /**
  51313. * Defines if the translucency is enabled in the material.
  51314. */
  51315. isTranslucencyEnabled: boolean;
  51316. private _isScatteringEnabled;
  51317. /**
  51318. * Defines the refraction intensity of the material.
  51319. * The refraction when enabled replaces the Diffuse part of the material.
  51320. * The intensity helps transitionning between diffuse and refraction.
  51321. */
  51322. refractionIntensity: number;
  51323. /**
  51324. * Defines the translucency intensity of the material.
  51325. * When translucency has been enabled, this defines how much of the "translucency"
  51326. * is addded to the diffuse part of the material.
  51327. */
  51328. translucencyIntensity: number;
  51329. /**
  51330. * Defines the scattering intensity of the material.
  51331. * When scattering has been enabled, this defines how much of the "scattered light"
  51332. * is addded to the diffuse part of the material.
  51333. */
  51334. scatteringIntensity: number;
  51335. private _thicknessTexture;
  51336. /**
  51337. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  51338. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  51339. * 0 would mean minimumThickness
  51340. * 1 would mean maximumThickness
  51341. * The other channels might be use as a mask to vary the different effects intensity.
  51342. */
  51343. thicknessTexture: Nullable<BaseTexture>;
  51344. private _refractionTexture;
  51345. /**
  51346. * Defines the texture to use for refraction.
  51347. */
  51348. refractionTexture: Nullable<BaseTexture>;
  51349. private _indexOfRefraction;
  51350. /**
  51351. * Defines the index of refraction used in the material.
  51352. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  51353. */
  51354. indexOfRefraction: number;
  51355. private _invertRefractionY;
  51356. /**
  51357. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51358. */
  51359. invertRefractionY: boolean;
  51360. private _linkRefractionWithTransparency;
  51361. /**
  51362. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51363. * Materials half opaque for instance using refraction could benefit from this control.
  51364. */
  51365. linkRefractionWithTransparency: boolean;
  51366. /**
  51367. * Defines the minimum thickness stored in the thickness map.
  51368. * If no thickness map is defined, this value will be used to simulate thickness.
  51369. */
  51370. minimumThickness: number;
  51371. /**
  51372. * Defines the maximum thickness stored in the thickness map.
  51373. */
  51374. maximumThickness: number;
  51375. /**
  51376. * Defines the volume tint of the material.
  51377. * This is used for both translucency and scattering.
  51378. */
  51379. tintColor: Color3;
  51380. /**
  51381. * Defines the distance at which the tint color should be found in the media.
  51382. * This is used for refraction only.
  51383. */
  51384. tintColorAtDistance: number;
  51385. /**
  51386. * Defines how far each channel transmit through the media.
  51387. * It is defined as a color to simplify it selection.
  51388. */
  51389. diffusionDistance: Color3;
  51390. private _useMaskFromThicknessTexture;
  51391. /**
  51392. * Stores the intensity of the different subsurface effects in the thickness texture.
  51393. * * the green channel is the translucency intensity.
  51394. * * the blue channel is the scattering intensity.
  51395. * * the alpha channel is the refraction intensity.
  51396. */
  51397. useMaskFromThicknessTexture: boolean;
  51398. /** @hidden */
  51399. private _internalMarkAllSubMeshesAsTexturesDirty;
  51400. /** @hidden */
  51401. _markAllSubMeshesAsTexturesDirty(): void;
  51402. /**
  51403. * Instantiate a new istance of sub surface configuration.
  51404. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51405. */
  51406. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51407. /**
  51408. * Gets wehter the submesh is ready to be used or not.
  51409. * @param defines the list of "defines" to update.
  51410. * @param scene defines the scene the material belongs to.
  51411. * @returns - boolean indicating that the submesh is ready or not.
  51412. */
  51413. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51414. /**
  51415. * Checks to see if a texture is used in the material.
  51416. * @param defines the list of "defines" to update.
  51417. * @param scene defines the scene to the material belongs to.
  51418. */
  51419. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51420. /**
  51421. * Binds the material data.
  51422. * @param uniformBuffer defines the Uniform buffer to fill in.
  51423. * @param scene defines the scene the material belongs to.
  51424. * @param engine defines the engine the material belongs to.
  51425. * @param isFrozen defines wether the material is frozen or not.
  51426. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51427. */
  51428. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51429. /**
  51430. * Unbinds the material from the mesh.
  51431. * @param activeEffect defines the effect that should be unbound from.
  51432. * @returns true if unbound, otherwise false
  51433. */
  51434. unbind(activeEffect: Effect): boolean;
  51435. /**
  51436. * Returns the texture used for refraction or null if none is used.
  51437. * @param scene defines the scene the material belongs to.
  51438. * @returns - Refraction texture if present. If no refraction texture and refraction
  51439. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51440. */
  51441. private _getRefractionTexture;
  51442. /**
  51443. * Returns true if alpha blending should be disabled.
  51444. */
  51445. get disableAlphaBlending(): boolean;
  51446. /**
  51447. * Fills the list of render target textures.
  51448. * @param renderTargets the list of render targets to update
  51449. */
  51450. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51451. /**
  51452. * Checks to see if a texture is used in the material.
  51453. * @param texture - Base texture to use.
  51454. * @returns - Boolean specifying if a texture is used in the material.
  51455. */
  51456. hasTexture(texture: BaseTexture): boolean;
  51457. /**
  51458. * Gets a boolean indicating that current material needs to register RTT
  51459. * @returns true if this uses a render target otherwise false.
  51460. */
  51461. hasRenderTargetTextures(): boolean;
  51462. /**
  51463. * Returns an array of the actively used textures.
  51464. * @param activeTextures Array of BaseTextures
  51465. */
  51466. getActiveTextures(activeTextures: BaseTexture[]): void;
  51467. /**
  51468. * Returns the animatable textures.
  51469. * @param animatables Array of animatable textures.
  51470. */
  51471. getAnimatables(animatables: IAnimatable[]): void;
  51472. /**
  51473. * Disposes the resources of the material.
  51474. * @param forceDisposeTextures - Forces the disposal of all textures.
  51475. */
  51476. dispose(forceDisposeTextures?: boolean): void;
  51477. /**
  51478. * Get the current class name of the texture useful for serialization or dynamic coding.
  51479. * @returns "PBRSubSurfaceConfiguration"
  51480. */
  51481. getClassName(): string;
  51482. /**
  51483. * Add fallbacks to the effect fallbacks list.
  51484. * @param defines defines the Base texture to use.
  51485. * @param fallbacks defines the current fallback list.
  51486. * @param currentRank defines the current fallback rank.
  51487. * @returns the new fallback rank.
  51488. */
  51489. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51490. /**
  51491. * Add the required uniforms to the current list.
  51492. * @param uniforms defines the current uniform list.
  51493. */
  51494. static AddUniforms(uniforms: string[]): void;
  51495. /**
  51496. * Add the required samplers to the current list.
  51497. * @param samplers defines the current sampler list.
  51498. */
  51499. static AddSamplers(samplers: string[]): void;
  51500. /**
  51501. * Add the required uniforms to the current buffer.
  51502. * @param uniformBuffer defines the current uniform buffer.
  51503. */
  51504. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51505. /**
  51506. * Makes a duplicate of the current configuration into another one.
  51507. * @param configuration define the config where to copy the info
  51508. */
  51509. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51510. /**
  51511. * Serializes this Sub Surface configuration.
  51512. * @returns - An object with the serialized config.
  51513. */
  51514. serialize(): any;
  51515. /**
  51516. * Parses a anisotropy Configuration from a serialized object.
  51517. * @param source - Serialized object.
  51518. * @param scene Defines the scene we are parsing for
  51519. * @param rootUrl Defines the rootUrl to load from
  51520. */
  51521. parse(source: any, scene: Scene, rootUrl: string): void;
  51522. }
  51523. }
  51524. declare module BABYLON {
  51525. /** @hidden */
  51526. export var pbrFragmentDeclaration: {
  51527. name: string;
  51528. shader: string;
  51529. };
  51530. }
  51531. declare module BABYLON {
  51532. /** @hidden */
  51533. export var pbrUboDeclaration: {
  51534. name: string;
  51535. shader: string;
  51536. };
  51537. }
  51538. declare module BABYLON {
  51539. /** @hidden */
  51540. export var pbrFragmentExtraDeclaration: {
  51541. name: string;
  51542. shader: string;
  51543. };
  51544. }
  51545. declare module BABYLON {
  51546. /** @hidden */
  51547. export var pbrFragmentSamplersDeclaration: {
  51548. name: string;
  51549. shader: string;
  51550. };
  51551. }
  51552. declare module BABYLON {
  51553. /** @hidden */
  51554. export var pbrHelperFunctions: {
  51555. name: string;
  51556. shader: string;
  51557. };
  51558. }
  51559. declare module BABYLON {
  51560. /** @hidden */
  51561. export var harmonicsFunctions: {
  51562. name: string;
  51563. shader: string;
  51564. };
  51565. }
  51566. declare module BABYLON {
  51567. /** @hidden */
  51568. export var pbrDirectLightingSetupFunctions: {
  51569. name: string;
  51570. shader: string;
  51571. };
  51572. }
  51573. declare module BABYLON {
  51574. /** @hidden */
  51575. export var pbrDirectLightingFalloffFunctions: {
  51576. name: string;
  51577. shader: string;
  51578. };
  51579. }
  51580. declare module BABYLON {
  51581. /** @hidden */
  51582. export var pbrBRDFFunctions: {
  51583. name: string;
  51584. shader: string;
  51585. };
  51586. }
  51587. declare module BABYLON {
  51588. /** @hidden */
  51589. export var pbrDirectLightingFunctions: {
  51590. name: string;
  51591. shader: string;
  51592. };
  51593. }
  51594. declare module BABYLON {
  51595. /** @hidden */
  51596. export var pbrIBLFunctions: {
  51597. name: string;
  51598. shader: string;
  51599. };
  51600. }
  51601. declare module BABYLON {
  51602. /** @hidden */
  51603. export var pbrBlockAlbedoOpacity: {
  51604. name: string;
  51605. shader: string;
  51606. };
  51607. }
  51608. declare module BABYLON {
  51609. /** @hidden */
  51610. export var pbrBlockReflectivity: {
  51611. name: string;
  51612. shader: string;
  51613. };
  51614. }
  51615. declare module BABYLON {
  51616. /** @hidden */
  51617. export var pbrBlockAmbientOcclusion: {
  51618. name: string;
  51619. shader: string;
  51620. };
  51621. }
  51622. declare module BABYLON {
  51623. /** @hidden */
  51624. export var pbrBlockAlphaFresnel: {
  51625. name: string;
  51626. shader: string;
  51627. };
  51628. }
  51629. declare module BABYLON {
  51630. /** @hidden */
  51631. export var pbrBlockAnisotropic: {
  51632. name: string;
  51633. shader: string;
  51634. };
  51635. }
  51636. declare module BABYLON {
  51637. /** @hidden */
  51638. export var pbrBlockReflection: {
  51639. name: string;
  51640. shader: string;
  51641. };
  51642. }
  51643. declare module BABYLON {
  51644. /** @hidden */
  51645. export var pbrBlockSheen: {
  51646. name: string;
  51647. shader: string;
  51648. };
  51649. }
  51650. declare module BABYLON {
  51651. /** @hidden */
  51652. export var pbrBlockClearcoat: {
  51653. name: string;
  51654. shader: string;
  51655. };
  51656. }
  51657. declare module BABYLON {
  51658. /** @hidden */
  51659. export var pbrBlockSubSurface: {
  51660. name: string;
  51661. shader: string;
  51662. };
  51663. }
  51664. declare module BABYLON {
  51665. /** @hidden */
  51666. export var pbrBlockNormalGeometric: {
  51667. name: string;
  51668. shader: string;
  51669. };
  51670. }
  51671. declare module BABYLON {
  51672. /** @hidden */
  51673. export var pbrBlockNormalFinal: {
  51674. name: string;
  51675. shader: string;
  51676. };
  51677. }
  51678. declare module BABYLON {
  51679. /** @hidden */
  51680. export var pbrBlockGeometryInfo: {
  51681. name: string;
  51682. shader: string;
  51683. };
  51684. }
  51685. declare module BABYLON {
  51686. /** @hidden */
  51687. export var pbrBlockReflectance0: {
  51688. name: string;
  51689. shader: string;
  51690. };
  51691. }
  51692. declare module BABYLON {
  51693. /** @hidden */
  51694. export var pbrBlockReflectance: {
  51695. name: string;
  51696. shader: string;
  51697. };
  51698. }
  51699. declare module BABYLON {
  51700. /** @hidden */
  51701. export var pbrBlockDirectLighting: {
  51702. name: string;
  51703. shader: string;
  51704. };
  51705. }
  51706. declare module BABYLON {
  51707. /** @hidden */
  51708. export var pbrBlockFinalLitComponents: {
  51709. name: string;
  51710. shader: string;
  51711. };
  51712. }
  51713. declare module BABYLON {
  51714. /** @hidden */
  51715. export var pbrBlockFinalUnlitComponents: {
  51716. name: string;
  51717. shader: string;
  51718. };
  51719. }
  51720. declare module BABYLON {
  51721. /** @hidden */
  51722. export var pbrBlockFinalColorComposition: {
  51723. name: string;
  51724. shader: string;
  51725. };
  51726. }
  51727. declare module BABYLON {
  51728. /** @hidden */
  51729. export var pbrBlockImageProcessing: {
  51730. name: string;
  51731. shader: string;
  51732. };
  51733. }
  51734. declare module BABYLON {
  51735. /** @hidden */
  51736. export var pbrDebug: {
  51737. name: string;
  51738. shader: string;
  51739. };
  51740. }
  51741. declare module BABYLON {
  51742. /** @hidden */
  51743. export var pbrPixelShader: {
  51744. name: string;
  51745. shader: string;
  51746. };
  51747. }
  51748. declare module BABYLON {
  51749. /** @hidden */
  51750. export var pbrVertexDeclaration: {
  51751. name: string;
  51752. shader: string;
  51753. };
  51754. }
  51755. declare module BABYLON {
  51756. /** @hidden */
  51757. export var pbrVertexShader: {
  51758. name: string;
  51759. shader: string;
  51760. };
  51761. }
  51762. declare module BABYLON {
  51763. /**
  51764. * Manages the defines for the PBR Material.
  51765. * @hidden
  51766. */
  51767. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51768. PBR: boolean;
  51769. MAINUV1: boolean;
  51770. MAINUV2: boolean;
  51771. UV1: boolean;
  51772. UV2: boolean;
  51773. ALBEDO: boolean;
  51774. GAMMAALBEDO: boolean;
  51775. ALBEDODIRECTUV: number;
  51776. VERTEXCOLOR: boolean;
  51777. AMBIENT: boolean;
  51778. AMBIENTDIRECTUV: number;
  51779. AMBIENTINGRAYSCALE: boolean;
  51780. OPACITY: boolean;
  51781. VERTEXALPHA: boolean;
  51782. OPACITYDIRECTUV: number;
  51783. OPACITYRGB: boolean;
  51784. ALPHATEST: boolean;
  51785. DEPTHPREPASS: boolean;
  51786. ALPHABLEND: boolean;
  51787. ALPHAFROMALBEDO: boolean;
  51788. ALPHATESTVALUE: string;
  51789. SPECULAROVERALPHA: boolean;
  51790. RADIANCEOVERALPHA: boolean;
  51791. ALPHAFRESNEL: boolean;
  51792. LINEARALPHAFRESNEL: boolean;
  51793. PREMULTIPLYALPHA: boolean;
  51794. EMISSIVE: boolean;
  51795. EMISSIVEDIRECTUV: number;
  51796. REFLECTIVITY: boolean;
  51797. REFLECTIVITYDIRECTUV: number;
  51798. SPECULARTERM: boolean;
  51799. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51800. MICROSURFACEAUTOMATIC: boolean;
  51801. LODBASEDMICROSFURACE: boolean;
  51802. MICROSURFACEMAP: boolean;
  51803. MICROSURFACEMAPDIRECTUV: number;
  51804. METALLICWORKFLOW: boolean;
  51805. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51806. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51807. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51808. AOSTOREINMETALMAPRED: boolean;
  51809. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51810. ENVIRONMENTBRDF: boolean;
  51811. ENVIRONMENTBRDF_RGBD: boolean;
  51812. NORMAL: boolean;
  51813. TANGENT: boolean;
  51814. BUMP: boolean;
  51815. BUMPDIRECTUV: number;
  51816. OBJECTSPACE_NORMALMAP: boolean;
  51817. PARALLAX: boolean;
  51818. PARALLAXOCCLUSION: boolean;
  51819. NORMALXYSCALE: boolean;
  51820. LIGHTMAP: boolean;
  51821. LIGHTMAPDIRECTUV: number;
  51822. USELIGHTMAPASSHADOWMAP: boolean;
  51823. GAMMALIGHTMAP: boolean;
  51824. RGBDLIGHTMAP: boolean;
  51825. REFLECTION: boolean;
  51826. REFLECTIONMAP_3D: boolean;
  51827. REFLECTIONMAP_SPHERICAL: boolean;
  51828. REFLECTIONMAP_PLANAR: boolean;
  51829. REFLECTIONMAP_CUBIC: boolean;
  51830. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51831. REFLECTIONMAP_PROJECTION: boolean;
  51832. REFLECTIONMAP_SKYBOX: boolean;
  51833. REFLECTIONMAP_EXPLICIT: boolean;
  51834. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51835. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51836. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51837. INVERTCUBICMAP: boolean;
  51838. USESPHERICALFROMREFLECTIONMAP: boolean;
  51839. USEIRRADIANCEMAP: boolean;
  51840. SPHERICAL_HARMONICS: boolean;
  51841. USESPHERICALINVERTEX: boolean;
  51842. REFLECTIONMAP_OPPOSITEZ: boolean;
  51843. LODINREFLECTIONALPHA: boolean;
  51844. GAMMAREFLECTION: boolean;
  51845. RGBDREFLECTION: boolean;
  51846. LINEARSPECULARREFLECTION: boolean;
  51847. RADIANCEOCCLUSION: boolean;
  51848. HORIZONOCCLUSION: boolean;
  51849. INSTANCES: boolean;
  51850. NUM_BONE_INFLUENCERS: number;
  51851. BonesPerMesh: number;
  51852. BONETEXTURE: boolean;
  51853. NONUNIFORMSCALING: boolean;
  51854. MORPHTARGETS: boolean;
  51855. MORPHTARGETS_NORMAL: boolean;
  51856. MORPHTARGETS_TANGENT: boolean;
  51857. MORPHTARGETS_UV: boolean;
  51858. NUM_MORPH_INFLUENCERS: number;
  51859. IMAGEPROCESSING: boolean;
  51860. VIGNETTE: boolean;
  51861. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51862. VIGNETTEBLENDMODEOPAQUE: boolean;
  51863. TONEMAPPING: boolean;
  51864. TONEMAPPING_ACES: boolean;
  51865. CONTRAST: boolean;
  51866. COLORCURVES: boolean;
  51867. COLORGRADING: boolean;
  51868. COLORGRADING3D: boolean;
  51869. SAMPLER3DGREENDEPTH: boolean;
  51870. SAMPLER3DBGRMAP: boolean;
  51871. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51872. EXPOSURE: boolean;
  51873. MULTIVIEW: boolean;
  51874. USEPHYSICALLIGHTFALLOFF: boolean;
  51875. USEGLTFLIGHTFALLOFF: boolean;
  51876. TWOSIDEDLIGHTING: boolean;
  51877. SHADOWFLOAT: boolean;
  51878. CLIPPLANE: boolean;
  51879. CLIPPLANE2: boolean;
  51880. CLIPPLANE3: boolean;
  51881. CLIPPLANE4: boolean;
  51882. CLIPPLANE5: boolean;
  51883. CLIPPLANE6: boolean;
  51884. POINTSIZE: boolean;
  51885. FOG: boolean;
  51886. LOGARITHMICDEPTH: boolean;
  51887. FORCENORMALFORWARD: boolean;
  51888. SPECULARAA: boolean;
  51889. CLEARCOAT: boolean;
  51890. CLEARCOAT_DEFAULTIOR: boolean;
  51891. CLEARCOAT_TEXTURE: boolean;
  51892. CLEARCOAT_TEXTUREDIRECTUV: number;
  51893. CLEARCOAT_BUMP: boolean;
  51894. CLEARCOAT_BUMPDIRECTUV: number;
  51895. CLEARCOAT_TINT: boolean;
  51896. CLEARCOAT_TINT_TEXTURE: boolean;
  51897. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51898. ANISOTROPIC: boolean;
  51899. ANISOTROPIC_TEXTURE: boolean;
  51900. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51901. BRDF_V_HEIGHT_CORRELATED: boolean;
  51902. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51903. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51904. SHEEN: boolean;
  51905. SHEEN_TEXTURE: boolean;
  51906. SHEEN_TEXTUREDIRECTUV: number;
  51907. SHEEN_LINKWITHALBEDO: boolean;
  51908. SHEEN_ROUGHNESS: boolean;
  51909. SHEEN_ALBEDOSCALING: boolean;
  51910. SUBSURFACE: boolean;
  51911. SS_REFRACTION: boolean;
  51912. SS_TRANSLUCENCY: boolean;
  51913. SS_SCATERRING: boolean;
  51914. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51915. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51916. SS_REFRACTIONMAP_3D: boolean;
  51917. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51918. SS_LODINREFRACTIONALPHA: boolean;
  51919. SS_GAMMAREFRACTION: boolean;
  51920. SS_RGBDREFRACTION: boolean;
  51921. SS_LINEARSPECULARREFRACTION: boolean;
  51922. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51923. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51924. UNLIT: boolean;
  51925. DEBUGMODE: number;
  51926. /**
  51927. * Initializes the PBR Material defines.
  51928. */
  51929. constructor();
  51930. /**
  51931. * Resets the PBR Material defines.
  51932. */
  51933. reset(): void;
  51934. }
  51935. /**
  51936. * The Physically based material base class of BJS.
  51937. *
  51938. * This offers the main features of a standard PBR material.
  51939. * For more information, please refer to the documentation :
  51940. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51941. */
  51942. export abstract class PBRBaseMaterial extends PushMaterial {
  51943. /**
  51944. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51945. */
  51946. static readonly PBRMATERIAL_OPAQUE: number;
  51947. /**
  51948. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51949. */
  51950. static readonly PBRMATERIAL_ALPHATEST: number;
  51951. /**
  51952. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51953. */
  51954. static readonly PBRMATERIAL_ALPHABLEND: number;
  51955. /**
  51956. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51957. * They are also discarded below the alpha cutoff threshold to improve performances.
  51958. */
  51959. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51960. /**
  51961. * Defines the default value of how much AO map is occluding the analytical lights
  51962. * (point spot...).
  51963. */
  51964. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51965. /**
  51966. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51967. */
  51968. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51969. /**
  51970. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51971. * to enhance interoperability with other engines.
  51972. */
  51973. static readonly LIGHTFALLOFF_GLTF: number;
  51974. /**
  51975. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51976. * to enhance interoperability with other materials.
  51977. */
  51978. static readonly LIGHTFALLOFF_STANDARD: number;
  51979. /**
  51980. * Intensity of the direct lights e.g. the four lights available in your scene.
  51981. * This impacts both the direct diffuse and specular highlights.
  51982. */
  51983. protected _directIntensity: number;
  51984. /**
  51985. * Intensity of the emissive part of the material.
  51986. * This helps controlling the emissive effect without modifying the emissive color.
  51987. */
  51988. protected _emissiveIntensity: number;
  51989. /**
  51990. * Intensity of the environment e.g. how much the environment will light the object
  51991. * either through harmonics for rough material or through the refelction for shiny ones.
  51992. */
  51993. protected _environmentIntensity: number;
  51994. /**
  51995. * This is a special control allowing the reduction of the specular highlights coming from the
  51996. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51997. */
  51998. protected _specularIntensity: number;
  51999. /**
  52000. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52001. */
  52002. private _lightingInfos;
  52003. /**
  52004. * Debug Control allowing disabling the bump map on this material.
  52005. */
  52006. protected _disableBumpMap: boolean;
  52007. /**
  52008. * AKA Diffuse Texture in standard nomenclature.
  52009. */
  52010. protected _albedoTexture: Nullable<BaseTexture>;
  52011. /**
  52012. * AKA Occlusion Texture in other nomenclature.
  52013. */
  52014. protected _ambientTexture: Nullable<BaseTexture>;
  52015. /**
  52016. * AKA Occlusion Texture Intensity in other nomenclature.
  52017. */
  52018. protected _ambientTextureStrength: number;
  52019. /**
  52020. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52021. * 1 means it completely occludes it
  52022. * 0 mean it has no impact
  52023. */
  52024. protected _ambientTextureImpactOnAnalyticalLights: number;
  52025. /**
  52026. * Stores the alpha values in a texture.
  52027. */
  52028. protected _opacityTexture: Nullable<BaseTexture>;
  52029. /**
  52030. * Stores the reflection values in a texture.
  52031. */
  52032. protected _reflectionTexture: Nullable<BaseTexture>;
  52033. /**
  52034. * Stores the emissive values in a texture.
  52035. */
  52036. protected _emissiveTexture: Nullable<BaseTexture>;
  52037. /**
  52038. * AKA Specular texture in other nomenclature.
  52039. */
  52040. protected _reflectivityTexture: Nullable<BaseTexture>;
  52041. /**
  52042. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52043. */
  52044. protected _metallicTexture: Nullable<BaseTexture>;
  52045. /**
  52046. * Specifies the metallic scalar of the metallic/roughness workflow.
  52047. * Can also be used to scale the metalness values of the metallic texture.
  52048. */
  52049. protected _metallic: Nullable<number>;
  52050. /**
  52051. * Specifies the roughness scalar of the metallic/roughness workflow.
  52052. * Can also be used to scale the roughness values of the metallic texture.
  52053. */
  52054. protected _roughness: Nullable<number>;
  52055. /**
  52056. * Specifies the an F0 factor to help configuring the material F0.
  52057. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52058. * to 0.5 the previously hard coded value stays the same.
  52059. * Can also be used to scale the F0 values of the metallic texture.
  52060. */
  52061. protected _metallicF0Factor: number;
  52062. /**
  52063. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52064. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52065. * your expectation as it multiplies with the texture data.
  52066. */
  52067. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52068. /**
  52069. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52070. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52071. */
  52072. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52073. /**
  52074. * Stores surface normal data used to displace a mesh in a texture.
  52075. */
  52076. protected _bumpTexture: Nullable<BaseTexture>;
  52077. /**
  52078. * Stores the pre-calculated light information of a mesh in a texture.
  52079. */
  52080. protected _lightmapTexture: Nullable<BaseTexture>;
  52081. /**
  52082. * The color of a material in ambient lighting.
  52083. */
  52084. protected _ambientColor: Color3;
  52085. /**
  52086. * AKA Diffuse Color in other nomenclature.
  52087. */
  52088. protected _albedoColor: Color3;
  52089. /**
  52090. * AKA Specular Color in other nomenclature.
  52091. */
  52092. protected _reflectivityColor: Color3;
  52093. /**
  52094. * The color applied when light is reflected from a material.
  52095. */
  52096. protected _reflectionColor: Color3;
  52097. /**
  52098. * The color applied when light is emitted from a material.
  52099. */
  52100. protected _emissiveColor: Color3;
  52101. /**
  52102. * AKA Glossiness in other nomenclature.
  52103. */
  52104. protected _microSurface: number;
  52105. /**
  52106. * Specifies that the material will use the light map as a show map.
  52107. */
  52108. protected _useLightmapAsShadowmap: boolean;
  52109. /**
  52110. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52111. * makes the reflect vector face the model (under horizon).
  52112. */
  52113. protected _useHorizonOcclusion: boolean;
  52114. /**
  52115. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52116. * too much the area relying on ambient texture to define their ambient occlusion.
  52117. */
  52118. protected _useRadianceOcclusion: boolean;
  52119. /**
  52120. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52121. */
  52122. protected _useAlphaFromAlbedoTexture: boolean;
  52123. /**
  52124. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  52125. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52126. */
  52127. protected _useSpecularOverAlpha: boolean;
  52128. /**
  52129. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52130. */
  52131. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52132. /**
  52133. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52134. */
  52135. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  52136. /**
  52137. * Specifies if the metallic texture contains the roughness information in its green channel.
  52138. */
  52139. protected _useRoughnessFromMetallicTextureGreen: boolean;
  52140. /**
  52141. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52142. */
  52143. protected _useMetallnessFromMetallicTextureBlue: boolean;
  52144. /**
  52145. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52146. */
  52147. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  52148. /**
  52149. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52150. */
  52151. protected _useAmbientInGrayScale: boolean;
  52152. /**
  52153. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52154. * The material will try to infer what glossiness each pixel should be.
  52155. */
  52156. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  52157. /**
  52158. * Defines the falloff type used in this material.
  52159. * It by default is Physical.
  52160. */
  52161. protected _lightFalloff: number;
  52162. /**
  52163. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52164. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52165. */
  52166. protected _useRadianceOverAlpha: boolean;
  52167. /**
  52168. * Allows using an object space normal map (instead of tangent space).
  52169. */
  52170. protected _useObjectSpaceNormalMap: boolean;
  52171. /**
  52172. * Allows using the bump map in parallax mode.
  52173. */
  52174. protected _useParallax: boolean;
  52175. /**
  52176. * Allows using the bump map in parallax occlusion mode.
  52177. */
  52178. protected _useParallaxOcclusion: boolean;
  52179. /**
  52180. * Controls the scale bias of the parallax mode.
  52181. */
  52182. protected _parallaxScaleBias: number;
  52183. /**
  52184. * If sets to true, disables all the lights affecting the material.
  52185. */
  52186. protected _disableLighting: boolean;
  52187. /**
  52188. * Number of Simultaneous lights allowed on the material.
  52189. */
  52190. protected _maxSimultaneousLights: number;
  52191. /**
  52192. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52193. */
  52194. protected _invertNormalMapX: boolean;
  52195. /**
  52196. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52197. */
  52198. protected _invertNormalMapY: boolean;
  52199. /**
  52200. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52201. */
  52202. protected _twoSidedLighting: boolean;
  52203. /**
  52204. * Defines the alpha limits in alpha test mode.
  52205. */
  52206. protected _alphaCutOff: number;
  52207. /**
  52208. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52209. */
  52210. protected _forceAlphaTest: boolean;
  52211. /**
  52212. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52213. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52214. */
  52215. protected _useAlphaFresnel: boolean;
  52216. /**
  52217. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52218. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52219. */
  52220. protected _useLinearAlphaFresnel: boolean;
  52221. /**
  52222. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  52223. * from cos thetav and roughness:
  52224. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  52225. */
  52226. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  52227. /**
  52228. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52229. */
  52230. protected _forceIrradianceInFragment: boolean;
  52231. /**
  52232. * Force normal to face away from face.
  52233. */
  52234. protected _forceNormalForward: boolean;
  52235. /**
  52236. * Enables specular anti aliasing in the PBR shader.
  52237. * It will both interacts on the Geometry for analytical and IBL lighting.
  52238. * It also prefilter the roughness map based on the bump values.
  52239. */
  52240. protected _enableSpecularAntiAliasing: boolean;
  52241. /**
  52242. * Default configuration related to image processing available in the PBR Material.
  52243. */
  52244. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52245. /**
  52246. * Keep track of the image processing observer to allow dispose and replace.
  52247. */
  52248. private _imageProcessingObserver;
  52249. /**
  52250. * Attaches a new image processing configuration to the PBR Material.
  52251. * @param configuration
  52252. */
  52253. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52254. /**
  52255. * Stores the available render targets.
  52256. */
  52257. private _renderTargets;
  52258. /**
  52259. * Sets the global ambient color for the material used in lighting calculations.
  52260. */
  52261. private _globalAmbientColor;
  52262. /**
  52263. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  52264. */
  52265. private _useLogarithmicDepth;
  52266. /**
  52267. * If set to true, no lighting calculations will be applied.
  52268. */
  52269. private _unlit;
  52270. private _debugMode;
  52271. /**
  52272. * @hidden
  52273. * This is reserved for the inspector.
  52274. * Defines the material debug mode.
  52275. * It helps seeing only some components of the material while troubleshooting.
  52276. */
  52277. debugMode: number;
  52278. /**
  52279. * @hidden
  52280. * This is reserved for the inspector.
  52281. * Specify from where on screen the debug mode should start.
  52282. * The value goes from -1 (full screen) to 1 (not visible)
  52283. * It helps with side by side comparison against the final render
  52284. * This defaults to -1
  52285. */
  52286. private debugLimit;
  52287. /**
  52288. * @hidden
  52289. * This is reserved for the inspector.
  52290. * As the default viewing range might not be enough (if the ambient is really small for instance)
  52291. * You can use the factor to better multiply the final value.
  52292. */
  52293. private debugFactor;
  52294. /**
  52295. * Defines the clear coat layer parameters for the material.
  52296. */
  52297. readonly clearCoat: PBRClearCoatConfiguration;
  52298. /**
  52299. * Defines the anisotropic parameters for the material.
  52300. */
  52301. readonly anisotropy: PBRAnisotropicConfiguration;
  52302. /**
  52303. * Defines the BRDF parameters for the material.
  52304. */
  52305. readonly brdf: PBRBRDFConfiguration;
  52306. /**
  52307. * Defines the Sheen parameters for the material.
  52308. */
  52309. readonly sheen: PBRSheenConfiguration;
  52310. /**
  52311. * Defines the SubSurface parameters for the material.
  52312. */
  52313. readonly subSurface: PBRSubSurfaceConfiguration;
  52314. protected _rebuildInParallel: boolean;
  52315. /**
  52316. * Instantiates a new PBRMaterial instance.
  52317. *
  52318. * @param name The material name
  52319. * @param scene The scene the material will be use in.
  52320. */
  52321. constructor(name: string, scene: Scene);
  52322. /**
  52323. * Gets a boolean indicating that current material needs to register RTT
  52324. */
  52325. get hasRenderTargetTextures(): boolean;
  52326. /**
  52327. * Gets the name of the material class.
  52328. */
  52329. getClassName(): string;
  52330. /**
  52331. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52332. */
  52333. get useLogarithmicDepth(): boolean;
  52334. /**
  52335. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  52336. */
  52337. set useLogarithmicDepth(value: boolean);
  52338. /**
  52339. * Returns true if alpha blending should be disabled.
  52340. */
  52341. protected get _disableAlphaBlending(): boolean;
  52342. /**
  52343. * Specifies whether or not this material should be rendered in alpha blend mode.
  52344. */
  52345. needAlphaBlending(): boolean;
  52346. /**
  52347. * Specifies whether or not this material should be rendered in alpha test mode.
  52348. */
  52349. needAlphaTesting(): boolean;
  52350. /**
  52351. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  52352. */
  52353. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  52354. /**
  52355. * Gets the texture used for the alpha test.
  52356. */
  52357. getAlphaTestTexture(): Nullable<BaseTexture>;
  52358. /**
  52359. * Specifies that the submesh is ready to be used.
  52360. * @param mesh - BJS mesh.
  52361. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  52362. * @param useInstances - Specifies that instances should be used.
  52363. * @returns - boolean indicating that the submesh is ready or not.
  52364. */
  52365. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52366. /**
  52367. * Specifies if the material uses metallic roughness workflow.
  52368. * @returns boolean specifiying if the material uses metallic roughness workflow.
  52369. */
  52370. isMetallicWorkflow(): boolean;
  52371. private _prepareEffect;
  52372. private _prepareDefines;
  52373. /**
  52374. * Force shader compilation
  52375. */
  52376. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52377. /**
  52378. * Initializes the uniform buffer layout for the shader.
  52379. */
  52380. buildUniformLayout(): void;
  52381. /**
  52382. * Unbinds the material from the mesh
  52383. */
  52384. unbind(): void;
  52385. /**
  52386. * Binds the submesh data.
  52387. * @param world - The world matrix.
  52388. * @param mesh - The BJS mesh.
  52389. * @param subMesh - A submesh of the BJS mesh.
  52390. */
  52391. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52392. /**
  52393. * Returns the animatable textures.
  52394. * @returns - Array of animatable textures.
  52395. */
  52396. getAnimatables(): IAnimatable[];
  52397. /**
  52398. * Returns the texture used for reflections.
  52399. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52400. */
  52401. private _getReflectionTexture;
  52402. /**
  52403. * Returns an array of the actively used textures.
  52404. * @returns - Array of BaseTextures
  52405. */
  52406. getActiveTextures(): BaseTexture[];
  52407. /**
  52408. * Checks to see if a texture is used in the material.
  52409. * @param texture - Base texture to use.
  52410. * @returns - Boolean specifying if a texture is used in the material.
  52411. */
  52412. hasTexture(texture: BaseTexture): boolean;
  52413. /**
  52414. * Disposes the resources of the material.
  52415. * @param forceDisposeEffect - Forces the disposal of effects.
  52416. * @param forceDisposeTextures - Forces the disposal of all textures.
  52417. */
  52418. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52419. }
  52420. }
  52421. declare module BABYLON {
  52422. /**
  52423. * The Physically based material of BJS.
  52424. *
  52425. * This offers the main features of a standard PBR material.
  52426. * For more information, please refer to the documentation :
  52427. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52428. */
  52429. export class PBRMaterial extends PBRBaseMaterial {
  52430. /**
  52431. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52432. */
  52433. static readonly PBRMATERIAL_OPAQUE: number;
  52434. /**
  52435. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52436. */
  52437. static readonly PBRMATERIAL_ALPHATEST: number;
  52438. /**
  52439. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52440. */
  52441. static readonly PBRMATERIAL_ALPHABLEND: number;
  52442. /**
  52443. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52444. * They are also discarded below the alpha cutoff threshold to improve performances.
  52445. */
  52446. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52447. /**
  52448. * Defines the default value of how much AO map is occluding the analytical lights
  52449. * (point spot...).
  52450. */
  52451. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52452. /**
  52453. * Intensity of the direct lights e.g. the four lights available in your scene.
  52454. * This impacts both the direct diffuse and specular highlights.
  52455. */
  52456. directIntensity: number;
  52457. /**
  52458. * Intensity of the emissive part of the material.
  52459. * This helps controlling the emissive effect without modifying the emissive color.
  52460. */
  52461. emissiveIntensity: number;
  52462. /**
  52463. * Intensity of the environment e.g. how much the environment will light the object
  52464. * either through harmonics for rough material or through the refelction for shiny ones.
  52465. */
  52466. environmentIntensity: number;
  52467. /**
  52468. * This is a special control allowing the reduction of the specular highlights coming from the
  52469. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52470. */
  52471. specularIntensity: number;
  52472. /**
  52473. * Debug Control allowing disabling the bump map on this material.
  52474. */
  52475. disableBumpMap: boolean;
  52476. /**
  52477. * AKA Diffuse Texture in standard nomenclature.
  52478. */
  52479. albedoTexture: BaseTexture;
  52480. /**
  52481. * AKA Occlusion Texture in other nomenclature.
  52482. */
  52483. ambientTexture: BaseTexture;
  52484. /**
  52485. * AKA Occlusion Texture Intensity in other nomenclature.
  52486. */
  52487. ambientTextureStrength: number;
  52488. /**
  52489. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52490. * 1 means it completely occludes it
  52491. * 0 mean it has no impact
  52492. */
  52493. ambientTextureImpactOnAnalyticalLights: number;
  52494. /**
  52495. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52496. */
  52497. opacityTexture: BaseTexture;
  52498. /**
  52499. * Stores the reflection values in a texture.
  52500. */
  52501. reflectionTexture: Nullable<BaseTexture>;
  52502. /**
  52503. * Stores the emissive values in a texture.
  52504. */
  52505. emissiveTexture: BaseTexture;
  52506. /**
  52507. * AKA Specular texture in other nomenclature.
  52508. */
  52509. reflectivityTexture: BaseTexture;
  52510. /**
  52511. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52512. */
  52513. metallicTexture: BaseTexture;
  52514. /**
  52515. * Specifies the metallic scalar of the metallic/roughness workflow.
  52516. * Can also be used to scale the metalness values of the metallic texture.
  52517. */
  52518. metallic: Nullable<number>;
  52519. /**
  52520. * Specifies the roughness scalar of the metallic/roughness workflow.
  52521. * Can also be used to scale the roughness values of the metallic texture.
  52522. */
  52523. roughness: Nullable<number>;
  52524. /**
  52525. * Specifies the an F0 factor to help configuring the material F0.
  52526. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52527. * to 0.5 the previously hard coded value stays the same.
  52528. * Can also be used to scale the F0 values of the metallic texture.
  52529. */
  52530. metallicF0Factor: number;
  52531. /**
  52532. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52533. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52534. * your expectation as it multiplies with the texture data.
  52535. */
  52536. useMetallicF0FactorFromMetallicTexture: boolean;
  52537. /**
  52538. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52539. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52540. */
  52541. microSurfaceTexture: BaseTexture;
  52542. /**
  52543. * Stores surface normal data used to displace a mesh in a texture.
  52544. */
  52545. bumpTexture: BaseTexture;
  52546. /**
  52547. * Stores the pre-calculated light information of a mesh in a texture.
  52548. */
  52549. lightmapTexture: BaseTexture;
  52550. /**
  52551. * Stores the refracted light information in a texture.
  52552. */
  52553. get refractionTexture(): Nullable<BaseTexture>;
  52554. set refractionTexture(value: Nullable<BaseTexture>);
  52555. /**
  52556. * The color of a material in ambient lighting.
  52557. */
  52558. ambientColor: Color3;
  52559. /**
  52560. * AKA Diffuse Color in other nomenclature.
  52561. */
  52562. albedoColor: Color3;
  52563. /**
  52564. * AKA Specular Color in other nomenclature.
  52565. */
  52566. reflectivityColor: Color3;
  52567. /**
  52568. * The color reflected from the material.
  52569. */
  52570. reflectionColor: Color3;
  52571. /**
  52572. * The color emitted from the material.
  52573. */
  52574. emissiveColor: Color3;
  52575. /**
  52576. * AKA Glossiness in other nomenclature.
  52577. */
  52578. microSurface: number;
  52579. /**
  52580. * source material index of refraction (IOR)' / 'destination material IOR.
  52581. */
  52582. get indexOfRefraction(): number;
  52583. set indexOfRefraction(value: number);
  52584. /**
  52585. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52586. */
  52587. get invertRefractionY(): boolean;
  52588. set invertRefractionY(value: boolean);
  52589. /**
  52590. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52591. * Materials half opaque for instance using refraction could benefit from this control.
  52592. */
  52593. get linkRefractionWithTransparency(): boolean;
  52594. set linkRefractionWithTransparency(value: boolean);
  52595. /**
  52596. * If true, the light map contains occlusion information instead of lighting info.
  52597. */
  52598. useLightmapAsShadowmap: boolean;
  52599. /**
  52600. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52601. */
  52602. useAlphaFromAlbedoTexture: boolean;
  52603. /**
  52604. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52605. */
  52606. forceAlphaTest: boolean;
  52607. /**
  52608. * Defines the alpha limits in alpha test mode.
  52609. */
  52610. alphaCutOff: number;
  52611. /**
  52612. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52613. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52614. */
  52615. useSpecularOverAlpha: boolean;
  52616. /**
  52617. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52618. */
  52619. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52620. /**
  52621. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52622. */
  52623. useRoughnessFromMetallicTextureAlpha: boolean;
  52624. /**
  52625. * Specifies if the metallic texture contains the roughness information in its green channel.
  52626. */
  52627. useRoughnessFromMetallicTextureGreen: boolean;
  52628. /**
  52629. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52630. */
  52631. useMetallnessFromMetallicTextureBlue: boolean;
  52632. /**
  52633. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52634. */
  52635. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52636. /**
  52637. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52638. */
  52639. useAmbientInGrayScale: boolean;
  52640. /**
  52641. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52642. * The material will try to infer what glossiness each pixel should be.
  52643. */
  52644. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52645. /**
  52646. * BJS is using an harcoded light falloff based on a manually sets up range.
  52647. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52648. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52649. */
  52650. get usePhysicalLightFalloff(): boolean;
  52651. /**
  52652. * BJS is using an harcoded light falloff based on a manually sets up range.
  52653. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52654. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52655. */
  52656. set usePhysicalLightFalloff(value: boolean);
  52657. /**
  52658. * In order to support the falloff compatibility with gltf, a special mode has been added
  52659. * to reproduce the gltf light falloff.
  52660. */
  52661. get useGLTFLightFalloff(): boolean;
  52662. /**
  52663. * In order to support the falloff compatibility with gltf, a special mode has been added
  52664. * to reproduce the gltf light falloff.
  52665. */
  52666. set useGLTFLightFalloff(value: boolean);
  52667. /**
  52668. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52669. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52670. */
  52671. useRadianceOverAlpha: boolean;
  52672. /**
  52673. * Allows using an object space normal map (instead of tangent space).
  52674. */
  52675. useObjectSpaceNormalMap: boolean;
  52676. /**
  52677. * Allows using the bump map in parallax mode.
  52678. */
  52679. useParallax: boolean;
  52680. /**
  52681. * Allows using the bump map in parallax occlusion mode.
  52682. */
  52683. useParallaxOcclusion: boolean;
  52684. /**
  52685. * Controls the scale bias of the parallax mode.
  52686. */
  52687. parallaxScaleBias: number;
  52688. /**
  52689. * If sets to true, disables all the lights affecting the material.
  52690. */
  52691. disableLighting: boolean;
  52692. /**
  52693. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52694. */
  52695. forceIrradianceInFragment: boolean;
  52696. /**
  52697. * Number of Simultaneous lights allowed on the material.
  52698. */
  52699. maxSimultaneousLights: number;
  52700. /**
  52701. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52702. */
  52703. invertNormalMapX: boolean;
  52704. /**
  52705. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52706. */
  52707. invertNormalMapY: boolean;
  52708. /**
  52709. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52710. */
  52711. twoSidedLighting: boolean;
  52712. /**
  52713. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52714. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52715. */
  52716. useAlphaFresnel: boolean;
  52717. /**
  52718. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52719. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52720. */
  52721. useLinearAlphaFresnel: boolean;
  52722. /**
  52723. * Let user defines the brdf lookup texture used for IBL.
  52724. * A default 8bit version is embedded but you could point at :
  52725. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52726. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52727. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52728. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52729. */
  52730. environmentBRDFTexture: Nullable<BaseTexture>;
  52731. /**
  52732. * Force normal to face away from face.
  52733. */
  52734. forceNormalForward: boolean;
  52735. /**
  52736. * Enables specular anti aliasing in the PBR shader.
  52737. * It will both interacts on the Geometry for analytical and IBL lighting.
  52738. * It also prefilter the roughness map based on the bump values.
  52739. */
  52740. enableSpecularAntiAliasing: boolean;
  52741. /**
  52742. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52743. * makes the reflect vector face the model (under horizon).
  52744. */
  52745. useHorizonOcclusion: boolean;
  52746. /**
  52747. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52748. * too much the area relying on ambient texture to define their ambient occlusion.
  52749. */
  52750. useRadianceOcclusion: boolean;
  52751. /**
  52752. * If set to true, no lighting calculations will be applied.
  52753. */
  52754. unlit: boolean;
  52755. /**
  52756. * Gets the image processing configuration used either in this material.
  52757. */
  52758. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52759. /**
  52760. * Sets the Default image processing configuration used either in the this material.
  52761. *
  52762. * If sets to null, the scene one is in use.
  52763. */
  52764. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52765. /**
  52766. * Gets wether the color curves effect is enabled.
  52767. */
  52768. get cameraColorCurvesEnabled(): boolean;
  52769. /**
  52770. * Sets wether the color curves effect is enabled.
  52771. */
  52772. set cameraColorCurvesEnabled(value: boolean);
  52773. /**
  52774. * Gets wether the color grading effect is enabled.
  52775. */
  52776. get cameraColorGradingEnabled(): boolean;
  52777. /**
  52778. * Gets wether the color grading effect is enabled.
  52779. */
  52780. set cameraColorGradingEnabled(value: boolean);
  52781. /**
  52782. * Gets wether tonemapping is enabled or not.
  52783. */
  52784. get cameraToneMappingEnabled(): boolean;
  52785. /**
  52786. * Sets wether tonemapping is enabled or not
  52787. */
  52788. set cameraToneMappingEnabled(value: boolean);
  52789. /**
  52790. * The camera exposure used on this material.
  52791. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52792. * This corresponds to a photographic exposure.
  52793. */
  52794. get cameraExposure(): number;
  52795. /**
  52796. * The camera exposure used on this material.
  52797. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52798. * This corresponds to a photographic exposure.
  52799. */
  52800. set cameraExposure(value: number);
  52801. /**
  52802. * Gets The camera contrast used on this material.
  52803. */
  52804. get cameraContrast(): number;
  52805. /**
  52806. * Sets The camera contrast used on this material.
  52807. */
  52808. set cameraContrast(value: number);
  52809. /**
  52810. * Gets the Color Grading 2D Lookup Texture.
  52811. */
  52812. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52813. /**
  52814. * Sets the Color Grading 2D Lookup Texture.
  52815. */
  52816. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52817. /**
  52818. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52819. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52820. * 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;
  52821. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52822. */
  52823. get cameraColorCurves(): Nullable<ColorCurves>;
  52824. /**
  52825. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52826. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52827. * 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;
  52828. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52829. */
  52830. set cameraColorCurves(value: Nullable<ColorCurves>);
  52831. /**
  52832. * Instantiates a new PBRMaterial instance.
  52833. *
  52834. * @param name The material name
  52835. * @param scene The scene the material will be use in.
  52836. */
  52837. constructor(name: string, scene: Scene);
  52838. /**
  52839. * Returns the name of this material class.
  52840. */
  52841. getClassName(): string;
  52842. /**
  52843. * Makes a duplicate of the current material.
  52844. * @param name - name to use for the new material.
  52845. */
  52846. clone(name: string): PBRMaterial;
  52847. /**
  52848. * Serializes this PBR Material.
  52849. * @returns - An object with the serialized material.
  52850. */
  52851. serialize(): any;
  52852. /**
  52853. * Parses a PBR Material from a serialized object.
  52854. * @param source - Serialized object.
  52855. * @param scene - BJS scene instance.
  52856. * @param rootUrl - url for the scene object
  52857. * @returns - PBRMaterial
  52858. */
  52859. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52860. }
  52861. }
  52862. declare module BABYLON {
  52863. /**
  52864. * Direct draw surface info
  52865. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52866. */
  52867. export interface DDSInfo {
  52868. /**
  52869. * Width of the texture
  52870. */
  52871. width: number;
  52872. /**
  52873. * Width of the texture
  52874. */
  52875. height: number;
  52876. /**
  52877. * Number of Mipmaps for the texture
  52878. * @see https://en.wikipedia.org/wiki/Mipmap
  52879. */
  52880. mipmapCount: number;
  52881. /**
  52882. * If the textures format is a known fourCC format
  52883. * @see https://www.fourcc.org/
  52884. */
  52885. isFourCC: boolean;
  52886. /**
  52887. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52888. */
  52889. isRGB: boolean;
  52890. /**
  52891. * If the texture is a lumincance format
  52892. */
  52893. isLuminance: boolean;
  52894. /**
  52895. * If this is a cube texture
  52896. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52897. */
  52898. isCube: boolean;
  52899. /**
  52900. * If the texture is a compressed format eg. FOURCC_DXT1
  52901. */
  52902. isCompressed: boolean;
  52903. /**
  52904. * The dxgiFormat of the texture
  52905. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52906. */
  52907. dxgiFormat: number;
  52908. /**
  52909. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52910. */
  52911. textureType: number;
  52912. /**
  52913. * Sphericle polynomial created for the dds texture
  52914. */
  52915. sphericalPolynomial?: SphericalPolynomial;
  52916. }
  52917. /**
  52918. * Class used to provide DDS decompression tools
  52919. */
  52920. export class DDSTools {
  52921. /**
  52922. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52923. */
  52924. static StoreLODInAlphaChannel: boolean;
  52925. /**
  52926. * Gets DDS information from an array buffer
  52927. * @param data defines the array buffer view to read data from
  52928. * @returns the DDS information
  52929. */
  52930. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52931. private static _FloatView;
  52932. private static _Int32View;
  52933. private static _ToHalfFloat;
  52934. private static _FromHalfFloat;
  52935. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52936. private static _GetHalfFloatRGBAArrayBuffer;
  52937. private static _GetFloatRGBAArrayBuffer;
  52938. private static _GetFloatAsUIntRGBAArrayBuffer;
  52939. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52940. private static _GetRGBAArrayBuffer;
  52941. private static _ExtractLongWordOrder;
  52942. private static _GetRGBArrayBuffer;
  52943. private static _GetLuminanceArrayBuffer;
  52944. /**
  52945. * Uploads DDS Levels to a Babylon Texture
  52946. * @hidden
  52947. */
  52948. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52949. }
  52950. interface ThinEngine {
  52951. /**
  52952. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52953. * @param rootUrl defines the url where the file to load is located
  52954. * @param scene defines the current scene
  52955. * @param lodScale defines scale to apply to the mip map selection
  52956. * @param lodOffset defines offset to apply to the mip map selection
  52957. * @param onLoad defines an optional callback raised when the texture is loaded
  52958. * @param onError defines an optional callback raised if there is an issue to load the texture
  52959. * @param format defines the format of the data
  52960. * @param forcedExtension defines the extension to use to pick the right loader
  52961. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52962. * @returns the cube texture as an InternalTexture
  52963. */
  52964. 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;
  52965. }
  52966. }
  52967. declare module BABYLON {
  52968. /**
  52969. * Implementation of the DDS Texture Loader.
  52970. * @hidden
  52971. */
  52972. export class _DDSTextureLoader implements IInternalTextureLoader {
  52973. /**
  52974. * Defines wether the loader supports cascade loading the different faces.
  52975. */
  52976. readonly supportCascades: boolean;
  52977. /**
  52978. * This returns if the loader support the current file information.
  52979. * @param extension defines the file extension of the file being loaded
  52980. * @returns true if the loader can load the specified file
  52981. */
  52982. canLoad(extension: string): boolean;
  52983. /**
  52984. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52985. * @param data contains the texture data
  52986. * @param texture defines the BabylonJS internal texture
  52987. * @param createPolynomials will be true if polynomials have been requested
  52988. * @param onLoad defines the callback to trigger once the texture is ready
  52989. * @param onError defines the callback to trigger in case of error
  52990. */
  52991. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52992. /**
  52993. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52994. * @param data contains the texture data
  52995. * @param texture defines the BabylonJS internal texture
  52996. * @param callback defines the method to call once ready to upload
  52997. */
  52998. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52999. }
  53000. }
  53001. declare module BABYLON {
  53002. /**
  53003. * Implementation of the ENV Texture Loader.
  53004. * @hidden
  53005. */
  53006. export class _ENVTextureLoader implements IInternalTextureLoader {
  53007. /**
  53008. * Defines wether the loader supports cascade loading the different faces.
  53009. */
  53010. readonly supportCascades: boolean;
  53011. /**
  53012. * This returns if the loader support the current file information.
  53013. * @param extension defines the file extension of the file being loaded
  53014. * @returns true if the loader can load the specified file
  53015. */
  53016. canLoad(extension: string): boolean;
  53017. /**
  53018. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  53019. * @param data contains the texture data
  53020. * @param texture defines the BabylonJS internal texture
  53021. * @param createPolynomials will be true if polynomials have been requested
  53022. * @param onLoad defines the callback to trigger once the texture is ready
  53023. * @param onError defines the callback to trigger in case of error
  53024. */
  53025. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53026. /**
  53027. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  53028. * @param data contains the texture data
  53029. * @param texture defines the BabylonJS internal texture
  53030. * @param callback defines the method to call once ready to upload
  53031. */
  53032. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53033. }
  53034. }
  53035. declare module BABYLON {
  53036. /**
  53037. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53038. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53039. */
  53040. export class KhronosTextureContainer {
  53041. /** contents of the KTX container file */
  53042. data: ArrayBufferView;
  53043. private static HEADER_LEN;
  53044. private static COMPRESSED_2D;
  53045. private static COMPRESSED_3D;
  53046. private static TEX_2D;
  53047. private static TEX_3D;
  53048. /**
  53049. * Gets the openGL type
  53050. */
  53051. glType: number;
  53052. /**
  53053. * Gets the openGL type size
  53054. */
  53055. glTypeSize: number;
  53056. /**
  53057. * Gets the openGL format
  53058. */
  53059. glFormat: number;
  53060. /**
  53061. * Gets the openGL internal format
  53062. */
  53063. glInternalFormat: number;
  53064. /**
  53065. * Gets the base internal format
  53066. */
  53067. glBaseInternalFormat: number;
  53068. /**
  53069. * Gets image width in pixel
  53070. */
  53071. pixelWidth: number;
  53072. /**
  53073. * Gets image height in pixel
  53074. */
  53075. pixelHeight: number;
  53076. /**
  53077. * Gets image depth in pixels
  53078. */
  53079. pixelDepth: number;
  53080. /**
  53081. * Gets the number of array elements
  53082. */
  53083. numberOfArrayElements: number;
  53084. /**
  53085. * Gets the number of faces
  53086. */
  53087. numberOfFaces: number;
  53088. /**
  53089. * Gets the number of mipmap levels
  53090. */
  53091. numberOfMipmapLevels: number;
  53092. /**
  53093. * Gets the bytes of key value data
  53094. */
  53095. bytesOfKeyValueData: number;
  53096. /**
  53097. * Gets the load type
  53098. */
  53099. loadType: number;
  53100. /**
  53101. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  53102. */
  53103. isInvalid: boolean;
  53104. /**
  53105. * Creates a new KhronosTextureContainer
  53106. * @param data contents of the KTX container file
  53107. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  53108. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  53109. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  53110. */
  53111. constructor(
  53112. /** contents of the KTX container file */
  53113. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  53114. /**
  53115. * Uploads KTX content to a Babylon Texture.
  53116. * It is assumed that the texture has already been created & is currently bound
  53117. * @hidden
  53118. */
  53119. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  53120. private _upload2DCompressedLevels;
  53121. /**
  53122. * Checks if the given data starts with a KTX file identifier.
  53123. * @param data the data to check
  53124. * @returns true if the data is a KTX file or false otherwise
  53125. */
  53126. static IsValid(data: ArrayBufferView): boolean;
  53127. }
  53128. }
  53129. declare module BABYLON {
  53130. /**
  53131. * Class for loading KTX2 files
  53132. * !!! Experimental Extension Subject to Changes !!!
  53133. * @hidden
  53134. */
  53135. export class KhronosTextureContainer2 {
  53136. private static _ModulePromise;
  53137. private static _TranscodeFormat;
  53138. constructor(engine: ThinEngine);
  53139. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  53140. private _determineTranscodeFormat;
  53141. /**
  53142. * Checks if the given data starts with a KTX2 file identifier.
  53143. * @param data the data to check
  53144. * @returns true if the data is a KTX2 file or false otherwise
  53145. */
  53146. static IsValid(data: ArrayBufferView): boolean;
  53147. }
  53148. }
  53149. declare module BABYLON {
  53150. /**
  53151. * Implementation of the KTX Texture Loader.
  53152. * @hidden
  53153. */
  53154. export class _KTXTextureLoader implements IInternalTextureLoader {
  53155. /**
  53156. * Defines wether the loader supports cascade loading the different faces.
  53157. */
  53158. readonly supportCascades: boolean;
  53159. /**
  53160. * This returns if the loader support the current file information.
  53161. * @param extension defines the file extension of the file being loaded
  53162. * @returns true if the loader can load the specified file
  53163. */
  53164. canLoad(extension: string): boolean;
  53165. /**
  53166. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  53167. * @param data contains the texture data
  53168. * @param texture defines the BabylonJS internal texture
  53169. * @param createPolynomials will be true if polynomials have been requested
  53170. * @param onLoad defines the callback to trigger once the texture is ready
  53171. * @param onError defines the callback to trigger in case of error
  53172. */
  53173. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53174. /**
  53175. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  53176. * @param data contains the texture data
  53177. * @param texture defines the BabylonJS internal texture
  53178. * @param callback defines the method to call once ready to upload
  53179. */
  53180. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  53181. }
  53182. }
  53183. declare module BABYLON {
  53184. /** @hidden */
  53185. export var _forceSceneHelpersToBundle: boolean;
  53186. interface Scene {
  53187. /**
  53188. * Creates a default light for the scene.
  53189. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  53190. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  53191. */
  53192. createDefaultLight(replace?: boolean): void;
  53193. /**
  53194. * Creates a default camera for the scene.
  53195. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  53196. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53197. * @param replace has default false, when true replaces the active camera in the scene
  53198. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  53199. */
  53200. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53201. /**
  53202. * Creates a default camera and a default light.
  53203. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  53204. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  53205. * @param replace has the default false, when true replaces the active camera/light in the scene
  53206. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  53207. */
  53208. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  53209. /**
  53210. * Creates a new sky box
  53211. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  53212. * @param environmentTexture defines the texture to use as environment texture
  53213. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  53214. * @param scale defines the overall scale of the skybox
  53215. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  53216. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  53217. * @returns a new mesh holding the sky box
  53218. */
  53219. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  53220. /**
  53221. * Creates a new environment
  53222. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  53223. * @param options defines the options you can use to configure the environment
  53224. * @returns the new EnvironmentHelper
  53225. */
  53226. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  53227. /**
  53228. * Creates a new VREXperienceHelper
  53229. * @see http://doc.babylonjs.com/how_to/webvr_helper
  53230. * @param webVROptions defines the options used to create the new VREXperienceHelper
  53231. * @returns a new VREXperienceHelper
  53232. */
  53233. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  53234. /**
  53235. * Creates a new WebXRDefaultExperience
  53236. * @see http://doc.babylonjs.com/how_to/webxr
  53237. * @param options experience options
  53238. * @returns a promise for a new WebXRDefaultExperience
  53239. */
  53240. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  53241. }
  53242. }
  53243. declare module BABYLON {
  53244. /**
  53245. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  53246. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  53247. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  53248. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  53249. */
  53250. export class VideoDome extends TransformNode {
  53251. /**
  53252. * Define the video source as a Monoscopic panoramic 360 video.
  53253. */
  53254. static readonly MODE_MONOSCOPIC: number;
  53255. /**
  53256. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53257. */
  53258. static readonly MODE_TOPBOTTOM: number;
  53259. /**
  53260. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53261. */
  53262. static readonly MODE_SIDEBYSIDE: number;
  53263. private _halfDome;
  53264. private _useDirectMapping;
  53265. /**
  53266. * The video texture being displayed on the sphere
  53267. */
  53268. protected _videoTexture: VideoTexture;
  53269. /**
  53270. * Gets the video texture being displayed on the sphere
  53271. */
  53272. get videoTexture(): VideoTexture;
  53273. /**
  53274. * The skybox material
  53275. */
  53276. protected _material: BackgroundMaterial;
  53277. /**
  53278. * The surface used for the skybox
  53279. */
  53280. protected _mesh: Mesh;
  53281. /**
  53282. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  53283. */
  53284. private _halfDomeMask;
  53285. /**
  53286. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53287. * Also see the options.resolution property.
  53288. */
  53289. get fovMultiplier(): number;
  53290. set fovMultiplier(value: number);
  53291. private _videoMode;
  53292. /**
  53293. * Gets or set the current video mode for the video. It can be:
  53294. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  53295. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  53296. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  53297. */
  53298. get videoMode(): number;
  53299. set videoMode(value: number);
  53300. /**
  53301. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  53302. *
  53303. */
  53304. get halfDome(): boolean;
  53305. /**
  53306. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  53307. */
  53308. set halfDome(enabled: boolean);
  53309. /**
  53310. * Oberserver used in Stereoscopic VR Mode.
  53311. */
  53312. private _onBeforeCameraRenderObserver;
  53313. /**
  53314. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  53315. * @param name Element's name, child elements will append suffixes for their own names.
  53316. * @param urlsOrVideo defines the url(s) or the video element to use
  53317. * @param options An object containing optional or exposed sub element properties
  53318. */
  53319. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  53320. resolution?: number;
  53321. clickToPlay?: boolean;
  53322. autoPlay?: boolean;
  53323. loop?: boolean;
  53324. size?: number;
  53325. poster?: string;
  53326. faceForward?: boolean;
  53327. useDirectMapping?: boolean;
  53328. halfDomeMode?: boolean;
  53329. }, scene: Scene);
  53330. private _changeVideoMode;
  53331. /**
  53332. * Releases resources associated with this node.
  53333. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  53334. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  53335. */
  53336. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  53337. }
  53338. }
  53339. declare module BABYLON {
  53340. /**
  53341. * This class can be used to get instrumentation data from a Babylon engine
  53342. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53343. */
  53344. export class EngineInstrumentation implements IDisposable {
  53345. /**
  53346. * Define the instrumented engine.
  53347. */
  53348. engine: Engine;
  53349. private _captureGPUFrameTime;
  53350. private _gpuFrameTimeToken;
  53351. private _gpuFrameTime;
  53352. private _captureShaderCompilationTime;
  53353. private _shaderCompilationTime;
  53354. private _onBeginFrameObserver;
  53355. private _onEndFrameObserver;
  53356. private _onBeforeShaderCompilationObserver;
  53357. private _onAfterShaderCompilationObserver;
  53358. /**
  53359. * Gets the perf counter used for GPU frame time
  53360. */
  53361. get gpuFrameTimeCounter(): PerfCounter;
  53362. /**
  53363. * Gets the GPU frame time capture status
  53364. */
  53365. get captureGPUFrameTime(): boolean;
  53366. /**
  53367. * Enable or disable the GPU frame time capture
  53368. */
  53369. set captureGPUFrameTime(value: boolean);
  53370. /**
  53371. * Gets the perf counter used for shader compilation time
  53372. */
  53373. get shaderCompilationTimeCounter(): PerfCounter;
  53374. /**
  53375. * Gets the shader compilation time capture status
  53376. */
  53377. get captureShaderCompilationTime(): boolean;
  53378. /**
  53379. * Enable or disable the shader compilation time capture
  53380. */
  53381. set captureShaderCompilationTime(value: boolean);
  53382. /**
  53383. * Instantiates a new engine instrumentation.
  53384. * This class can be used to get instrumentation data from a Babylon engine
  53385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53386. * @param engine Defines the engine to instrument
  53387. */
  53388. constructor(
  53389. /**
  53390. * Define the instrumented engine.
  53391. */
  53392. engine: Engine);
  53393. /**
  53394. * Dispose and release associated resources.
  53395. */
  53396. dispose(): void;
  53397. }
  53398. }
  53399. declare module BABYLON {
  53400. /**
  53401. * This class can be used to get instrumentation data from a Babylon engine
  53402. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53403. */
  53404. export class SceneInstrumentation implements IDisposable {
  53405. /**
  53406. * Defines the scene to instrument
  53407. */
  53408. scene: Scene;
  53409. private _captureActiveMeshesEvaluationTime;
  53410. private _activeMeshesEvaluationTime;
  53411. private _captureRenderTargetsRenderTime;
  53412. private _renderTargetsRenderTime;
  53413. private _captureFrameTime;
  53414. private _frameTime;
  53415. private _captureRenderTime;
  53416. private _renderTime;
  53417. private _captureInterFrameTime;
  53418. private _interFrameTime;
  53419. private _captureParticlesRenderTime;
  53420. private _particlesRenderTime;
  53421. private _captureSpritesRenderTime;
  53422. private _spritesRenderTime;
  53423. private _capturePhysicsTime;
  53424. private _physicsTime;
  53425. private _captureAnimationsTime;
  53426. private _animationsTime;
  53427. private _captureCameraRenderTime;
  53428. private _cameraRenderTime;
  53429. private _onBeforeActiveMeshesEvaluationObserver;
  53430. private _onAfterActiveMeshesEvaluationObserver;
  53431. private _onBeforeRenderTargetsRenderObserver;
  53432. private _onAfterRenderTargetsRenderObserver;
  53433. private _onAfterRenderObserver;
  53434. private _onBeforeDrawPhaseObserver;
  53435. private _onAfterDrawPhaseObserver;
  53436. private _onBeforeAnimationsObserver;
  53437. private _onBeforeParticlesRenderingObserver;
  53438. private _onAfterParticlesRenderingObserver;
  53439. private _onBeforeSpritesRenderingObserver;
  53440. private _onAfterSpritesRenderingObserver;
  53441. private _onBeforePhysicsObserver;
  53442. private _onAfterPhysicsObserver;
  53443. private _onAfterAnimationsObserver;
  53444. private _onBeforeCameraRenderObserver;
  53445. private _onAfterCameraRenderObserver;
  53446. /**
  53447. * Gets the perf counter used for active meshes evaluation time
  53448. */
  53449. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53450. /**
  53451. * Gets the active meshes evaluation time capture status
  53452. */
  53453. get captureActiveMeshesEvaluationTime(): boolean;
  53454. /**
  53455. * Enable or disable the active meshes evaluation time capture
  53456. */
  53457. set captureActiveMeshesEvaluationTime(value: boolean);
  53458. /**
  53459. * Gets the perf counter used for render targets render time
  53460. */
  53461. get renderTargetsRenderTimeCounter(): PerfCounter;
  53462. /**
  53463. * Gets the render targets render time capture status
  53464. */
  53465. get captureRenderTargetsRenderTime(): boolean;
  53466. /**
  53467. * Enable or disable the render targets render time capture
  53468. */
  53469. set captureRenderTargetsRenderTime(value: boolean);
  53470. /**
  53471. * Gets the perf counter used for particles render time
  53472. */
  53473. get particlesRenderTimeCounter(): PerfCounter;
  53474. /**
  53475. * Gets the particles render time capture status
  53476. */
  53477. get captureParticlesRenderTime(): boolean;
  53478. /**
  53479. * Enable or disable the particles render time capture
  53480. */
  53481. set captureParticlesRenderTime(value: boolean);
  53482. /**
  53483. * Gets the perf counter used for sprites render time
  53484. */
  53485. get spritesRenderTimeCounter(): PerfCounter;
  53486. /**
  53487. * Gets the sprites render time capture status
  53488. */
  53489. get captureSpritesRenderTime(): boolean;
  53490. /**
  53491. * Enable or disable the sprites render time capture
  53492. */
  53493. set captureSpritesRenderTime(value: boolean);
  53494. /**
  53495. * Gets the perf counter used for physics time
  53496. */
  53497. get physicsTimeCounter(): PerfCounter;
  53498. /**
  53499. * Gets the physics time capture status
  53500. */
  53501. get capturePhysicsTime(): boolean;
  53502. /**
  53503. * Enable or disable the physics time capture
  53504. */
  53505. set capturePhysicsTime(value: boolean);
  53506. /**
  53507. * Gets the perf counter used for animations time
  53508. */
  53509. get animationsTimeCounter(): PerfCounter;
  53510. /**
  53511. * Gets the animations time capture status
  53512. */
  53513. get captureAnimationsTime(): boolean;
  53514. /**
  53515. * Enable or disable the animations time capture
  53516. */
  53517. set captureAnimationsTime(value: boolean);
  53518. /**
  53519. * Gets the perf counter used for frame time capture
  53520. */
  53521. get frameTimeCounter(): PerfCounter;
  53522. /**
  53523. * Gets the frame time capture status
  53524. */
  53525. get captureFrameTime(): boolean;
  53526. /**
  53527. * Enable or disable the frame time capture
  53528. */
  53529. set captureFrameTime(value: boolean);
  53530. /**
  53531. * Gets the perf counter used for inter-frames time capture
  53532. */
  53533. get interFrameTimeCounter(): PerfCounter;
  53534. /**
  53535. * Gets the inter-frames time capture status
  53536. */
  53537. get captureInterFrameTime(): boolean;
  53538. /**
  53539. * Enable or disable the inter-frames time capture
  53540. */
  53541. set captureInterFrameTime(value: boolean);
  53542. /**
  53543. * Gets the perf counter used for render time capture
  53544. */
  53545. get renderTimeCounter(): PerfCounter;
  53546. /**
  53547. * Gets the render time capture status
  53548. */
  53549. get captureRenderTime(): boolean;
  53550. /**
  53551. * Enable or disable the render time capture
  53552. */
  53553. set captureRenderTime(value: boolean);
  53554. /**
  53555. * Gets the perf counter used for camera render time capture
  53556. */
  53557. get cameraRenderTimeCounter(): PerfCounter;
  53558. /**
  53559. * Gets the camera render time capture status
  53560. */
  53561. get captureCameraRenderTime(): boolean;
  53562. /**
  53563. * Enable or disable the camera render time capture
  53564. */
  53565. set captureCameraRenderTime(value: boolean);
  53566. /**
  53567. * Gets the perf counter used for draw calls
  53568. */
  53569. get drawCallsCounter(): PerfCounter;
  53570. /**
  53571. * Instantiates a new scene instrumentation.
  53572. * This class can be used to get instrumentation data from a Babylon engine
  53573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53574. * @param scene Defines the scene to instrument
  53575. */
  53576. constructor(
  53577. /**
  53578. * Defines the scene to instrument
  53579. */
  53580. scene: Scene);
  53581. /**
  53582. * Dispose and release associated resources.
  53583. */
  53584. dispose(): void;
  53585. }
  53586. }
  53587. declare module BABYLON {
  53588. /** @hidden */
  53589. export var glowMapGenerationPixelShader: {
  53590. name: string;
  53591. shader: string;
  53592. };
  53593. }
  53594. declare module BABYLON {
  53595. /** @hidden */
  53596. export var glowMapGenerationVertexShader: {
  53597. name: string;
  53598. shader: string;
  53599. };
  53600. }
  53601. declare module BABYLON {
  53602. /**
  53603. * Effect layer options. This helps customizing the behaviour
  53604. * of the effect layer.
  53605. */
  53606. export interface IEffectLayerOptions {
  53607. /**
  53608. * Multiplication factor apply to the canvas size to compute the render target size
  53609. * used to generated the objects (the smaller the faster).
  53610. */
  53611. mainTextureRatio: number;
  53612. /**
  53613. * Enforces a fixed size texture to ensure effect stability across devices.
  53614. */
  53615. mainTextureFixedSize?: number;
  53616. /**
  53617. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53618. */
  53619. alphaBlendingMode: number;
  53620. /**
  53621. * The camera attached to the layer.
  53622. */
  53623. camera: Nullable<Camera>;
  53624. /**
  53625. * The rendering group to draw the layer in.
  53626. */
  53627. renderingGroupId: number;
  53628. }
  53629. /**
  53630. * The effect layer Helps adding post process effect blended with the main pass.
  53631. *
  53632. * This can be for instance use to generate glow or higlight effects on the scene.
  53633. *
  53634. * The effect layer class can not be used directly and is intented to inherited from to be
  53635. * customized per effects.
  53636. */
  53637. export abstract class EffectLayer {
  53638. private _vertexBuffers;
  53639. private _indexBuffer;
  53640. private _cachedDefines;
  53641. private _effectLayerMapGenerationEffect;
  53642. private _effectLayerOptions;
  53643. private _mergeEffect;
  53644. protected _scene: Scene;
  53645. protected _engine: Engine;
  53646. protected _maxSize: number;
  53647. protected _mainTextureDesiredSize: ISize;
  53648. protected _mainTexture: RenderTargetTexture;
  53649. protected _shouldRender: boolean;
  53650. protected _postProcesses: PostProcess[];
  53651. protected _textures: BaseTexture[];
  53652. protected _emissiveTextureAndColor: {
  53653. texture: Nullable<BaseTexture>;
  53654. color: Color4;
  53655. };
  53656. /**
  53657. * The name of the layer
  53658. */
  53659. name: string;
  53660. /**
  53661. * The clear color of the texture used to generate the glow map.
  53662. */
  53663. neutralColor: Color4;
  53664. /**
  53665. * Specifies whether the highlight layer is enabled or not.
  53666. */
  53667. isEnabled: boolean;
  53668. /**
  53669. * Gets the camera attached to the layer.
  53670. */
  53671. get camera(): Nullable<Camera>;
  53672. /**
  53673. * Gets the rendering group id the layer should render in.
  53674. */
  53675. get renderingGroupId(): number;
  53676. set renderingGroupId(renderingGroupId: number);
  53677. /**
  53678. * An event triggered when the effect layer has been disposed.
  53679. */
  53680. onDisposeObservable: Observable<EffectLayer>;
  53681. /**
  53682. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53683. */
  53684. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53685. /**
  53686. * An event triggered when the generated texture is being merged in the scene.
  53687. */
  53688. onBeforeComposeObservable: Observable<EffectLayer>;
  53689. /**
  53690. * An event triggered when the mesh is rendered into the effect render target.
  53691. */
  53692. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53693. /**
  53694. * An event triggered after the mesh has been rendered into the effect render target.
  53695. */
  53696. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53697. /**
  53698. * An event triggered when the generated texture has been merged in the scene.
  53699. */
  53700. onAfterComposeObservable: Observable<EffectLayer>;
  53701. /**
  53702. * An event triggered when the efffect layer changes its size.
  53703. */
  53704. onSizeChangedObservable: Observable<EffectLayer>;
  53705. /** @hidden */
  53706. static _SceneComponentInitialization: (scene: Scene) => void;
  53707. /**
  53708. * Instantiates a new effect Layer and references it in the scene.
  53709. * @param name The name of the layer
  53710. * @param scene The scene to use the layer in
  53711. */
  53712. constructor(
  53713. /** The Friendly of the effect in the scene */
  53714. name: string, scene: Scene);
  53715. /**
  53716. * Get the effect name of the layer.
  53717. * @return The effect name
  53718. */
  53719. abstract getEffectName(): string;
  53720. /**
  53721. * Checks for the readiness of the element composing the layer.
  53722. * @param subMesh the mesh to check for
  53723. * @param useInstances specify whether or not to use instances to render the mesh
  53724. * @return true if ready otherwise, false
  53725. */
  53726. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53727. /**
  53728. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53729. * @returns true if the effect requires stencil during the main canvas render pass.
  53730. */
  53731. abstract needStencil(): boolean;
  53732. /**
  53733. * Create the merge effect. This is the shader use to blit the information back
  53734. * to the main canvas at the end of the scene rendering.
  53735. * @returns The effect containing the shader used to merge the effect on the main canvas
  53736. */
  53737. protected abstract _createMergeEffect(): Effect;
  53738. /**
  53739. * Creates the render target textures and post processes used in the effect layer.
  53740. */
  53741. protected abstract _createTextureAndPostProcesses(): void;
  53742. /**
  53743. * Implementation specific of rendering the generating effect on the main canvas.
  53744. * @param effect The effect used to render through
  53745. */
  53746. protected abstract _internalRender(effect: Effect): void;
  53747. /**
  53748. * Sets the required values for both the emissive texture and and the main color.
  53749. */
  53750. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53751. /**
  53752. * Free any resources and references associated to a mesh.
  53753. * Internal use
  53754. * @param mesh The mesh to free.
  53755. */
  53756. abstract _disposeMesh(mesh: Mesh): void;
  53757. /**
  53758. * Serializes this layer (Glow or Highlight for example)
  53759. * @returns a serialized layer object
  53760. */
  53761. abstract serialize?(): any;
  53762. /**
  53763. * Initializes the effect layer with the required options.
  53764. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53765. */
  53766. protected _init(options: Partial<IEffectLayerOptions>): void;
  53767. /**
  53768. * Generates the index buffer of the full screen quad blending to the main canvas.
  53769. */
  53770. private _generateIndexBuffer;
  53771. /**
  53772. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53773. */
  53774. private _generateVertexBuffer;
  53775. /**
  53776. * Sets the main texture desired size which is the closest power of two
  53777. * of the engine canvas size.
  53778. */
  53779. private _setMainTextureSize;
  53780. /**
  53781. * Creates the main texture for the effect layer.
  53782. */
  53783. protected _createMainTexture(): void;
  53784. /**
  53785. * Adds specific effects defines.
  53786. * @param defines The defines to add specifics to.
  53787. */
  53788. protected _addCustomEffectDefines(defines: string[]): void;
  53789. /**
  53790. * Checks for the readiness of the element composing the layer.
  53791. * @param subMesh the mesh to check for
  53792. * @param useInstances specify whether or not to use instances to render the mesh
  53793. * @param emissiveTexture the associated emissive texture used to generate the glow
  53794. * @return true if ready otherwise, false
  53795. */
  53796. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53797. /**
  53798. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53799. */
  53800. render(): void;
  53801. /**
  53802. * Determine if a given mesh will be used in the current effect.
  53803. * @param mesh mesh to test
  53804. * @returns true if the mesh will be used
  53805. */
  53806. hasMesh(mesh: AbstractMesh): boolean;
  53807. /**
  53808. * Returns true if the layer contains information to display, otherwise false.
  53809. * @returns true if the glow layer should be rendered
  53810. */
  53811. shouldRender(): boolean;
  53812. /**
  53813. * Returns true if the mesh should render, otherwise false.
  53814. * @param mesh The mesh to render
  53815. * @returns true if it should render otherwise false
  53816. */
  53817. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53818. /**
  53819. * Returns true if the mesh can be rendered, otherwise false.
  53820. * @param mesh The mesh to render
  53821. * @param material The material used on the mesh
  53822. * @returns true if it can be rendered otherwise false
  53823. */
  53824. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53825. /**
  53826. * Returns true if the mesh should render, otherwise false.
  53827. * @param mesh The mesh to render
  53828. * @returns true if it should render otherwise false
  53829. */
  53830. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53831. /**
  53832. * Renders the submesh passed in parameter to the generation map.
  53833. */
  53834. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53835. /**
  53836. * Defines whether the current material of the mesh should be use to render the effect.
  53837. * @param mesh defines the current mesh to render
  53838. */
  53839. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53840. /**
  53841. * Rebuild the required buffers.
  53842. * @hidden Internal use only.
  53843. */
  53844. _rebuild(): void;
  53845. /**
  53846. * Dispose only the render target textures and post process.
  53847. */
  53848. private _disposeTextureAndPostProcesses;
  53849. /**
  53850. * Dispose the highlight layer and free resources.
  53851. */
  53852. dispose(): void;
  53853. /**
  53854. * Gets the class name of the effect layer
  53855. * @returns the string with the class name of the effect layer
  53856. */
  53857. getClassName(): string;
  53858. /**
  53859. * Creates an effect layer from parsed effect layer data
  53860. * @param parsedEffectLayer defines effect layer data
  53861. * @param scene defines the current scene
  53862. * @param rootUrl defines the root URL containing the effect layer information
  53863. * @returns a parsed effect Layer
  53864. */
  53865. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53866. }
  53867. }
  53868. declare module BABYLON {
  53869. interface AbstractScene {
  53870. /**
  53871. * The list of effect layers (highlights/glow) added to the scene
  53872. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53873. * @see http://doc.babylonjs.com/how_to/glow_layer
  53874. */
  53875. effectLayers: Array<EffectLayer>;
  53876. /**
  53877. * Removes the given effect layer from this scene.
  53878. * @param toRemove defines the effect layer to remove
  53879. * @returns the index of the removed effect layer
  53880. */
  53881. removeEffectLayer(toRemove: EffectLayer): number;
  53882. /**
  53883. * Adds the given effect layer to this scene
  53884. * @param newEffectLayer defines the effect layer to add
  53885. */
  53886. addEffectLayer(newEffectLayer: EffectLayer): void;
  53887. }
  53888. /**
  53889. * Defines the layer scene component responsible to manage any effect layers
  53890. * in a given scene.
  53891. */
  53892. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53893. /**
  53894. * The component name helpfull to identify the component in the list of scene components.
  53895. */
  53896. readonly name: string;
  53897. /**
  53898. * The scene the component belongs to.
  53899. */
  53900. scene: Scene;
  53901. private _engine;
  53902. private _renderEffects;
  53903. private _needStencil;
  53904. private _previousStencilState;
  53905. /**
  53906. * Creates a new instance of the component for the given scene
  53907. * @param scene Defines the scene to register the component in
  53908. */
  53909. constructor(scene: Scene);
  53910. /**
  53911. * Registers the component in a given scene
  53912. */
  53913. register(): void;
  53914. /**
  53915. * Rebuilds the elements related to this component in case of
  53916. * context lost for instance.
  53917. */
  53918. rebuild(): void;
  53919. /**
  53920. * Serializes the component data to the specified json object
  53921. * @param serializationObject The object to serialize to
  53922. */
  53923. serialize(serializationObject: any): void;
  53924. /**
  53925. * Adds all the elements from the container to the scene
  53926. * @param container the container holding the elements
  53927. */
  53928. addFromContainer(container: AbstractScene): void;
  53929. /**
  53930. * Removes all the elements in the container from the scene
  53931. * @param container contains the elements to remove
  53932. * @param dispose if the removed element should be disposed (default: false)
  53933. */
  53934. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53935. /**
  53936. * Disposes the component and the associated ressources.
  53937. */
  53938. dispose(): void;
  53939. private _isReadyForMesh;
  53940. private _renderMainTexture;
  53941. private _setStencil;
  53942. private _setStencilBack;
  53943. private _draw;
  53944. private _drawCamera;
  53945. private _drawRenderingGroup;
  53946. }
  53947. }
  53948. declare module BABYLON {
  53949. /** @hidden */
  53950. export var glowMapMergePixelShader: {
  53951. name: string;
  53952. shader: string;
  53953. };
  53954. }
  53955. declare module BABYLON {
  53956. /** @hidden */
  53957. export var glowMapMergeVertexShader: {
  53958. name: string;
  53959. shader: string;
  53960. };
  53961. }
  53962. declare module BABYLON {
  53963. interface AbstractScene {
  53964. /**
  53965. * Return a the first highlight layer of the scene with a given name.
  53966. * @param name The name of the highlight layer to look for.
  53967. * @return The highlight layer if found otherwise null.
  53968. */
  53969. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53970. }
  53971. /**
  53972. * Glow layer options. This helps customizing the behaviour
  53973. * of the glow layer.
  53974. */
  53975. export interface IGlowLayerOptions {
  53976. /**
  53977. * Multiplication factor apply to the canvas size to compute the render target size
  53978. * used to generated the glowing objects (the smaller the faster).
  53979. */
  53980. mainTextureRatio: number;
  53981. /**
  53982. * Enforces a fixed size texture to ensure resize independant blur.
  53983. */
  53984. mainTextureFixedSize?: number;
  53985. /**
  53986. * How big is the kernel of the blur texture.
  53987. */
  53988. blurKernelSize: number;
  53989. /**
  53990. * The camera attached to the layer.
  53991. */
  53992. camera: Nullable<Camera>;
  53993. /**
  53994. * Enable MSAA by chosing the number of samples.
  53995. */
  53996. mainTextureSamples?: number;
  53997. /**
  53998. * The rendering group to draw the layer in.
  53999. */
  54000. renderingGroupId: number;
  54001. }
  54002. /**
  54003. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  54004. *
  54005. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  54006. *
  54007. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  54008. */
  54009. export class GlowLayer extends EffectLayer {
  54010. /**
  54011. * Effect Name of the layer.
  54012. */
  54013. static readonly EffectName: string;
  54014. /**
  54015. * The default blur kernel size used for the glow.
  54016. */
  54017. static DefaultBlurKernelSize: number;
  54018. /**
  54019. * The default texture size ratio used for the glow.
  54020. */
  54021. static DefaultTextureRatio: number;
  54022. /**
  54023. * Sets the kernel size of the blur.
  54024. */
  54025. set blurKernelSize(value: number);
  54026. /**
  54027. * Gets the kernel size of the blur.
  54028. */
  54029. get blurKernelSize(): number;
  54030. /**
  54031. * Sets the glow intensity.
  54032. */
  54033. set intensity(value: number);
  54034. /**
  54035. * Gets the glow intensity.
  54036. */
  54037. get intensity(): number;
  54038. private _options;
  54039. private _intensity;
  54040. private _horizontalBlurPostprocess1;
  54041. private _verticalBlurPostprocess1;
  54042. private _horizontalBlurPostprocess2;
  54043. private _verticalBlurPostprocess2;
  54044. private _blurTexture1;
  54045. private _blurTexture2;
  54046. private _postProcesses1;
  54047. private _postProcesses2;
  54048. private _includedOnlyMeshes;
  54049. private _excludedMeshes;
  54050. private _meshesUsingTheirOwnMaterials;
  54051. /**
  54052. * Callback used to let the user override the color selection on a per mesh basis
  54053. */
  54054. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  54055. /**
  54056. * Callback used to let the user override the texture selection on a per mesh basis
  54057. */
  54058. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  54059. /**
  54060. * Instantiates a new glow Layer and references it to the scene.
  54061. * @param name The name of the layer
  54062. * @param scene The scene to use the layer in
  54063. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  54064. */
  54065. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  54066. /**
  54067. * Get the effect name of the layer.
  54068. * @return The effect name
  54069. */
  54070. getEffectName(): string;
  54071. /**
  54072. * Create the merge effect. This is the shader use to blit the information back
  54073. * to the main canvas at the end of the scene rendering.
  54074. */
  54075. protected _createMergeEffect(): Effect;
  54076. /**
  54077. * Creates the render target textures and post processes used in the glow layer.
  54078. */
  54079. protected _createTextureAndPostProcesses(): void;
  54080. /**
  54081. * Checks for the readiness of the element composing the layer.
  54082. * @param subMesh the mesh to check for
  54083. * @param useInstances specify wether or not to use instances to render the mesh
  54084. * @param emissiveTexture the associated emissive texture used to generate the glow
  54085. * @return true if ready otherwise, false
  54086. */
  54087. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54088. /**
  54089. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  54090. */
  54091. needStencil(): boolean;
  54092. /**
  54093. * Returns true if the mesh can be rendered, otherwise false.
  54094. * @param mesh The mesh to render
  54095. * @param material The material used on the mesh
  54096. * @returns true if it can be rendered otherwise false
  54097. */
  54098. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54099. /**
  54100. * Implementation specific of rendering the generating effect on the main canvas.
  54101. * @param effect The effect used to render through
  54102. */
  54103. protected _internalRender(effect: Effect): void;
  54104. /**
  54105. * Sets the required values for both the emissive texture and and the main color.
  54106. */
  54107. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54108. /**
  54109. * Returns true if the mesh should render, otherwise false.
  54110. * @param mesh The mesh to render
  54111. * @returns true if it should render otherwise false
  54112. */
  54113. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54114. /**
  54115. * Adds specific effects defines.
  54116. * @param defines The defines to add specifics to.
  54117. */
  54118. protected _addCustomEffectDefines(defines: string[]): void;
  54119. /**
  54120. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  54121. * @param mesh The mesh to exclude from the glow layer
  54122. */
  54123. addExcludedMesh(mesh: Mesh): void;
  54124. /**
  54125. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  54126. * @param mesh The mesh to remove
  54127. */
  54128. removeExcludedMesh(mesh: Mesh): void;
  54129. /**
  54130. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  54131. * @param mesh The mesh to include in the glow layer
  54132. */
  54133. addIncludedOnlyMesh(mesh: Mesh): void;
  54134. /**
  54135. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  54136. * @param mesh The mesh to remove
  54137. */
  54138. removeIncludedOnlyMesh(mesh: Mesh): void;
  54139. /**
  54140. * Determine if a given mesh will be used in the glow layer
  54141. * @param mesh The mesh to test
  54142. * @returns true if the mesh will be highlighted by the current glow layer
  54143. */
  54144. hasMesh(mesh: AbstractMesh): boolean;
  54145. /**
  54146. * Defines whether the current material of the mesh should be use to render the effect.
  54147. * @param mesh defines the current mesh to render
  54148. */
  54149. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54150. /**
  54151. * Add a mesh to be rendered through its own material and not with emissive only.
  54152. * @param mesh The mesh for which we need to use its material
  54153. */
  54154. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  54155. /**
  54156. * Remove a mesh from being rendered through its own material and not with emissive only.
  54157. * @param mesh The mesh for which we need to not use its material
  54158. */
  54159. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  54160. /**
  54161. * Free any resources and references associated to a mesh.
  54162. * Internal use
  54163. * @param mesh The mesh to free.
  54164. * @hidden
  54165. */
  54166. _disposeMesh(mesh: Mesh): void;
  54167. /**
  54168. * Gets the class name of the effect layer
  54169. * @returns the string with the class name of the effect layer
  54170. */
  54171. getClassName(): string;
  54172. /**
  54173. * Serializes this glow layer
  54174. * @returns a serialized glow layer object
  54175. */
  54176. serialize(): any;
  54177. /**
  54178. * Creates a Glow Layer from parsed glow layer data
  54179. * @param parsedGlowLayer defines glow layer data
  54180. * @param scene defines the current scene
  54181. * @param rootUrl defines the root URL containing the glow layer information
  54182. * @returns a parsed Glow Layer
  54183. */
  54184. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  54185. }
  54186. }
  54187. declare module BABYLON {
  54188. /** @hidden */
  54189. export var glowBlurPostProcessPixelShader: {
  54190. name: string;
  54191. shader: string;
  54192. };
  54193. }
  54194. declare module BABYLON {
  54195. interface AbstractScene {
  54196. /**
  54197. * Return a the first highlight layer of the scene with a given name.
  54198. * @param name The name of the highlight layer to look for.
  54199. * @return The highlight layer if found otherwise null.
  54200. */
  54201. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  54202. }
  54203. /**
  54204. * Highlight layer options. This helps customizing the behaviour
  54205. * of the highlight layer.
  54206. */
  54207. export interface IHighlightLayerOptions {
  54208. /**
  54209. * Multiplication factor apply to the canvas size to compute the render target size
  54210. * used to generated the glowing objects (the smaller the faster).
  54211. */
  54212. mainTextureRatio: number;
  54213. /**
  54214. * Enforces a fixed size texture to ensure resize independant blur.
  54215. */
  54216. mainTextureFixedSize?: number;
  54217. /**
  54218. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  54219. * of the picture to blur (the smaller the faster).
  54220. */
  54221. blurTextureSizeRatio: number;
  54222. /**
  54223. * How big in texel of the blur texture is the vertical blur.
  54224. */
  54225. blurVerticalSize: number;
  54226. /**
  54227. * How big in texel of the blur texture is the horizontal blur.
  54228. */
  54229. blurHorizontalSize: number;
  54230. /**
  54231. * Alpha blending mode used to apply the blur. Default is combine.
  54232. */
  54233. alphaBlendingMode: number;
  54234. /**
  54235. * The camera attached to the layer.
  54236. */
  54237. camera: Nullable<Camera>;
  54238. /**
  54239. * Should we display highlight as a solid stroke?
  54240. */
  54241. isStroke?: boolean;
  54242. /**
  54243. * The rendering group to draw the layer in.
  54244. */
  54245. renderingGroupId: number;
  54246. }
  54247. /**
  54248. * The highlight layer Helps adding a glow effect around a mesh.
  54249. *
  54250. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  54251. * glowy meshes to your scene.
  54252. *
  54253. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  54254. */
  54255. export class HighlightLayer extends EffectLayer {
  54256. name: string;
  54257. /**
  54258. * Effect Name of the highlight layer.
  54259. */
  54260. static readonly EffectName: string;
  54261. /**
  54262. * The neutral color used during the preparation of the glow effect.
  54263. * This is black by default as the blend operation is a blend operation.
  54264. */
  54265. static NeutralColor: Color4;
  54266. /**
  54267. * Stencil value used for glowing meshes.
  54268. */
  54269. static GlowingMeshStencilReference: number;
  54270. /**
  54271. * Stencil value used for the other meshes in the scene.
  54272. */
  54273. static NormalMeshStencilReference: number;
  54274. /**
  54275. * Specifies whether or not the inner glow is ACTIVE in the layer.
  54276. */
  54277. innerGlow: boolean;
  54278. /**
  54279. * Specifies whether or not the outer glow is ACTIVE in the layer.
  54280. */
  54281. outerGlow: boolean;
  54282. /**
  54283. * Specifies the horizontal size of the blur.
  54284. */
  54285. set blurHorizontalSize(value: number);
  54286. /**
  54287. * Specifies the vertical size of the blur.
  54288. */
  54289. set blurVerticalSize(value: number);
  54290. /**
  54291. * Gets the horizontal size of the blur.
  54292. */
  54293. get blurHorizontalSize(): number;
  54294. /**
  54295. * Gets the vertical size of the blur.
  54296. */
  54297. get blurVerticalSize(): number;
  54298. /**
  54299. * An event triggered when the highlight layer is being blurred.
  54300. */
  54301. onBeforeBlurObservable: Observable<HighlightLayer>;
  54302. /**
  54303. * An event triggered when the highlight layer has been blurred.
  54304. */
  54305. onAfterBlurObservable: Observable<HighlightLayer>;
  54306. private _instanceGlowingMeshStencilReference;
  54307. private _options;
  54308. private _downSamplePostprocess;
  54309. private _horizontalBlurPostprocess;
  54310. private _verticalBlurPostprocess;
  54311. private _blurTexture;
  54312. private _meshes;
  54313. private _excludedMeshes;
  54314. /**
  54315. * Instantiates a new highlight Layer and references it to the scene..
  54316. * @param name The name of the layer
  54317. * @param scene The scene to use the layer in
  54318. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  54319. */
  54320. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  54321. /**
  54322. * Get the effect name of the layer.
  54323. * @return The effect name
  54324. */
  54325. getEffectName(): string;
  54326. /**
  54327. * Create the merge effect. This is the shader use to blit the information back
  54328. * to the main canvas at the end of the scene rendering.
  54329. */
  54330. protected _createMergeEffect(): Effect;
  54331. /**
  54332. * Creates the render target textures and post processes used in the highlight layer.
  54333. */
  54334. protected _createTextureAndPostProcesses(): void;
  54335. /**
  54336. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54337. */
  54338. needStencil(): boolean;
  54339. /**
  54340. * Checks for the readiness of the element composing the layer.
  54341. * @param subMesh the mesh to check for
  54342. * @param useInstances specify wether or not to use instances to render the mesh
  54343. * @param emissiveTexture the associated emissive texture used to generate the glow
  54344. * @return true if ready otherwise, false
  54345. */
  54346. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54347. /**
  54348. * Implementation specific of rendering the generating effect on the main canvas.
  54349. * @param effect The effect used to render through
  54350. */
  54351. protected _internalRender(effect: Effect): void;
  54352. /**
  54353. * Returns true if the layer contains information to display, otherwise false.
  54354. */
  54355. shouldRender(): boolean;
  54356. /**
  54357. * Returns true if the mesh should render, otherwise false.
  54358. * @param mesh The mesh to render
  54359. * @returns true if it should render otherwise false
  54360. */
  54361. protected _shouldRenderMesh(mesh: Mesh): boolean;
  54362. /**
  54363. * Adds specific effects defines.
  54364. * @param defines The defines to add specifics to.
  54365. */
  54366. protected _addCustomEffectDefines(defines: string[]): void;
  54367. /**
  54368. * Sets the required values for both the emissive texture and and the main color.
  54369. */
  54370. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54371. /**
  54372. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  54373. * @param mesh The mesh to exclude from the highlight layer
  54374. */
  54375. addExcludedMesh(mesh: Mesh): void;
  54376. /**
  54377. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54378. * @param mesh The mesh to highlight
  54379. */
  54380. removeExcludedMesh(mesh: Mesh): void;
  54381. /**
  54382. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54383. * @param mesh mesh to test
  54384. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54385. */
  54386. hasMesh(mesh: AbstractMesh): boolean;
  54387. /**
  54388. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54389. * @param mesh The mesh to highlight
  54390. * @param color The color of the highlight
  54391. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54392. */
  54393. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54394. /**
  54395. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54396. * @param mesh The mesh to highlight
  54397. */
  54398. removeMesh(mesh: Mesh): void;
  54399. /**
  54400. * Remove all the meshes currently referenced in the highlight layer
  54401. */
  54402. removeAllMeshes(): void;
  54403. /**
  54404. * Force the stencil to the normal expected value for none glowing parts
  54405. */
  54406. private _defaultStencilReference;
  54407. /**
  54408. * Free any resources and references associated to a mesh.
  54409. * Internal use
  54410. * @param mesh The mesh to free.
  54411. * @hidden
  54412. */
  54413. _disposeMesh(mesh: Mesh): void;
  54414. /**
  54415. * Dispose the highlight layer and free resources.
  54416. */
  54417. dispose(): void;
  54418. /**
  54419. * Gets the class name of the effect layer
  54420. * @returns the string with the class name of the effect layer
  54421. */
  54422. getClassName(): string;
  54423. /**
  54424. * Serializes this Highlight layer
  54425. * @returns a serialized Highlight layer object
  54426. */
  54427. serialize(): any;
  54428. /**
  54429. * Creates a Highlight layer from parsed Highlight layer data
  54430. * @param parsedHightlightLayer defines the Highlight layer data
  54431. * @param scene defines the current scene
  54432. * @param rootUrl defines the root URL containing the Highlight layer information
  54433. * @returns a parsed Highlight layer
  54434. */
  54435. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54436. }
  54437. }
  54438. declare module BABYLON {
  54439. interface AbstractScene {
  54440. /**
  54441. * The list of layers (background and foreground) of the scene
  54442. */
  54443. layers: Array<Layer>;
  54444. }
  54445. /**
  54446. * Defines the layer scene component responsible to manage any layers
  54447. * in a given scene.
  54448. */
  54449. export class LayerSceneComponent implements ISceneComponent {
  54450. /**
  54451. * The component name helpfull to identify the component in the list of scene components.
  54452. */
  54453. readonly name: string;
  54454. /**
  54455. * The scene the component belongs to.
  54456. */
  54457. scene: Scene;
  54458. private _engine;
  54459. /**
  54460. * Creates a new instance of the component for the given scene
  54461. * @param scene Defines the scene to register the component in
  54462. */
  54463. constructor(scene: Scene);
  54464. /**
  54465. * Registers the component in a given scene
  54466. */
  54467. register(): void;
  54468. /**
  54469. * Rebuilds the elements related to this component in case of
  54470. * context lost for instance.
  54471. */
  54472. rebuild(): void;
  54473. /**
  54474. * Disposes the component and the associated ressources.
  54475. */
  54476. dispose(): void;
  54477. private _draw;
  54478. private _drawCameraPredicate;
  54479. private _drawCameraBackground;
  54480. private _drawCameraForeground;
  54481. private _drawRenderTargetPredicate;
  54482. private _drawRenderTargetBackground;
  54483. private _drawRenderTargetForeground;
  54484. /**
  54485. * Adds all the elements from the container to the scene
  54486. * @param container the container holding the elements
  54487. */
  54488. addFromContainer(container: AbstractScene): void;
  54489. /**
  54490. * Removes all the elements in the container from the scene
  54491. * @param container contains the elements to remove
  54492. * @param dispose if the removed element should be disposed (default: false)
  54493. */
  54494. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54495. }
  54496. }
  54497. declare module BABYLON {
  54498. /** @hidden */
  54499. export var layerPixelShader: {
  54500. name: string;
  54501. shader: string;
  54502. };
  54503. }
  54504. declare module BABYLON {
  54505. /** @hidden */
  54506. export var layerVertexShader: {
  54507. name: string;
  54508. shader: string;
  54509. };
  54510. }
  54511. declare module BABYLON {
  54512. /**
  54513. * This represents a full screen 2d layer.
  54514. * This can be useful to display a picture in the background of your scene for instance.
  54515. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54516. */
  54517. export class Layer {
  54518. /**
  54519. * Define the name of the layer.
  54520. */
  54521. name: string;
  54522. /**
  54523. * Define the texture the layer should display.
  54524. */
  54525. texture: Nullable<Texture>;
  54526. /**
  54527. * Is the layer in background or foreground.
  54528. */
  54529. isBackground: boolean;
  54530. /**
  54531. * Define the color of the layer (instead of texture).
  54532. */
  54533. color: Color4;
  54534. /**
  54535. * Define the scale of the layer in order to zoom in out of the texture.
  54536. */
  54537. scale: Vector2;
  54538. /**
  54539. * Define an offset for the layer in order to shift the texture.
  54540. */
  54541. offset: Vector2;
  54542. /**
  54543. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54544. */
  54545. alphaBlendingMode: number;
  54546. /**
  54547. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54548. * Alpha test will not mix with the background color in case of transparency.
  54549. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54550. */
  54551. alphaTest: boolean;
  54552. /**
  54553. * Define a mask to restrict the layer to only some of the scene cameras.
  54554. */
  54555. layerMask: number;
  54556. /**
  54557. * Define the list of render target the layer is visible into.
  54558. */
  54559. renderTargetTextures: RenderTargetTexture[];
  54560. /**
  54561. * Define if the layer is only used in renderTarget or if it also
  54562. * renders in the main frame buffer of the canvas.
  54563. */
  54564. renderOnlyInRenderTargetTextures: boolean;
  54565. private _scene;
  54566. private _vertexBuffers;
  54567. private _indexBuffer;
  54568. private _effect;
  54569. private _previousDefines;
  54570. /**
  54571. * An event triggered when the layer is disposed.
  54572. */
  54573. onDisposeObservable: Observable<Layer>;
  54574. private _onDisposeObserver;
  54575. /**
  54576. * Back compatibility with callback before the onDisposeObservable existed.
  54577. * The set callback will be triggered when the layer has been disposed.
  54578. */
  54579. set onDispose(callback: () => void);
  54580. /**
  54581. * An event triggered before rendering the scene
  54582. */
  54583. onBeforeRenderObservable: Observable<Layer>;
  54584. private _onBeforeRenderObserver;
  54585. /**
  54586. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54587. * The set callback will be triggered just before rendering the layer.
  54588. */
  54589. set onBeforeRender(callback: () => void);
  54590. /**
  54591. * An event triggered after rendering the scene
  54592. */
  54593. onAfterRenderObservable: Observable<Layer>;
  54594. private _onAfterRenderObserver;
  54595. /**
  54596. * Back compatibility with callback before the onAfterRenderObservable existed.
  54597. * The set callback will be triggered just after rendering the layer.
  54598. */
  54599. set onAfterRender(callback: () => void);
  54600. /**
  54601. * Instantiates a new layer.
  54602. * This represents a full screen 2d layer.
  54603. * This can be useful to display a picture in the background of your scene for instance.
  54604. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54605. * @param name Define the name of the layer in the scene
  54606. * @param imgUrl Define the url of the texture to display in the layer
  54607. * @param scene Define the scene the layer belongs to
  54608. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54609. * @param color Defines a color for the layer
  54610. */
  54611. constructor(
  54612. /**
  54613. * Define the name of the layer.
  54614. */
  54615. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54616. private _createIndexBuffer;
  54617. /** @hidden */
  54618. _rebuild(): void;
  54619. /**
  54620. * Renders the layer in the scene.
  54621. */
  54622. render(): void;
  54623. /**
  54624. * Disposes and releases the associated ressources.
  54625. */
  54626. dispose(): void;
  54627. }
  54628. }
  54629. declare module BABYLON {
  54630. /** @hidden */
  54631. export var lensFlarePixelShader: {
  54632. name: string;
  54633. shader: string;
  54634. };
  54635. }
  54636. declare module BABYLON {
  54637. /** @hidden */
  54638. export var lensFlareVertexShader: {
  54639. name: string;
  54640. shader: string;
  54641. };
  54642. }
  54643. declare module BABYLON {
  54644. /**
  54645. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54646. * It is usually composed of several `lensFlare`.
  54647. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54648. */
  54649. export class LensFlareSystem {
  54650. /**
  54651. * Define the name of the lens flare system
  54652. */
  54653. name: string;
  54654. /**
  54655. * List of lens flares used in this system.
  54656. */
  54657. lensFlares: LensFlare[];
  54658. /**
  54659. * Define a limit from the border the lens flare can be visible.
  54660. */
  54661. borderLimit: number;
  54662. /**
  54663. * Define a viewport border we do not want to see the lens flare in.
  54664. */
  54665. viewportBorder: number;
  54666. /**
  54667. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54668. */
  54669. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54670. /**
  54671. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54672. */
  54673. layerMask: number;
  54674. /**
  54675. * Define the id of the lens flare system in the scene.
  54676. * (equal to name by default)
  54677. */
  54678. id: string;
  54679. private _scene;
  54680. private _emitter;
  54681. private _vertexBuffers;
  54682. private _indexBuffer;
  54683. private _effect;
  54684. private _positionX;
  54685. private _positionY;
  54686. private _isEnabled;
  54687. /** @hidden */
  54688. static _SceneComponentInitialization: (scene: Scene) => void;
  54689. /**
  54690. * Instantiates a lens flare system.
  54691. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54692. * It is usually composed of several `lensFlare`.
  54693. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54694. * @param name Define the name of the lens flare system in the scene
  54695. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54696. * @param scene Define the scene the lens flare system belongs to
  54697. */
  54698. constructor(
  54699. /**
  54700. * Define the name of the lens flare system
  54701. */
  54702. name: string, emitter: any, scene: Scene);
  54703. /**
  54704. * Define if the lens flare system is enabled.
  54705. */
  54706. get isEnabled(): boolean;
  54707. set isEnabled(value: boolean);
  54708. /**
  54709. * Get the scene the effects belongs to.
  54710. * @returns the scene holding the lens flare system
  54711. */
  54712. getScene(): Scene;
  54713. /**
  54714. * Get the emitter of the lens flare system.
  54715. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54716. * @returns the emitter of the lens flare system
  54717. */
  54718. getEmitter(): any;
  54719. /**
  54720. * Set the emitter of the lens flare system.
  54721. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54722. * @param newEmitter Define the new emitter of the system
  54723. */
  54724. setEmitter(newEmitter: any): void;
  54725. /**
  54726. * Get the lens flare system emitter position.
  54727. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54728. * @returns the position
  54729. */
  54730. getEmitterPosition(): Vector3;
  54731. /**
  54732. * @hidden
  54733. */
  54734. computeEffectivePosition(globalViewport: Viewport): boolean;
  54735. /** @hidden */
  54736. _isVisible(): boolean;
  54737. /**
  54738. * @hidden
  54739. */
  54740. render(): boolean;
  54741. /**
  54742. * Dispose and release the lens flare with its associated resources.
  54743. */
  54744. dispose(): void;
  54745. /**
  54746. * Parse a lens flare system from a JSON repressentation
  54747. * @param parsedLensFlareSystem Define the JSON to parse
  54748. * @param scene Define the scene the parsed system should be instantiated in
  54749. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54750. * @returns the parsed system
  54751. */
  54752. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54753. /**
  54754. * Serialize the current Lens Flare System into a JSON representation.
  54755. * @returns the serialized JSON
  54756. */
  54757. serialize(): any;
  54758. }
  54759. }
  54760. declare module BABYLON {
  54761. /**
  54762. * This represents one of the lens effect in a `lensFlareSystem`.
  54763. * It controls one of the indiviual texture used in the effect.
  54764. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54765. */
  54766. export class LensFlare {
  54767. /**
  54768. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54769. */
  54770. size: number;
  54771. /**
  54772. * 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.
  54773. */
  54774. position: number;
  54775. /**
  54776. * Define the lens color.
  54777. */
  54778. color: Color3;
  54779. /**
  54780. * Define the lens texture.
  54781. */
  54782. texture: Nullable<Texture>;
  54783. /**
  54784. * Define the alpha mode to render this particular lens.
  54785. */
  54786. alphaMode: number;
  54787. private _system;
  54788. /**
  54789. * Creates a new Lens Flare.
  54790. * This represents one of the lens effect in a `lensFlareSystem`.
  54791. * It controls one of the indiviual texture used in the effect.
  54792. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54793. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54794. * @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.
  54795. * @param color Define the lens color
  54796. * @param imgUrl Define the lens texture url
  54797. * @param system Define the `lensFlareSystem` this flare is part of
  54798. * @returns The newly created Lens Flare
  54799. */
  54800. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54801. /**
  54802. * Instantiates a new Lens Flare.
  54803. * This represents one of the lens effect in a `lensFlareSystem`.
  54804. * It controls one of the indiviual texture used in the effect.
  54805. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54806. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54807. * @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.
  54808. * @param color Define the lens color
  54809. * @param imgUrl Define the lens texture url
  54810. * @param system Define the `lensFlareSystem` this flare is part of
  54811. */
  54812. constructor(
  54813. /**
  54814. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54815. */
  54816. size: number,
  54817. /**
  54818. * 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.
  54819. */
  54820. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54821. /**
  54822. * Dispose and release the lens flare with its associated resources.
  54823. */
  54824. dispose(): void;
  54825. }
  54826. }
  54827. declare module BABYLON {
  54828. interface AbstractScene {
  54829. /**
  54830. * The list of lens flare system added to the scene
  54831. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54832. */
  54833. lensFlareSystems: Array<LensFlareSystem>;
  54834. /**
  54835. * Removes the given lens flare system from this scene.
  54836. * @param toRemove The lens flare system to remove
  54837. * @returns The index of the removed lens flare system
  54838. */
  54839. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54840. /**
  54841. * Adds the given lens flare system to this scene
  54842. * @param newLensFlareSystem The lens flare system to add
  54843. */
  54844. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54845. /**
  54846. * Gets a lens flare system using its name
  54847. * @param name defines the name to look for
  54848. * @returns the lens flare system or null if not found
  54849. */
  54850. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54851. /**
  54852. * Gets a lens flare system using its id
  54853. * @param id defines the id to look for
  54854. * @returns the lens flare system or null if not found
  54855. */
  54856. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54857. }
  54858. /**
  54859. * Defines the lens flare scene component responsible to manage any lens flares
  54860. * in a given scene.
  54861. */
  54862. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54863. /**
  54864. * The component name helpfull to identify the component in the list of scene components.
  54865. */
  54866. readonly name: string;
  54867. /**
  54868. * The scene the component belongs to.
  54869. */
  54870. scene: Scene;
  54871. /**
  54872. * Creates a new instance of the component for the given scene
  54873. * @param scene Defines the scene to register the component in
  54874. */
  54875. constructor(scene: Scene);
  54876. /**
  54877. * Registers the component in a given scene
  54878. */
  54879. register(): void;
  54880. /**
  54881. * Rebuilds the elements related to this component in case of
  54882. * context lost for instance.
  54883. */
  54884. rebuild(): void;
  54885. /**
  54886. * Adds all the elements from the container to the scene
  54887. * @param container the container holding the elements
  54888. */
  54889. addFromContainer(container: AbstractScene): void;
  54890. /**
  54891. * Removes all the elements in the container from the scene
  54892. * @param container contains the elements to remove
  54893. * @param dispose if the removed element should be disposed (default: false)
  54894. */
  54895. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54896. /**
  54897. * Serializes the component data to the specified json object
  54898. * @param serializationObject The object to serialize to
  54899. */
  54900. serialize(serializationObject: any): void;
  54901. /**
  54902. * Disposes the component and the associated ressources.
  54903. */
  54904. dispose(): void;
  54905. private _draw;
  54906. }
  54907. }
  54908. declare module BABYLON {
  54909. /** @hidden */
  54910. export var depthPixelShader: {
  54911. name: string;
  54912. shader: string;
  54913. };
  54914. }
  54915. declare module BABYLON {
  54916. /** @hidden */
  54917. export var depthVertexShader: {
  54918. name: string;
  54919. shader: string;
  54920. };
  54921. }
  54922. declare module BABYLON {
  54923. /**
  54924. * This represents a depth renderer in Babylon.
  54925. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54926. */
  54927. export class DepthRenderer {
  54928. private _scene;
  54929. private _depthMap;
  54930. private _effect;
  54931. private readonly _storeNonLinearDepth;
  54932. private readonly _clearColor;
  54933. /** Get if the depth renderer is using packed depth or not */
  54934. readonly isPacked: boolean;
  54935. private _cachedDefines;
  54936. private _camera;
  54937. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54938. enabled: boolean;
  54939. /**
  54940. * Specifiess that the depth renderer will only be used within
  54941. * the camera it is created for.
  54942. * This can help forcing its rendering during the camera processing.
  54943. */
  54944. useOnlyInActiveCamera: boolean;
  54945. /** @hidden */
  54946. static _SceneComponentInitialization: (scene: Scene) => void;
  54947. /**
  54948. * Instantiates a depth renderer
  54949. * @param scene The scene the renderer belongs to
  54950. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54951. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54952. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54953. */
  54954. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54955. /**
  54956. * Creates the depth rendering effect and checks if the effect is ready.
  54957. * @param subMesh The submesh to be used to render the depth map of
  54958. * @param useInstances If multiple world instances should be used
  54959. * @returns if the depth renderer is ready to render the depth map
  54960. */
  54961. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54962. /**
  54963. * Gets the texture which the depth map will be written to.
  54964. * @returns The depth map texture
  54965. */
  54966. getDepthMap(): RenderTargetTexture;
  54967. /**
  54968. * Disposes of the depth renderer.
  54969. */
  54970. dispose(): void;
  54971. }
  54972. }
  54973. declare module BABYLON {
  54974. /** @hidden */
  54975. export var minmaxReduxPixelShader: {
  54976. name: string;
  54977. shader: string;
  54978. };
  54979. }
  54980. declare module BABYLON {
  54981. /**
  54982. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54983. * and maximum values from all values of the texture.
  54984. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54985. * The source values are read from the red channel of the texture.
  54986. */
  54987. export class MinMaxReducer {
  54988. /**
  54989. * Observable triggered when the computation has been performed
  54990. */
  54991. onAfterReductionPerformed: Observable<{
  54992. min: number;
  54993. max: number;
  54994. }>;
  54995. protected _camera: Camera;
  54996. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54997. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54998. protected _postProcessManager: PostProcessManager;
  54999. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  55000. protected _forceFullscreenViewport: boolean;
  55001. /**
  55002. * Creates a min/max reducer
  55003. * @param camera The camera to use for the post processes
  55004. */
  55005. constructor(camera: Camera);
  55006. /**
  55007. * Gets the texture used to read the values from.
  55008. */
  55009. get sourceTexture(): Nullable<RenderTargetTexture>;
  55010. /**
  55011. * Sets the source texture to read the values from.
  55012. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  55013. * because in such textures '1' value must not be taken into account to compute the maximum
  55014. * as this value is used to clear the texture.
  55015. * Note that the computation is not activated by calling this function, you must call activate() for that!
  55016. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  55017. * @param depthRedux Indicates if the texture is a depth texture or not
  55018. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  55019. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  55020. */
  55021. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  55022. /**
  55023. * Defines the refresh rate of the computation.
  55024. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55025. */
  55026. get refreshRate(): number;
  55027. set refreshRate(value: number);
  55028. protected _activated: boolean;
  55029. /**
  55030. * Gets the activation status of the reducer
  55031. */
  55032. get activated(): boolean;
  55033. /**
  55034. * Activates the reduction computation.
  55035. * When activated, the observers registered in onAfterReductionPerformed are
  55036. * called after the compuation is performed
  55037. */
  55038. activate(): void;
  55039. /**
  55040. * Deactivates the reduction computation.
  55041. */
  55042. deactivate(): void;
  55043. /**
  55044. * Disposes the min/max reducer
  55045. * @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.
  55046. */
  55047. dispose(disposeAll?: boolean): void;
  55048. }
  55049. }
  55050. declare module BABYLON {
  55051. /**
  55052. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  55053. */
  55054. export class DepthReducer extends MinMaxReducer {
  55055. private _depthRenderer;
  55056. private _depthRendererId;
  55057. /**
  55058. * Gets the depth renderer used for the computation.
  55059. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  55060. */
  55061. get depthRenderer(): Nullable<DepthRenderer>;
  55062. /**
  55063. * Creates a depth reducer
  55064. * @param camera The camera used to render the depth texture
  55065. */
  55066. constructor(camera: Camera);
  55067. /**
  55068. * Sets the depth renderer to use to generate the depth map
  55069. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  55070. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  55071. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  55072. */
  55073. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  55074. /** @hidden */
  55075. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  55076. /**
  55077. * Activates the reduction computation.
  55078. * When activated, the observers registered in onAfterReductionPerformed are
  55079. * called after the compuation is performed
  55080. */
  55081. activate(): void;
  55082. /**
  55083. * Deactivates the reduction computation.
  55084. */
  55085. deactivate(): void;
  55086. /**
  55087. * Disposes the depth reducer
  55088. * @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.
  55089. */
  55090. dispose(disposeAll?: boolean): void;
  55091. }
  55092. }
  55093. declare module BABYLON {
  55094. /**
  55095. * A CSM implementation allowing casting shadows on large scenes.
  55096. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55097. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  55098. */
  55099. export class CascadedShadowGenerator extends ShadowGenerator {
  55100. private static readonly frustumCornersNDCSpace;
  55101. /**
  55102. * Name of the CSM class
  55103. */
  55104. static CLASSNAME: string;
  55105. /**
  55106. * Defines the default number of cascades used by the CSM.
  55107. */
  55108. static readonly DEFAULT_CASCADES_COUNT: number;
  55109. /**
  55110. * Defines the minimum number of cascades used by the CSM.
  55111. */
  55112. static readonly MIN_CASCADES_COUNT: number;
  55113. /**
  55114. * Defines the maximum number of cascades used by the CSM.
  55115. */
  55116. static readonly MAX_CASCADES_COUNT: number;
  55117. protected _validateFilter(filter: number): number;
  55118. /**
  55119. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  55120. */
  55121. penumbraDarkness: number;
  55122. private _numCascades;
  55123. /**
  55124. * Gets or set the number of cascades used by the CSM.
  55125. */
  55126. get numCascades(): number;
  55127. set numCascades(value: number);
  55128. /**
  55129. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  55130. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  55131. */
  55132. stabilizeCascades: boolean;
  55133. private _freezeShadowCastersBoundingInfo;
  55134. private _freezeShadowCastersBoundingInfoObservable;
  55135. /**
  55136. * Enables or disables the shadow casters bounding info computation.
  55137. * If your shadow casters don't move, you can disable this feature.
  55138. * If it is enabled, the bounding box computation is done every frame.
  55139. */
  55140. get freezeShadowCastersBoundingInfo(): boolean;
  55141. set freezeShadowCastersBoundingInfo(freeze: boolean);
  55142. private _scbiMin;
  55143. private _scbiMax;
  55144. protected _computeShadowCastersBoundingInfo(): void;
  55145. protected _shadowCastersBoundingInfo: BoundingInfo;
  55146. /**
  55147. * Gets or sets the shadow casters bounding info.
  55148. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  55149. * so that the system won't overwrite the bounds you provide
  55150. */
  55151. get shadowCastersBoundingInfo(): BoundingInfo;
  55152. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  55153. protected _breaksAreDirty: boolean;
  55154. protected _minDistance: number;
  55155. protected _maxDistance: number;
  55156. /**
  55157. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  55158. *
  55159. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  55160. * If you don't know these values, simply leave them to their defaults and don't call this function.
  55161. * @param min minimal distance for the breaks (default to 0.)
  55162. * @param max maximal distance for the breaks (default to 1.)
  55163. */
  55164. setMinMaxDistance(min: number, max: number): void;
  55165. /** Gets the minimal distance used in the cascade break computation */
  55166. get minDistance(): number;
  55167. /** Gets the maximal distance used in the cascade break computation */
  55168. get maxDistance(): number;
  55169. /**
  55170. * Gets the class name of that object
  55171. * @returns "CascadedShadowGenerator"
  55172. */
  55173. getClassName(): string;
  55174. private _cascadeMinExtents;
  55175. private _cascadeMaxExtents;
  55176. /**
  55177. * Gets a cascade minimum extents
  55178. * @param cascadeIndex index of the cascade
  55179. * @returns the minimum cascade extents
  55180. */
  55181. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  55182. /**
  55183. * Gets a cascade maximum extents
  55184. * @param cascadeIndex index of the cascade
  55185. * @returns the maximum cascade extents
  55186. */
  55187. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  55188. private _cascades;
  55189. private _currentLayer;
  55190. private _viewSpaceFrustumsZ;
  55191. private _viewMatrices;
  55192. private _projectionMatrices;
  55193. private _transformMatrices;
  55194. private _transformMatricesAsArray;
  55195. private _frustumLengths;
  55196. private _lightSizeUVCorrection;
  55197. private _depthCorrection;
  55198. private _frustumCornersWorldSpace;
  55199. private _frustumCenter;
  55200. private _shadowCameraPos;
  55201. private _shadowMaxZ;
  55202. /**
  55203. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  55204. * It defaults to camera.maxZ
  55205. */
  55206. get shadowMaxZ(): number;
  55207. /**
  55208. * Sets the shadow max z distance.
  55209. */
  55210. set shadowMaxZ(value: number);
  55211. protected _debug: boolean;
  55212. /**
  55213. * Gets or sets the debug flag.
  55214. * When enabled, the cascades are materialized by different colors on the screen.
  55215. */
  55216. get debug(): boolean;
  55217. set debug(dbg: boolean);
  55218. private _depthClamp;
  55219. /**
  55220. * Gets or sets the depth clamping value.
  55221. *
  55222. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  55223. * to account for the shadow casters far away.
  55224. *
  55225. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  55226. */
  55227. get depthClamp(): boolean;
  55228. set depthClamp(value: boolean);
  55229. private _cascadeBlendPercentage;
  55230. /**
  55231. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  55232. * It defaults to 0.1 (10% blending).
  55233. */
  55234. get cascadeBlendPercentage(): number;
  55235. set cascadeBlendPercentage(value: number);
  55236. private _lambda;
  55237. /**
  55238. * Gets or set the lambda parameter.
  55239. * This parameter is used to split the camera frustum and create the cascades.
  55240. * 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.
  55241. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  55242. */
  55243. get lambda(): number;
  55244. set lambda(value: number);
  55245. /**
  55246. * Gets the view matrix corresponding to a given cascade
  55247. * @param cascadeNum cascade to retrieve the view matrix from
  55248. * @returns the cascade view matrix
  55249. */
  55250. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  55251. /**
  55252. * Gets the projection matrix corresponding to a given cascade
  55253. * @param cascadeNum cascade to retrieve the projection matrix from
  55254. * @returns the cascade projection matrix
  55255. */
  55256. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  55257. /**
  55258. * Gets the transformation matrix corresponding to a given cascade
  55259. * @param cascadeNum cascade to retrieve the transformation matrix from
  55260. * @returns the cascade transformation matrix
  55261. */
  55262. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  55263. private _depthRenderer;
  55264. /**
  55265. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  55266. *
  55267. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  55268. *
  55269. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  55270. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  55271. * @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
  55272. */
  55273. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  55274. private _depthReducer;
  55275. private _autoCalcDepthBounds;
  55276. /**
  55277. * Gets or sets the autoCalcDepthBounds property.
  55278. *
  55279. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  55280. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  55281. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  55282. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  55283. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  55284. */
  55285. get autoCalcDepthBounds(): boolean;
  55286. set autoCalcDepthBounds(value: boolean);
  55287. /**
  55288. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  55289. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  55290. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  55291. * for setting the refresh rate on the renderer yourself!
  55292. */
  55293. get autoCalcDepthBoundsRefreshRate(): number;
  55294. set autoCalcDepthBoundsRefreshRate(value: number);
  55295. /**
  55296. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  55297. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  55298. * you change the camera near/far planes!
  55299. */
  55300. splitFrustum(): void;
  55301. private _splitFrustum;
  55302. private _computeMatrices;
  55303. private _computeFrustumInWorldSpace;
  55304. private _computeCascadeFrustum;
  55305. /**
  55306. * Support test.
  55307. */
  55308. static get IsSupported(): boolean;
  55309. /** @hidden */
  55310. static _SceneComponentInitialization: (scene: Scene) => void;
  55311. /**
  55312. * Creates a Cascaded Shadow Generator object.
  55313. * A ShadowGenerator is the required tool to use the shadows.
  55314. * Each directional light casting shadows needs to use its own ShadowGenerator.
  55315. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  55316. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  55317. * @param light The directional light object generating the shadows.
  55318. * @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.
  55319. */
  55320. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  55321. protected _initializeGenerator(): void;
  55322. protected _createTargetRenderTexture(): void;
  55323. protected _initializeShadowMap(): void;
  55324. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  55325. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  55326. /**
  55327. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  55328. * @param defines Defines of the material we want to update
  55329. * @param lightIndex Index of the light in the enabled light list of the material
  55330. */
  55331. prepareDefines(defines: any, lightIndex: number): void;
  55332. /**
  55333. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  55334. * defined in the generator but impacting the effect).
  55335. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  55336. * @param effect The effect we are binfing the information for
  55337. */
  55338. bindShadowLight(lightIndex: string, effect: Effect): void;
  55339. /**
  55340. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  55341. * (eq to view projection * shadow projection matrices)
  55342. * @returns The transform matrix used to create the shadow map
  55343. */
  55344. getTransformMatrix(): Matrix;
  55345. /**
  55346. * Disposes the ShadowGenerator.
  55347. * Returns nothing.
  55348. */
  55349. dispose(): void;
  55350. /**
  55351. * Serializes the shadow generator setup to a json object.
  55352. * @returns The serialized JSON object
  55353. */
  55354. serialize(): any;
  55355. /**
  55356. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  55357. * @param parsedShadowGenerator The JSON object to parse
  55358. * @param scene The scene to create the shadow map for
  55359. * @returns The parsed shadow generator
  55360. */
  55361. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  55362. }
  55363. }
  55364. declare module BABYLON {
  55365. /**
  55366. * Defines the shadow generator component responsible to manage any shadow generators
  55367. * in a given scene.
  55368. */
  55369. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  55370. /**
  55371. * The component name helpfull to identify the component in the list of scene components.
  55372. */
  55373. readonly name: string;
  55374. /**
  55375. * The scene the component belongs to.
  55376. */
  55377. scene: Scene;
  55378. /**
  55379. * Creates a new instance of the component for the given scene
  55380. * @param scene Defines the scene to register the component in
  55381. */
  55382. constructor(scene: Scene);
  55383. /**
  55384. * Registers the component in a given scene
  55385. */
  55386. register(): void;
  55387. /**
  55388. * Rebuilds the elements related to this component in case of
  55389. * context lost for instance.
  55390. */
  55391. rebuild(): void;
  55392. /**
  55393. * Serializes the component data to the specified json object
  55394. * @param serializationObject The object to serialize to
  55395. */
  55396. serialize(serializationObject: any): void;
  55397. /**
  55398. * Adds all the elements from the container to the scene
  55399. * @param container the container holding the elements
  55400. */
  55401. addFromContainer(container: AbstractScene): void;
  55402. /**
  55403. * Removes all the elements in the container from the scene
  55404. * @param container contains the elements to remove
  55405. * @param dispose if the removed element should be disposed (default: false)
  55406. */
  55407. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55408. /**
  55409. * Rebuilds the elements related to this component in case of
  55410. * context lost for instance.
  55411. */
  55412. dispose(): void;
  55413. private _gatherRenderTargets;
  55414. }
  55415. }
  55416. declare module BABYLON {
  55417. /**
  55418. * A point light is a light defined by an unique point in world space.
  55419. * The light is emitted in every direction from this point.
  55420. * A good example of a point light is a standard light bulb.
  55421. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55422. */
  55423. export class PointLight extends ShadowLight {
  55424. private _shadowAngle;
  55425. /**
  55426. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55427. * This specifies what angle the shadow will use to be created.
  55428. *
  55429. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55430. */
  55431. get shadowAngle(): number;
  55432. /**
  55433. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55434. * This specifies what angle the shadow will use to be created.
  55435. *
  55436. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55437. */
  55438. set shadowAngle(value: number);
  55439. /**
  55440. * Gets the direction if it has been set.
  55441. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55442. */
  55443. get direction(): Vector3;
  55444. /**
  55445. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55446. */
  55447. set direction(value: Vector3);
  55448. /**
  55449. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55450. * A PointLight emits the light in every direction.
  55451. * It can cast shadows.
  55452. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55453. * ```javascript
  55454. * var pointLight = new PointLight("pl", camera.position, scene);
  55455. * ```
  55456. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55457. * @param name The light friendly name
  55458. * @param position The position of the point light in the scene
  55459. * @param scene The scene the lights belongs to
  55460. */
  55461. constructor(name: string, position: Vector3, scene: Scene);
  55462. /**
  55463. * Returns the string "PointLight"
  55464. * @returns the class name
  55465. */
  55466. getClassName(): string;
  55467. /**
  55468. * Returns the integer 0.
  55469. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55470. */
  55471. getTypeID(): number;
  55472. /**
  55473. * Specifies wether or not the shadowmap should be a cube texture.
  55474. * @returns true if the shadowmap needs to be a cube texture.
  55475. */
  55476. needCube(): boolean;
  55477. /**
  55478. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55479. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55480. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55481. */
  55482. getShadowDirection(faceIndex?: number): Vector3;
  55483. /**
  55484. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55485. * - fov = PI / 2
  55486. * - aspect ratio : 1.0
  55487. * - z-near and far equal to the active camera minZ and maxZ.
  55488. * Returns the PointLight.
  55489. */
  55490. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55491. protected _buildUniformLayout(): void;
  55492. /**
  55493. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55494. * @param effect The effect to update
  55495. * @param lightIndex The index of the light in the effect to update
  55496. * @returns The point light
  55497. */
  55498. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55499. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55500. /**
  55501. * Prepares the list of defines specific to the light type.
  55502. * @param defines the list of defines
  55503. * @param lightIndex defines the index of the light for the effect
  55504. */
  55505. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55506. }
  55507. }
  55508. declare module BABYLON {
  55509. /**
  55510. * Header information of HDR texture files.
  55511. */
  55512. export interface HDRInfo {
  55513. /**
  55514. * The height of the texture in pixels.
  55515. */
  55516. height: number;
  55517. /**
  55518. * The width of the texture in pixels.
  55519. */
  55520. width: number;
  55521. /**
  55522. * The index of the beginning of the data in the binary file.
  55523. */
  55524. dataPosition: number;
  55525. }
  55526. /**
  55527. * This groups tools to convert HDR texture to native colors array.
  55528. */
  55529. export class HDRTools {
  55530. private static Ldexp;
  55531. private static Rgbe2float;
  55532. private static readStringLine;
  55533. /**
  55534. * Reads header information from an RGBE texture stored in a native array.
  55535. * More information on this format are available here:
  55536. * https://en.wikipedia.org/wiki/RGBE_image_format
  55537. *
  55538. * @param uint8array The binary file stored in native array.
  55539. * @return The header information.
  55540. */
  55541. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55542. /**
  55543. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55544. * This RGBE texture needs to store the information as a panorama.
  55545. *
  55546. * More information on this format are available here:
  55547. * https://en.wikipedia.org/wiki/RGBE_image_format
  55548. *
  55549. * @param buffer The binary file stored in an array buffer.
  55550. * @param size The expected size of the extracted cubemap.
  55551. * @return The Cube Map information.
  55552. */
  55553. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55554. /**
  55555. * Returns the pixels data extracted from an RGBE texture.
  55556. * This pixels will be stored left to right up to down in the R G B order in one array.
  55557. *
  55558. * More information on this format are available here:
  55559. * https://en.wikipedia.org/wiki/RGBE_image_format
  55560. *
  55561. * @param uint8array The binary file stored in an array buffer.
  55562. * @param hdrInfo The header information of the file.
  55563. * @return The pixels data in RGB right to left up to down order.
  55564. */
  55565. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55566. private static RGBE_ReadPixels_RLE;
  55567. }
  55568. }
  55569. declare module BABYLON {
  55570. /**
  55571. * This represents a texture coming from an HDR input.
  55572. *
  55573. * The only supported format is currently panorama picture stored in RGBE format.
  55574. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55575. */
  55576. export class HDRCubeTexture extends BaseTexture {
  55577. private static _facesMapping;
  55578. private _generateHarmonics;
  55579. private _noMipmap;
  55580. private _textureMatrix;
  55581. private _size;
  55582. private _onLoad;
  55583. private _onError;
  55584. /**
  55585. * The texture URL.
  55586. */
  55587. url: string;
  55588. /**
  55589. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55590. */
  55591. coordinatesMode: number;
  55592. protected _isBlocking: boolean;
  55593. /**
  55594. * Sets wether or not the texture is blocking during loading.
  55595. */
  55596. set isBlocking(value: boolean);
  55597. /**
  55598. * Gets wether or not the texture is blocking during loading.
  55599. */
  55600. get isBlocking(): boolean;
  55601. protected _rotationY: number;
  55602. /**
  55603. * Sets texture matrix rotation angle around Y axis in radians.
  55604. */
  55605. set rotationY(value: number);
  55606. /**
  55607. * Gets texture matrix rotation angle around Y axis radians.
  55608. */
  55609. get rotationY(): number;
  55610. /**
  55611. * Gets or sets the center of the bounding box associated with the cube texture
  55612. * It must define where the camera used to render the texture was set
  55613. */
  55614. boundingBoxPosition: Vector3;
  55615. private _boundingBoxSize;
  55616. /**
  55617. * Gets or sets the size of the bounding box associated with the cube texture
  55618. * When defined, the cubemap will switch to local mode
  55619. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55620. * @example https://www.babylonjs-playground.com/#RNASML
  55621. */
  55622. set boundingBoxSize(value: Vector3);
  55623. get boundingBoxSize(): Vector3;
  55624. /**
  55625. * Instantiates an HDRTexture from the following parameters.
  55626. *
  55627. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55628. * @param sceneOrEngine The scene or engine the texture will be used in
  55629. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55630. * @param noMipmap Forces to not generate the mipmap if true
  55631. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55632. * @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)
  55633. * @param reserved Reserved flag for internal use.
  55634. */
  55635. constructor(url: string, sceneOrEngine: Scene | ThinEngine, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55636. /**
  55637. * Get the current class name of the texture useful for serialization or dynamic coding.
  55638. * @returns "HDRCubeTexture"
  55639. */
  55640. getClassName(): string;
  55641. /**
  55642. * Occurs when the file is raw .hdr file.
  55643. */
  55644. private loadTexture;
  55645. clone(): HDRCubeTexture;
  55646. delayLoad(): void;
  55647. /**
  55648. * Get the texture reflection matrix used to rotate/transform the reflection.
  55649. * @returns the reflection matrix
  55650. */
  55651. getReflectionTextureMatrix(): Matrix;
  55652. /**
  55653. * Set the texture reflection matrix used to rotate/transform the reflection.
  55654. * @param value Define the reflection matrix to set
  55655. */
  55656. setReflectionTextureMatrix(value: Matrix): void;
  55657. /**
  55658. * Parses a JSON representation of an HDR Texture in order to create the texture
  55659. * @param parsedTexture Define the JSON representation
  55660. * @param scene Define the scene the texture should be created in
  55661. * @param rootUrl Define the root url in case we need to load relative dependencies
  55662. * @returns the newly created texture after parsing
  55663. */
  55664. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55665. serialize(): any;
  55666. }
  55667. }
  55668. declare module BABYLON {
  55669. /**
  55670. * Class used to control physics engine
  55671. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55672. */
  55673. export class PhysicsEngine implements IPhysicsEngine {
  55674. private _physicsPlugin;
  55675. /**
  55676. * Global value used to control the smallest number supported by the simulation
  55677. */
  55678. static Epsilon: number;
  55679. private _impostors;
  55680. private _joints;
  55681. private _subTimeStep;
  55682. /**
  55683. * Gets the gravity vector used by the simulation
  55684. */
  55685. gravity: Vector3;
  55686. /**
  55687. * Factory used to create the default physics plugin.
  55688. * @returns The default physics plugin
  55689. */
  55690. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55691. /**
  55692. * Creates a new Physics Engine
  55693. * @param gravity defines the gravity vector used by the simulation
  55694. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55695. */
  55696. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55697. /**
  55698. * Sets the gravity vector used by the simulation
  55699. * @param gravity defines the gravity vector to use
  55700. */
  55701. setGravity(gravity: Vector3): void;
  55702. /**
  55703. * Set the time step of the physics engine.
  55704. * Default is 1/60.
  55705. * To slow it down, enter 1/600 for example.
  55706. * To speed it up, 1/30
  55707. * @param newTimeStep defines the new timestep to apply to this world.
  55708. */
  55709. setTimeStep(newTimeStep?: number): void;
  55710. /**
  55711. * Get the time step of the physics engine.
  55712. * @returns the current time step
  55713. */
  55714. getTimeStep(): number;
  55715. /**
  55716. * Set the sub time step of the physics engine.
  55717. * Default is 0 meaning there is no sub steps
  55718. * To increase physics resolution precision, set a small value (like 1 ms)
  55719. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55720. */
  55721. setSubTimeStep(subTimeStep?: number): void;
  55722. /**
  55723. * Get the sub time step of the physics engine.
  55724. * @returns the current sub time step
  55725. */
  55726. getSubTimeStep(): number;
  55727. /**
  55728. * Release all resources
  55729. */
  55730. dispose(): void;
  55731. /**
  55732. * Gets the name of the current physics plugin
  55733. * @returns the name of the plugin
  55734. */
  55735. getPhysicsPluginName(): string;
  55736. /**
  55737. * Adding a new impostor for the impostor tracking.
  55738. * This will be done by the impostor itself.
  55739. * @param impostor the impostor to add
  55740. */
  55741. addImpostor(impostor: PhysicsImpostor): void;
  55742. /**
  55743. * Remove an impostor from the engine.
  55744. * This impostor and its mesh will not longer be updated by the physics engine.
  55745. * @param impostor the impostor to remove
  55746. */
  55747. removeImpostor(impostor: PhysicsImpostor): void;
  55748. /**
  55749. * Add a joint to the physics engine
  55750. * @param mainImpostor defines the main impostor to which the joint is added.
  55751. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55752. * @param joint defines the joint that will connect both impostors.
  55753. */
  55754. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55755. /**
  55756. * Removes a joint from the simulation
  55757. * @param mainImpostor defines the impostor used with the joint
  55758. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55759. * @param joint defines the joint to remove
  55760. */
  55761. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55762. /**
  55763. * Called by the scene. No need to call it.
  55764. * @param delta defines the timespam between frames
  55765. */
  55766. _step(delta: number): void;
  55767. /**
  55768. * Gets the current plugin used to run the simulation
  55769. * @returns current plugin
  55770. */
  55771. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55772. /**
  55773. * Gets the list of physic impostors
  55774. * @returns an array of PhysicsImpostor
  55775. */
  55776. getImpostors(): Array<PhysicsImpostor>;
  55777. /**
  55778. * Gets the impostor for a physics enabled object
  55779. * @param object defines the object impersonated by the impostor
  55780. * @returns the PhysicsImpostor or null if not found
  55781. */
  55782. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55783. /**
  55784. * Gets the impostor for a physics body object
  55785. * @param body defines physics body used by the impostor
  55786. * @returns the PhysicsImpostor or null if not found
  55787. */
  55788. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55789. /**
  55790. * Does a raycast in the physics world
  55791. * @param from when should the ray start?
  55792. * @param to when should the ray end?
  55793. * @returns PhysicsRaycastResult
  55794. */
  55795. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55796. }
  55797. }
  55798. declare module BABYLON {
  55799. /** @hidden */
  55800. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55801. private _useDeltaForWorldStep;
  55802. world: any;
  55803. name: string;
  55804. private _physicsMaterials;
  55805. private _fixedTimeStep;
  55806. private _cannonRaycastResult;
  55807. private _raycastResult;
  55808. private _physicsBodysToRemoveAfterStep;
  55809. BJSCANNON: any;
  55810. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55811. setGravity(gravity: Vector3): void;
  55812. setTimeStep(timeStep: number): void;
  55813. getTimeStep(): number;
  55814. executeStep(delta: number): void;
  55815. private _removeMarkedPhysicsBodiesFromWorld;
  55816. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55817. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55818. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55819. private _processChildMeshes;
  55820. removePhysicsBody(impostor: PhysicsImpostor): void;
  55821. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55822. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55823. private _addMaterial;
  55824. private _checkWithEpsilon;
  55825. private _createShape;
  55826. private _createHeightmap;
  55827. private _minus90X;
  55828. private _plus90X;
  55829. private _tmpPosition;
  55830. private _tmpDeltaPosition;
  55831. private _tmpUnityRotation;
  55832. private _updatePhysicsBodyTransformation;
  55833. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55834. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55835. isSupported(): boolean;
  55836. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55837. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55838. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55839. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55840. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55841. getBodyMass(impostor: PhysicsImpostor): number;
  55842. getBodyFriction(impostor: PhysicsImpostor): number;
  55843. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55844. getBodyRestitution(impostor: PhysicsImpostor): number;
  55845. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55846. sleepBody(impostor: PhysicsImpostor): void;
  55847. wakeUpBody(impostor: PhysicsImpostor): void;
  55848. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55849. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55850. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55851. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55852. getRadius(impostor: PhysicsImpostor): number;
  55853. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55854. dispose(): void;
  55855. private _extendNamespace;
  55856. /**
  55857. * Does a raycast in the physics world
  55858. * @param from when should the ray start?
  55859. * @param to when should the ray end?
  55860. * @returns PhysicsRaycastResult
  55861. */
  55862. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55863. }
  55864. }
  55865. declare module BABYLON {
  55866. /** @hidden */
  55867. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55868. private _useDeltaForWorldStep;
  55869. world: any;
  55870. name: string;
  55871. BJSOIMO: any;
  55872. private _raycastResult;
  55873. private _fixedTimeStep;
  55874. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  55875. setGravity(gravity: Vector3): void;
  55876. setTimeStep(timeStep: number): void;
  55877. getTimeStep(): number;
  55878. private _tmpImpostorsArray;
  55879. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55880. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55881. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55882. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55883. private _tmpPositionVector;
  55884. removePhysicsBody(impostor: PhysicsImpostor): void;
  55885. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55886. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55887. isSupported(): boolean;
  55888. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55889. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55890. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55891. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55892. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55893. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55894. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55895. getBodyMass(impostor: PhysicsImpostor): number;
  55896. getBodyFriction(impostor: PhysicsImpostor): number;
  55897. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55898. getBodyRestitution(impostor: PhysicsImpostor): number;
  55899. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55900. sleepBody(impostor: PhysicsImpostor): void;
  55901. wakeUpBody(impostor: PhysicsImpostor): void;
  55902. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55903. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55904. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55905. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55906. getRadius(impostor: PhysicsImpostor): number;
  55907. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55908. dispose(): void;
  55909. /**
  55910. * Does a raycast in the physics world
  55911. * @param from when should the ray start?
  55912. * @param to when should the ray end?
  55913. * @returns PhysicsRaycastResult
  55914. */
  55915. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55916. }
  55917. }
  55918. declare module BABYLON {
  55919. /**
  55920. * Class containing static functions to help procedurally build meshes
  55921. */
  55922. export class RibbonBuilder {
  55923. /**
  55924. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55925. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55926. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55927. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55928. * * 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
  55929. * * 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
  55930. * * 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
  55931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55932. * * 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
  55933. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55934. * * 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
  55935. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55936. * * 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
  55937. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55939. * @param name defines the name of the mesh
  55940. * @param options defines the options used to create the mesh
  55941. * @param scene defines the hosting scene
  55942. * @returns the ribbon mesh
  55943. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55944. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55945. */
  55946. static CreateRibbon(name: string, options: {
  55947. pathArray: Vector3[][];
  55948. closeArray?: boolean;
  55949. closePath?: boolean;
  55950. offset?: number;
  55951. updatable?: boolean;
  55952. sideOrientation?: number;
  55953. frontUVs?: Vector4;
  55954. backUVs?: Vector4;
  55955. instance?: Mesh;
  55956. invertUV?: boolean;
  55957. uvs?: Vector2[];
  55958. colors?: Color4[];
  55959. }, scene?: Nullable<Scene>): Mesh;
  55960. }
  55961. }
  55962. declare module BABYLON {
  55963. /**
  55964. * Class containing static functions to help procedurally build meshes
  55965. */
  55966. export class ShapeBuilder {
  55967. /**
  55968. * 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.
  55969. * * 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.
  55970. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55971. * * 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.
  55972. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55973. * * 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
  55974. * * 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
  55975. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55977. * * 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
  55978. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55980. * @param name defines the name of the mesh
  55981. * @param options defines the options used to create the mesh
  55982. * @param scene defines the hosting scene
  55983. * @returns the extruded shape mesh
  55984. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55985. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55986. */
  55987. static ExtrudeShape(name: string, options: {
  55988. shape: Vector3[];
  55989. path: Vector3[];
  55990. scale?: number;
  55991. rotation?: number;
  55992. cap?: number;
  55993. updatable?: boolean;
  55994. sideOrientation?: number;
  55995. frontUVs?: Vector4;
  55996. backUVs?: Vector4;
  55997. instance?: Mesh;
  55998. invertUV?: boolean;
  55999. }, scene?: Nullable<Scene>): Mesh;
  56000. /**
  56001. * Creates an custom extruded shape mesh.
  56002. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56003. * * 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.
  56004. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56005. * * 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
  56006. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56007. * * 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
  56008. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56009. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56010. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56011. * * 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
  56012. * * 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
  56013. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56015. * * 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
  56016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56018. * @param name defines the name of the mesh
  56019. * @param options defines the options used to create the mesh
  56020. * @param scene defines the hosting scene
  56021. * @returns the custom extruded shape mesh
  56022. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56023. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56024. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56025. */
  56026. static ExtrudeShapeCustom(name: string, options: {
  56027. shape: Vector3[];
  56028. path: Vector3[];
  56029. scaleFunction?: any;
  56030. rotationFunction?: any;
  56031. ribbonCloseArray?: boolean;
  56032. ribbonClosePath?: boolean;
  56033. cap?: number;
  56034. updatable?: boolean;
  56035. sideOrientation?: number;
  56036. frontUVs?: Vector4;
  56037. backUVs?: Vector4;
  56038. instance?: Mesh;
  56039. invertUV?: boolean;
  56040. }, scene?: Nullable<Scene>): Mesh;
  56041. private static _ExtrudeShapeGeneric;
  56042. }
  56043. }
  56044. declare module BABYLON {
  56045. /**
  56046. * AmmoJS Physics plugin
  56047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56048. * @see https://github.com/kripken/ammo.js/
  56049. */
  56050. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56051. private _useDeltaForWorldStep;
  56052. /**
  56053. * Reference to the Ammo library
  56054. */
  56055. bjsAMMO: any;
  56056. /**
  56057. * Created ammoJS world which physics bodies are added to
  56058. */
  56059. world: any;
  56060. /**
  56061. * Name of the plugin
  56062. */
  56063. name: string;
  56064. private _timeStep;
  56065. private _fixedTimeStep;
  56066. private _maxSteps;
  56067. private _tmpQuaternion;
  56068. private _tmpAmmoTransform;
  56069. private _tmpAmmoQuaternion;
  56070. private _tmpAmmoConcreteContactResultCallback;
  56071. private _collisionConfiguration;
  56072. private _dispatcher;
  56073. private _overlappingPairCache;
  56074. private _solver;
  56075. private _softBodySolver;
  56076. private _tmpAmmoVectorA;
  56077. private _tmpAmmoVectorB;
  56078. private _tmpAmmoVectorC;
  56079. private _tmpAmmoVectorD;
  56080. private _tmpContactCallbackResult;
  56081. private _tmpAmmoVectorRCA;
  56082. private _tmpAmmoVectorRCB;
  56083. private _raycastResult;
  56084. private static readonly DISABLE_COLLISION_FLAG;
  56085. private static readonly KINEMATIC_FLAG;
  56086. private static readonly DISABLE_DEACTIVATION_FLAG;
  56087. /**
  56088. * Initializes the ammoJS plugin
  56089. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56090. * @param ammoInjection can be used to inject your own ammo reference
  56091. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56092. */
  56093. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56094. /**
  56095. * Sets the gravity of the physics world (m/(s^2))
  56096. * @param gravity Gravity to set
  56097. */
  56098. setGravity(gravity: Vector3): void;
  56099. /**
  56100. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56101. * @param timeStep timestep to use in seconds
  56102. */
  56103. setTimeStep(timeStep: number): void;
  56104. /**
  56105. * 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)
  56106. * @param fixedTimeStep fixedTimeStep to use in seconds
  56107. */
  56108. setFixedTimeStep(fixedTimeStep: number): void;
  56109. /**
  56110. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56111. * @param maxSteps the maximum number of steps by the physics engine per frame
  56112. */
  56113. setMaxSteps(maxSteps: number): void;
  56114. /**
  56115. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56116. * @returns the current timestep in seconds
  56117. */
  56118. getTimeStep(): number;
  56119. /**
  56120. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56121. */
  56122. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56123. private _isImpostorInContact;
  56124. private _isImpostorPairInContact;
  56125. private _stepSimulation;
  56126. /**
  56127. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56128. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56129. * After the step the babylon meshes are set to the position of the physics imposters
  56130. * @param delta amount of time to step forward
  56131. * @param impostors array of imposters to update before/after the step
  56132. */
  56133. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56134. /**
  56135. * Update babylon mesh to match physics world object
  56136. * @param impostor imposter to match
  56137. */
  56138. private _afterSoftStep;
  56139. /**
  56140. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56141. * @param impostor imposter to match
  56142. */
  56143. private _ropeStep;
  56144. /**
  56145. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56146. * @param impostor imposter to match
  56147. */
  56148. private _softbodyOrClothStep;
  56149. private _tmpMatrix;
  56150. /**
  56151. * Applies an impulse on the imposter
  56152. * @param impostor imposter to apply impulse to
  56153. * @param force amount of force to be applied to the imposter
  56154. * @param contactPoint the location to apply the impulse on the imposter
  56155. */
  56156. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56157. /**
  56158. * Applies a force on the imposter
  56159. * @param impostor imposter to apply force
  56160. * @param force amount of force to be applied to the imposter
  56161. * @param contactPoint the location to apply the force on the imposter
  56162. */
  56163. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56164. /**
  56165. * Creates a physics body using the plugin
  56166. * @param impostor the imposter to create the physics body on
  56167. */
  56168. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56169. /**
  56170. * Removes the physics body from the imposter and disposes of the body's memory
  56171. * @param impostor imposter to remove the physics body from
  56172. */
  56173. removePhysicsBody(impostor: PhysicsImpostor): void;
  56174. /**
  56175. * Generates a joint
  56176. * @param impostorJoint the imposter joint to create the joint with
  56177. */
  56178. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56179. /**
  56180. * Removes a joint
  56181. * @param impostorJoint the imposter joint to remove the joint from
  56182. */
  56183. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56184. private _addMeshVerts;
  56185. /**
  56186. * Initialise the soft body vertices to match its object's (mesh) vertices
  56187. * Softbody vertices (nodes) are in world space and to match this
  56188. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56189. * @param impostor to create the softbody for
  56190. */
  56191. private _softVertexData;
  56192. /**
  56193. * Create an impostor's soft body
  56194. * @param impostor to create the softbody for
  56195. */
  56196. private _createSoftbody;
  56197. /**
  56198. * Create cloth for an impostor
  56199. * @param impostor to create the softbody for
  56200. */
  56201. private _createCloth;
  56202. /**
  56203. * Create rope for an impostor
  56204. * @param impostor to create the softbody for
  56205. */
  56206. private _createRope;
  56207. /**
  56208. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56209. * @param impostor to create the custom physics shape for
  56210. */
  56211. private _createCustom;
  56212. private _addHullVerts;
  56213. private _createShape;
  56214. /**
  56215. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56216. * @param impostor imposter containing the physics body and babylon object
  56217. */
  56218. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56219. /**
  56220. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56221. * @param impostor imposter containing the physics body and babylon object
  56222. * @param newPosition new position
  56223. * @param newRotation new rotation
  56224. */
  56225. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56226. /**
  56227. * If this plugin is supported
  56228. * @returns true if its supported
  56229. */
  56230. isSupported(): boolean;
  56231. /**
  56232. * Sets the linear velocity of the physics body
  56233. * @param impostor imposter to set the velocity on
  56234. * @param velocity velocity to set
  56235. */
  56236. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56237. /**
  56238. * Sets the angular velocity of the physics body
  56239. * @param impostor imposter to set the velocity on
  56240. * @param velocity velocity to set
  56241. */
  56242. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56243. /**
  56244. * gets the linear velocity
  56245. * @param impostor imposter to get linear velocity from
  56246. * @returns linear velocity
  56247. */
  56248. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56249. /**
  56250. * gets the angular velocity
  56251. * @param impostor imposter to get angular velocity from
  56252. * @returns angular velocity
  56253. */
  56254. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56255. /**
  56256. * Sets the mass of physics body
  56257. * @param impostor imposter to set the mass on
  56258. * @param mass mass to set
  56259. */
  56260. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56261. /**
  56262. * Gets the mass of the physics body
  56263. * @param impostor imposter to get the mass from
  56264. * @returns mass
  56265. */
  56266. getBodyMass(impostor: PhysicsImpostor): number;
  56267. /**
  56268. * Gets friction of the impostor
  56269. * @param impostor impostor to get friction from
  56270. * @returns friction value
  56271. */
  56272. getBodyFriction(impostor: PhysicsImpostor): number;
  56273. /**
  56274. * Sets friction of the impostor
  56275. * @param impostor impostor to set friction on
  56276. * @param friction friction value
  56277. */
  56278. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56279. /**
  56280. * Gets restitution of the impostor
  56281. * @param impostor impostor to get restitution from
  56282. * @returns restitution value
  56283. */
  56284. getBodyRestitution(impostor: PhysicsImpostor): number;
  56285. /**
  56286. * Sets resitution of the impostor
  56287. * @param impostor impostor to set resitution on
  56288. * @param restitution resitution value
  56289. */
  56290. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56291. /**
  56292. * Gets pressure inside the impostor
  56293. * @param impostor impostor to get pressure from
  56294. * @returns pressure value
  56295. */
  56296. getBodyPressure(impostor: PhysicsImpostor): number;
  56297. /**
  56298. * Sets pressure inside a soft body impostor
  56299. * Cloth and rope must remain 0 pressure
  56300. * @param impostor impostor to set pressure on
  56301. * @param pressure pressure value
  56302. */
  56303. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  56304. /**
  56305. * Gets stiffness of the impostor
  56306. * @param impostor impostor to get stiffness from
  56307. * @returns pressure value
  56308. */
  56309. getBodyStiffness(impostor: PhysicsImpostor): number;
  56310. /**
  56311. * Sets stiffness of the impostor
  56312. * @param impostor impostor to set stiffness on
  56313. * @param stiffness stiffness value from 0 to 1
  56314. */
  56315. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  56316. /**
  56317. * Gets velocityIterations of the impostor
  56318. * @param impostor impostor to get velocity iterations from
  56319. * @returns velocityIterations value
  56320. */
  56321. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  56322. /**
  56323. * Sets velocityIterations of the impostor
  56324. * @param impostor impostor to set velocity iterations on
  56325. * @param velocityIterations velocityIterations value
  56326. */
  56327. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  56328. /**
  56329. * Gets positionIterations of the impostor
  56330. * @param impostor impostor to get position iterations from
  56331. * @returns positionIterations value
  56332. */
  56333. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  56334. /**
  56335. * Sets positionIterations of the impostor
  56336. * @param impostor impostor to set position on
  56337. * @param positionIterations positionIterations value
  56338. */
  56339. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  56340. /**
  56341. * Append an anchor to a cloth object
  56342. * @param impostor is the cloth impostor to add anchor to
  56343. * @param otherImpostor is the rigid impostor to anchor to
  56344. * @param width ratio across width from 0 to 1
  56345. * @param height ratio up height from 0 to 1
  56346. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  56347. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56348. */
  56349. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56350. /**
  56351. * Append an hook to a rope object
  56352. * @param impostor is the rope impostor to add hook to
  56353. * @param otherImpostor is the rigid impostor to hook to
  56354. * @param length ratio along the rope from 0 to 1
  56355. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  56356. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  56357. */
  56358. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  56359. /**
  56360. * Sleeps the physics body and stops it from being active
  56361. * @param impostor impostor to sleep
  56362. */
  56363. sleepBody(impostor: PhysicsImpostor): void;
  56364. /**
  56365. * Activates the physics body
  56366. * @param impostor impostor to activate
  56367. */
  56368. wakeUpBody(impostor: PhysicsImpostor): void;
  56369. /**
  56370. * Updates the distance parameters of the joint
  56371. * @param joint joint to update
  56372. * @param maxDistance maximum distance of the joint
  56373. * @param minDistance minimum distance of the joint
  56374. */
  56375. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56376. /**
  56377. * Sets a motor on the joint
  56378. * @param joint joint to set motor on
  56379. * @param speed speed of the motor
  56380. * @param maxForce maximum force of the motor
  56381. * @param motorIndex index of the motor
  56382. */
  56383. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56384. /**
  56385. * Sets the motors limit
  56386. * @param joint joint to set limit on
  56387. * @param upperLimit upper limit
  56388. * @param lowerLimit lower limit
  56389. */
  56390. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56391. /**
  56392. * Syncs the position and rotation of a mesh with the impostor
  56393. * @param mesh mesh to sync
  56394. * @param impostor impostor to update the mesh with
  56395. */
  56396. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56397. /**
  56398. * Gets the radius of the impostor
  56399. * @param impostor impostor to get radius from
  56400. * @returns the radius
  56401. */
  56402. getRadius(impostor: PhysicsImpostor): number;
  56403. /**
  56404. * Gets the box size of the impostor
  56405. * @param impostor impostor to get box size from
  56406. * @param result the resulting box size
  56407. */
  56408. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56409. /**
  56410. * Disposes of the impostor
  56411. */
  56412. dispose(): void;
  56413. /**
  56414. * Does a raycast in the physics world
  56415. * @param from when should the ray start?
  56416. * @param to when should the ray end?
  56417. * @returns PhysicsRaycastResult
  56418. */
  56419. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56420. }
  56421. }
  56422. declare module BABYLON {
  56423. interface AbstractScene {
  56424. /**
  56425. * The list of reflection probes added to the scene
  56426. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56427. */
  56428. reflectionProbes: Array<ReflectionProbe>;
  56429. /**
  56430. * Removes the given reflection probe from this scene.
  56431. * @param toRemove The reflection probe to remove
  56432. * @returns The index of the removed reflection probe
  56433. */
  56434. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56435. /**
  56436. * Adds the given reflection probe to this scene.
  56437. * @param newReflectionProbe The reflection probe to add
  56438. */
  56439. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56440. }
  56441. /**
  56442. * Class used to generate realtime reflection / refraction cube textures
  56443. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56444. */
  56445. export class ReflectionProbe {
  56446. /** defines the name of the probe */
  56447. name: string;
  56448. private _scene;
  56449. private _renderTargetTexture;
  56450. private _projectionMatrix;
  56451. private _viewMatrix;
  56452. private _target;
  56453. private _add;
  56454. private _attachedMesh;
  56455. private _invertYAxis;
  56456. /** Gets or sets probe position (center of the cube map) */
  56457. position: Vector3;
  56458. /**
  56459. * Creates a new reflection probe
  56460. * @param name defines the name of the probe
  56461. * @param size defines the texture resolution (for each face)
  56462. * @param scene defines the hosting scene
  56463. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56464. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56465. */
  56466. constructor(
  56467. /** defines the name of the probe */
  56468. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56469. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56470. get samples(): number;
  56471. set samples(value: number);
  56472. /** Gets or sets the refresh rate to use (on every frame by default) */
  56473. get refreshRate(): number;
  56474. set refreshRate(value: number);
  56475. /**
  56476. * Gets the hosting scene
  56477. * @returns a Scene
  56478. */
  56479. getScene(): Scene;
  56480. /** Gets the internal CubeTexture used to render to */
  56481. get cubeTexture(): RenderTargetTexture;
  56482. /** Gets the list of meshes to render */
  56483. get renderList(): Nullable<AbstractMesh[]>;
  56484. /**
  56485. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56486. * @param mesh defines the mesh to attach to
  56487. */
  56488. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56489. /**
  56490. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56491. * @param renderingGroupId The rendering group id corresponding to its index
  56492. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56493. */
  56494. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56495. /**
  56496. * Clean all associated resources
  56497. */
  56498. dispose(): void;
  56499. /**
  56500. * Converts the reflection probe information to a readable string for debug purpose.
  56501. * @param fullDetails Supports for multiple levels of logging within scene loading
  56502. * @returns the human readable reflection probe info
  56503. */
  56504. toString(fullDetails?: boolean): string;
  56505. /**
  56506. * Get the class name of the relfection probe.
  56507. * @returns "ReflectionProbe"
  56508. */
  56509. getClassName(): string;
  56510. /**
  56511. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56512. * @returns The JSON representation of the texture
  56513. */
  56514. serialize(): any;
  56515. /**
  56516. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56517. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56518. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56519. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56520. * @returns The parsed reflection probe if successful
  56521. */
  56522. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56523. }
  56524. }
  56525. declare module BABYLON {
  56526. /** @hidden */
  56527. export var _BabylonLoaderRegistered: boolean;
  56528. /**
  56529. * Helps setting up some configuration for the babylon file loader.
  56530. */
  56531. export class BabylonFileLoaderConfiguration {
  56532. /**
  56533. * The loader does not allow injecting custom physix engine into the plugins.
  56534. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56535. * So you could set this variable to your engine import to make it work.
  56536. */
  56537. static LoaderInjectedPhysicsEngine: any;
  56538. }
  56539. }
  56540. declare module BABYLON {
  56541. /**
  56542. * The Physically based simple base material of BJS.
  56543. *
  56544. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56545. * It is used as the base class for both the specGloss and metalRough conventions.
  56546. */
  56547. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56548. /**
  56549. * Number of Simultaneous lights allowed on the material.
  56550. */
  56551. maxSimultaneousLights: number;
  56552. /**
  56553. * If sets to true, disables all the lights affecting the material.
  56554. */
  56555. disableLighting: boolean;
  56556. /**
  56557. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56558. */
  56559. environmentTexture: BaseTexture;
  56560. /**
  56561. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56562. */
  56563. invertNormalMapX: boolean;
  56564. /**
  56565. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56566. */
  56567. invertNormalMapY: boolean;
  56568. /**
  56569. * Normal map used in the model.
  56570. */
  56571. normalTexture: BaseTexture;
  56572. /**
  56573. * Emissivie color used to self-illuminate the model.
  56574. */
  56575. emissiveColor: Color3;
  56576. /**
  56577. * Emissivie texture used to self-illuminate the model.
  56578. */
  56579. emissiveTexture: BaseTexture;
  56580. /**
  56581. * Occlusion Channel Strenght.
  56582. */
  56583. occlusionStrength: number;
  56584. /**
  56585. * Occlusion Texture of the material (adding extra occlusion effects).
  56586. */
  56587. occlusionTexture: BaseTexture;
  56588. /**
  56589. * Defines the alpha limits in alpha test mode.
  56590. */
  56591. alphaCutOff: number;
  56592. /**
  56593. * Gets the current double sided mode.
  56594. */
  56595. get doubleSided(): boolean;
  56596. /**
  56597. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56598. */
  56599. set doubleSided(value: boolean);
  56600. /**
  56601. * Stores the pre-calculated light information of a mesh in a texture.
  56602. */
  56603. lightmapTexture: BaseTexture;
  56604. /**
  56605. * If true, the light map contains occlusion information instead of lighting info.
  56606. */
  56607. useLightmapAsShadowmap: boolean;
  56608. /**
  56609. * Instantiates a new PBRMaterial instance.
  56610. *
  56611. * @param name The material name
  56612. * @param scene The scene the material will be use in.
  56613. */
  56614. constructor(name: string, scene: Scene);
  56615. getClassName(): string;
  56616. }
  56617. }
  56618. declare module BABYLON {
  56619. /**
  56620. * The PBR material of BJS following the metal roughness convention.
  56621. *
  56622. * This fits to the PBR convention in the GLTF definition:
  56623. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56624. */
  56625. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56626. /**
  56627. * The base color has two different interpretations depending on the value of metalness.
  56628. * When the material is a metal, the base color is the specific measured reflectance value
  56629. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56630. * of the material.
  56631. */
  56632. baseColor: Color3;
  56633. /**
  56634. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56635. * well as opacity information in the alpha channel.
  56636. */
  56637. baseTexture: BaseTexture;
  56638. /**
  56639. * Specifies the metallic scalar value of the material.
  56640. * Can also be used to scale the metalness values of the metallic texture.
  56641. */
  56642. metallic: number;
  56643. /**
  56644. * Specifies the roughness scalar value of the material.
  56645. * Can also be used to scale the roughness values of the metallic texture.
  56646. */
  56647. roughness: number;
  56648. /**
  56649. * Texture containing both the metallic value in the B channel and the
  56650. * roughness value in the G channel to keep better precision.
  56651. */
  56652. metallicRoughnessTexture: BaseTexture;
  56653. /**
  56654. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56655. *
  56656. * @param name The material name
  56657. * @param scene The scene the material will be use in.
  56658. */
  56659. constructor(name: string, scene: Scene);
  56660. /**
  56661. * Return the currrent class name of the material.
  56662. */
  56663. getClassName(): string;
  56664. /**
  56665. * Makes a duplicate of the current material.
  56666. * @param name - name to use for the new material.
  56667. */
  56668. clone(name: string): PBRMetallicRoughnessMaterial;
  56669. /**
  56670. * Serialize the material to a parsable JSON object.
  56671. */
  56672. serialize(): any;
  56673. /**
  56674. * Parses a JSON object correponding to the serialize function.
  56675. */
  56676. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56677. }
  56678. }
  56679. declare module BABYLON {
  56680. /**
  56681. * The PBR material of BJS following the specular glossiness convention.
  56682. *
  56683. * This fits to the PBR convention in the GLTF definition:
  56684. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56685. */
  56686. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56687. /**
  56688. * Specifies the diffuse color of the material.
  56689. */
  56690. diffuseColor: Color3;
  56691. /**
  56692. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56693. * channel.
  56694. */
  56695. diffuseTexture: BaseTexture;
  56696. /**
  56697. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56698. */
  56699. specularColor: Color3;
  56700. /**
  56701. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56702. */
  56703. glossiness: number;
  56704. /**
  56705. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56706. */
  56707. specularGlossinessTexture: BaseTexture;
  56708. /**
  56709. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56710. *
  56711. * @param name The material name
  56712. * @param scene The scene the material will be use in.
  56713. */
  56714. constructor(name: string, scene: Scene);
  56715. /**
  56716. * Return the currrent class name of the material.
  56717. */
  56718. getClassName(): string;
  56719. /**
  56720. * Makes a duplicate of the current material.
  56721. * @param name - name to use for the new material.
  56722. */
  56723. clone(name: string): PBRSpecularGlossinessMaterial;
  56724. /**
  56725. * Serialize the material to a parsable JSON object.
  56726. */
  56727. serialize(): any;
  56728. /**
  56729. * Parses a JSON object correponding to the serialize function.
  56730. */
  56731. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56732. }
  56733. }
  56734. declare module BABYLON {
  56735. /**
  56736. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56737. * It can help converting any input color in a desired output one. This can then be used to create effects
  56738. * from sepia, black and white to sixties or futuristic rendering...
  56739. *
  56740. * The only supported format is currently 3dl.
  56741. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56742. */
  56743. export class ColorGradingTexture extends BaseTexture {
  56744. /**
  56745. * The texture URL.
  56746. */
  56747. url: string;
  56748. /**
  56749. * Empty line regex stored for GC.
  56750. */
  56751. private static _noneEmptyLineRegex;
  56752. private _textureMatrix;
  56753. private _onLoad;
  56754. /**
  56755. * Instantiates a ColorGradingTexture from the following parameters.
  56756. *
  56757. * @param url The location of the color gradind data (currently only supporting 3dl)
  56758. * @param sceneOrEngine The scene or engine the texture will be used in
  56759. * @param onLoad defines a callback triggered when the texture has been loaded
  56760. */
  56761. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  56762. /**
  56763. * Fires the onload event from the constructor if requested.
  56764. */
  56765. private _triggerOnLoad;
  56766. /**
  56767. * Returns the texture matrix used in most of the material.
  56768. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56769. */
  56770. getTextureMatrix(): Matrix;
  56771. /**
  56772. * Occurs when the file being loaded is a .3dl LUT file.
  56773. */
  56774. private load3dlTexture;
  56775. /**
  56776. * Starts the loading process of the texture.
  56777. */
  56778. private loadTexture;
  56779. /**
  56780. * Clones the color gradind texture.
  56781. */
  56782. clone(): ColorGradingTexture;
  56783. /**
  56784. * Called during delayed load for textures.
  56785. */
  56786. delayLoad(): void;
  56787. /**
  56788. * Parses a color grading texture serialized by Babylon.
  56789. * @param parsedTexture The texture information being parsedTexture
  56790. * @param scene The scene to load the texture in
  56791. * @param rootUrl The root url of the data assets to load
  56792. * @return A color gradind texture
  56793. */
  56794. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56795. /**
  56796. * Serializes the LUT texture to json format.
  56797. */
  56798. serialize(): any;
  56799. }
  56800. }
  56801. declare module BABYLON {
  56802. /**
  56803. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56804. */
  56805. export class EquiRectangularCubeTexture extends BaseTexture {
  56806. /** The six faces of the cube. */
  56807. private static _FacesMapping;
  56808. private _noMipmap;
  56809. private _onLoad;
  56810. private _onError;
  56811. /** The size of the cubemap. */
  56812. private _size;
  56813. /** The buffer of the image. */
  56814. private _buffer;
  56815. /** The width of the input image. */
  56816. private _width;
  56817. /** The height of the input image. */
  56818. private _height;
  56819. /** The URL to the image. */
  56820. url: string;
  56821. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56822. coordinatesMode: number;
  56823. /**
  56824. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56825. * @param url The location of the image
  56826. * @param scene The scene the texture will be used in
  56827. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56828. * @param noMipmap Forces to not generate the mipmap if true
  56829. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56830. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56831. * @param onLoad — defines a callback called when texture is loaded
  56832. * @param onError — defines a callback called if there is an error
  56833. */
  56834. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56835. /**
  56836. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56837. */
  56838. private loadImage;
  56839. /**
  56840. * Convert the image buffer into a cubemap and create a CubeTexture.
  56841. */
  56842. private loadTexture;
  56843. /**
  56844. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56845. * @param buffer The ArrayBuffer that should be converted.
  56846. * @returns The buffer as Float32Array.
  56847. */
  56848. private getFloat32ArrayFromArrayBuffer;
  56849. /**
  56850. * Get the current class name of the texture useful for serialization or dynamic coding.
  56851. * @returns "EquiRectangularCubeTexture"
  56852. */
  56853. getClassName(): string;
  56854. /**
  56855. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56856. * @returns A clone of the current EquiRectangularCubeTexture.
  56857. */
  56858. clone(): EquiRectangularCubeTexture;
  56859. }
  56860. }
  56861. declare module BABYLON {
  56862. /**
  56863. * Based on jsTGALoader - Javascript loader for TGA file
  56864. * By Vincent Thibault
  56865. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56866. */
  56867. export class TGATools {
  56868. private static _TYPE_INDEXED;
  56869. private static _TYPE_RGB;
  56870. private static _TYPE_GREY;
  56871. private static _TYPE_RLE_INDEXED;
  56872. private static _TYPE_RLE_RGB;
  56873. private static _TYPE_RLE_GREY;
  56874. private static _ORIGIN_MASK;
  56875. private static _ORIGIN_SHIFT;
  56876. private static _ORIGIN_BL;
  56877. private static _ORIGIN_BR;
  56878. private static _ORIGIN_UL;
  56879. private static _ORIGIN_UR;
  56880. /**
  56881. * Gets the header of a TGA file
  56882. * @param data defines the TGA data
  56883. * @returns the header
  56884. */
  56885. static GetTGAHeader(data: Uint8Array): any;
  56886. /**
  56887. * Uploads TGA content to a Babylon Texture
  56888. * @hidden
  56889. */
  56890. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56891. /** @hidden */
  56892. 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;
  56893. /** @hidden */
  56894. 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;
  56895. /** @hidden */
  56896. 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;
  56897. /** @hidden */
  56898. 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;
  56899. /** @hidden */
  56900. 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;
  56901. /** @hidden */
  56902. 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;
  56903. }
  56904. }
  56905. declare module BABYLON {
  56906. /**
  56907. * Implementation of the TGA Texture Loader.
  56908. * @hidden
  56909. */
  56910. export class _TGATextureLoader implements IInternalTextureLoader {
  56911. /**
  56912. * Defines wether the loader supports cascade loading the different faces.
  56913. */
  56914. readonly supportCascades: boolean;
  56915. /**
  56916. * This returns if the loader support the current file information.
  56917. * @param extension defines the file extension of the file being loaded
  56918. * @returns true if the loader can load the specified file
  56919. */
  56920. canLoad(extension: string): boolean;
  56921. /**
  56922. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56923. * @param data contains the texture data
  56924. * @param texture defines the BabylonJS internal texture
  56925. * @param createPolynomials will be true if polynomials have been requested
  56926. * @param onLoad defines the callback to trigger once the texture is ready
  56927. * @param onError defines the callback to trigger in case of error
  56928. */
  56929. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56930. /**
  56931. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56932. * @param data contains the texture data
  56933. * @param texture defines the BabylonJS internal texture
  56934. * @param callback defines the method to call once ready to upload
  56935. */
  56936. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56937. }
  56938. }
  56939. declare module BABYLON {
  56940. /**
  56941. * Info about the .basis files
  56942. */
  56943. class BasisFileInfo {
  56944. /**
  56945. * If the file has alpha
  56946. */
  56947. hasAlpha: boolean;
  56948. /**
  56949. * Info about each image of the basis file
  56950. */
  56951. images: Array<{
  56952. levels: Array<{
  56953. width: number;
  56954. height: number;
  56955. transcodedPixels: ArrayBufferView;
  56956. }>;
  56957. }>;
  56958. }
  56959. /**
  56960. * Result of transcoding a basis file
  56961. */
  56962. class TranscodeResult {
  56963. /**
  56964. * Info about the .basis file
  56965. */
  56966. fileInfo: BasisFileInfo;
  56967. /**
  56968. * Format to use when loading the file
  56969. */
  56970. format: number;
  56971. }
  56972. /**
  56973. * Configuration options for the Basis transcoder
  56974. */
  56975. export class BasisTranscodeConfiguration {
  56976. /**
  56977. * Supported compression formats used to determine the supported output format of the transcoder
  56978. */
  56979. supportedCompressionFormats?: {
  56980. /**
  56981. * etc1 compression format
  56982. */
  56983. etc1?: boolean;
  56984. /**
  56985. * s3tc compression format
  56986. */
  56987. s3tc?: boolean;
  56988. /**
  56989. * pvrtc compression format
  56990. */
  56991. pvrtc?: boolean;
  56992. /**
  56993. * etc2 compression format
  56994. */
  56995. etc2?: boolean;
  56996. };
  56997. /**
  56998. * If mipmap levels should be loaded for transcoded images (Default: true)
  56999. */
  57000. loadMipmapLevels?: boolean;
  57001. /**
  57002. * Index of a single image to load (Default: all images)
  57003. */
  57004. loadSingleImage?: number;
  57005. }
  57006. /**
  57007. * Used to load .Basis files
  57008. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57009. */
  57010. export class BasisTools {
  57011. private static _IgnoreSupportedFormats;
  57012. /**
  57013. * URL to use when loading the basis transcoder
  57014. */
  57015. static JSModuleURL: string;
  57016. /**
  57017. * URL to use when loading the wasm module for the transcoder
  57018. */
  57019. static WasmModuleURL: string;
  57020. /**
  57021. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57022. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57023. * @returns internal format corresponding to the Basis format
  57024. */
  57025. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57026. private static _WorkerPromise;
  57027. private static _Worker;
  57028. private static _actionId;
  57029. private static _CreateWorkerAsync;
  57030. /**
  57031. * Transcodes a loaded image file to compressed pixel data
  57032. * @param data image data to transcode
  57033. * @param config configuration options for the transcoding
  57034. * @returns a promise resulting in the transcoded image
  57035. */
  57036. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57037. /**
  57038. * Loads a texture from the transcode result
  57039. * @param texture texture load to
  57040. * @param transcodeResult the result of transcoding the basis file to load from
  57041. */
  57042. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57043. }
  57044. }
  57045. declare module BABYLON {
  57046. /**
  57047. * Loader for .basis file format
  57048. */
  57049. export class _BasisTextureLoader implements IInternalTextureLoader {
  57050. /**
  57051. * Defines whether the loader supports cascade loading the different faces.
  57052. */
  57053. readonly supportCascades: boolean;
  57054. /**
  57055. * This returns if the loader support the current file information.
  57056. * @param extension defines the file extension of the file being loaded
  57057. * @returns true if the loader can load the specified file
  57058. */
  57059. canLoad(extension: string): boolean;
  57060. /**
  57061. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57062. * @param data contains the texture data
  57063. * @param texture defines the BabylonJS internal texture
  57064. * @param createPolynomials will be true if polynomials have been requested
  57065. * @param onLoad defines the callback to trigger once the texture is ready
  57066. * @param onError defines the callback to trigger in case of error
  57067. */
  57068. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57069. /**
  57070. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57071. * @param data contains the texture data
  57072. * @param texture defines the BabylonJS internal texture
  57073. * @param callback defines the method to call once ready to upload
  57074. */
  57075. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57076. }
  57077. }
  57078. declare module BABYLON {
  57079. /**
  57080. * 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.
  57081. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57082. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57083. */
  57084. export class CustomProceduralTexture extends ProceduralTexture {
  57085. private _animate;
  57086. private _time;
  57087. private _config;
  57088. private _texturePath;
  57089. /**
  57090. * Instantiates a new Custom Procedural Texture.
  57091. * 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.
  57092. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57093. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57094. * @param name Define the name of the texture
  57095. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57096. * @param size Define the size of the texture to create
  57097. * @param scene Define the scene the texture belongs to
  57098. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57099. * @param generateMipMaps Define if the texture should creates mip maps or not
  57100. */
  57101. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57102. private _loadJson;
  57103. /**
  57104. * Is the texture ready to be used ? (rendered at least once)
  57105. * @returns true if ready, otherwise, false.
  57106. */
  57107. isReady(): boolean;
  57108. /**
  57109. * Render the texture to its associated render target.
  57110. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57111. */
  57112. render(useCameraPostProcess?: boolean): void;
  57113. /**
  57114. * Update the list of dependant textures samplers in the shader.
  57115. */
  57116. updateTextures(): void;
  57117. /**
  57118. * Update the uniform values of the procedural texture in the shader.
  57119. */
  57120. updateShaderUniforms(): void;
  57121. /**
  57122. * Define if the texture animates or not.
  57123. */
  57124. get animate(): boolean;
  57125. set animate(value: boolean);
  57126. }
  57127. }
  57128. declare module BABYLON {
  57129. /** @hidden */
  57130. export var noisePixelShader: {
  57131. name: string;
  57132. shader: string;
  57133. };
  57134. }
  57135. declare module BABYLON {
  57136. /**
  57137. * Class used to generate noise procedural textures
  57138. */
  57139. export class NoiseProceduralTexture extends ProceduralTexture {
  57140. private _time;
  57141. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57142. brightness: number;
  57143. /** Defines the number of octaves to process */
  57144. octaves: number;
  57145. /** Defines the level of persistence (0.8 by default) */
  57146. persistence: number;
  57147. /** Gets or sets animation speed factor (default is 1) */
  57148. animationSpeedFactor: number;
  57149. /**
  57150. * Creates a new NoiseProceduralTexture
  57151. * @param name defines the name fo the texture
  57152. * @param size defines the size of the texture (default is 256)
  57153. * @param scene defines the hosting scene
  57154. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  57155. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  57156. */
  57157. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57158. private _updateShaderUniforms;
  57159. protected _getDefines(): string;
  57160. /** Generate the current state of the procedural texture */
  57161. render(useCameraPostProcess?: boolean): void;
  57162. /**
  57163. * Serializes this noise procedural texture
  57164. * @returns a serialized noise procedural texture object
  57165. */
  57166. serialize(): any;
  57167. /**
  57168. * Clone the texture.
  57169. * @returns the cloned texture
  57170. */
  57171. clone(): NoiseProceduralTexture;
  57172. /**
  57173. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  57174. * @param parsedTexture defines parsed texture data
  57175. * @param scene defines the current scene
  57176. * @param rootUrl defines the root URL containing noise procedural texture information
  57177. * @returns a parsed NoiseProceduralTexture
  57178. */
  57179. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  57180. }
  57181. }
  57182. declare module BABYLON {
  57183. /**
  57184. * Raw cube texture where the raw buffers are passed in
  57185. */
  57186. export class RawCubeTexture extends CubeTexture {
  57187. /**
  57188. * Creates a cube texture where the raw buffers are passed in.
  57189. * @param scene defines the scene the texture is attached to
  57190. * @param data defines the array of data to use to create each face
  57191. * @param size defines the size of the textures
  57192. * @param format defines the format of the data
  57193. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57194. * @param generateMipMaps defines if the engine should generate the mip levels
  57195. * @param invertY defines if data must be stored with Y axis inverted
  57196. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57197. * @param compression defines the compression used (null by default)
  57198. */
  57199. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  57200. /**
  57201. * Updates the raw cube texture.
  57202. * @param data defines the data to store
  57203. * @param format defines the data format
  57204. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57205. * @param invertY defines if data must be stored with Y axis inverted
  57206. * @param compression defines the compression used (null by default)
  57207. * @param level defines which level of the texture to update
  57208. */
  57209. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  57210. /**
  57211. * Updates a raw cube texture with RGBD encoded data.
  57212. * @param data defines the array of data [mipmap][face] to use to create each face
  57213. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57214. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57215. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57216. * @returns a promsie that resolves when the operation is complete
  57217. */
  57218. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  57219. /**
  57220. * Clones the raw cube texture.
  57221. * @return a new cube texture
  57222. */
  57223. clone(): CubeTexture;
  57224. /** @hidden */
  57225. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  57226. }
  57227. }
  57228. declare module BABYLON {
  57229. /**
  57230. * Class used to store 3D textures containing user data
  57231. */
  57232. export class RawTexture3D extends Texture {
  57233. /** Gets or sets the texture format to use */
  57234. format: number;
  57235. /**
  57236. * Create a new RawTexture3D
  57237. * @param data defines the data of the texture
  57238. * @param width defines the width of the texture
  57239. * @param height defines the height of the texture
  57240. * @param depth defines the depth of the texture
  57241. * @param format defines the texture format to use
  57242. * @param scene defines the hosting scene
  57243. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57244. * @param invertY defines if texture must be stored with Y axis inverted
  57245. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57246. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57247. */
  57248. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57249. /** Gets or sets the texture format to use */
  57250. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57251. /**
  57252. * Update the texture with new data
  57253. * @param data defines the data to store in the texture
  57254. */
  57255. update(data: ArrayBufferView): void;
  57256. }
  57257. }
  57258. declare module BABYLON {
  57259. /**
  57260. * Class used to store 2D array textures containing user data
  57261. */
  57262. export class RawTexture2DArray extends Texture {
  57263. /** Gets or sets the texture format to use */
  57264. format: number;
  57265. /**
  57266. * Create a new RawTexture2DArray
  57267. * @param data defines the data of the texture
  57268. * @param width defines the width of the texture
  57269. * @param height defines the height of the texture
  57270. * @param depth defines the number of layers of the texture
  57271. * @param format defines the texture format to use
  57272. * @param scene defines the hosting scene
  57273. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57274. * @param invertY defines if texture must be stored with Y axis inverted
  57275. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57276. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57277. */
  57278. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  57279. /** Gets or sets the texture format to use */
  57280. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  57281. /**
  57282. * Update the texture with new data
  57283. * @param data defines the data to store in the texture
  57284. */
  57285. update(data: ArrayBufferView): void;
  57286. }
  57287. }
  57288. declare module BABYLON {
  57289. /**
  57290. * Creates a refraction texture used by refraction channel of the standard material.
  57291. * It is like a mirror but to see through a material.
  57292. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57293. */
  57294. export class RefractionTexture extends RenderTargetTexture {
  57295. /**
  57296. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57297. * 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.
  57298. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57299. */
  57300. refractionPlane: Plane;
  57301. /**
  57302. * Define how deep under the surface we should see.
  57303. */
  57304. depth: number;
  57305. /**
  57306. * Creates a refraction texture used by refraction channel of the standard material.
  57307. * It is like a mirror but to see through a material.
  57308. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57309. * @param name Define the texture name
  57310. * @param size Define the size of the underlying texture
  57311. * @param scene Define the scene the refraction belongs to
  57312. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57313. */
  57314. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  57315. /**
  57316. * Clone the refraction texture.
  57317. * @returns the cloned texture
  57318. */
  57319. clone(): RefractionTexture;
  57320. /**
  57321. * Serialize the texture to a JSON representation you could use in Parse later on
  57322. * @returns the serialized JSON representation
  57323. */
  57324. serialize(): any;
  57325. }
  57326. }
  57327. declare module BABYLON {
  57328. /**
  57329. * Defines the options related to the creation of an HtmlElementTexture
  57330. */
  57331. export interface IHtmlElementTextureOptions {
  57332. /**
  57333. * Defines wether mip maps should be created or not.
  57334. */
  57335. generateMipMaps?: boolean;
  57336. /**
  57337. * Defines the sampling mode of the texture.
  57338. */
  57339. samplingMode?: number;
  57340. /**
  57341. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  57342. */
  57343. engine: Nullable<ThinEngine>;
  57344. /**
  57345. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  57346. */
  57347. scene: Nullable<Scene>;
  57348. }
  57349. /**
  57350. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  57351. * To be as efficient as possible depending on your constraints nothing aside the first upload
  57352. * is automatically managed.
  57353. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  57354. * in your application.
  57355. *
  57356. * As the update is not automatic, you need to call them manually.
  57357. */
  57358. export class HtmlElementTexture extends BaseTexture {
  57359. /**
  57360. * The texture URL.
  57361. */
  57362. element: HTMLVideoElement | HTMLCanvasElement;
  57363. private static readonly DefaultOptions;
  57364. private _textureMatrix;
  57365. private _isVideo;
  57366. private _generateMipMaps;
  57367. private _samplingMode;
  57368. /**
  57369. * Instantiates a HtmlElementTexture from the following parameters.
  57370. *
  57371. * @param name Defines the name of the texture
  57372. * @param element Defines the video or canvas the texture is filled with
  57373. * @param options Defines the other none mandatory texture creation options
  57374. */
  57375. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57376. private _createInternalTexture;
  57377. /**
  57378. * Returns the texture matrix used in most of the material.
  57379. */
  57380. getTextureMatrix(): Matrix;
  57381. /**
  57382. * Updates the content of the texture.
  57383. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57384. */
  57385. update(invertY?: Nullable<boolean>): void;
  57386. }
  57387. }
  57388. declare module BABYLON {
  57389. /**
  57390. * Defines the basic options interface of a TexturePacker Frame
  57391. */
  57392. export interface ITexturePackerFrame {
  57393. /**
  57394. * The frame ID
  57395. */
  57396. id: number;
  57397. /**
  57398. * The frames Scale
  57399. */
  57400. scale: Vector2;
  57401. /**
  57402. * The Frames offset
  57403. */
  57404. offset: Vector2;
  57405. }
  57406. /**
  57407. * This is a support class for frame Data on texture packer sets.
  57408. */
  57409. export class TexturePackerFrame implements ITexturePackerFrame {
  57410. /**
  57411. * The frame ID
  57412. */
  57413. id: number;
  57414. /**
  57415. * The frames Scale
  57416. */
  57417. scale: Vector2;
  57418. /**
  57419. * The Frames offset
  57420. */
  57421. offset: Vector2;
  57422. /**
  57423. * Initializes a texture package frame.
  57424. * @param id The numerical frame identifier
  57425. * @param scale Scalar Vector2 for UV frame
  57426. * @param offset Vector2 for the frame position in UV units.
  57427. * @returns TexturePackerFrame
  57428. */
  57429. constructor(id: number, scale: Vector2, offset: Vector2);
  57430. }
  57431. }
  57432. declare module BABYLON {
  57433. /**
  57434. * Defines the basic options interface of a TexturePacker
  57435. */
  57436. export interface ITexturePackerOptions {
  57437. /**
  57438. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57439. */
  57440. map?: string[];
  57441. /**
  57442. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57443. */
  57444. uvsIn?: string;
  57445. /**
  57446. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57447. */
  57448. uvsOut?: string;
  57449. /**
  57450. * number representing the layout style. Defaults to LAYOUT_STRIP
  57451. */
  57452. layout?: number;
  57453. /**
  57454. * number of columns if using custom column count layout(2). This defaults to 4.
  57455. */
  57456. colnum?: number;
  57457. /**
  57458. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57459. */
  57460. updateInputMeshes?: boolean;
  57461. /**
  57462. * boolean flag to dispose all the source textures. Defaults to true.
  57463. */
  57464. disposeSources?: boolean;
  57465. /**
  57466. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57467. */
  57468. fillBlanks?: boolean;
  57469. /**
  57470. * string value representing the context fill style color. Defaults to 'black'.
  57471. */
  57472. customFillColor?: string;
  57473. /**
  57474. * Width and Height Value of each Frame in the TexturePacker Sets
  57475. */
  57476. frameSize?: number;
  57477. /**
  57478. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57479. */
  57480. paddingRatio?: number;
  57481. /**
  57482. * Number that declares the fill method for the padding gutter.
  57483. */
  57484. paddingMode?: number;
  57485. /**
  57486. * If in SUBUV_COLOR padding mode what color to use.
  57487. */
  57488. paddingColor?: Color3 | Color4;
  57489. }
  57490. /**
  57491. * Defines the basic interface of a TexturePacker JSON File
  57492. */
  57493. export interface ITexturePackerJSON {
  57494. /**
  57495. * The frame ID
  57496. */
  57497. name: string;
  57498. /**
  57499. * The base64 channel data
  57500. */
  57501. sets: any;
  57502. /**
  57503. * The options of the Packer
  57504. */
  57505. options: ITexturePackerOptions;
  57506. /**
  57507. * The frame data of the Packer
  57508. */
  57509. frames: Array<number>;
  57510. }
  57511. /**
  57512. * This is a support class that generates a series of packed texture sets.
  57513. * @see https://doc.babylonjs.com/babylon101/materials
  57514. */
  57515. export class TexturePacker {
  57516. /** Packer Layout Constant 0 */
  57517. static readonly LAYOUT_STRIP: number;
  57518. /** Packer Layout Constant 1 */
  57519. static readonly LAYOUT_POWER2: number;
  57520. /** Packer Layout Constant 2 */
  57521. static readonly LAYOUT_COLNUM: number;
  57522. /** Packer Layout Constant 0 */
  57523. static readonly SUBUV_WRAP: number;
  57524. /** Packer Layout Constant 1 */
  57525. static readonly SUBUV_EXTEND: number;
  57526. /** Packer Layout Constant 2 */
  57527. static readonly SUBUV_COLOR: number;
  57528. /** The Name of the Texture Package */
  57529. name: string;
  57530. /** The scene scope of the TexturePacker */
  57531. scene: Scene;
  57532. /** The Meshes to target */
  57533. meshes: AbstractMesh[];
  57534. /** Arguments passed with the Constructor */
  57535. options: ITexturePackerOptions;
  57536. /** The promise that is started upon initialization */
  57537. promise: Nullable<Promise<TexturePacker | string>>;
  57538. /** The Container object for the channel sets that are generated */
  57539. sets: object;
  57540. /** The Container array for the frames that are generated */
  57541. frames: TexturePackerFrame[];
  57542. /** The expected number of textures the system is parsing. */
  57543. private _expecting;
  57544. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57545. private _paddingValue;
  57546. /**
  57547. * Initializes a texture package series from an array of meshes or a single mesh.
  57548. * @param name The name of the package
  57549. * @param meshes The target meshes to compose the package from
  57550. * @param options The arguments that texture packer should follow while building.
  57551. * @param scene The scene which the textures are scoped to.
  57552. * @returns TexturePacker
  57553. */
  57554. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57555. /**
  57556. * Starts the package process
  57557. * @param resolve The promises resolution function
  57558. * @returns TexturePacker
  57559. */
  57560. private _createFrames;
  57561. /**
  57562. * Calculates the Size of the Channel Sets
  57563. * @returns Vector2
  57564. */
  57565. private _calculateSize;
  57566. /**
  57567. * Calculates the UV data for the frames.
  57568. * @param baseSize the base frameSize
  57569. * @param padding the base frame padding
  57570. * @param dtSize size of the Dynamic Texture for that channel
  57571. * @param dtUnits is 1/dtSize
  57572. * @param update flag to update the input meshes
  57573. */
  57574. private _calculateMeshUVFrames;
  57575. /**
  57576. * Calculates the frames Offset.
  57577. * @param index of the frame
  57578. * @returns Vector2
  57579. */
  57580. private _getFrameOffset;
  57581. /**
  57582. * Updates a Mesh to the frame data
  57583. * @param mesh that is the target
  57584. * @param frameID or the frame index
  57585. */
  57586. private _updateMeshUV;
  57587. /**
  57588. * Updates a Meshes materials to use the texture packer channels
  57589. * @param m is the mesh to target
  57590. * @param force all channels on the packer to be set.
  57591. */
  57592. private _updateTextureReferences;
  57593. /**
  57594. * Public method to set a Mesh to a frame
  57595. * @param m that is the target
  57596. * @param frameID or the frame index
  57597. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57598. */
  57599. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57600. /**
  57601. * Starts the async promise to compile the texture packer.
  57602. * @returns Promise<void>
  57603. */
  57604. processAsync(): Promise<void>;
  57605. /**
  57606. * Disposes all textures associated with this packer
  57607. */
  57608. dispose(): void;
  57609. /**
  57610. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57611. * @param imageType is the image type to use.
  57612. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57613. */
  57614. download(imageType?: string, quality?: number): void;
  57615. /**
  57616. * Public method to load a texturePacker JSON file.
  57617. * @param data of the JSON file in string format.
  57618. */
  57619. updateFromJSON(data: string): void;
  57620. }
  57621. }
  57622. declare module BABYLON {
  57623. /**
  57624. * Enum used to define the target of a block
  57625. */
  57626. export enum NodeMaterialBlockTargets {
  57627. /** Vertex shader */
  57628. Vertex = 1,
  57629. /** Fragment shader */
  57630. Fragment = 2,
  57631. /** Neutral */
  57632. Neutral = 4,
  57633. /** Vertex and Fragment */
  57634. VertexAndFragment = 3
  57635. }
  57636. }
  57637. declare module BABYLON {
  57638. /**
  57639. * Defines the kind of connection point for node based material
  57640. */
  57641. export enum NodeMaterialBlockConnectionPointTypes {
  57642. /** Float */
  57643. Float = 1,
  57644. /** Int */
  57645. Int = 2,
  57646. /** Vector2 */
  57647. Vector2 = 4,
  57648. /** Vector3 */
  57649. Vector3 = 8,
  57650. /** Vector4 */
  57651. Vector4 = 16,
  57652. /** Color3 */
  57653. Color3 = 32,
  57654. /** Color4 */
  57655. Color4 = 64,
  57656. /** Matrix */
  57657. Matrix = 128,
  57658. /** Custom object */
  57659. Object = 256,
  57660. /** Detect type based on connection */
  57661. AutoDetect = 1024,
  57662. /** Output type that will be defined by input type */
  57663. BasedOnInput = 2048
  57664. }
  57665. }
  57666. declare module BABYLON {
  57667. /**
  57668. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57669. */
  57670. export enum NodeMaterialBlockConnectionPointMode {
  57671. /** Value is an uniform */
  57672. Uniform = 0,
  57673. /** Value is a mesh attribute */
  57674. Attribute = 1,
  57675. /** Value is a varying between vertex and fragment shaders */
  57676. Varying = 2,
  57677. /** Mode is undefined */
  57678. Undefined = 3
  57679. }
  57680. }
  57681. declare module BABYLON {
  57682. /**
  57683. * Enum used to define system values e.g. values automatically provided by the system
  57684. */
  57685. export enum NodeMaterialSystemValues {
  57686. /** World */
  57687. World = 1,
  57688. /** View */
  57689. View = 2,
  57690. /** Projection */
  57691. Projection = 3,
  57692. /** ViewProjection */
  57693. ViewProjection = 4,
  57694. /** WorldView */
  57695. WorldView = 5,
  57696. /** WorldViewProjection */
  57697. WorldViewProjection = 6,
  57698. /** CameraPosition */
  57699. CameraPosition = 7,
  57700. /** Fog Color */
  57701. FogColor = 8,
  57702. /** Delta time */
  57703. DeltaTime = 9
  57704. }
  57705. }
  57706. declare module BABYLON {
  57707. /**
  57708. * Enum used to define the material modes
  57709. */
  57710. export enum NodeMaterialModes {
  57711. /** Regular material */
  57712. Material = 0,
  57713. /** For post process */
  57714. PostProcess = 1
  57715. }
  57716. }
  57717. declare module BABYLON {
  57718. /**
  57719. * Root class for all node material optimizers
  57720. */
  57721. export class NodeMaterialOptimizer {
  57722. /**
  57723. * Function used to optimize a NodeMaterial graph
  57724. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57725. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57726. */
  57727. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57728. }
  57729. }
  57730. declare module BABYLON {
  57731. /**
  57732. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57733. */
  57734. export class TransformBlock extends NodeMaterialBlock {
  57735. /**
  57736. * Defines the value to use to complement W value to transform it to a Vector4
  57737. */
  57738. complementW: number;
  57739. /**
  57740. * Defines the value to use to complement z value to transform it to a Vector4
  57741. */
  57742. complementZ: number;
  57743. /**
  57744. * Creates a new TransformBlock
  57745. * @param name defines the block name
  57746. */
  57747. constructor(name: string);
  57748. /**
  57749. * Gets the current class name
  57750. * @returns the class name
  57751. */
  57752. getClassName(): string;
  57753. /**
  57754. * Gets the vector input
  57755. */
  57756. get vector(): NodeMaterialConnectionPoint;
  57757. /**
  57758. * Gets the output component
  57759. */
  57760. get output(): NodeMaterialConnectionPoint;
  57761. /**
  57762. * Gets the xyz output component
  57763. */
  57764. get xyz(): NodeMaterialConnectionPoint;
  57765. /**
  57766. * Gets the matrix transform input
  57767. */
  57768. get transform(): NodeMaterialConnectionPoint;
  57769. protected _buildBlock(state: NodeMaterialBuildState): this;
  57770. serialize(): any;
  57771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57772. protected _dumpPropertiesCode(): string;
  57773. }
  57774. }
  57775. declare module BABYLON {
  57776. /**
  57777. * Block used to output the vertex position
  57778. */
  57779. export class VertexOutputBlock extends NodeMaterialBlock {
  57780. /**
  57781. * Creates a new VertexOutputBlock
  57782. * @param name defines the block name
  57783. */
  57784. constructor(name: string);
  57785. /**
  57786. * Gets the current class name
  57787. * @returns the class name
  57788. */
  57789. getClassName(): string;
  57790. /**
  57791. * Gets the vector input component
  57792. */
  57793. get vector(): NodeMaterialConnectionPoint;
  57794. protected _buildBlock(state: NodeMaterialBuildState): this;
  57795. }
  57796. }
  57797. declare module BABYLON {
  57798. /**
  57799. * Block used to output the final color
  57800. */
  57801. export class FragmentOutputBlock extends NodeMaterialBlock {
  57802. /**
  57803. * Create a new FragmentOutputBlock
  57804. * @param name defines the block name
  57805. */
  57806. constructor(name: string);
  57807. /**
  57808. * Gets the current class name
  57809. * @returns the class name
  57810. */
  57811. getClassName(): string;
  57812. /**
  57813. * Gets the rgba input component
  57814. */
  57815. get rgba(): NodeMaterialConnectionPoint;
  57816. /**
  57817. * Gets the rgb input component
  57818. */
  57819. get rgb(): NodeMaterialConnectionPoint;
  57820. /**
  57821. * Gets the a input component
  57822. */
  57823. get a(): NodeMaterialConnectionPoint;
  57824. protected _buildBlock(state: NodeMaterialBuildState): this;
  57825. }
  57826. }
  57827. declare module BABYLON {
  57828. /**
  57829. * Base block used to read a reflection texture from a sampler
  57830. */
  57831. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  57832. /** @hidden */
  57833. _define3DName: string;
  57834. /** @hidden */
  57835. _defineCubicName: string;
  57836. /** @hidden */
  57837. _defineExplicitName: string;
  57838. /** @hidden */
  57839. _defineProjectionName: string;
  57840. /** @hidden */
  57841. _defineLocalCubicName: string;
  57842. /** @hidden */
  57843. _defineSphericalName: string;
  57844. /** @hidden */
  57845. _definePlanarName: string;
  57846. /** @hidden */
  57847. _defineEquirectangularName: string;
  57848. /** @hidden */
  57849. _defineMirroredEquirectangularFixedName: string;
  57850. /** @hidden */
  57851. _defineEquirectangularFixedName: string;
  57852. /** @hidden */
  57853. _defineSkyboxName: string;
  57854. /** @hidden */
  57855. _defineOppositeZ: string;
  57856. /** @hidden */
  57857. _cubeSamplerName: string;
  57858. /** @hidden */
  57859. _2DSamplerName: string;
  57860. protected _positionUVWName: string;
  57861. protected _directionWName: string;
  57862. protected _reflectionVectorName: string;
  57863. /** @hidden */
  57864. _reflectionCoordsName: string;
  57865. /** @hidden */
  57866. _reflectionMatrixName: string;
  57867. protected _reflectionColorName: string;
  57868. /**
  57869. * Gets or sets the texture associated with the node
  57870. */
  57871. texture: Nullable<BaseTexture>;
  57872. /**
  57873. * Create a new ReflectionTextureBaseBlock
  57874. * @param name defines the block name
  57875. */
  57876. constructor(name: string);
  57877. /**
  57878. * Gets the current class name
  57879. * @returns the class name
  57880. */
  57881. getClassName(): string;
  57882. /**
  57883. * Gets the world position input component
  57884. */
  57885. abstract get position(): NodeMaterialConnectionPoint;
  57886. /**
  57887. * Gets the world position input component
  57888. */
  57889. abstract get worldPosition(): NodeMaterialConnectionPoint;
  57890. /**
  57891. * Gets the world normal input component
  57892. */
  57893. abstract get worldNormal(): NodeMaterialConnectionPoint;
  57894. /**
  57895. * Gets the world input component
  57896. */
  57897. abstract get world(): NodeMaterialConnectionPoint;
  57898. /**
  57899. * Gets the camera (or eye) position component
  57900. */
  57901. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  57902. /**
  57903. * Gets the view input component
  57904. */
  57905. abstract get view(): NodeMaterialConnectionPoint;
  57906. protected _getTexture(): Nullable<BaseTexture>;
  57907. autoConfigure(material: NodeMaterial): void;
  57908. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57909. isReady(): boolean;
  57910. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57911. /**
  57912. * Gets the code to inject in the vertex shader
  57913. * @param state current state of the node material building
  57914. * @returns the shader code
  57915. */
  57916. handleVertexSide(state: NodeMaterialBuildState): string;
  57917. /**
  57918. * Handles the inits for the fragment code path
  57919. * @param state node material build state
  57920. */
  57921. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  57922. /**
  57923. * Generates the reflection coords code for the fragment code path
  57924. * @param worldNormalVarName name of the world normal variable
  57925. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  57926. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  57927. * @returns the shader code
  57928. */
  57929. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  57930. /**
  57931. * Generates the reflection color code for the fragment code path
  57932. * @param lodVarName name of the lod variable
  57933. * @param swizzleLookupTexture swizzle to use for the final color variable
  57934. * @returns the shader code
  57935. */
  57936. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  57937. /**
  57938. * Generates the code corresponding to the connected output points
  57939. * @param state node material build state
  57940. * @param varName name of the variable to output
  57941. * @returns the shader code
  57942. */
  57943. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  57944. protected _buildBlock(state: NodeMaterialBuildState): this;
  57945. protected _dumpPropertiesCode(): string;
  57946. serialize(): any;
  57947. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57948. }
  57949. }
  57950. declare module BABYLON {
  57951. /**
  57952. * Defines a connection point to be used for points with a custom object type
  57953. */
  57954. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  57955. private _blockType;
  57956. private _blockName;
  57957. private _nameForCheking?;
  57958. /**
  57959. * Creates a new connection point
  57960. * @param name defines the connection point name
  57961. * @param ownerBlock defines the block hosting this connection point
  57962. * @param direction defines the direction of the connection point
  57963. */
  57964. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  57965. /**
  57966. * Gets a number indicating if the current point can be connected to another point
  57967. * @param connectionPoint defines the other connection point
  57968. * @returns a number defining the compatibility state
  57969. */
  57970. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  57971. /**
  57972. * Creates a block suitable to be used as an input for this input point.
  57973. * If null is returned, a block based on the point type will be created.
  57974. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  57975. */
  57976. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  57977. }
  57978. }
  57979. declare module BABYLON {
  57980. /**
  57981. * Enum defining the type of properties that can be edited in the property pages in the NME
  57982. */
  57983. export enum PropertyTypeForEdition {
  57984. /** property is a boolean */
  57985. Boolean = 0,
  57986. /** property is a float */
  57987. Float = 1,
  57988. /** property is a Vector2 */
  57989. Vector2 = 2,
  57990. /** property is a list of values */
  57991. List = 3
  57992. }
  57993. /**
  57994. * Interface that defines an option in a variable of type list
  57995. */
  57996. export interface IEditablePropertyListOption {
  57997. /** label of the option */
  57998. "label": string;
  57999. /** value of the option */
  58000. "value": number;
  58001. }
  58002. /**
  58003. * Interface that defines the options available for an editable property
  58004. */
  58005. export interface IEditablePropertyOption {
  58006. /** min value */
  58007. "min"?: number;
  58008. /** max value */
  58009. "max"?: number;
  58010. /** notifiers: indicates which actions to take when the property is changed */
  58011. "notifiers"?: {
  58012. /** the material should be rebuilt */
  58013. "rebuild"?: boolean;
  58014. /** the preview should be updated */
  58015. "update"?: boolean;
  58016. };
  58017. /** list of the options for a variable of type list */
  58018. "options"?: IEditablePropertyListOption[];
  58019. }
  58020. /**
  58021. * Interface that describes an editable property
  58022. */
  58023. export interface IPropertyDescriptionForEdition {
  58024. /** name of the property */
  58025. "propertyName": string;
  58026. /** display name of the property */
  58027. "displayName": string;
  58028. /** type of the property */
  58029. "type": PropertyTypeForEdition;
  58030. /** group of the property - all properties with the same group value will be displayed in a specific section */
  58031. "groupName": string;
  58032. /** options for the property */
  58033. "options": IEditablePropertyOption;
  58034. }
  58035. /**
  58036. * Decorator that flags a property in a node material block as being editable
  58037. */
  58038. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  58039. }
  58040. declare module BABYLON {
  58041. /**
  58042. * Block used to implement the refraction part of the sub surface module of the PBR material
  58043. */
  58044. export class RefractionBlock extends NodeMaterialBlock {
  58045. /** @hidden */
  58046. _define3DName: string;
  58047. /** @hidden */
  58048. _refractionMatrixName: string;
  58049. /** @hidden */
  58050. _defineLODRefractionAlpha: string;
  58051. /** @hidden */
  58052. _defineLinearSpecularRefraction: string;
  58053. /** @hidden */
  58054. _defineOppositeZ: string;
  58055. /** @hidden */
  58056. _cubeSamplerName: string;
  58057. /** @hidden */
  58058. _2DSamplerName: string;
  58059. /** @hidden */
  58060. _vRefractionMicrosurfaceInfosName: string;
  58061. /** @hidden */
  58062. _vRefractionInfosName: string;
  58063. private _scene;
  58064. /**
  58065. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58066. * Materials half opaque for instance using refraction could benefit from this control.
  58067. */
  58068. linkRefractionWithTransparency: boolean;
  58069. /**
  58070. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58071. */
  58072. invertRefractionY: boolean;
  58073. /**
  58074. * Gets or sets the texture associated with the node
  58075. */
  58076. texture: Nullable<BaseTexture>;
  58077. /**
  58078. * Create a new RefractionBlock
  58079. * @param name defines the block name
  58080. */
  58081. constructor(name: string);
  58082. /**
  58083. * Gets the current class name
  58084. * @returns the class name
  58085. */
  58086. getClassName(): string;
  58087. /**
  58088. * Gets the intensity input component
  58089. */
  58090. get intensity(): NodeMaterialConnectionPoint;
  58091. /**
  58092. * Gets the index of refraction input component
  58093. */
  58094. get indexOfRefraction(): NodeMaterialConnectionPoint;
  58095. /**
  58096. * Gets the tint at distance input component
  58097. */
  58098. get tintAtDistance(): NodeMaterialConnectionPoint;
  58099. /**
  58100. * Gets the view input component
  58101. */
  58102. get view(): NodeMaterialConnectionPoint;
  58103. /**
  58104. * Gets the refraction object output component
  58105. */
  58106. get refraction(): NodeMaterialConnectionPoint;
  58107. /**
  58108. * Returns true if the block has a texture
  58109. */
  58110. get hasTexture(): boolean;
  58111. protected _getTexture(): Nullable<BaseTexture>;
  58112. autoConfigure(material: NodeMaterial): void;
  58113. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58114. isReady(): boolean;
  58115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  58116. /**
  58117. * Gets the main code of the block (fragment side)
  58118. * @param state current state of the node material building
  58119. * @returns the shader code
  58120. */
  58121. getCode(state: NodeMaterialBuildState): string;
  58122. protected _buildBlock(state: NodeMaterialBuildState): this;
  58123. protected _dumpPropertiesCode(): string;
  58124. serialize(): any;
  58125. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58126. }
  58127. }
  58128. declare module BABYLON {
  58129. /**
  58130. * Base block used as input for post process
  58131. */
  58132. export class CurrentScreenBlock extends NodeMaterialBlock {
  58133. private _samplerName;
  58134. private _linearDefineName;
  58135. private _gammaDefineName;
  58136. private _mainUVName;
  58137. private _tempTextureRead;
  58138. /**
  58139. * Gets or sets the texture associated with the node
  58140. */
  58141. texture: Nullable<BaseTexture>;
  58142. /**
  58143. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58144. */
  58145. convertToGammaSpace: boolean;
  58146. /**
  58147. * Gets or sets a boolean indicating if content needs to be converted to linear space
  58148. */
  58149. convertToLinearSpace: boolean;
  58150. /**
  58151. * Create a new CurrentScreenBlock
  58152. * @param name defines the block name
  58153. */
  58154. constructor(name: string);
  58155. /**
  58156. * Gets the current class name
  58157. * @returns the class name
  58158. */
  58159. getClassName(): string;
  58160. /**
  58161. * Gets the uv input component
  58162. */
  58163. get uv(): NodeMaterialConnectionPoint;
  58164. /**
  58165. * Gets the rgba output component
  58166. */
  58167. get rgba(): NodeMaterialConnectionPoint;
  58168. /**
  58169. * Gets the rgb output component
  58170. */
  58171. get rgb(): NodeMaterialConnectionPoint;
  58172. /**
  58173. * Gets the r output component
  58174. */
  58175. get r(): NodeMaterialConnectionPoint;
  58176. /**
  58177. * Gets the g output component
  58178. */
  58179. get g(): NodeMaterialConnectionPoint;
  58180. /**
  58181. * Gets the b output component
  58182. */
  58183. get b(): NodeMaterialConnectionPoint;
  58184. /**
  58185. * Gets the a output component
  58186. */
  58187. get a(): NodeMaterialConnectionPoint;
  58188. /**
  58189. * Initialize the block and prepare the context for build
  58190. * @param state defines the state that will be used for the build
  58191. */
  58192. initialize(state: NodeMaterialBuildState): void;
  58193. get target(): NodeMaterialBlockTargets;
  58194. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58195. isReady(): boolean;
  58196. private _injectVertexCode;
  58197. private _writeTextureRead;
  58198. private _writeOutput;
  58199. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58200. serialize(): any;
  58201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58202. }
  58203. }
  58204. declare module BABYLON {
  58205. /**
  58206. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58207. */
  58208. export class VectorMergerBlock extends NodeMaterialBlock {
  58209. /**
  58210. * Create a new VectorMergerBlock
  58211. * @param name defines the block name
  58212. */
  58213. constructor(name: string);
  58214. /**
  58215. * Gets the current class name
  58216. * @returns the class name
  58217. */
  58218. getClassName(): string;
  58219. /**
  58220. * Gets the xyz component (input)
  58221. */
  58222. get xyzIn(): NodeMaterialConnectionPoint;
  58223. /**
  58224. * Gets the xy component (input)
  58225. */
  58226. get xyIn(): NodeMaterialConnectionPoint;
  58227. /**
  58228. * Gets the x component (input)
  58229. */
  58230. get x(): NodeMaterialConnectionPoint;
  58231. /**
  58232. * Gets the y component (input)
  58233. */
  58234. get y(): NodeMaterialConnectionPoint;
  58235. /**
  58236. * Gets the z component (input)
  58237. */
  58238. get z(): NodeMaterialConnectionPoint;
  58239. /**
  58240. * Gets the w component (input)
  58241. */
  58242. get w(): NodeMaterialConnectionPoint;
  58243. /**
  58244. * Gets the xyzw component (output)
  58245. */
  58246. get xyzw(): NodeMaterialConnectionPoint;
  58247. /**
  58248. * Gets the xyz component (output)
  58249. */
  58250. get xyzOut(): NodeMaterialConnectionPoint;
  58251. /**
  58252. * Gets the xy component (output)
  58253. */
  58254. get xyOut(): NodeMaterialConnectionPoint;
  58255. /**
  58256. * Gets the xy component (output)
  58257. * @deprecated Please use xyOut instead.
  58258. */
  58259. get xy(): NodeMaterialConnectionPoint;
  58260. /**
  58261. * Gets the xyz component (output)
  58262. * @deprecated Please use xyzOut instead.
  58263. */
  58264. get xyz(): NodeMaterialConnectionPoint;
  58265. protected _buildBlock(state: NodeMaterialBuildState): this;
  58266. }
  58267. }
  58268. declare module BABYLON {
  58269. /**
  58270. * Block used to remap a float from a range to a new one
  58271. */
  58272. export class RemapBlock extends NodeMaterialBlock {
  58273. /**
  58274. * Gets or sets the source range
  58275. */
  58276. sourceRange: Vector2;
  58277. /**
  58278. * Gets or sets the target range
  58279. */
  58280. targetRange: Vector2;
  58281. /**
  58282. * Creates a new RemapBlock
  58283. * @param name defines the block name
  58284. */
  58285. constructor(name: string);
  58286. /**
  58287. * Gets the current class name
  58288. * @returns the class name
  58289. */
  58290. getClassName(): string;
  58291. /**
  58292. * Gets the input component
  58293. */
  58294. get input(): NodeMaterialConnectionPoint;
  58295. /**
  58296. * Gets the source min input component
  58297. */
  58298. get sourceMin(): NodeMaterialConnectionPoint;
  58299. /**
  58300. * Gets the source max input component
  58301. */
  58302. get sourceMax(): NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the target min input component
  58305. */
  58306. get targetMin(): NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the target max input component
  58309. */
  58310. get targetMax(): NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the output component
  58313. */
  58314. get output(): NodeMaterialConnectionPoint;
  58315. protected _buildBlock(state: NodeMaterialBuildState): this;
  58316. protected _dumpPropertiesCode(): string;
  58317. serialize(): any;
  58318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58319. }
  58320. }
  58321. declare module BABYLON {
  58322. /**
  58323. * Block used to multiply 2 values
  58324. */
  58325. export class MultiplyBlock extends NodeMaterialBlock {
  58326. /**
  58327. * Creates a new MultiplyBlock
  58328. * @param name defines the block name
  58329. */
  58330. constructor(name: string);
  58331. /**
  58332. * Gets the current class name
  58333. * @returns the class name
  58334. */
  58335. getClassName(): string;
  58336. /**
  58337. * Gets the left operand input component
  58338. */
  58339. get left(): NodeMaterialConnectionPoint;
  58340. /**
  58341. * Gets the right operand input component
  58342. */
  58343. get right(): NodeMaterialConnectionPoint;
  58344. /**
  58345. * Gets the output component
  58346. */
  58347. get output(): NodeMaterialConnectionPoint;
  58348. protected _buildBlock(state: NodeMaterialBuildState): this;
  58349. }
  58350. }
  58351. declare module BABYLON {
  58352. /**
  58353. * Interface used to configure the node material editor
  58354. */
  58355. export interface INodeMaterialEditorOptions {
  58356. /** Define the URl to load node editor script */
  58357. editorURL?: string;
  58358. }
  58359. /** @hidden */
  58360. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  58361. NORMAL: boolean;
  58362. TANGENT: boolean;
  58363. UV1: boolean;
  58364. /** BONES */
  58365. NUM_BONE_INFLUENCERS: number;
  58366. BonesPerMesh: number;
  58367. BONETEXTURE: boolean;
  58368. /** MORPH TARGETS */
  58369. MORPHTARGETS: boolean;
  58370. MORPHTARGETS_NORMAL: boolean;
  58371. MORPHTARGETS_TANGENT: boolean;
  58372. MORPHTARGETS_UV: boolean;
  58373. NUM_MORPH_INFLUENCERS: number;
  58374. /** IMAGE PROCESSING */
  58375. IMAGEPROCESSING: boolean;
  58376. VIGNETTE: boolean;
  58377. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58378. VIGNETTEBLENDMODEOPAQUE: boolean;
  58379. TONEMAPPING: boolean;
  58380. TONEMAPPING_ACES: boolean;
  58381. CONTRAST: boolean;
  58382. EXPOSURE: boolean;
  58383. COLORCURVES: boolean;
  58384. COLORGRADING: boolean;
  58385. COLORGRADING3D: boolean;
  58386. SAMPLER3DGREENDEPTH: boolean;
  58387. SAMPLER3DBGRMAP: boolean;
  58388. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58389. /** MISC. */
  58390. BUMPDIRECTUV: number;
  58391. constructor();
  58392. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  58393. }
  58394. /**
  58395. * Class used to configure NodeMaterial
  58396. */
  58397. export interface INodeMaterialOptions {
  58398. /**
  58399. * Defines if blocks should emit comments
  58400. */
  58401. emitComments: boolean;
  58402. }
  58403. /**
  58404. * Class used to create a node based material built by assembling shader blocks
  58405. */
  58406. export class NodeMaterial extends PushMaterial {
  58407. private static _BuildIdGenerator;
  58408. private _options;
  58409. private _vertexCompilationState;
  58410. private _fragmentCompilationState;
  58411. private _sharedData;
  58412. private _buildId;
  58413. private _buildWasSuccessful;
  58414. private _cachedWorldViewMatrix;
  58415. private _cachedWorldViewProjectionMatrix;
  58416. private _optimizers;
  58417. private _animationFrame;
  58418. /** Define the Url to load node editor script */
  58419. static EditorURL: string;
  58420. /** Define the Url to load snippets */
  58421. static SnippetUrl: string;
  58422. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  58423. static IgnoreTexturesAtLoadTime: boolean;
  58424. private BJSNODEMATERIALEDITOR;
  58425. /** Get the inspector from bundle or global */
  58426. private _getGlobalNodeMaterialEditor;
  58427. /**
  58428. * Snippet ID if the material was created from the snippet server
  58429. */
  58430. snippetId: string;
  58431. /**
  58432. * Gets or sets data used by visual editor
  58433. * @see https://nme.babylonjs.com
  58434. */
  58435. editorData: any;
  58436. /**
  58437. * 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)
  58438. */
  58439. ignoreAlpha: boolean;
  58440. /**
  58441. * Defines the maximum number of lights that can be used in the material
  58442. */
  58443. maxSimultaneousLights: number;
  58444. /**
  58445. * Observable raised when the material is built
  58446. */
  58447. onBuildObservable: Observable<NodeMaterial>;
  58448. /**
  58449. * Gets or sets the root nodes of the material vertex shader
  58450. */
  58451. _vertexOutputNodes: NodeMaterialBlock[];
  58452. /**
  58453. * Gets or sets the root nodes of the material fragment (pixel) shader
  58454. */
  58455. _fragmentOutputNodes: NodeMaterialBlock[];
  58456. /** Gets or sets options to control the node material overall behavior */
  58457. get options(): INodeMaterialOptions;
  58458. set options(options: INodeMaterialOptions);
  58459. /**
  58460. * Default configuration related to image processing available in the standard Material.
  58461. */
  58462. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58463. /**
  58464. * Gets the image processing configuration used either in this material.
  58465. */
  58466. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58467. /**
  58468. * Sets the Default image processing configuration used either in the this material.
  58469. *
  58470. * If sets to null, the scene one is in use.
  58471. */
  58472. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58473. /**
  58474. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58475. */
  58476. attachedBlocks: NodeMaterialBlock[];
  58477. /**
  58478. * Specifies the mode of the node material
  58479. * @hidden
  58480. */
  58481. _mode: NodeMaterialModes;
  58482. /**
  58483. * Gets the mode property
  58484. */
  58485. get mode(): NodeMaterialModes;
  58486. /**
  58487. * Create a new node based material
  58488. * @param name defines the material name
  58489. * @param scene defines the hosting scene
  58490. * @param options defines creation option
  58491. */
  58492. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58493. /**
  58494. * Gets the current class name of the material e.g. "NodeMaterial"
  58495. * @returns the class name
  58496. */
  58497. getClassName(): string;
  58498. /**
  58499. * Keep track of the image processing observer to allow dispose and replace.
  58500. */
  58501. private _imageProcessingObserver;
  58502. /**
  58503. * Attaches a new image processing configuration to the Standard Material.
  58504. * @param configuration
  58505. */
  58506. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58507. /**
  58508. * Get a block by its name
  58509. * @param name defines the name of the block to retrieve
  58510. * @returns the required block or null if not found
  58511. */
  58512. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58513. /**
  58514. * Get a block by its name
  58515. * @param predicate defines the predicate used to find the good candidate
  58516. * @returns the required block or null if not found
  58517. */
  58518. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58519. /**
  58520. * Get an input block by its name
  58521. * @param predicate defines the predicate used to find the good candidate
  58522. * @returns the required input block or null if not found
  58523. */
  58524. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58525. /**
  58526. * Gets the list of input blocks attached to this material
  58527. * @returns an array of InputBlocks
  58528. */
  58529. getInputBlocks(): InputBlock[];
  58530. /**
  58531. * Adds a new optimizer to the list of optimizers
  58532. * @param optimizer defines the optimizers to add
  58533. * @returns the current material
  58534. */
  58535. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58536. /**
  58537. * Remove an optimizer from the list of optimizers
  58538. * @param optimizer defines the optimizers to remove
  58539. * @returns the current material
  58540. */
  58541. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58542. /**
  58543. * Add a new block to the list of output nodes
  58544. * @param node defines the node to add
  58545. * @returns the current material
  58546. */
  58547. addOutputNode(node: NodeMaterialBlock): this;
  58548. /**
  58549. * Remove a block from the list of root nodes
  58550. * @param node defines the node to remove
  58551. * @returns the current material
  58552. */
  58553. removeOutputNode(node: NodeMaterialBlock): this;
  58554. private _addVertexOutputNode;
  58555. private _removeVertexOutputNode;
  58556. private _addFragmentOutputNode;
  58557. private _removeFragmentOutputNode;
  58558. /**
  58559. * Specifies if the material will require alpha blending
  58560. * @returns a boolean specifying if alpha blending is needed
  58561. */
  58562. needAlphaBlending(): boolean;
  58563. /**
  58564. * Specifies if this material should be rendered in alpha test mode
  58565. * @returns a boolean specifying if an alpha test is needed.
  58566. */
  58567. needAlphaTesting(): boolean;
  58568. private _initializeBlock;
  58569. private _resetDualBlocks;
  58570. /**
  58571. * Remove a block from the current node material
  58572. * @param block defines the block to remove
  58573. */
  58574. removeBlock(block: NodeMaterialBlock): void;
  58575. /**
  58576. * Build the material and generates the inner effect
  58577. * @param verbose defines if the build should log activity
  58578. */
  58579. build(verbose?: boolean): void;
  58580. /**
  58581. * Runs an otpimization phase to try to improve the shader code
  58582. */
  58583. optimize(): void;
  58584. private _prepareDefinesForAttributes;
  58585. /**
  58586. * Create a post process from the material
  58587. * @param camera The camera to apply the render pass to.
  58588. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  58589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58590. * @param engine The engine which the post process will be applied. (default: current engine)
  58591. * @param reusable If the post process can be reused on the same frame. (default: false)
  58592. * @param textureType Type of textures used when performing the post process. (default: 0)
  58593. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  58594. * @returns the post process created
  58595. */
  58596. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  58597. private _processDefines;
  58598. /**
  58599. * Get if the submesh is ready to be used and all its information available.
  58600. * Child classes can use it to update shaders
  58601. * @param mesh defines the mesh to check
  58602. * @param subMesh defines which submesh to check
  58603. * @param useInstances specifies that instances should be used
  58604. * @returns a boolean indicating that the submesh is ready or not
  58605. */
  58606. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58607. /**
  58608. * Get a string representing the shaders built by the current node graph
  58609. */
  58610. get compiledShaders(): string;
  58611. /**
  58612. * Binds the world matrix to the material
  58613. * @param world defines the world transformation matrix
  58614. */
  58615. bindOnlyWorldMatrix(world: Matrix): void;
  58616. /**
  58617. * Binds the submesh to this material by preparing the effect and shader to draw
  58618. * @param world defines the world transformation matrix
  58619. * @param mesh defines the mesh containing the submesh
  58620. * @param subMesh defines the submesh to bind the material to
  58621. */
  58622. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58623. /**
  58624. * Gets the active textures from the material
  58625. * @returns an array of textures
  58626. */
  58627. getActiveTextures(): BaseTexture[];
  58628. /**
  58629. * Gets the list of texture blocks
  58630. * @returns an array of texture blocks
  58631. */
  58632. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock)[];
  58633. /**
  58634. * Specifies if the material uses a texture
  58635. * @param texture defines the texture to check against the material
  58636. * @returns a boolean specifying if the material uses the texture
  58637. */
  58638. hasTexture(texture: BaseTexture): boolean;
  58639. /**
  58640. * Disposes the material
  58641. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58642. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58643. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58644. */
  58645. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58646. /** Creates the node editor window. */
  58647. private _createNodeEditor;
  58648. /**
  58649. * Launch the node material editor
  58650. * @param config Define the configuration of the editor
  58651. * @return a promise fulfilled when the node editor is visible
  58652. */
  58653. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58654. /**
  58655. * Clear the current material
  58656. */
  58657. clear(): void;
  58658. /**
  58659. * Clear the current material and set it to a default state
  58660. */
  58661. setToDefault(): void;
  58662. /**
  58663. * Clear the current material and set it to a default state for post process
  58664. */
  58665. setToDefaultPostProcess(): void;
  58666. /**
  58667. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58668. * @param url defines the url to load from
  58669. * @returns a promise that will fullfil when the material is fully loaded
  58670. */
  58671. loadAsync(url: string): Promise<void>;
  58672. private _gatherBlocks;
  58673. /**
  58674. * Generate a string containing the code declaration required to create an equivalent of this material
  58675. * @returns a string
  58676. */
  58677. generateCode(): string;
  58678. /**
  58679. * Serializes this material in a JSON representation
  58680. * @returns the serialized material object
  58681. */
  58682. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58683. private _restoreConnections;
  58684. /**
  58685. * Clear the current graph and load a new one from a serialization object
  58686. * @param source defines the JSON representation of the material
  58687. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58688. */
  58689. loadFromSerialization(source: any, rootUrl?: string): void;
  58690. /**
  58691. * Makes a duplicate of the current material.
  58692. * @param name - name to use for the new material.
  58693. */
  58694. clone(name: string): NodeMaterial;
  58695. /**
  58696. * Creates a node material from parsed material data
  58697. * @param source defines the JSON representation of the material
  58698. * @param scene defines the hosting scene
  58699. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58700. * @returns a new node material
  58701. */
  58702. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58703. /**
  58704. * Creates a node material from a snippet saved in a remote file
  58705. * @param name defines the name of the material to create
  58706. * @param url defines the url to load from
  58707. * @param scene defines the hosting scene
  58708. * @returns a promise that will resolve to the new node material
  58709. */
  58710. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  58711. /**
  58712. * Creates a node material from a snippet saved by the node material editor
  58713. * @param snippetId defines the snippet to load
  58714. * @param scene defines the hosting scene
  58715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58716. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  58717. * @returns a promise that will resolve to the new node material
  58718. */
  58719. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  58720. /**
  58721. * Creates a new node material set to default basic configuration
  58722. * @param name defines the name of the material
  58723. * @param scene defines the hosting scene
  58724. * @returns a new NodeMaterial
  58725. */
  58726. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58727. }
  58728. }
  58729. declare module BABYLON {
  58730. /**
  58731. * Block used to read a texture from a sampler
  58732. */
  58733. export class TextureBlock extends NodeMaterialBlock {
  58734. private _defineName;
  58735. private _linearDefineName;
  58736. private _gammaDefineName;
  58737. private _tempTextureRead;
  58738. private _samplerName;
  58739. private _transformedUVName;
  58740. private _textureTransformName;
  58741. private _textureInfoName;
  58742. private _mainUVName;
  58743. private _mainUVDefineName;
  58744. /**
  58745. * Gets or sets the texture associated with the node
  58746. */
  58747. texture: Nullable<Texture>;
  58748. /**
  58749. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  58750. */
  58751. convertToGammaSpace: boolean;
  58752. /**
  58753. * Gets or sets a boolean indicating if content needs to be converted to linear space
  58754. */
  58755. convertToLinearSpace: boolean;
  58756. /**
  58757. * Create a new TextureBlock
  58758. * @param name defines the block name
  58759. */
  58760. constructor(name: string);
  58761. /**
  58762. * Gets the current class name
  58763. * @returns the class name
  58764. */
  58765. getClassName(): string;
  58766. /**
  58767. * Gets the uv input component
  58768. */
  58769. get uv(): NodeMaterialConnectionPoint;
  58770. /**
  58771. * Gets the rgba output component
  58772. */
  58773. get rgba(): NodeMaterialConnectionPoint;
  58774. /**
  58775. * Gets the rgb output component
  58776. */
  58777. get rgb(): NodeMaterialConnectionPoint;
  58778. /**
  58779. * Gets the r output component
  58780. */
  58781. get r(): NodeMaterialConnectionPoint;
  58782. /**
  58783. * Gets the g output component
  58784. */
  58785. get g(): NodeMaterialConnectionPoint;
  58786. /**
  58787. * Gets the b output component
  58788. */
  58789. get b(): NodeMaterialConnectionPoint;
  58790. /**
  58791. * Gets the a output component
  58792. */
  58793. get a(): NodeMaterialConnectionPoint;
  58794. get target(): NodeMaterialBlockTargets;
  58795. autoConfigure(material: NodeMaterial): void;
  58796. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58798. isReady(): boolean;
  58799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58800. private get _isMixed();
  58801. private _injectVertexCode;
  58802. private _writeTextureRead;
  58803. private _writeOutput;
  58804. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58805. protected _dumpPropertiesCode(): string;
  58806. serialize(): any;
  58807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58808. }
  58809. }
  58810. declare module BABYLON {
  58811. /**
  58812. * Class used to store shared data between 2 NodeMaterialBuildState
  58813. */
  58814. export class NodeMaterialBuildStateSharedData {
  58815. /**
  58816. * Gets the list of emitted varyings
  58817. */
  58818. temps: string[];
  58819. /**
  58820. * Gets the list of emitted varyings
  58821. */
  58822. varyings: string[];
  58823. /**
  58824. * Gets the varying declaration string
  58825. */
  58826. varyingDeclaration: string;
  58827. /**
  58828. * Input blocks
  58829. */
  58830. inputBlocks: InputBlock[];
  58831. /**
  58832. * Input blocks
  58833. */
  58834. textureBlocks: (ReflectionTextureBaseBlock | TextureBlock | RefractionBlock | CurrentScreenBlock)[];
  58835. /**
  58836. * Bindable blocks (Blocks that need to set data to the effect)
  58837. */
  58838. bindableBlocks: NodeMaterialBlock[];
  58839. /**
  58840. * List of blocks that can provide a compilation fallback
  58841. */
  58842. blocksWithFallbacks: NodeMaterialBlock[];
  58843. /**
  58844. * List of blocks that can provide a define update
  58845. */
  58846. blocksWithDefines: NodeMaterialBlock[];
  58847. /**
  58848. * List of blocks that can provide a repeatable content
  58849. */
  58850. repeatableContentBlocks: NodeMaterialBlock[];
  58851. /**
  58852. * List of blocks that can provide a dynamic list of uniforms
  58853. */
  58854. dynamicUniformBlocks: NodeMaterialBlock[];
  58855. /**
  58856. * List of blocks that can block the isReady function for the material
  58857. */
  58858. blockingBlocks: NodeMaterialBlock[];
  58859. /**
  58860. * Gets the list of animated inputs
  58861. */
  58862. animatedInputs: InputBlock[];
  58863. /**
  58864. * Build Id used to avoid multiple recompilations
  58865. */
  58866. buildId: number;
  58867. /** List of emitted variables */
  58868. variableNames: {
  58869. [key: string]: number;
  58870. };
  58871. /** List of emitted defines */
  58872. defineNames: {
  58873. [key: string]: number;
  58874. };
  58875. /** Should emit comments? */
  58876. emitComments: boolean;
  58877. /** Emit build activity */
  58878. verbose: boolean;
  58879. /** Gets or sets the hosting scene */
  58880. scene: Scene;
  58881. /**
  58882. * Gets the compilation hints emitted at compilation time
  58883. */
  58884. hints: {
  58885. needWorldViewMatrix: boolean;
  58886. needWorldViewProjectionMatrix: boolean;
  58887. needAlphaBlending: boolean;
  58888. needAlphaTesting: boolean;
  58889. };
  58890. /**
  58891. * List of compilation checks
  58892. */
  58893. checks: {
  58894. emitVertex: boolean;
  58895. emitFragment: boolean;
  58896. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58897. };
  58898. /** Creates a new shared data */
  58899. constructor();
  58900. /**
  58901. * Emits console errors and exceptions if there is a failing check
  58902. */
  58903. emitErrors(): void;
  58904. }
  58905. }
  58906. declare module BABYLON {
  58907. /**
  58908. * Class used to store node based material build state
  58909. */
  58910. export class NodeMaterialBuildState {
  58911. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58912. supportUniformBuffers: boolean;
  58913. /**
  58914. * Gets the list of emitted attributes
  58915. */
  58916. attributes: string[];
  58917. /**
  58918. * Gets the list of emitted uniforms
  58919. */
  58920. uniforms: string[];
  58921. /**
  58922. * Gets the list of emitted constants
  58923. */
  58924. constants: string[];
  58925. /**
  58926. * Gets the list of emitted samplers
  58927. */
  58928. samplers: string[];
  58929. /**
  58930. * Gets the list of emitted functions
  58931. */
  58932. functions: {
  58933. [key: string]: string;
  58934. };
  58935. /**
  58936. * Gets the list of emitted extensions
  58937. */
  58938. extensions: {
  58939. [key: string]: string;
  58940. };
  58941. /**
  58942. * Gets the target of the compilation state
  58943. */
  58944. target: NodeMaterialBlockTargets;
  58945. /**
  58946. * Gets the list of emitted counters
  58947. */
  58948. counters: {
  58949. [key: string]: number;
  58950. };
  58951. /**
  58952. * Shared data between multiple NodeMaterialBuildState instances
  58953. */
  58954. sharedData: NodeMaterialBuildStateSharedData;
  58955. /** @hidden */
  58956. _vertexState: NodeMaterialBuildState;
  58957. /** @hidden */
  58958. _attributeDeclaration: string;
  58959. /** @hidden */
  58960. _uniformDeclaration: string;
  58961. /** @hidden */
  58962. _constantDeclaration: string;
  58963. /** @hidden */
  58964. _samplerDeclaration: string;
  58965. /** @hidden */
  58966. _varyingTransfer: string;
  58967. /** @hidden */
  58968. _injectAtEnd: string;
  58969. private _repeatableContentAnchorIndex;
  58970. /** @hidden */
  58971. _builtCompilationString: string;
  58972. /**
  58973. * Gets the emitted compilation strings
  58974. */
  58975. compilationString: string;
  58976. /**
  58977. * Finalize the compilation strings
  58978. * @param state defines the current compilation state
  58979. */
  58980. finalize(state: NodeMaterialBuildState): void;
  58981. /** @hidden */
  58982. get _repeatableContentAnchor(): string;
  58983. /** @hidden */
  58984. _getFreeVariableName(prefix: string): string;
  58985. /** @hidden */
  58986. _getFreeDefineName(prefix: string): string;
  58987. /** @hidden */
  58988. _excludeVariableName(name: string): void;
  58989. /** @hidden */
  58990. _emit2DSampler(name: string): void;
  58991. /** @hidden */
  58992. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58993. /** @hidden */
  58994. _emitExtension(name: string, extension: string, define?: string): void;
  58995. /** @hidden */
  58996. _emitFunction(name: string, code: string, comments: string): void;
  58997. /** @hidden */
  58998. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58999. replaceStrings?: {
  59000. search: RegExp;
  59001. replace: string;
  59002. }[];
  59003. repeatKey?: string;
  59004. }): string;
  59005. /** @hidden */
  59006. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  59007. repeatKey?: string;
  59008. removeAttributes?: boolean;
  59009. removeUniforms?: boolean;
  59010. removeVaryings?: boolean;
  59011. removeIfDef?: boolean;
  59012. replaceStrings?: {
  59013. search: RegExp;
  59014. replace: string;
  59015. }[];
  59016. }, storeKey?: string): void;
  59017. /** @hidden */
  59018. _registerTempVariable(name: string): boolean;
  59019. /** @hidden */
  59020. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  59021. /** @hidden */
  59022. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  59023. /** @hidden */
  59024. _emitFloat(value: number): string;
  59025. }
  59026. }
  59027. declare module BABYLON {
  59028. /**
  59029. * Defines a block that can be used inside a node based material
  59030. */
  59031. export class NodeMaterialBlock {
  59032. private _buildId;
  59033. private _buildTarget;
  59034. private _target;
  59035. private _isFinalMerger;
  59036. private _isInput;
  59037. protected _isUnique: boolean;
  59038. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  59039. inputsAreExclusive: boolean;
  59040. /** @hidden */
  59041. _codeVariableName: string;
  59042. /** @hidden */
  59043. _inputs: NodeMaterialConnectionPoint[];
  59044. /** @hidden */
  59045. _outputs: NodeMaterialConnectionPoint[];
  59046. /** @hidden */
  59047. _preparationId: number;
  59048. /**
  59049. * Gets or sets the name of the block
  59050. */
  59051. name: string;
  59052. /**
  59053. * Gets or sets the unique id of the node
  59054. */
  59055. uniqueId: number;
  59056. /**
  59057. * Gets or sets the comments associated with this block
  59058. */
  59059. comments: string;
  59060. /**
  59061. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  59062. */
  59063. get isUnique(): boolean;
  59064. /**
  59065. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  59066. */
  59067. get isFinalMerger(): boolean;
  59068. /**
  59069. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59070. */
  59071. get isInput(): boolean;
  59072. /**
  59073. * Gets or sets the build Id
  59074. */
  59075. get buildId(): number;
  59076. set buildId(value: number);
  59077. /**
  59078. * Gets or sets the target of the block
  59079. */
  59080. get target(): NodeMaterialBlockTargets;
  59081. set target(value: NodeMaterialBlockTargets);
  59082. /**
  59083. * Gets the list of input points
  59084. */
  59085. get inputs(): NodeMaterialConnectionPoint[];
  59086. /** Gets the list of output points */
  59087. get outputs(): NodeMaterialConnectionPoint[];
  59088. /**
  59089. * Find an input by its name
  59090. * @param name defines the name of the input to look for
  59091. * @returns the input or null if not found
  59092. */
  59093. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59094. /**
  59095. * Find an output by its name
  59096. * @param name defines the name of the outputto look for
  59097. * @returns the output or null if not found
  59098. */
  59099. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59100. /**
  59101. * Creates a new NodeMaterialBlock
  59102. * @param name defines the block name
  59103. * @param target defines the target of that block (Vertex by default)
  59104. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  59105. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59106. */
  59107. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  59108. /**
  59109. * Initialize the block and prepare the context for build
  59110. * @param state defines the state that will be used for the build
  59111. */
  59112. initialize(state: NodeMaterialBuildState): void;
  59113. /**
  59114. * Bind data to effect. Will only be called for blocks with isBindable === true
  59115. * @param effect defines the effect to bind data to
  59116. * @param nodeMaterial defines the hosting NodeMaterial
  59117. * @param mesh defines the mesh that will be rendered
  59118. * @param subMesh defines the submesh that will be rendered
  59119. */
  59120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  59121. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  59122. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  59123. protected _writeFloat(value: number): string;
  59124. /**
  59125. * Gets the current class name e.g. "NodeMaterialBlock"
  59126. * @returns the class name
  59127. */
  59128. getClassName(): string;
  59129. /**
  59130. * Register a new input. Must be called inside a block constructor
  59131. * @param name defines the connection point name
  59132. * @param type defines the connection point type
  59133. * @param isOptional defines a boolean indicating that this input can be omitted
  59134. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59135. * @param point an already created connection point. If not provided, create a new one
  59136. * @returns the current block
  59137. */
  59138. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  59139. /**
  59140. * Register a new output. Must be called inside a block constructor
  59141. * @param name defines the connection point name
  59142. * @param type defines the connection point type
  59143. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59144. * @param point an already created connection point. If not provided, create a new one
  59145. * @returns the current block
  59146. */
  59147. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  59148. /**
  59149. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  59150. * @param forOutput defines an optional connection point to check compatibility with
  59151. * @returns the first available input or null
  59152. */
  59153. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  59154. /**
  59155. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  59156. * @param forBlock defines an optional block to check compatibility with
  59157. * @returns the first available input or null
  59158. */
  59159. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  59160. /**
  59161. * Gets the sibling of the given output
  59162. * @param current defines the current output
  59163. * @returns the next output in the list or null
  59164. */
  59165. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  59166. /**
  59167. * Connect current block with another block
  59168. * @param other defines the block to connect with
  59169. * @param options define the various options to help pick the right connections
  59170. * @returns the current block
  59171. */
  59172. connectTo(other: NodeMaterialBlock, options?: {
  59173. input?: string;
  59174. output?: string;
  59175. outputSwizzle?: string;
  59176. }): this | undefined;
  59177. protected _buildBlock(state: NodeMaterialBuildState): void;
  59178. /**
  59179. * Add uniforms, samplers and uniform buffers at compilation time
  59180. * @param state defines the state to update
  59181. * @param nodeMaterial defines the node material requesting the update
  59182. * @param defines defines the material defines to update
  59183. * @param uniformBuffers defines the list of uniform buffer names
  59184. */
  59185. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59186. /**
  59187. * Add potential fallbacks if shader compilation fails
  59188. * @param mesh defines the mesh to be rendered
  59189. * @param fallbacks defines the current prioritized list of fallbacks
  59190. */
  59191. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59192. /**
  59193. * Initialize defines for shader compilation
  59194. * @param mesh defines the mesh to be rendered
  59195. * @param nodeMaterial defines the node material requesting the update
  59196. * @param defines defines the material defines to update
  59197. * @param useInstances specifies that instances should be used
  59198. */
  59199. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59200. /**
  59201. * Update defines for shader compilation
  59202. * @param mesh defines the mesh to be rendered
  59203. * @param nodeMaterial defines the node material requesting the update
  59204. * @param defines defines the material defines to update
  59205. * @param useInstances specifies that instances should be used
  59206. */
  59207. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59208. /**
  59209. * Lets the block try to connect some inputs automatically
  59210. * @param material defines the hosting NodeMaterial
  59211. */
  59212. autoConfigure(material: NodeMaterial): void;
  59213. /**
  59214. * Function called when a block is declared as repeatable content generator
  59215. * @param vertexShaderState defines the current compilation state for the vertex shader
  59216. * @param fragmentShaderState defines the current compilation state for the fragment shader
  59217. * @param mesh defines the mesh to be rendered
  59218. * @param defines defines the material defines to update
  59219. */
  59220. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59221. /**
  59222. * Checks if the block is ready
  59223. * @param mesh defines the mesh to be rendered
  59224. * @param nodeMaterial defines the node material requesting the update
  59225. * @param defines defines the material defines to update
  59226. * @param useInstances specifies that instances should be used
  59227. * @returns true if the block is ready
  59228. */
  59229. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  59230. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  59231. private _processBuild;
  59232. /**
  59233. * Compile the current node and generate the shader code
  59234. * @param state defines the current compilation state (uniforms, samplers, current string)
  59235. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  59236. * @returns true if already built
  59237. */
  59238. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  59239. protected _inputRename(name: string): string;
  59240. protected _outputRename(name: string): string;
  59241. protected _dumpPropertiesCode(): string;
  59242. /** @hidden */
  59243. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  59244. /** @hidden */
  59245. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  59246. /**
  59247. * Clone the current block to a new identical block
  59248. * @param scene defines the hosting scene
  59249. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59250. * @returns a copy of the current block
  59251. */
  59252. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  59253. /**
  59254. * Serializes this block in a JSON representation
  59255. * @returns the serialized block object
  59256. */
  59257. serialize(): any;
  59258. /** @hidden */
  59259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59260. private _deserializePortDisplayNames;
  59261. /**
  59262. * Release resources
  59263. */
  59264. dispose(): void;
  59265. }
  59266. }
  59267. declare module BABYLON {
  59268. /**
  59269. * Enum defining the type of animations supported by InputBlock
  59270. */
  59271. export enum AnimatedInputBlockTypes {
  59272. /** No animation */
  59273. None = 0,
  59274. /** Time based animation. Will only work for floats */
  59275. Time = 1
  59276. }
  59277. }
  59278. declare module BABYLON {
  59279. /**
  59280. * Block used to expose an input value
  59281. */
  59282. export class InputBlock extends NodeMaterialBlock {
  59283. private _mode;
  59284. private _associatedVariableName;
  59285. private _storedValue;
  59286. private _valueCallback;
  59287. private _type;
  59288. private _animationType;
  59289. /** Gets or set a value used to limit the range of float values */
  59290. min: number;
  59291. /** Gets or set a value used to limit the range of float values */
  59292. max: number;
  59293. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  59294. isBoolean: boolean;
  59295. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  59296. matrixMode: number;
  59297. /** @hidden */
  59298. _systemValue: Nullable<NodeMaterialSystemValues>;
  59299. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  59300. visibleInInspector: boolean;
  59301. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  59302. isConstant: boolean;
  59303. /** Gets or sets the group to use to display this block in the Inspector */
  59304. groupInInspector: string;
  59305. /** Gets an observable raised when the value is changed */
  59306. onValueChangedObservable: Observable<InputBlock>;
  59307. /**
  59308. * Gets or sets the connection point type (default is float)
  59309. */
  59310. get type(): NodeMaterialBlockConnectionPointTypes;
  59311. /**
  59312. * Creates a new InputBlock
  59313. * @param name defines the block name
  59314. * @param target defines the target of that block (Vertex by default)
  59315. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  59316. */
  59317. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  59318. /**
  59319. * Gets the output component
  59320. */
  59321. get output(): NodeMaterialConnectionPoint;
  59322. /**
  59323. * Set the source of this connection point to a vertex attribute
  59324. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  59325. * @returns the current connection point
  59326. */
  59327. setAsAttribute(attributeName?: string): InputBlock;
  59328. /**
  59329. * Set the source of this connection point to a system value
  59330. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  59331. * @returns the current connection point
  59332. */
  59333. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  59334. /**
  59335. * Gets or sets the value of that point.
  59336. * Please note that this value will be ignored if valueCallback is defined
  59337. */
  59338. get value(): any;
  59339. set value(value: any);
  59340. /**
  59341. * Gets or sets a callback used to get the value of that point.
  59342. * Please note that setting this value will force the connection point to ignore the value property
  59343. */
  59344. get valueCallback(): () => any;
  59345. set valueCallback(value: () => any);
  59346. /**
  59347. * Gets or sets the associated variable name in the shader
  59348. */
  59349. get associatedVariableName(): string;
  59350. set associatedVariableName(value: string);
  59351. /** Gets or sets the type of animation applied to the input */
  59352. get animationType(): AnimatedInputBlockTypes;
  59353. set animationType(value: AnimatedInputBlockTypes);
  59354. /**
  59355. * Gets a boolean indicating that this connection point not defined yet
  59356. */
  59357. get isUndefined(): boolean;
  59358. /**
  59359. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  59360. * In this case the connection point name must be the name of the uniform to use.
  59361. * Can only be set on inputs
  59362. */
  59363. get isUniform(): boolean;
  59364. set isUniform(value: boolean);
  59365. /**
  59366. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  59367. * In this case the connection point name must be the name of the attribute to use
  59368. * Can only be set on inputs
  59369. */
  59370. get isAttribute(): boolean;
  59371. set isAttribute(value: boolean);
  59372. /**
  59373. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  59374. * Can only be set on exit points
  59375. */
  59376. get isVarying(): boolean;
  59377. set isVarying(value: boolean);
  59378. /**
  59379. * Gets a boolean indicating that the current connection point is a system value
  59380. */
  59381. get isSystemValue(): boolean;
  59382. /**
  59383. * Gets or sets the current well known value or null if not defined as a system value
  59384. */
  59385. get systemValue(): Nullable<NodeMaterialSystemValues>;
  59386. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  59387. /**
  59388. * Gets the current class name
  59389. * @returns the class name
  59390. */
  59391. getClassName(): string;
  59392. /**
  59393. * Animate the input if animationType !== None
  59394. * @param scene defines the rendering scene
  59395. */
  59396. animate(scene: Scene): void;
  59397. private _emitDefine;
  59398. initialize(state: NodeMaterialBuildState): void;
  59399. /**
  59400. * Set the input block to its default value (based on its type)
  59401. */
  59402. setDefaultValue(): void;
  59403. private _emitConstant;
  59404. private _emit;
  59405. /** @hidden */
  59406. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  59407. /** @hidden */
  59408. _transmit(effect: Effect, scene: Scene): void;
  59409. protected _buildBlock(state: NodeMaterialBuildState): void;
  59410. protected _dumpPropertiesCode(): string;
  59411. dispose(): void;
  59412. serialize(): any;
  59413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59414. }
  59415. }
  59416. declare module BABYLON {
  59417. /**
  59418. * Enum used to define the compatibility state between two connection points
  59419. */
  59420. export enum NodeMaterialConnectionPointCompatibilityStates {
  59421. /** Points are compatibles */
  59422. Compatible = 0,
  59423. /** Points are incompatible because of their types */
  59424. TypeIncompatible = 1,
  59425. /** Points are incompatible because of their targets (vertex vs fragment) */
  59426. TargetIncompatible = 2
  59427. }
  59428. /**
  59429. * Defines the direction of a connection point
  59430. */
  59431. export enum NodeMaterialConnectionPointDirection {
  59432. /** Input */
  59433. Input = 0,
  59434. /** Output */
  59435. Output = 1
  59436. }
  59437. /**
  59438. * Defines a connection point for a block
  59439. */
  59440. export class NodeMaterialConnectionPoint {
  59441. /** @hidden */
  59442. _ownerBlock: NodeMaterialBlock;
  59443. /** @hidden */
  59444. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  59445. private _endpoints;
  59446. private _associatedVariableName;
  59447. private _direction;
  59448. /** @hidden */
  59449. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59450. /** @hidden */
  59451. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59452. private _type;
  59453. /** @hidden */
  59454. _enforceAssociatedVariableName: boolean;
  59455. /** Gets the direction of the point */
  59456. get direction(): NodeMaterialConnectionPointDirection;
  59457. /** Indicates that this connection point needs dual validation before being connected to another point */
  59458. needDualDirectionValidation: boolean;
  59459. /**
  59460. * Gets or sets the additional types supported by this connection point
  59461. */
  59462. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59463. /**
  59464. * Gets or sets the additional types excluded by this connection point
  59465. */
  59466. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59467. /**
  59468. * Observable triggered when this point is connected
  59469. */
  59470. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  59471. /**
  59472. * Gets or sets the associated variable name in the shader
  59473. */
  59474. get associatedVariableName(): string;
  59475. set associatedVariableName(value: string);
  59476. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  59477. get innerType(): NodeMaterialBlockConnectionPointTypes;
  59478. /**
  59479. * Gets or sets the connection point type (default is float)
  59480. */
  59481. get type(): NodeMaterialBlockConnectionPointTypes;
  59482. set type(value: NodeMaterialBlockConnectionPointTypes);
  59483. /**
  59484. * Gets or sets the connection point name
  59485. */
  59486. name: string;
  59487. /**
  59488. * Gets or sets the connection point name
  59489. */
  59490. displayName: string;
  59491. /**
  59492. * Gets or sets a boolean indicating that this connection point can be omitted
  59493. */
  59494. isOptional: boolean;
  59495. /**
  59496. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59497. */
  59498. define: string;
  59499. /** @hidden */
  59500. _prioritizeVertex: boolean;
  59501. private _target;
  59502. /** Gets or sets the target of that connection point */
  59503. get target(): NodeMaterialBlockTargets;
  59504. set target(value: NodeMaterialBlockTargets);
  59505. /**
  59506. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  59507. */
  59508. get isConnected(): boolean;
  59509. /**
  59510. * Gets a boolean indicating that the current point is connected to an input block
  59511. */
  59512. get isConnectedToInputBlock(): boolean;
  59513. /**
  59514. * Gets a the connected input block (if any)
  59515. */
  59516. get connectInputBlock(): Nullable<InputBlock>;
  59517. /** Get the other side of the connection (if any) */
  59518. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59519. /** Get the block that owns this connection point */
  59520. get ownerBlock(): NodeMaterialBlock;
  59521. /** Get the block connected on the other side of this connection (if any) */
  59522. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59523. /** Get the block connected on the endpoints of this connection (if any) */
  59524. get connectedBlocks(): Array<NodeMaterialBlock>;
  59525. /** Gets the list of connected endpoints */
  59526. get endpoints(): NodeMaterialConnectionPoint[];
  59527. /** Gets a boolean indicating if that output point is connected to at least one input */
  59528. get hasEndpoints(): boolean;
  59529. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59530. get isConnectedInVertexShader(): boolean;
  59531. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59532. get isConnectedInFragmentShader(): boolean;
  59533. /**
  59534. * Creates a block suitable to be used as an input for this input point.
  59535. * If null is returned, a block based on the point type will be created.
  59536. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  59537. */
  59538. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  59539. /**
  59540. * Creates a new connection point
  59541. * @param name defines the connection point name
  59542. * @param ownerBlock defines the block hosting this connection point
  59543. * @param direction defines the direction of the connection point
  59544. */
  59545. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59546. /**
  59547. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59548. * @returns the class name
  59549. */
  59550. getClassName(): string;
  59551. /**
  59552. * Gets a boolean indicating if the current point can be connected to another point
  59553. * @param connectionPoint defines the other connection point
  59554. * @returns a boolean
  59555. */
  59556. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59557. /**
  59558. * Gets a number indicating if the current point can be connected to another point
  59559. * @param connectionPoint defines the other connection point
  59560. * @returns a number defining the compatibility state
  59561. */
  59562. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59563. /**
  59564. * Connect this point to another connection point
  59565. * @param connectionPoint defines the other connection point
  59566. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59567. * @returns the current connection point
  59568. */
  59569. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59570. /**
  59571. * Disconnect this point from one of his endpoint
  59572. * @param endpoint defines the other connection point
  59573. * @returns the current connection point
  59574. */
  59575. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59576. /**
  59577. * Serializes this point in a JSON representation
  59578. * @param isInput defines if the connection point is an input (default is true)
  59579. * @returns the serialized point object
  59580. */
  59581. serialize(isInput?: boolean): any;
  59582. /**
  59583. * Release resources
  59584. */
  59585. dispose(): void;
  59586. }
  59587. }
  59588. declare module BABYLON {
  59589. /**
  59590. * Block used to add support for vertex skinning (bones)
  59591. */
  59592. export class BonesBlock extends NodeMaterialBlock {
  59593. /**
  59594. * Creates a new BonesBlock
  59595. * @param name defines the block name
  59596. */
  59597. constructor(name: string);
  59598. /**
  59599. * Initialize the block and prepare the context for build
  59600. * @param state defines the state that will be used for the build
  59601. */
  59602. initialize(state: NodeMaterialBuildState): void;
  59603. /**
  59604. * Gets the current class name
  59605. * @returns the class name
  59606. */
  59607. getClassName(): string;
  59608. /**
  59609. * Gets the matrix indices input component
  59610. */
  59611. get matricesIndices(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the matrix weights input component
  59614. */
  59615. get matricesWeights(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the extra matrix indices input component
  59618. */
  59619. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the extra matrix weights input component
  59622. */
  59623. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the world input component
  59626. */
  59627. get world(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the output component
  59630. */
  59631. get output(): NodeMaterialConnectionPoint;
  59632. autoConfigure(material: NodeMaterial): void;
  59633. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59634. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59636. protected _buildBlock(state: NodeMaterialBuildState): this;
  59637. }
  59638. }
  59639. declare module BABYLON {
  59640. /**
  59641. * Block used to add support for instances
  59642. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59643. */
  59644. export class InstancesBlock extends NodeMaterialBlock {
  59645. /**
  59646. * Creates a new InstancesBlock
  59647. * @param name defines the block name
  59648. */
  59649. constructor(name: string);
  59650. /**
  59651. * Gets the current class name
  59652. * @returns the class name
  59653. */
  59654. getClassName(): string;
  59655. /**
  59656. * Gets the first world row input component
  59657. */
  59658. get world0(): NodeMaterialConnectionPoint;
  59659. /**
  59660. * Gets the second world row input component
  59661. */
  59662. get world1(): NodeMaterialConnectionPoint;
  59663. /**
  59664. * Gets the third world row input component
  59665. */
  59666. get world2(): NodeMaterialConnectionPoint;
  59667. /**
  59668. * Gets the forth world row input component
  59669. */
  59670. get world3(): NodeMaterialConnectionPoint;
  59671. /**
  59672. * Gets the world input component
  59673. */
  59674. get world(): NodeMaterialConnectionPoint;
  59675. /**
  59676. * Gets the output component
  59677. */
  59678. get output(): NodeMaterialConnectionPoint;
  59679. /**
  59680. * Gets the isntanceID component
  59681. */
  59682. get instanceID(): NodeMaterialConnectionPoint;
  59683. autoConfigure(material: NodeMaterial): void;
  59684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59685. protected _buildBlock(state: NodeMaterialBuildState): this;
  59686. }
  59687. }
  59688. declare module BABYLON {
  59689. /**
  59690. * Block used to add morph targets support to vertex shader
  59691. */
  59692. export class MorphTargetsBlock extends NodeMaterialBlock {
  59693. private _repeatableContentAnchor;
  59694. /**
  59695. * Create a new MorphTargetsBlock
  59696. * @param name defines the block name
  59697. */
  59698. constructor(name: string);
  59699. /**
  59700. * Gets the current class name
  59701. * @returns the class name
  59702. */
  59703. getClassName(): string;
  59704. /**
  59705. * Gets the position input component
  59706. */
  59707. get position(): NodeMaterialConnectionPoint;
  59708. /**
  59709. * Gets the normal input component
  59710. */
  59711. get normal(): NodeMaterialConnectionPoint;
  59712. /**
  59713. * Gets the tangent input component
  59714. */
  59715. get tangent(): NodeMaterialConnectionPoint;
  59716. /**
  59717. * Gets the tangent input component
  59718. */
  59719. get uv(): NodeMaterialConnectionPoint;
  59720. /**
  59721. * Gets the position output component
  59722. */
  59723. get positionOutput(): NodeMaterialConnectionPoint;
  59724. /**
  59725. * Gets the normal output component
  59726. */
  59727. get normalOutput(): NodeMaterialConnectionPoint;
  59728. /**
  59729. * Gets the tangent output component
  59730. */
  59731. get tangentOutput(): NodeMaterialConnectionPoint;
  59732. /**
  59733. * Gets the tangent output component
  59734. */
  59735. get uvOutput(): NodeMaterialConnectionPoint;
  59736. initialize(state: NodeMaterialBuildState): void;
  59737. autoConfigure(material: NodeMaterial): void;
  59738. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59739. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59740. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59741. protected _buildBlock(state: NodeMaterialBuildState): this;
  59742. }
  59743. }
  59744. declare module BABYLON {
  59745. /**
  59746. * Block used to get data information from a light
  59747. */
  59748. export class LightInformationBlock extends NodeMaterialBlock {
  59749. private _lightDataUniformName;
  59750. private _lightColorUniformName;
  59751. private _lightTypeDefineName;
  59752. /**
  59753. * Gets or sets the light associated with this block
  59754. */
  59755. light: Nullable<Light>;
  59756. /**
  59757. * Creates a new LightInformationBlock
  59758. * @param name defines the block name
  59759. */
  59760. constructor(name: string);
  59761. /**
  59762. * Gets the current class name
  59763. * @returns the class name
  59764. */
  59765. getClassName(): string;
  59766. /**
  59767. * Gets the world position input component
  59768. */
  59769. get worldPosition(): NodeMaterialConnectionPoint;
  59770. /**
  59771. * Gets the direction output component
  59772. */
  59773. get direction(): NodeMaterialConnectionPoint;
  59774. /**
  59775. * Gets the direction output component
  59776. */
  59777. get color(): NodeMaterialConnectionPoint;
  59778. /**
  59779. * Gets the direction output component
  59780. */
  59781. get intensity(): NodeMaterialConnectionPoint;
  59782. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59783. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59784. protected _buildBlock(state: NodeMaterialBuildState): this;
  59785. serialize(): any;
  59786. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59787. }
  59788. }
  59789. declare module BABYLON {
  59790. /**
  59791. * Block used to add image processing support to fragment shader
  59792. */
  59793. export class ImageProcessingBlock extends NodeMaterialBlock {
  59794. /**
  59795. * Create a new ImageProcessingBlock
  59796. * @param name defines the block name
  59797. */
  59798. constructor(name: string);
  59799. /**
  59800. * Gets the current class name
  59801. * @returns the class name
  59802. */
  59803. getClassName(): string;
  59804. /**
  59805. * Gets the color input component
  59806. */
  59807. get color(): NodeMaterialConnectionPoint;
  59808. /**
  59809. * Gets the output component
  59810. */
  59811. get output(): NodeMaterialConnectionPoint;
  59812. /**
  59813. * Initialize the block and prepare the context for build
  59814. * @param state defines the state that will be used for the build
  59815. */
  59816. initialize(state: NodeMaterialBuildState): void;
  59817. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  59818. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59819. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59820. protected _buildBlock(state: NodeMaterialBuildState): this;
  59821. }
  59822. }
  59823. declare module BABYLON {
  59824. /**
  59825. * Block used to pertub normals based on a normal map
  59826. */
  59827. export class PerturbNormalBlock extends NodeMaterialBlock {
  59828. private _tangentSpaceParameterName;
  59829. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59830. invertX: boolean;
  59831. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  59832. invertY: boolean;
  59833. /**
  59834. * Create a new PerturbNormalBlock
  59835. * @param name defines the block name
  59836. */
  59837. constructor(name: string);
  59838. /**
  59839. * Gets the current class name
  59840. * @returns the class name
  59841. */
  59842. getClassName(): string;
  59843. /**
  59844. * Gets the world position input component
  59845. */
  59846. get worldPosition(): NodeMaterialConnectionPoint;
  59847. /**
  59848. * Gets the world normal input component
  59849. */
  59850. get worldNormal(): NodeMaterialConnectionPoint;
  59851. /**
  59852. * Gets the world tangent input component
  59853. */
  59854. get worldTangent(): NodeMaterialConnectionPoint;
  59855. /**
  59856. * Gets the uv input component
  59857. */
  59858. get uv(): NodeMaterialConnectionPoint;
  59859. /**
  59860. * Gets the normal map color input component
  59861. */
  59862. get normalMapColor(): NodeMaterialConnectionPoint;
  59863. /**
  59864. * Gets the strength input component
  59865. */
  59866. get strength(): NodeMaterialConnectionPoint;
  59867. /**
  59868. * Gets the output component
  59869. */
  59870. get output(): NodeMaterialConnectionPoint;
  59871. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59872. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59873. autoConfigure(material: NodeMaterial): void;
  59874. protected _buildBlock(state: NodeMaterialBuildState): this;
  59875. protected _dumpPropertiesCode(): string;
  59876. serialize(): any;
  59877. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59878. }
  59879. }
  59880. declare module BABYLON {
  59881. /**
  59882. * Block used to discard a pixel if a value is smaller than a cutoff
  59883. */
  59884. export class DiscardBlock extends NodeMaterialBlock {
  59885. /**
  59886. * Create a new DiscardBlock
  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 color input component
  59897. */
  59898. get value(): NodeMaterialConnectionPoint;
  59899. /**
  59900. * Gets the cutoff input component
  59901. */
  59902. get cutoff(): NodeMaterialConnectionPoint;
  59903. protected _buildBlock(state: NodeMaterialBuildState): this;
  59904. }
  59905. }
  59906. declare module BABYLON {
  59907. /**
  59908. * Block used to test if the fragment shader is front facing
  59909. */
  59910. export class FrontFacingBlock extends NodeMaterialBlock {
  59911. /**
  59912. * Creates a new FrontFacingBlock
  59913. * @param name defines the block name
  59914. */
  59915. constructor(name: string);
  59916. /**
  59917. * Gets the current class name
  59918. * @returns the class name
  59919. */
  59920. getClassName(): string;
  59921. /**
  59922. * Gets the output component
  59923. */
  59924. get output(): NodeMaterialConnectionPoint;
  59925. protected _buildBlock(state: NodeMaterialBuildState): this;
  59926. }
  59927. }
  59928. declare module BABYLON {
  59929. /**
  59930. * Block used to get the derivative value on x and y of a given input
  59931. */
  59932. export class DerivativeBlock extends NodeMaterialBlock {
  59933. /**
  59934. * Create a new DerivativeBlock
  59935. * @param name defines the block name
  59936. */
  59937. constructor(name: string);
  59938. /**
  59939. * Gets the current class name
  59940. * @returns the class name
  59941. */
  59942. getClassName(): string;
  59943. /**
  59944. * Gets the input component
  59945. */
  59946. get input(): NodeMaterialConnectionPoint;
  59947. /**
  59948. * Gets the derivative output on x
  59949. */
  59950. get dx(): NodeMaterialConnectionPoint;
  59951. /**
  59952. * Gets the derivative output on y
  59953. */
  59954. get dy(): NodeMaterialConnectionPoint;
  59955. protected _buildBlock(state: NodeMaterialBuildState): this;
  59956. }
  59957. }
  59958. declare module BABYLON {
  59959. /**
  59960. * Block used to add support for scene fog
  59961. */
  59962. export class FogBlock extends NodeMaterialBlock {
  59963. private _fogDistanceName;
  59964. private _fogParameters;
  59965. /**
  59966. * Create a new FogBlock
  59967. * @param name defines the block name
  59968. */
  59969. constructor(name: string);
  59970. /**
  59971. * Gets the current class name
  59972. * @returns the class name
  59973. */
  59974. getClassName(): string;
  59975. /**
  59976. * Gets the world position input component
  59977. */
  59978. get worldPosition(): NodeMaterialConnectionPoint;
  59979. /**
  59980. * Gets the view input component
  59981. */
  59982. get view(): NodeMaterialConnectionPoint;
  59983. /**
  59984. * Gets the color input component
  59985. */
  59986. get input(): NodeMaterialConnectionPoint;
  59987. /**
  59988. * Gets the fog color input component
  59989. */
  59990. get fogColor(): NodeMaterialConnectionPoint;
  59991. /**
  59992. * Gets the output component
  59993. */
  59994. get output(): NodeMaterialConnectionPoint;
  59995. autoConfigure(material: NodeMaterial): void;
  59996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59998. protected _buildBlock(state: NodeMaterialBuildState): this;
  59999. }
  60000. }
  60001. declare module BABYLON {
  60002. /**
  60003. * Block used to add light in the fragment shader
  60004. */
  60005. export class LightBlock extends NodeMaterialBlock {
  60006. private _lightId;
  60007. /**
  60008. * Gets or sets the light associated with this block
  60009. */
  60010. light: Nullable<Light>;
  60011. /**
  60012. * Create a new LightBlock
  60013. * @param name defines the block name
  60014. */
  60015. constructor(name: string);
  60016. /**
  60017. * Gets the current class name
  60018. * @returns the class name
  60019. */
  60020. getClassName(): string;
  60021. /**
  60022. * Gets the world position input component
  60023. */
  60024. get worldPosition(): NodeMaterialConnectionPoint;
  60025. /**
  60026. * Gets the world normal input component
  60027. */
  60028. get worldNormal(): NodeMaterialConnectionPoint;
  60029. /**
  60030. * Gets the camera (or eye) position component
  60031. */
  60032. get cameraPosition(): NodeMaterialConnectionPoint;
  60033. /**
  60034. * Gets the glossiness component
  60035. */
  60036. get glossiness(): NodeMaterialConnectionPoint;
  60037. /**
  60038. * Gets the glossinness power component
  60039. */
  60040. get glossPower(): NodeMaterialConnectionPoint;
  60041. /**
  60042. * Gets the diffuse color component
  60043. */
  60044. get diffuseColor(): NodeMaterialConnectionPoint;
  60045. /**
  60046. * Gets the specular color component
  60047. */
  60048. get specularColor(): NodeMaterialConnectionPoint;
  60049. /**
  60050. * Gets the diffuse output component
  60051. */
  60052. get diffuseOutput(): NodeMaterialConnectionPoint;
  60053. /**
  60054. * Gets the specular output component
  60055. */
  60056. get specularOutput(): NodeMaterialConnectionPoint;
  60057. /**
  60058. * Gets the shadow output component
  60059. */
  60060. get shadow(): NodeMaterialConnectionPoint;
  60061. autoConfigure(material: NodeMaterial): void;
  60062. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60063. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60064. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60065. private _injectVertexCode;
  60066. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60067. serialize(): any;
  60068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60069. }
  60070. }
  60071. declare module BABYLON {
  60072. /**
  60073. * Block used to read a reflection texture from a sampler
  60074. */
  60075. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  60076. /**
  60077. * Create a new ReflectionTextureBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the world position input component
  60088. */
  60089. get position(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the world position input component
  60092. */
  60093. get worldPosition(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Gets the world normal input component
  60096. */
  60097. get worldNormal(): NodeMaterialConnectionPoint;
  60098. /**
  60099. * Gets the world input component
  60100. */
  60101. get world(): NodeMaterialConnectionPoint;
  60102. /**
  60103. * Gets the camera (or eye) position component
  60104. */
  60105. get cameraPosition(): NodeMaterialConnectionPoint;
  60106. /**
  60107. * Gets the view input component
  60108. */
  60109. get view(): NodeMaterialConnectionPoint;
  60110. /**
  60111. * Gets the rgb output component
  60112. */
  60113. get rgb(): NodeMaterialConnectionPoint;
  60114. /**
  60115. * Gets the r output component
  60116. */
  60117. get r(): NodeMaterialConnectionPoint;
  60118. /**
  60119. * Gets the g output component
  60120. */
  60121. get g(): NodeMaterialConnectionPoint;
  60122. /**
  60123. * Gets the b output component
  60124. */
  60125. get b(): NodeMaterialConnectionPoint;
  60126. autoConfigure(material: NodeMaterial): void;
  60127. protected _buildBlock(state: NodeMaterialBuildState): this;
  60128. }
  60129. }
  60130. declare module BABYLON {
  60131. /**
  60132. * Block used to add 2 vectors
  60133. */
  60134. export class AddBlock extends NodeMaterialBlock {
  60135. /**
  60136. * Creates a new AddBlock
  60137. * @param name defines the block name
  60138. */
  60139. constructor(name: string);
  60140. /**
  60141. * Gets the current class name
  60142. * @returns the class name
  60143. */
  60144. getClassName(): string;
  60145. /**
  60146. * Gets the left operand input component
  60147. */
  60148. get left(): NodeMaterialConnectionPoint;
  60149. /**
  60150. * Gets the right operand input component
  60151. */
  60152. get right(): NodeMaterialConnectionPoint;
  60153. /**
  60154. * Gets the output component
  60155. */
  60156. get output(): NodeMaterialConnectionPoint;
  60157. protected _buildBlock(state: NodeMaterialBuildState): this;
  60158. }
  60159. }
  60160. declare module BABYLON {
  60161. /**
  60162. * Block used to scale a vector by a float
  60163. */
  60164. export class ScaleBlock extends NodeMaterialBlock {
  60165. /**
  60166. * Creates a new ScaleBlock
  60167. * @param name defines the block name
  60168. */
  60169. constructor(name: string);
  60170. /**
  60171. * Gets the current class name
  60172. * @returns the class name
  60173. */
  60174. getClassName(): string;
  60175. /**
  60176. * Gets the input component
  60177. */
  60178. get input(): NodeMaterialConnectionPoint;
  60179. /**
  60180. * Gets the factor input component
  60181. */
  60182. get factor(): NodeMaterialConnectionPoint;
  60183. /**
  60184. * Gets the output component
  60185. */
  60186. get output(): NodeMaterialConnectionPoint;
  60187. protected _buildBlock(state: NodeMaterialBuildState): this;
  60188. }
  60189. }
  60190. declare module BABYLON {
  60191. /**
  60192. * Block used to clamp a float
  60193. */
  60194. export class ClampBlock extends NodeMaterialBlock {
  60195. /** Gets or sets the minimum range */
  60196. minimum: number;
  60197. /** Gets or sets the maximum range */
  60198. maximum: number;
  60199. /**
  60200. * Creates a new ClampBlock
  60201. * @param name defines the block name
  60202. */
  60203. constructor(name: string);
  60204. /**
  60205. * Gets the current class name
  60206. * @returns the class name
  60207. */
  60208. getClassName(): string;
  60209. /**
  60210. * Gets the value input component
  60211. */
  60212. get value(): NodeMaterialConnectionPoint;
  60213. /**
  60214. * Gets the output component
  60215. */
  60216. get output(): NodeMaterialConnectionPoint;
  60217. protected _buildBlock(state: NodeMaterialBuildState): this;
  60218. protected _dumpPropertiesCode(): string;
  60219. serialize(): any;
  60220. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60221. }
  60222. }
  60223. declare module BABYLON {
  60224. /**
  60225. * Block used to apply a cross product between 2 vectors
  60226. */
  60227. export class CrossBlock extends NodeMaterialBlock {
  60228. /**
  60229. * Creates a new CrossBlock
  60230. * @param name defines the block name
  60231. */
  60232. constructor(name: string);
  60233. /**
  60234. * Gets the current class name
  60235. * @returns the class name
  60236. */
  60237. getClassName(): string;
  60238. /**
  60239. * Gets the left operand input component
  60240. */
  60241. get left(): NodeMaterialConnectionPoint;
  60242. /**
  60243. * Gets the right operand input component
  60244. */
  60245. get right(): NodeMaterialConnectionPoint;
  60246. /**
  60247. * Gets the output component
  60248. */
  60249. get output(): NodeMaterialConnectionPoint;
  60250. protected _buildBlock(state: NodeMaterialBuildState): this;
  60251. }
  60252. }
  60253. declare module BABYLON {
  60254. /**
  60255. * Block used to apply a dot product between 2 vectors
  60256. */
  60257. export class DotBlock extends NodeMaterialBlock {
  60258. /**
  60259. * Creates a new DotBlock
  60260. * @param name defines the block name
  60261. */
  60262. constructor(name: string);
  60263. /**
  60264. * Gets the current class name
  60265. * @returns the class name
  60266. */
  60267. getClassName(): string;
  60268. /**
  60269. * Gets the left operand input component
  60270. */
  60271. get left(): NodeMaterialConnectionPoint;
  60272. /**
  60273. * Gets the right operand input component
  60274. */
  60275. get right(): NodeMaterialConnectionPoint;
  60276. /**
  60277. * Gets the output component
  60278. */
  60279. get output(): NodeMaterialConnectionPoint;
  60280. protected _buildBlock(state: NodeMaterialBuildState): this;
  60281. }
  60282. }
  60283. declare module BABYLON {
  60284. /**
  60285. * Block used to normalize a vector
  60286. */
  60287. export class NormalizeBlock extends NodeMaterialBlock {
  60288. /**
  60289. * Creates a new NormalizeBlock
  60290. * @param name defines the block name
  60291. */
  60292. constructor(name: string);
  60293. /**
  60294. * Gets the current class name
  60295. * @returns the class name
  60296. */
  60297. getClassName(): string;
  60298. /**
  60299. * Gets the input component
  60300. */
  60301. get input(): NodeMaterialConnectionPoint;
  60302. /**
  60303. * Gets the output component
  60304. */
  60305. get output(): NodeMaterialConnectionPoint;
  60306. protected _buildBlock(state: NodeMaterialBuildState): this;
  60307. }
  60308. }
  60309. declare module BABYLON {
  60310. /**
  60311. * Operations supported by the Trigonometry block
  60312. */
  60313. export enum TrigonometryBlockOperations {
  60314. /** Cos */
  60315. Cos = 0,
  60316. /** Sin */
  60317. Sin = 1,
  60318. /** Abs */
  60319. Abs = 2,
  60320. /** Exp */
  60321. Exp = 3,
  60322. /** Exp2 */
  60323. Exp2 = 4,
  60324. /** Round */
  60325. Round = 5,
  60326. /** Floor */
  60327. Floor = 6,
  60328. /** Ceiling */
  60329. Ceiling = 7,
  60330. /** Square root */
  60331. Sqrt = 8,
  60332. /** Log */
  60333. Log = 9,
  60334. /** Tangent */
  60335. Tan = 10,
  60336. /** Arc tangent */
  60337. ArcTan = 11,
  60338. /** Arc cosinus */
  60339. ArcCos = 12,
  60340. /** Arc sinus */
  60341. ArcSin = 13,
  60342. /** Fraction */
  60343. Fract = 14,
  60344. /** Sign */
  60345. Sign = 15,
  60346. /** To radians (from degrees) */
  60347. Radians = 16,
  60348. /** To degrees (from radians) */
  60349. Degrees = 17
  60350. }
  60351. /**
  60352. * Block used to apply trigonometry operation to floats
  60353. */
  60354. export class TrigonometryBlock extends NodeMaterialBlock {
  60355. /**
  60356. * Gets or sets the operation applied by the block
  60357. */
  60358. operation: TrigonometryBlockOperations;
  60359. /**
  60360. * Creates a new TrigonometryBlock
  60361. * @param name defines the block name
  60362. */
  60363. constructor(name: string);
  60364. /**
  60365. * Gets the current class name
  60366. * @returns the class name
  60367. */
  60368. getClassName(): string;
  60369. /**
  60370. * Gets the input component
  60371. */
  60372. get input(): NodeMaterialConnectionPoint;
  60373. /**
  60374. * Gets the output component
  60375. */
  60376. get output(): NodeMaterialConnectionPoint;
  60377. protected _buildBlock(state: NodeMaterialBuildState): this;
  60378. serialize(): any;
  60379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60380. protected _dumpPropertiesCode(): string;
  60381. }
  60382. }
  60383. declare module BABYLON {
  60384. /**
  60385. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60386. */
  60387. export class ColorMergerBlock extends NodeMaterialBlock {
  60388. /**
  60389. * Create a new ColorMergerBlock
  60390. * @param name defines the block name
  60391. */
  60392. constructor(name: string);
  60393. /**
  60394. * Gets the current class name
  60395. * @returns the class name
  60396. */
  60397. getClassName(): string;
  60398. /**
  60399. * Gets the rgb component (input)
  60400. */
  60401. get rgbIn(): NodeMaterialConnectionPoint;
  60402. /**
  60403. * Gets the r component (input)
  60404. */
  60405. get r(): NodeMaterialConnectionPoint;
  60406. /**
  60407. * Gets the g component (input)
  60408. */
  60409. get g(): NodeMaterialConnectionPoint;
  60410. /**
  60411. * Gets the b component (input)
  60412. */
  60413. get b(): NodeMaterialConnectionPoint;
  60414. /**
  60415. * Gets the a component (input)
  60416. */
  60417. get a(): NodeMaterialConnectionPoint;
  60418. /**
  60419. * Gets the rgba component (output)
  60420. */
  60421. get rgba(): NodeMaterialConnectionPoint;
  60422. /**
  60423. * Gets the rgb component (output)
  60424. */
  60425. get rgbOut(): NodeMaterialConnectionPoint;
  60426. /**
  60427. * Gets the rgb component (output)
  60428. * @deprecated Please use rgbOut instead.
  60429. */
  60430. get rgb(): NodeMaterialConnectionPoint;
  60431. protected _buildBlock(state: NodeMaterialBuildState): this;
  60432. }
  60433. }
  60434. declare module BABYLON {
  60435. /**
  60436. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60437. */
  60438. export class ColorSplitterBlock extends NodeMaterialBlock {
  60439. /**
  60440. * Create a new ColorSplitterBlock
  60441. * @param name defines the block name
  60442. */
  60443. constructor(name: string);
  60444. /**
  60445. * Gets the current class name
  60446. * @returns the class name
  60447. */
  60448. getClassName(): string;
  60449. /**
  60450. * Gets the rgba component (input)
  60451. */
  60452. get rgba(): NodeMaterialConnectionPoint;
  60453. /**
  60454. * Gets the rgb component (input)
  60455. */
  60456. get rgbIn(): NodeMaterialConnectionPoint;
  60457. /**
  60458. * Gets the rgb component (output)
  60459. */
  60460. get rgbOut(): NodeMaterialConnectionPoint;
  60461. /**
  60462. * Gets the r component (output)
  60463. */
  60464. get r(): NodeMaterialConnectionPoint;
  60465. /**
  60466. * Gets the g component (output)
  60467. */
  60468. get g(): NodeMaterialConnectionPoint;
  60469. /**
  60470. * Gets the b component (output)
  60471. */
  60472. get b(): NodeMaterialConnectionPoint;
  60473. /**
  60474. * Gets the a component (output)
  60475. */
  60476. get a(): NodeMaterialConnectionPoint;
  60477. protected _inputRename(name: string): string;
  60478. protected _outputRename(name: string): string;
  60479. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60480. }
  60481. }
  60482. declare module BABYLON {
  60483. /**
  60484. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60485. */
  60486. export class VectorSplitterBlock extends NodeMaterialBlock {
  60487. /**
  60488. * Create a new VectorSplitterBlock
  60489. * @param name defines the block name
  60490. */
  60491. constructor(name: string);
  60492. /**
  60493. * Gets the current class name
  60494. * @returns the class name
  60495. */
  60496. getClassName(): string;
  60497. /**
  60498. * Gets the xyzw component (input)
  60499. */
  60500. get xyzw(): NodeMaterialConnectionPoint;
  60501. /**
  60502. * Gets the xyz component (input)
  60503. */
  60504. get xyzIn(): NodeMaterialConnectionPoint;
  60505. /**
  60506. * Gets the xy component (input)
  60507. */
  60508. get xyIn(): NodeMaterialConnectionPoint;
  60509. /**
  60510. * Gets the xyz component (output)
  60511. */
  60512. get xyzOut(): NodeMaterialConnectionPoint;
  60513. /**
  60514. * Gets the xy component (output)
  60515. */
  60516. get xyOut(): NodeMaterialConnectionPoint;
  60517. /**
  60518. * Gets the x component (output)
  60519. */
  60520. get x(): NodeMaterialConnectionPoint;
  60521. /**
  60522. * Gets the y component (output)
  60523. */
  60524. get y(): NodeMaterialConnectionPoint;
  60525. /**
  60526. * Gets the z component (output)
  60527. */
  60528. get z(): NodeMaterialConnectionPoint;
  60529. /**
  60530. * Gets the w component (output)
  60531. */
  60532. get w(): NodeMaterialConnectionPoint;
  60533. protected _inputRename(name: string): string;
  60534. protected _outputRename(name: string): string;
  60535. protected _buildBlock(state: NodeMaterialBuildState): this;
  60536. }
  60537. }
  60538. declare module BABYLON {
  60539. /**
  60540. * Block used to lerp between 2 values
  60541. */
  60542. export class LerpBlock extends NodeMaterialBlock {
  60543. /**
  60544. * Creates a new LerpBlock
  60545. * @param name defines the block name
  60546. */
  60547. constructor(name: string);
  60548. /**
  60549. * Gets the current class name
  60550. * @returns the class name
  60551. */
  60552. getClassName(): string;
  60553. /**
  60554. * Gets the left operand input component
  60555. */
  60556. get left(): NodeMaterialConnectionPoint;
  60557. /**
  60558. * Gets the right operand input component
  60559. */
  60560. get right(): NodeMaterialConnectionPoint;
  60561. /**
  60562. * Gets the gradient operand input component
  60563. */
  60564. get gradient(): NodeMaterialConnectionPoint;
  60565. /**
  60566. * Gets the output component
  60567. */
  60568. get output(): NodeMaterialConnectionPoint;
  60569. protected _buildBlock(state: NodeMaterialBuildState): this;
  60570. }
  60571. }
  60572. declare module BABYLON {
  60573. /**
  60574. * Block used to divide 2 vectors
  60575. */
  60576. export class DivideBlock extends NodeMaterialBlock {
  60577. /**
  60578. * Creates a new DivideBlock
  60579. * @param name defines the block name
  60580. */
  60581. constructor(name: string);
  60582. /**
  60583. * Gets the current class name
  60584. * @returns the class name
  60585. */
  60586. getClassName(): string;
  60587. /**
  60588. * Gets the left operand input component
  60589. */
  60590. get left(): NodeMaterialConnectionPoint;
  60591. /**
  60592. * Gets the right operand input component
  60593. */
  60594. get right(): NodeMaterialConnectionPoint;
  60595. /**
  60596. * Gets the output component
  60597. */
  60598. get output(): NodeMaterialConnectionPoint;
  60599. protected _buildBlock(state: NodeMaterialBuildState): this;
  60600. }
  60601. }
  60602. declare module BABYLON {
  60603. /**
  60604. * Block used to subtract 2 vectors
  60605. */
  60606. export class SubtractBlock extends NodeMaterialBlock {
  60607. /**
  60608. * Creates a new SubtractBlock
  60609. * @param name defines the block name
  60610. */
  60611. constructor(name: string);
  60612. /**
  60613. * Gets the current class name
  60614. * @returns the class name
  60615. */
  60616. getClassName(): string;
  60617. /**
  60618. * Gets the left operand input component
  60619. */
  60620. get left(): NodeMaterialConnectionPoint;
  60621. /**
  60622. * Gets the right operand input component
  60623. */
  60624. get right(): NodeMaterialConnectionPoint;
  60625. /**
  60626. * Gets the output component
  60627. */
  60628. get output(): NodeMaterialConnectionPoint;
  60629. protected _buildBlock(state: NodeMaterialBuildState): this;
  60630. }
  60631. }
  60632. declare module BABYLON {
  60633. /**
  60634. * Block used to step a value
  60635. */
  60636. export class StepBlock extends NodeMaterialBlock {
  60637. /**
  60638. * Creates a new StepBlock
  60639. * @param name defines the block name
  60640. */
  60641. constructor(name: string);
  60642. /**
  60643. * Gets the current class name
  60644. * @returns the class name
  60645. */
  60646. getClassName(): string;
  60647. /**
  60648. * Gets the value operand input component
  60649. */
  60650. get value(): NodeMaterialConnectionPoint;
  60651. /**
  60652. * Gets the edge operand input component
  60653. */
  60654. get edge(): NodeMaterialConnectionPoint;
  60655. /**
  60656. * Gets the output component
  60657. */
  60658. get output(): NodeMaterialConnectionPoint;
  60659. protected _buildBlock(state: NodeMaterialBuildState): this;
  60660. }
  60661. }
  60662. declare module BABYLON {
  60663. /**
  60664. * Block used to get the opposite (1 - x) of a value
  60665. */
  60666. export class OneMinusBlock extends NodeMaterialBlock {
  60667. /**
  60668. * Creates a new OneMinusBlock
  60669. * @param name defines the block name
  60670. */
  60671. constructor(name: string);
  60672. /**
  60673. * Gets the current class name
  60674. * @returns the class name
  60675. */
  60676. getClassName(): string;
  60677. /**
  60678. * Gets the input component
  60679. */
  60680. get input(): NodeMaterialConnectionPoint;
  60681. /**
  60682. * Gets the output component
  60683. */
  60684. get output(): NodeMaterialConnectionPoint;
  60685. protected _buildBlock(state: NodeMaterialBuildState): this;
  60686. }
  60687. }
  60688. declare module BABYLON {
  60689. /**
  60690. * Block used to get the view direction
  60691. */
  60692. export class ViewDirectionBlock extends NodeMaterialBlock {
  60693. /**
  60694. * Creates a new ViewDirectionBlock
  60695. * @param name defines the block name
  60696. */
  60697. constructor(name: string);
  60698. /**
  60699. * Gets the current class name
  60700. * @returns the class name
  60701. */
  60702. getClassName(): string;
  60703. /**
  60704. * Gets the world position component
  60705. */
  60706. get worldPosition(): NodeMaterialConnectionPoint;
  60707. /**
  60708. * Gets the camera position component
  60709. */
  60710. get cameraPosition(): NodeMaterialConnectionPoint;
  60711. /**
  60712. * Gets the output component
  60713. */
  60714. get output(): NodeMaterialConnectionPoint;
  60715. autoConfigure(material: NodeMaterial): void;
  60716. protected _buildBlock(state: NodeMaterialBuildState): this;
  60717. }
  60718. }
  60719. declare module BABYLON {
  60720. /**
  60721. * Block used to compute fresnel value
  60722. */
  60723. export class FresnelBlock extends NodeMaterialBlock {
  60724. /**
  60725. * Create a new FresnelBlock
  60726. * @param name defines the block name
  60727. */
  60728. constructor(name: string);
  60729. /**
  60730. * Gets the current class name
  60731. * @returns the class name
  60732. */
  60733. getClassName(): string;
  60734. /**
  60735. * Gets the world normal input component
  60736. */
  60737. get worldNormal(): NodeMaterialConnectionPoint;
  60738. /**
  60739. * Gets the view direction input component
  60740. */
  60741. get viewDirection(): NodeMaterialConnectionPoint;
  60742. /**
  60743. * Gets the bias input component
  60744. */
  60745. get bias(): NodeMaterialConnectionPoint;
  60746. /**
  60747. * Gets the camera (or eye) position component
  60748. */
  60749. get power(): NodeMaterialConnectionPoint;
  60750. /**
  60751. * Gets the fresnel output component
  60752. */
  60753. get fresnel(): NodeMaterialConnectionPoint;
  60754. autoConfigure(material: NodeMaterial): void;
  60755. protected _buildBlock(state: NodeMaterialBuildState): this;
  60756. }
  60757. }
  60758. declare module BABYLON {
  60759. /**
  60760. * Block used to get the max of 2 values
  60761. */
  60762. export class MaxBlock extends NodeMaterialBlock {
  60763. /**
  60764. * Creates a new MaxBlock
  60765. * @param name defines the block name
  60766. */
  60767. constructor(name: string);
  60768. /**
  60769. * Gets the current class name
  60770. * @returns the class name
  60771. */
  60772. getClassName(): string;
  60773. /**
  60774. * Gets the left operand input component
  60775. */
  60776. get left(): NodeMaterialConnectionPoint;
  60777. /**
  60778. * Gets the right operand input component
  60779. */
  60780. get right(): NodeMaterialConnectionPoint;
  60781. /**
  60782. * Gets the output component
  60783. */
  60784. get output(): NodeMaterialConnectionPoint;
  60785. protected _buildBlock(state: NodeMaterialBuildState): this;
  60786. }
  60787. }
  60788. declare module BABYLON {
  60789. /**
  60790. * Block used to get the min of 2 values
  60791. */
  60792. export class MinBlock extends NodeMaterialBlock {
  60793. /**
  60794. * Creates a new MinBlock
  60795. * @param name defines the block name
  60796. */
  60797. constructor(name: string);
  60798. /**
  60799. * Gets the current class name
  60800. * @returns the class name
  60801. */
  60802. getClassName(): string;
  60803. /**
  60804. * Gets the left operand input component
  60805. */
  60806. get left(): NodeMaterialConnectionPoint;
  60807. /**
  60808. * Gets the right operand input component
  60809. */
  60810. get right(): NodeMaterialConnectionPoint;
  60811. /**
  60812. * Gets the output component
  60813. */
  60814. get output(): NodeMaterialConnectionPoint;
  60815. protected _buildBlock(state: NodeMaterialBuildState): this;
  60816. }
  60817. }
  60818. declare module BABYLON {
  60819. /**
  60820. * Block used to get the distance between 2 values
  60821. */
  60822. export class DistanceBlock extends NodeMaterialBlock {
  60823. /**
  60824. * Creates a new DistanceBlock
  60825. * @param name defines the block name
  60826. */
  60827. constructor(name: string);
  60828. /**
  60829. * Gets the current class name
  60830. * @returns the class name
  60831. */
  60832. getClassName(): string;
  60833. /**
  60834. * Gets the left operand input component
  60835. */
  60836. get left(): NodeMaterialConnectionPoint;
  60837. /**
  60838. * Gets the right operand input component
  60839. */
  60840. get right(): NodeMaterialConnectionPoint;
  60841. /**
  60842. * Gets the output component
  60843. */
  60844. get output(): NodeMaterialConnectionPoint;
  60845. protected _buildBlock(state: NodeMaterialBuildState): this;
  60846. }
  60847. }
  60848. declare module BABYLON {
  60849. /**
  60850. * Block used to get the length of a vector
  60851. */
  60852. export class LengthBlock extends NodeMaterialBlock {
  60853. /**
  60854. * Creates a new LengthBlock
  60855. * @param name defines the block name
  60856. */
  60857. constructor(name: string);
  60858. /**
  60859. * Gets the current class name
  60860. * @returns the class name
  60861. */
  60862. getClassName(): string;
  60863. /**
  60864. * Gets the value input component
  60865. */
  60866. get value(): NodeMaterialConnectionPoint;
  60867. /**
  60868. * Gets the output component
  60869. */
  60870. get output(): NodeMaterialConnectionPoint;
  60871. protected _buildBlock(state: NodeMaterialBuildState): this;
  60872. }
  60873. }
  60874. declare module BABYLON {
  60875. /**
  60876. * Block used to get negative version of a value (i.e. x * -1)
  60877. */
  60878. export class NegateBlock extends NodeMaterialBlock {
  60879. /**
  60880. * Creates a new NegateBlock
  60881. * @param name defines the block name
  60882. */
  60883. constructor(name: string);
  60884. /**
  60885. * Gets the current class name
  60886. * @returns the class name
  60887. */
  60888. getClassName(): string;
  60889. /**
  60890. * Gets the value input component
  60891. */
  60892. get value(): NodeMaterialConnectionPoint;
  60893. /**
  60894. * Gets the output component
  60895. */
  60896. get output(): NodeMaterialConnectionPoint;
  60897. protected _buildBlock(state: NodeMaterialBuildState): this;
  60898. }
  60899. }
  60900. declare module BABYLON {
  60901. /**
  60902. * Block used to get the value of the first parameter raised to the power of the second
  60903. */
  60904. export class PowBlock extends NodeMaterialBlock {
  60905. /**
  60906. * Creates a new PowBlock
  60907. * @param name defines the block name
  60908. */
  60909. constructor(name: string);
  60910. /**
  60911. * Gets the current class name
  60912. * @returns the class name
  60913. */
  60914. getClassName(): string;
  60915. /**
  60916. * Gets the value operand input component
  60917. */
  60918. get value(): NodeMaterialConnectionPoint;
  60919. /**
  60920. * Gets the power operand input component
  60921. */
  60922. get power(): NodeMaterialConnectionPoint;
  60923. /**
  60924. * Gets the output component
  60925. */
  60926. get output(): NodeMaterialConnectionPoint;
  60927. protected _buildBlock(state: NodeMaterialBuildState): this;
  60928. }
  60929. }
  60930. declare module BABYLON {
  60931. /**
  60932. * Block used to get a random number
  60933. */
  60934. export class RandomNumberBlock extends NodeMaterialBlock {
  60935. /**
  60936. * Creates a new RandomNumberBlock
  60937. * @param name defines the block name
  60938. */
  60939. constructor(name: string);
  60940. /**
  60941. * Gets the current class name
  60942. * @returns the class name
  60943. */
  60944. getClassName(): string;
  60945. /**
  60946. * Gets the seed input component
  60947. */
  60948. get seed(): NodeMaterialConnectionPoint;
  60949. /**
  60950. * Gets the output component
  60951. */
  60952. get output(): NodeMaterialConnectionPoint;
  60953. protected _buildBlock(state: NodeMaterialBuildState): this;
  60954. }
  60955. }
  60956. declare module BABYLON {
  60957. /**
  60958. * Block used to compute arc tangent of 2 values
  60959. */
  60960. export class ArcTan2Block extends NodeMaterialBlock {
  60961. /**
  60962. * Creates a new ArcTan2Block
  60963. * @param name defines the block name
  60964. */
  60965. constructor(name: string);
  60966. /**
  60967. * Gets the current class name
  60968. * @returns the class name
  60969. */
  60970. getClassName(): string;
  60971. /**
  60972. * Gets the x operand input component
  60973. */
  60974. get x(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the y operand input component
  60977. */
  60978. get y(): NodeMaterialConnectionPoint;
  60979. /**
  60980. * Gets the output component
  60981. */
  60982. get output(): NodeMaterialConnectionPoint;
  60983. protected _buildBlock(state: NodeMaterialBuildState): this;
  60984. }
  60985. }
  60986. declare module BABYLON {
  60987. /**
  60988. * Block used to smooth step a value
  60989. */
  60990. export class SmoothStepBlock extends NodeMaterialBlock {
  60991. /**
  60992. * Creates a new SmoothStepBlock
  60993. * @param name defines the block name
  60994. */
  60995. constructor(name: string);
  60996. /**
  60997. * Gets the current class name
  60998. * @returns the class name
  60999. */
  61000. getClassName(): string;
  61001. /**
  61002. * Gets the value operand input component
  61003. */
  61004. get value(): NodeMaterialConnectionPoint;
  61005. /**
  61006. * Gets the first edge operand input component
  61007. */
  61008. get edge0(): NodeMaterialConnectionPoint;
  61009. /**
  61010. * Gets the second edge operand input component
  61011. */
  61012. get edge1(): NodeMaterialConnectionPoint;
  61013. /**
  61014. * Gets the output component
  61015. */
  61016. get output(): NodeMaterialConnectionPoint;
  61017. protected _buildBlock(state: NodeMaterialBuildState): this;
  61018. }
  61019. }
  61020. declare module BABYLON {
  61021. /**
  61022. * Block used to get the reciprocal (1 / x) of a value
  61023. */
  61024. export class ReciprocalBlock extends NodeMaterialBlock {
  61025. /**
  61026. * Creates a new ReciprocalBlock
  61027. * @param name defines the block name
  61028. */
  61029. constructor(name: string);
  61030. /**
  61031. * Gets the current class name
  61032. * @returns the class name
  61033. */
  61034. getClassName(): string;
  61035. /**
  61036. * Gets the input component
  61037. */
  61038. get input(): NodeMaterialConnectionPoint;
  61039. /**
  61040. * Gets the output component
  61041. */
  61042. get output(): NodeMaterialConnectionPoint;
  61043. protected _buildBlock(state: NodeMaterialBuildState): this;
  61044. }
  61045. }
  61046. declare module BABYLON {
  61047. /**
  61048. * Block used to replace a color by another one
  61049. */
  61050. export class ReplaceColorBlock extends NodeMaterialBlock {
  61051. /**
  61052. * Creates a new ReplaceColorBlock
  61053. * @param name defines the block name
  61054. */
  61055. constructor(name: string);
  61056. /**
  61057. * Gets the current class name
  61058. * @returns the class name
  61059. */
  61060. getClassName(): string;
  61061. /**
  61062. * Gets the value input component
  61063. */
  61064. get value(): NodeMaterialConnectionPoint;
  61065. /**
  61066. * Gets the reference input component
  61067. */
  61068. get reference(): NodeMaterialConnectionPoint;
  61069. /**
  61070. * Gets the distance input component
  61071. */
  61072. get distance(): NodeMaterialConnectionPoint;
  61073. /**
  61074. * Gets the replacement input component
  61075. */
  61076. get replacement(): NodeMaterialConnectionPoint;
  61077. /**
  61078. * Gets the output component
  61079. */
  61080. get output(): NodeMaterialConnectionPoint;
  61081. protected _buildBlock(state: NodeMaterialBuildState): this;
  61082. }
  61083. }
  61084. declare module BABYLON {
  61085. /**
  61086. * Block used to posterize a value
  61087. * @see https://en.wikipedia.org/wiki/Posterization
  61088. */
  61089. export class PosterizeBlock extends NodeMaterialBlock {
  61090. /**
  61091. * Creates a new PosterizeBlock
  61092. * @param name defines the block name
  61093. */
  61094. constructor(name: string);
  61095. /**
  61096. * Gets the current class name
  61097. * @returns the class name
  61098. */
  61099. getClassName(): string;
  61100. /**
  61101. * Gets the value input component
  61102. */
  61103. get value(): NodeMaterialConnectionPoint;
  61104. /**
  61105. * Gets the steps input component
  61106. */
  61107. get steps(): NodeMaterialConnectionPoint;
  61108. /**
  61109. * Gets the output component
  61110. */
  61111. get output(): NodeMaterialConnectionPoint;
  61112. protected _buildBlock(state: NodeMaterialBuildState): this;
  61113. }
  61114. }
  61115. declare module BABYLON {
  61116. /**
  61117. * Operations supported by the Wave block
  61118. */
  61119. export enum WaveBlockKind {
  61120. /** SawTooth */
  61121. SawTooth = 0,
  61122. /** Square */
  61123. Square = 1,
  61124. /** Triangle */
  61125. Triangle = 2
  61126. }
  61127. /**
  61128. * Block used to apply wave operation to floats
  61129. */
  61130. export class WaveBlock extends NodeMaterialBlock {
  61131. /**
  61132. * Gets or sets the kibnd of wave to be applied by the block
  61133. */
  61134. kind: WaveBlockKind;
  61135. /**
  61136. * Creates a new WaveBlock
  61137. * @param name defines the block name
  61138. */
  61139. constructor(name: string);
  61140. /**
  61141. * Gets the current class name
  61142. * @returns the class name
  61143. */
  61144. getClassName(): string;
  61145. /**
  61146. * Gets the input component
  61147. */
  61148. get input(): NodeMaterialConnectionPoint;
  61149. /**
  61150. * Gets the output component
  61151. */
  61152. get output(): NodeMaterialConnectionPoint;
  61153. protected _buildBlock(state: NodeMaterialBuildState): this;
  61154. serialize(): any;
  61155. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61156. }
  61157. }
  61158. declare module BABYLON {
  61159. /**
  61160. * Class used to store a color step for the GradientBlock
  61161. */
  61162. export class GradientBlockColorStep {
  61163. /**
  61164. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61165. */
  61166. step: number;
  61167. /**
  61168. * Gets or sets the color associated with this step
  61169. */
  61170. color: Color3;
  61171. /**
  61172. * Creates a new GradientBlockColorStep
  61173. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  61174. * @param color defines the color associated with this step
  61175. */
  61176. constructor(
  61177. /**
  61178. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61179. */
  61180. step: number,
  61181. /**
  61182. * Gets or sets the color associated with this step
  61183. */
  61184. color: Color3);
  61185. }
  61186. /**
  61187. * Block used to return a color from a gradient based on an input value between 0 and 1
  61188. */
  61189. export class GradientBlock extends NodeMaterialBlock {
  61190. /**
  61191. * Gets or sets the list of color steps
  61192. */
  61193. colorSteps: GradientBlockColorStep[];
  61194. /**
  61195. * Creates a new GradientBlock
  61196. * @param name defines the block name
  61197. */
  61198. constructor(name: string);
  61199. /**
  61200. * Gets the current class name
  61201. * @returns the class name
  61202. */
  61203. getClassName(): string;
  61204. /**
  61205. * Gets the gradient input component
  61206. */
  61207. get gradient(): NodeMaterialConnectionPoint;
  61208. /**
  61209. * Gets the output component
  61210. */
  61211. get output(): NodeMaterialConnectionPoint;
  61212. private _writeColorConstant;
  61213. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61214. serialize(): any;
  61215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61216. protected _dumpPropertiesCode(): string;
  61217. }
  61218. }
  61219. declare module BABYLON {
  61220. /**
  61221. * Block used to normalize lerp between 2 values
  61222. */
  61223. export class NLerpBlock extends NodeMaterialBlock {
  61224. /**
  61225. * Creates a new NLerpBlock
  61226. * @param name defines the block name
  61227. */
  61228. constructor(name: string);
  61229. /**
  61230. * Gets the current class name
  61231. * @returns the class name
  61232. */
  61233. getClassName(): string;
  61234. /**
  61235. * Gets the left operand input component
  61236. */
  61237. get left(): NodeMaterialConnectionPoint;
  61238. /**
  61239. * Gets the right operand input component
  61240. */
  61241. get right(): NodeMaterialConnectionPoint;
  61242. /**
  61243. * Gets the gradient operand input component
  61244. */
  61245. get gradient(): NodeMaterialConnectionPoint;
  61246. /**
  61247. * Gets the output component
  61248. */
  61249. get output(): NodeMaterialConnectionPoint;
  61250. protected _buildBlock(state: NodeMaterialBuildState): this;
  61251. }
  61252. }
  61253. declare module BABYLON {
  61254. /**
  61255. * block used to Generate a Worley Noise 3D Noise Pattern
  61256. */
  61257. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61258. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61259. manhattanDistance: boolean;
  61260. /**
  61261. * Creates a new WorleyNoise3DBlock
  61262. * @param name defines the block name
  61263. */
  61264. constructor(name: string);
  61265. /**
  61266. * Gets the current class name
  61267. * @returns the class name
  61268. */
  61269. getClassName(): string;
  61270. /**
  61271. * Gets the seed input component
  61272. */
  61273. get seed(): NodeMaterialConnectionPoint;
  61274. /**
  61275. * Gets the jitter input component
  61276. */
  61277. get jitter(): NodeMaterialConnectionPoint;
  61278. /**
  61279. * Gets the output component
  61280. */
  61281. get output(): NodeMaterialConnectionPoint;
  61282. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61283. /**
  61284. * Exposes the properties to the UI?
  61285. */
  61286. protected _dumpPropertiesCode(): string;
  61287. /**
  61288. * Exposes the properties to the Seralize?
  61289. */
  61290. serialize(): any;
  61291. /**
  61292. * Exposes the properties to the deseralize?
  61293. */
  61294. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61295. }
  61296. }
  61297. declare module BABYLON {
  61298. /**
  61299. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61300. */
  61301. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61302. /**
  61303. * Creates a new SimplexPerlin3DBlock
  61304. * @param name defines the block name
  61305. */
  61306. constructor(name: string);
  61307. /**
  61308. * Gets the current class name
  61309. * @returns the class name
  61310. */
  61311. getClassName(): string;
  61312. /**
  61313. * Gets the seed operand input component
  61314. */
  61315. get seed(): NodeMaterialConnectionPoint;
  61316. /**
  61317. * Gets the output component
  61318. */
  61319. get output(): NodeMaterialConnectionPoint;
  61320. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61321. }
  61322. }
  61323. declare module BABYLON {
  61324. /**
  61325. * Block used to blend normals
  61326. */
  61327. export class NormalBlendBlock extends NodeMaterialBlock {
  61328. /**
  61329. * Creates a new NormalBlendBlock
  61330. * @param name defines the block name
  61331. */
  61332. constructor(name: string);
  61333. /**
  61334. * Gets the current class name
  61335. * @returns the class name
  61336. */
  61337. getClassName(): string;
  61338. /**
  61339. * Gets the first input component
  61340. */
  61341. get normalMap0(): NodeMaterialConnectionPoint;
  61342. /**
  61343. * Gets the second input component
  61344. */
  61345. get normalMap1(): NodeMaterialConnectionPoint;
  61346. /**
  61347. * Gets the output component
  61348. */
  61349. get output(): NodeMaterialConnectionPoint;
  61350. protected _buildBlock(state: NodeMaterialBuildState): this;
  61351. }
  61352. }
  61353. declare module BABYLON {
  61354. /**
  61355. * Block used to rotate a 2d vector by a given angle
  61356. */
  61357. export class Rotate2dBlock extends NodeMaterialBlock {
  61358. /**
  61359. * Creates a new Rotate2dBlock
  61360. * @param name defines the block name
  61361. */
  61362. constructor(name: string);
  61363. /**
  61364. * Gets the current class name
  61365. * @returns the class name
  61366. */
  61367. getClassName(): string;
  61368. /**
  61369. * Gets the input vector
  61370. */
  61371. get input(): NodeMaterialConnectionPoint;
  61372. /**
  61373. * Gets the input angle
  61374. */
  61375. get angle(): NodeMaterialConnectionPoint;
  61376. /**
  61377. * Gets the output component
  61378. */
  61379. get output(): NodeMaterialConnectionPoint;
  61380. autoConfigure(material: NodeMaterial): void;
  61381. protected _buildBlock(state: NodeMaterialBuildState): this;
  61382. }
  61383. }
  61384. declare module BABYLON {
  61385. /**
  61386. * Block used to get the reflected vector from a direction and a normal
  61387. */
  61388. export class ReflectBlock extends NodeMaterialBlock {
  61389. /**
  61390. * Creates a new ReflectBlock
  61391. * @param name defines the block name
  61392. */
  61393. constructor(name: string);
  61394. /**
  61395. * Gets the current class name
  61396. * @returns the class name
  61397. */
  61398. getClassName(): string;
  61399. /**
  61400. * Gets the incident component
  61401. */
  61402. get incident(): NodeMaterialConnectionPoint;
  61403. /**
  61404. * Gets the normal component
  61405. */
  61406. get normal(): NodeMaterialConnectionPoint;
  61407. /**
  61408. * Gets the output component
  61409. */
  61410. get output(): NodeMaterialConnectionPoint;
  61411. protected _buildBlock(state: NodeMaterialBuildState): this;
  61412. }
  61413. }
  61414. declare module BABYLON {
  61415. /**
  61416. * Block used to get the refracted vector from a direction and a normal
  61417. */
  61418. export class RefractBlock extends NodeMaterialBlock {
  61419. /**
  61420. * Creates a new RefractBlock
  61421. * @param name defines the block name
  61422. */
  61423. constructor(name: string);
  61424. /**
  61425. * Gets the current class name
  61426. * @returns the class name
  61427. */
  61428. getClassName(): string;
  61429. /**
  61430. * Gets the incident component
  61431. */
  61432. get incident(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the normal component
  61435. */
  61436. get normal(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the index of refraction component
  61439. */
  61440. get ior(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the output component
  61443. */
  61444. get output(): NodeMaterialConnectionPoint;
  61445. protected _buildBlock(state: NodeMaterialBuildState): this;
  61446. }
  61447. }
  61448. declare module BABYLON {
  61449. /**
  61450. * Block used to desaturate a color
  61451. */
  61452. export class DesaturateBlock extends NodeMaterialBlock {
  61453. /**
  61454. * Creates a new DesaturateBlock
  61455. * @param name defines the block name
  61456. */
  61457. constructor(name: string);
  61458. /**
  61459. * Gets the current class name
  61460. * @returns the class name
  61461. */
  61462. getClassName(): string;
  61463. /**
  61464. * Gets the color operand input component
  61465. */
  61466. get color(): NodeMaterialConnectionPoint;
  61467. /**
  61468. * Gets the level operand input component
  61469. */
  61470. get level(): NodeMaterialConnectionPoint;
  61471. /**
  61472. * Gets the output component
  61473. */
  61474. get output(): NodeMaterialConnectionPoint;
  61475. protected _buildBlock(state: NodeMaterialBuildState): this;
  61476. }
  61477. }
  61478. declare module BABYLON {
  61479. /**
  61480. * Block used to implement the ambient occlusion module of the PBR material
  61481. */
  61482. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  61483. /**
  61484. * Create a new AmbientOcclusionBlock
  61485. * @param name defines the block name
  61486. */
  61487. constructor(name: string);
  61488. /**
  61489. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  61490. */
  61491. useAmbientInGrayScale: boolean;
  61492. /**
  61493. * Initialize the block and prepare the context for build
  61494. * @param state defines the state that will be used for the build
  61495. */
  61496. initialize(state: NodeMaterialBuildState): void;
  61497. /**
  61498. * Gets the current class name
  61499. * @returns the class name
  61500. */
  61501. getClassName(): string;
  61502. /**
  61503. * Gets the texture input component
  61504. */
  61505. get texture(): NodeMaterialConnectionPoint;
  61506. /**
  61507. * Gets the texture intensity component
  61508. */
  61509. get intensity(): NodeMaterialConnectionPoint;
  61510. /**
  61511. * Gets the direct light intensity input component
  61512. */
  61513. get directLightIntensity(): NodeMaterialConnectionPoint;
  61514. /**
  61515. * Gets the ambient occlusion object output component
  61516. */
  61517. get ambientOcclusion(): NodeMaterialConnectionPoint;
  61518. /**
  61519. * Gets the main code of the block (fragment side)
  61520. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  61521. * @returns the shader code
  61522. */
  61523. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  61524. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61525. protected _buildBlock(state: NodeMaterialBuildState): this;
  61526. protected _dumpPropertiesCode(): string;
  61527. serialize(): any;
  61528. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61529. }
  61530. }
  61531. declare module BABYLON {
  61532. /**
  61533. * Block used to implement the reflection module of the PBR material
  61534. */
  61535. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  61536. /** @hidden */
  61537. _defineLODReflectionAlpha: string;
  61538. /** @hidden */
  61539. _defineLinearSpecularReflection: string;
  61540. private _vEnvironmentIrradianceName;
  61541. /** @hidden */
  61542. _vReflectionMicrosurfaceInfosName: string;
  61543. /** @hidden */
  61544. _vReflectionInfosName: string;
  61545. private _scene;
  61546. /**
  61547. * The three properties below are set by the main PBR block prior to calling methods of this class.
  61548. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61549. * It's less burden on the user side in the editor part.
  61550. */
  61551. /** @hidden */
  61552. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61553. /** @hidden */
  61554. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61555. /** @hidden */
  61556. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  61557. /**
  61558. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  61559. * diffuse part of the IBL.
  61560. */
  61561. useSphericalHarmonics: boolean;
  61562. /**
  61563. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  61564. */
  61565. forceIrradianceInFragment: boolean;
  61566. /**
  61567. * Create a new ReflectionBlock
  61568. * @param name defines the block name
  61569. */
  61570. constructor(name: string);
  61571. /**
  61572. * Gets the current class name
  61573. * @returns the class name
  61574. */
  61575. getClassName(): string;
  61576. /**
  61577. * Gets the position input component
  61578. */
  61579. get position(): NodeMaterialConnectionPoint;
  61580. /**
  61581. * Gets the world position input component
  61582. */
  61583. get worldPosition(): NodeMaterialConnectionPoint;
  61584. /**
  61585. * Gets the world normal input component
  61586. */
  61587. get worldNormal(): NodeMaterialConnectionPoint;
  61588. /**
  61589. * Gets the world input component
  61590. */
  61591. get world(): NodeMaterialConnectionPoint;
  61592. /**
  61593. * Gets the camera (or eye) position component
  61594. */
  61595. get cameraPosition(): NodeMaterialConnectionPoint;
  61596. /**
  61597. * Gets the view input component
  61598. */
  61599. get view(): NodeMaterialConnectionPoint;
  61600. /**
  61601. * Gets the color input component
  61602. */
  61603. get color(): NodeMaterialConnectionPoint;
  61604. /**
  61605. * Gets the reflection object output component
  61606. */
  61607. get reflection(): NodeMaterialConnectionPoint;
  61608. /**
  61609. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  61610. */
  61611. get hasTexture(): boolean;
  61612. /**
  61613. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  61614. */
  61615. get reflectionColor(): string;
  61616. protected _getTexture(): Nullable<BaseTexture>;
  61617. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61619. /**
  61620. * Gets the code to inject in the vertex shader
  61621. * @param state current state of the node material building
  61622. * @returns the shader code
  61623. */
  61624. handleVertexSide(state: NodeMaterialBuildState): string;
  61625. /**
  61626. * Gets the main code of the block (fragment side)
  61627. * @param state current state of the node material building
  61628. * @param normalVarName name of the existing variable corresponding to the normal
  61629. * @returns the shader code
  61630. */
  61631. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  61632. protected _buildBlock(state: NodeMaterialBuildState): this;
  61633. protected _dumpPropertiesCode(): string;
  61634. serialize(): any;
  61635. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61636. }
  61637. }
  61638. declare module BABYLON {
  61639. /**
  61640. * Block used to implement the sheen module of the PBR material
  61641. */
  61642. export class SheenBlock extends NodeMaterialBlock {
  61643. /**
  61644. * Create a new SheenBlock
  61645. * @param name defines the block name
  61646. */
  61647. constructor(name: string);
  61648. /**
  61649. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  61650. * It allows the strength of the sheen effect to not depend on the base color of the material,
  61651. * making it easier to setup and tweak the effect
  61652. */
  61653. albedoScaling: boolean;
  61654. /**
  61655. * Defines if the sheen is linked to the sheen color.
  61656. */
  61657. linkSheenWithAlbedo: boolean;
  61658. /**
  61659. * Initialize the block and prepare the context for build
  61660. * @param state defines the state that will be used for the build
  61661. */
  61662. initialize(state: NodeMaterialBuildState): void;
  61663. /**
  61664. * Gets the current class name
  61665. * @returns the class name
  61666. */
  61667. getClassName(): string;
  61668. /**
  61669. * Gets the intensity input component
  61670. */
  61671. get intensity(): NodeMaterialConnectionPoint;
  61672. /**
  61673. * Gets the color input component
  61674. */
  61675. get color(): NodeMaterialConnectionPoint;
  61676. /**
  61677. * Gets the roughness input component
  61678. */
  61679. get roughness(): NodeMaterialConnectionPoint;
  61680. /**
  61681. * Gets the texture input component
  61682. */
  61683. get texture(): NodeMaterialConnectionPoint;
  61684. /**
  61685. * Gets the sheen object output component
  61686. */
  61687. get sheen(): NodeMaterialConnectionPoint;
  61688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61689. /**
  61690. * Gets the main code of the block (fragment side)
  61691. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61692. * @returns the shader code
  61693. */
  61694. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  61695. protected _buildBlock(state: NodeMaterialBuildState): this;
  61696. protected _dumpPropertiesCode(): string;
  61697. serialize(): any;
  61698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61699. }
  61700. }
  61701. declare module BABYLON {
  61702. /**
  61703. * Block used to implement the reflectivity module of the PBR material
  61704. */
  61705. export class ReflectivityBlock extends NodeMaterialBlock {
  61706. /**
  61707. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  61708. */
  61709. useAmbientOcclusionFromMetallicTextureRed: boolean;
  61710. /**
  61711. * Specifies if the metallic texture contains the metallness information in its blue channel.
  61712. */
  61713. useMetallnessFromMetallicTextureBlue: boolean;
  61714. /**
  61715. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  61716. */
  61717. useRoughnessFromMetallicTextureAlpha: boolean;
  61718. /**
  61719. * Specifies if the metallic texture contains the roughness information in its green channel.
  61720. */
  61721. useRoughnessFromMetallicTextureGreen: boolean;
  61722. /**
  61723. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  61724. */
  61725. useMetallicF0FactorFromMetallicTexture: boolean;
  61726. /**
  61727. * Create a new ReflectivityBlock
  61728. * @param name defines the block name
  61729. */
  61730. constructor(name: string);
  61731. /**
  61732. * Initialize the block and prepare the context for build
  61733. * @param state defines the state that will be used for the build
  61734. */
  61735. initialize(state: NodeMaterialBuildState): void;
  61736. /**
  61737. * Gets the current class name
  61738. * @returns the class name
  61739. */
  61740. getClassName(): string;
  61741. /**
  61742. * Gets the metallic input component
  61743. */
  61744. get metallic(): NodeMaterialConnectionPoint;
  61745. /**
  61746. * Gets the roughness input component
  61747. */
  61748. get roughness(): NodeMaterialConnectionPoint;
  61749. /**
  61750. * Gets the texture input component
  61751. */
  61752. get texture(): NodeMaterialConnectionPoint;
  61753. /**
  61754. * Gets the reflectivity object output component
  61755. */
  61756. get reflectivity(): NodeMaterialConnectionPoint;
  61757. /**
  61758. * Gets the main code of the block (fragment side)
  61759. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  61760. * @returns the shader code
  61761. */
  61762. getCode(aoIntensityVarName: string): string;
  61763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61764. protected _buildBlock(state: NodeMaterialBuildState): this;
  61765. protected _dumpPropertiesCode(): string;
  61766. serialize(): any;
  61767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61768. }
  61769. }
  61770. declare module BABYLON {
  61771. /**
  61772. * Block used to implement the anisotropy module of the PBR material
  61773. */
  61774. export class AnisotropyBlock extends NodeMaterialBlock {
  61775. /**
  61776. * The two properties below are set by the main PBR block prior to calling methods of this class.
  61777. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  61778. * It's less burden on the user side in the editor part.
  61779. */
  61780. /** @hidden */
  61781. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  61782. /** @hidden */
  61783. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  61784. /**
  61785. * Create a new AnisotropyBlock
  61786. * @param name defines the block name
  61787. */
  61788. constructor(name: string);
  61789. /**
  61790. * Initialize the block and prepare the context for build
  61791. * @param state defines the state that will be used for the build
  61792. */
  61793. initialize(state: NodeMaterialBuildState): void;
  61794. /**
  61795. * Gets the current class name
  61796. * @returns the class name
  61797. */
  61798. getClassName(): string;
  61799. /**
  61800. * Gets the intensity input component
  61801. */
  61802. get intensity(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the direction input component
  61805. */
  61806. get direction(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the texture input component
  61809. */
  61810. get texture(): NodeMaterialConnectionPoint;
  61811. /**
  61812. * Gets the uv input component
  61813. */
  61814. get uv(): NodeMaterialConnectionPoint;
  61815. /**
  61816. * Gets the worldTangent input component
  61817. */
  61818. get worldTangent(): NodeMaterialConnectionPoint;
  61819. /**
  61820. * Gets the anisotropy object output component
  61821. */
  61822. get anisotropy(): NodeMaterialConnectionPoint;
  61823. private _generateTBNSpace;
  61824. /**
  61825. * Gets the main code of the block (fragment side)
  61826. * @param state current state of the node material building
  61827. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61828. * @returns the shader code
  61829. */
  61830. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  61831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61832. protected _buildBlock(state: NodeMaterialBuildState): this;
  61833. }
  61834. }
  61835. declare module BABYLON {
  61836. /**
  61837. * Block used to implement the clear coat module of the PBR material
  61838. */
  61839. export class ClearCoatBlock extends NodeMaterialBlock {
  61840. private _scene;
  61841. /**
  61842. * Create a new ClearCoatBlock
  61843. * @param name defines the block name
  61844. */
  61845. constructor(name: string);
  61846. /**
  61847. * Initialize the block and prepare the context for build
  61848. * @param state defines the state that will be used for the build
  61849. */
  61850. initialize(state: NodeMaterialBuildState): void;
  61851. /**
  61852. * Gets the current class name
  61853. * @returns the class name
  61854. */
  61855. getClassName(): string;
  61856. /**
  61857. * Gets the intensity input component
  61858. */
  61859. get intensity(): NodeMaterialConnectionPoint;
  61860. /**
  61861. * Gets the roughness input component
  61862. */
  61863. get roughness(): NodeMaterialConnectionPoint;
  61864. /**
  61865. * Gets the ior input component
  61866. */
  61867. get ior(): NodeMaterialConnectionPoint;
  61868. /**
  61869. * Gets the texture input component
  61870. */
  61871. get texture(): NodeMaterialConnectionPoint;
  61872. /**
  61873. * Gets the bump texture input component
  61874. */
  61875. get bumpTexture(): NodeMaterialConnectionPoint;
  61876. /**
  61877. * Gets the uv input component
  61878. */
  61879. get uv(): NodeMaterialConnectionPoint;
  61880. /**
  61881. * Gets the tint color input component
  61882. */
  61883. get tintColor(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the tint "at distance" input component
  61886. */
  61887. get tintAtDistance(): NodeMaterialConnectionPoint;
  61888. /**
  61889. * Gets the tint thickness input component
  61890. */
  61891. get tintThickness(): NodeMaterialConnectionPoint;
  61892. /**
  61893. * Gets the tint texture input component
  61894. */
  61895. get tintTexture(): NodeMaterialConnectionPoint;
  61896. /**
  61897. * Gets the world tangent input component
  61898. */
  61899. get worldTangent(): NodeMaterialConnectionPoint;
  61900. /**
  61901. * Gets the clear coat object output component
  61902. */
  61903. get clearcoat(): NodeMaterialConnectionPoint;
  61904. autoConfigure(material: NodeMaterial): void;
  61905. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61906. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  61907. private _generateTBNSpace;
  61908. /**
  61909. * Gets the main code of the block (fragment side)
  61910. * @param state current state of the node material building
  61911. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  61912. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61913. * @param worldPosVarName name of the variable holding the world position
  61914. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  61915. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  61916. * @param worldNormalVarName name of the variable holding the world normal
  61917. * @returns the shader code
  61918. */
  61919. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  61920. protected _buildBlock(state: NodeMaterialBuildState): this;
  61921. }
  61922. }
  61923. declare module BABYLON {
  61924. /**
  61925. * Block used to implement the sub surface module of the PBR material
  61926. */
  61927. export class SubSurfaceBlock extends NodeMaterialBlock {
  61928. /**
  61929. * Create a new SubSurfaceBlock
  61930. * @param name defines the block name
  61931. */
  61932. constructor(name: string);
  61933. /**
  61934. * Stores the intensity of the different subsurface effects in the thickness texture.
  61935. * * the green channel is the translucency intensity.
  61936. * * the blue channel is the scattering intensity.
  61937. * * the alpha channel is the refraction intensity.
  61938. */
  61939. useMaskFromThicknessTexture: boolean;
  61940. /**
  61941. * Initialize the block and prepare the context for build
  61942. * @param state defines the state that will be used for the build
  61943. */
  61944. initialize(state: NodeMaterialBuildState): void;
  61945. /**
  61946. * Gets the current class name
  61947. * @returns the class name
  61948. */
  61949. getClassName(): string;
  61950. /**
  61951. * Gets the min thickness input component
  61952. */
  61953. get minThickness(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the max thickness input component
  61956. */
  61957. get maxThickness(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the thickness texture component
  61960. */
  61961. get thicknessTexture(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the tint color input component
  61964. */
  61965. get tintColor(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the translucency intensity input component
  61968. */
  61969. get translucencyIntensity(): NodeMaterialConnectionPoint;
  61970. /**
  61971. * Gets the translucency diffusion distance input component
  61972. */
  61973. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  61974. /**
  61975. * Gets the refraction object parameters
  61976. */
  61977. get refraction(): NodeMaterialConnectionPoint;
  61978. /**
  61979. * Gets the sub surface object output component
  61980. */
  61981. get subsurface(): NodeMaterialConnectionPoint;
  61982. autoConfigure(material: NodeMaterial): void;
  61983. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61984. /**
  61985. * Gets the main code of the block (fragment side)
  61986. * @param state current state of the node material building
  61987. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  61988. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  61989. * @param worldPosVarName name of the variable holding the world position
  61990. * @returns the shader code
  61991. */
  61992. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  61993. protected _buildBlock(state: NodeMaterialBuildState): this;
  61994. }
  61995. }
  61996. declare module BABYLON {
  61997. /**
  61998. * Block used to implement the PBR metallic/roughness model
  61999. */
  62000. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  62001. /**
  62002. * Gets or sets the light associated with this block
  62003. */
  62004. light: Nullable<Light>;
  62005. private _lightId;
  62006. private _scene;
  62007. private _environmentBRDFTexture;
  62008. private _environmentBrdfSamplerName;
  62009. private _vNormalWName;
  62010. private _invertNormalName;
  62011. /**
  62012. * Create a new ReflectionBlock
  62013. * @param name defines the block name
  62014. */
  62015. constructor(name: string);
  62016. /**
  62017. * Intensity of the direct lights e.g. the four lights available in your scene.
  62018. * This impacts both the direct diffuse and specular highlights.
  62019. */
  62020. directIntensity: number;
  62021. /**
  62022. * Intensity of the environment e.g. how much the environment will light the object
  62023. * either through harmonics for rough material or through the refelction for shiny ones.
  62024. */
  62025. environmentIntensity: number;
  62026. /**
  62027. * This is a special control allowing the reduction of the specular highlights coming from the
  62028. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  62029. */
  62030. specularIntensity: number;
  62031. /**
  62032. * Defines the falloff type used in this material.
  62033. * It by default is Physical.
  62034. */
  62035. lightFalloff: number;
  62036. /**
  62037. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  62038. */
  62039. useAlphaFromAlbedoTexture: boolean;
  62040. /**
  62041. * Specifies that alpha test should be used
  62042. */
  62043. useAlphaTest: boolean;
  62044. /**
  62045. * Defines the alpha limits in alpha test mode.
  62046. */
  62047. alphaTestCutoff: number;
  62048. /**
  62049. * Specifies that alpha blending should be used
  62050. */
  62051. useAlphaBlending: boolean;
  62052. /**
  62053. * Defines if the alpha value should be determined via the rgb values.
  62054. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  62055. */
  62056. opacityRGB: boolean;
  62057. /**
  62058. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  62059. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  62060. */
  62061. useRadianceOverAlpha: boolean;
  62062. /**
  62063. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  62064. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  62065. */
  62066. useSpecularOverAlpha: boolean;
  62067. /**
  62068. * Enables specular anti aliasing in the PBR shader.
  62069. * It will both interacts on the Geometry for analytical and IBL lighting.
  62070. * It also prefilter the roughness map based on the bump values.
  62071. */
  62072. enableSpecularAntiAliasing: boolean;
  62073. /**
  62074. * Defines if the material uses energy conservation.
  62075. */
  62076. useEnergyConservation: boolean;
  62077. /**
  62078. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  62079. * too much the area relying on ambient texture to define their ambient occlusion.
  62080. */
  62081. useRadianceOcclusion: boolean;
  62082. /**
  62083. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  62084. * makes the reflect vector face the model (under horizon).
  62085. */
  62086. useHorizonOcclusion: boolean;
  62087. /**
  62088. * If set to true, no lighting calculations will be applied.
  62089. */
  62090. unlit: boolean;
  62091. /**
  62092. * Force normal to face away from face.
  62093. */
  62094. forceNormalForward: boolean;
  62095. /**
  62096. * Defines the material debug mode.
  62097. * It helps seeing only some components of the material while troubleshooting.
  62098. */
  62099. debugMode: number;
  62100. /**
  62101. * Specify from where on screen the debug mode should start.
  62102. * The value goes from -1 (full screen) to 1 (not visible)
  62103. * It helps with side by side comparison against the final render
  62104. * This defaults to 0
  62105. */
  62106. debugLimit: number;
  62107. /**
  62108. * As the default viewing range might not be enough (if the ambient is really small for instance)
  62109. * You can use the factor to better multiply the final value.
  62110. */
  62111. debugFactor: number;
  62112. /**
  62113. * Initialize the block and prepare the context for build
  62114. * @param state defines the state that will be used for the build
  62115. */
  62116. initialize(state: NodeMaterialBuildState): void;
  62117. /**
  62118. * Gets the current class name
  62119. * @returns the class name
  62120. */
  62121. getClassName(): string;
  62122. /**
  62123. * Gets the world position input component
  62124. */
  62125. get worldPosition(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the world normal input component
  62128. */
  62129. get worldNormal(): NodeMaterialConnectionPoint;
  62130. /**
  62131. * Gets the perturbed normal input component
  62132. */
  62133. get perturbedNormal(): NodeMaterialConnectionPoint;
  62134. /**
  62135. * Gets the camera position input component
  62136. */
  62137. get cameraPosition(): NodeMaterialConnectionPoint;
  62138. /**
  62139. * Gets the base color input component
  62140. */
  62141. get baseColor(): NodeMaterialConnectionPoint;
  62142. /**
  62143. * Gets the base texture input component
  62144. */
  62145. get baseTexture(): NodeMaterialConnectionPoint;
  62146. /**
  62147. * Gets the opacity texture input component
  62148. */
  62149. get opacityTexture(): NodeMaterialConnectionPoint;
  62150. /**
  62151. * Gets the ambient color input component
  62152. */
  62153. get ambientColor(): NodeMaterialConnectionPoint;
  62154. /**
  62155. * Gets the reflectivity object parameters
  62156. */
  62157. get reflectivity(): NodeMaterialConnectionPoint;
  62158. /**
  62159. * Gets the ambient occlusion object parameters
  62160. */
  62161. get ambientOcclusion(): NodeMaterialConnectionPoint;
  62162. /**
  62163. * Gets the reflection object parameters
  62164. */
  62165. get reflection(): NodeMaterialConnectionPoint;
  62166. /**
  62167. * Gets the sheen object parameters
  62168. */
  62169. get sheen(): NodeMaterialConnectionPoint;
  62170. /**
  62171. * Gets the clear coat object parameters
  62172. */
  62173. get clearcoat(): NodeMaterialConnectionPoint;
  62174. /**
  62175. * Gets the sub surface object parameters
  62176. */
  62177. get subsurface(): NodeMaterialConnectionPoint;
  62178. /**
  62179. * Gets the anisotropy object parameters
  62180. */
  62181. get anisotropy(): NodeMaterialConnectionPoint;
  62182. /**
  62183. * Gets the ambient output component
  62184. */
  62185. get ambient(): NodeMaterialConnectionPoint;
  62186. /**
  62187. * Gets the diffuse output component
  62188. */
  62189. get diffuse(): NodeMaterialConnectionPoint;
  62190. /**
  62191. * Gets the specular output component
  62192. */
  62193. get specular(): NodeMaterialConnectionPoint;
  62194. /**
  62195. * Gets the sheen output component
  62196. */
  62197. get sheenDir(): NodeMaterialConnectionPoint;
  62198. /**
  62199. * Gets the clear coat output component
  62200. */
  62201. get clearcoatDir(): NodeMaterialConnectionPoint;
  62202. /**
  62203. * Gets the indirect diffuse output component
  62204. */
  62205. get diffuseIndirect(): NodeMaterialConnectionPoint;
  62206. /**
  62207. * Gets the indirect specular output component
  62208. */
  62209. get specularIndirect(): NodeMaterialConnectionPoint;
  62210. /**
  62211. * Gets the indirect sheen output component
  62212. */
  62213. get sheenIndirect(): NodeMaterialConnectionPoint;
  62214. /**
  62215. * Gets the indirect clear coat output component
  62216. */
  62217. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  62218. /**
  62219. * Gets the refraction output component
  62220. */
  62221. get refraction(): NodeMaterialConnectionPoint;
  62222. /**
  62223. * Gets the global lighting output component
  62224. */
  62225. get lighting(): NodeMaterialConnectionPoint;
  62226. /**
  62227. * Gets the shadow output component
  62228. */
  62229. get shadow(): NodeMaterialConnectionPoint;
  62230. /**
  62231. * Gets the alpha output component
  62232. */
  62233. get alpha(): NodeMaterialConnectionPoint;
  62234. autoConfigure(material: NodeMaterial): void;
  62235. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62236. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62237. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62238. private _injectVertexCode;
  62239. /**
  62240. * Gets the code corresponding to the albedo/opacity module
  62241. * @returns the shader code
  62242. */
  62243. getAlbedoOpacityCode(): string;
  62244. protected _buildBlock(state: NodeMaterialBuildState): this;
  62245. protected _dumpPropertiesCode(): string;
  62246. serialize(): any;
  62247. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62248. }
  62249. }
  62250. declare module BABYLON {
  62251. /**
  62252. * Effect Render Options
  62253. */
  62254. export interface IEffectRendererOptions {
  62255. /**
  62256. * Defines the vertices positions.
  62257. */
  62258. positions?: number[];
  62259. /**
  62260. * Defines the indices.
  62261. */
  62262. indices?: number[];
  62263. }
  62264. /**
  62265. * Helper class to render one or more effects.
  62266. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  62267. */
  62268. export class EffectRenderer {
  62269. private engine;
  62270. private static _DefaultOptions;
  62271. private _vertexBuffers;
  62272. private _indexBuffer;
  62273. private _fullscreenViewport;
  62274. /**
  62275. * Creates an effect renderer
  62276. * @param engine the engine to use for rendering
  62277. * @param options defines the options of the effect renderer
  62278. */
  62279. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62280. /**
  62281. * Sets the current viewport in normalized coordinates 0-1
  62282. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62283. */
  62284. setViewport(viewport?: Viewport): void;
  62285. /**
  62286. * Binds the embedded attributes buffer to the effect.
  62287. * @param effect Defines the effect to bind the attributes for
  62288. */
  62289. bindBuffers(effect: Effect): void;
  62290. /**
  62291. * Sets the current effect wrapper to use during draw.
  62292. * The effect needs to be ready before calling this api.
  62293. * This also sets the default full screen position attribute.
  62294. * @param effectWrapper Defines the effect to draw with
  62295. */
  62296. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62297. /**
  62298. * Draws a full screen quad.
  62299. */
  62300. draw(): void;
  62301. private isRenderTargetTexture;
  62302. /**
  62303. * renders one or more effects to a specified texture
  62304. * @param effectWrapper the effect to renderer
  62305. * @param outputTexture texture to draw to, if null it will render to the screen.
  62306. */
  62307. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  62308. /**
  62309. * Disposes of the effect renderer
  62310. */
  62311. dispose(): void;
  62312. }
  62313. /**
  62314. * Options to create an EffectWrapper
  62315. */
  62316. interface EffectWrapperCreationOptions {
  62317. /**
  62318. * Engine to use to create the effect
  62319. */
  62320. engine: ThinEngine;
  62321. /**
  62322. * Fragment shader for the effect
  62323. */
  62324. fragmentShader: string;
  62325. /**
  62326. * Vertex shader for the effect
  62327. */
  62328. vertexShader?: string;
  62329. /**
  62330. * Attributes to use in the shader
  62331. */
  62332. attributeNames?: Array<string>;
  62333. /**
  62334. * Uniforms to use in the shader
  62335. */
  62336. uniformNames?: Array<string>;
  62337. /**
  62338. * Texture sampler names to use in the shader
  62339. */
  62340. samplerNames?: Array<string>;
  62341. /**
  62342. * The friendly name of the effect displayed in Spector.
  62343. */
  62344. name?: string;
  62345. }
  62346. /**
  62347. * Wraps an effect to be used for rendering
  62348. */
  62349. export class EffectWrapper {
  62350. /**
  62351. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62352. */
  62353. onApplyObservable: Observable<{}>;
  62354. /**
  62355. * The underlying effect
  62356. */
  62357. effect: Effect;
  62358. /**
  62359. * Creates an effect to be renderer
  62360. * @param creationOptions options to create the effect
  62361. */
  62362. constructor(creationOptions: EffectWrapperCreationOptions);
  62363. /**
  62364. * Disposes of the effect wrapper
  62365. */
  62366. dispose(): void;
  62367. }
  62368. }
  62369. declare module BABYLON {
  62370. /**
  62371. * Helper class to push actions to a pool of workers.
  62372. */
  62373. export class WorkerPool implements IDisposable {
  62374. private _workerInfos;
  62375. private _pendingActions;
  62376. /**
  62377. * Constructor
  62378. * @param workers Array of workers to use for actions
  62379. */
  62380. constructor(workers: Array<Worker>);
  62381. /**
  62382. * Terminates all workers and clears any pending actions.
  62383. */
  62384. dispose(): void;
  62385. /**
  62386. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62387. * pended until a worker has completed its action.
  62388. * @param action The action to perform. Call onComplete when the action is complete.
  62389. */
  62390. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62391. private _execute;
  62392. }
  62393. }
  62394. declare module BABYLON {
  62395. /**
  62396. * Configuration for Draco compression
  62397. */
  62398. export interface IDracoCompressionConfiguration {
  62399. /**
  62400. * Configuration for the decoder.
  62401. */
  62402. decoder: {
  62403. /**
  62404. * The url to the WebAssembly module.
  62405. */
  62406. wasmUrl?: string;
  62407. /**
  62408. * The url to the WebAssembly binary.
  62409. */
  62410. wasmBinaryUrl?: string;
  62411. /**
  62412. * The url to the fallback JavaScript module.
  62413. */
  62414. fallbackUrl?: string;
  62415. };
  62416. }
  62417. /**
  62418. * Draco compression (https://google.github.io/draco/)
  62419. *
  62420. * This class wraps the Draco module.
  62421. *
  62422. * **Encoder**
  62423. *
  62424. * The encoder is not currently implemented.
  62425. *
  62426. * **Decoder**
  62427. *
  62428. * 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.
  62429. *
  62430. * To update the configuration, use the following code:
  62431. * ```javascript
  62432. * DracoCompression.Configuration = {
  62433. * decoder: {
  62434. * wasmUrl: "<url to the WebAssembly library>",
  62435. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62436. * fallbackUrl: "<url to the fallback JavaScript library>",
  62437. * }
  62438. * };
  62439. * ```
  62440. *
  62441. * 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.
  62442. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62443. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62444. *
  62445. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62446. * ```javascript
  62447. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62448. * ```
  62449. *
  62450. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62451. */
  62452. export class DracoCompression implements IDisposable {
  62453. private _workerPoolPromise?;
  62454. private _decoderModulePromise?;
  62455. /**
  62456. * The configuration. Defaults to the following urls:
  62457. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62458. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62459. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62460. */
  62461. static Configuration: IDracoCompressionConfiguration;
  62462. /**
  62463. * Returns true if the decoder configuration is available.
  62464. */
  62465. static get DecoderAvailable(): boolean;
  62466. /**
  62467. * Default number of workers to create when creating the draco compression object.
  62468. */
  62469. static DefaultNumWorkers: number;
  62470. private static GetDefaultNumWorkers;
  62471. private static _Default;
  62472. /**
  62473. * Default instance for the draco compression object.
  62474. */
  62475. static get Default(): DracoCompression;
  62476. /**
  62477. * Constructor
  62478. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62479. */
  62480. constructor(numWorkers?: number);
  62481. /**
  62482. * Stop all async operations and release resources.
  62483. */
  62484. dispose(): void;
  62485. /**
  62486. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62487. * @returns a promise that resolves when ready
  62488. */
  62489. whenReadyAsync(): Promise<void>;
  62490. /**
  62491. * Decode Draco compressed mesh data to vertex data.
  62492. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62493. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62494. * @returns A promise that resolves with the decoded vertex data
  62495. */
  62496. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62497. [kind: string]: number;
  62498. }): Promise<VertexData>;
  62499. }
  62500. }
  62501. declare module BABYLON {
  62502. /**
  62503. * Class for building Constructive Solid Geometry
  62504. */
  62505. export class CSG {
  62506. private polygons;
  62507. /**
  62508. * The world matrix
  62509. */
  62510. matrix: Matrix;
  62511. /**
  62512. * Stores the position
  62513. */
  62514. position: Vector3;
  62515. /**
  62516. * Stores the rotation
  62517. */
  62518. rotation: Vector3;
  62519. /**
  62520. * Stores the rotation quaternion
  62521. */
  62522. rotationQuaternion: Nullable<Quaternion>;
  62523. /**
  62524. * Stores the scaling vector
  62525. */
  62526. scaling: Vector3;
  62527. /**
  62528. * Convert the Mesh to CSG
  62529. * @param mesh The Mesh to convert to CSG
  62530. * @returns A new CSG from the Mesh
  62531. */
  62532. static FromMesh(mesh: Mesh): CSG;
  62533. /**
  62534. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62535. * @param polygons Polygons used to construct a CSG solid
  62536. */
  62537. private static FromPolygons;
  62538. /**
  62539. * Clones, or makes a deep copy, of the CSG
  62540. * @returns A new CSG
  62541. */
  62542. clone(): CSG;
  62543. /**
  62544. * Unions this CSG with another CSG
  62545. * @param csg The CSG to union against this CSG
  62546. * @returns The unioned CSG
  62547. */
  62548. union(csg: CSG): CSG;
  62549. /**
  62550. * Unions this CSG with another CSG in place
  62551. * @param csg The CSG to union against this CSG
  62552. */
  62553. unionInPlace(csg: CSG): void;
  62554. /**
  62555. * Subtracts this CSG with another CSG
  62556. * @param csg The CSG to subtract against this CSG
  62557. * @returns A new CSG
  62558. */
  62559. subtract(csg: CSG): CSG;
  62560. /**
  62561. * Subtracts this CSG with another CSG in place
  62562. * @param csg The CSG to subtact against this CSG
  62563. */
  62564. subtractInPlace(csg: CSG): void;
  62565. /**
  62566. * Intersect this CSG with another CSG
  62567. * @param csg The CSG to intersect against this CSG
  62568. * @returns A new CSG
  62569. */
  62570. intersect(csg: CSG): CSG;
  62571. /**
  62572. * Intersects this CSG with another CSG in place
  62573. * @param csg The CSG to intersect against this CSG
  62574. */
  62575. intersectInPlace(csg: CSG): void;
  62576. /**
  62577. * Return a new CSG solid with solid and empty space switched. This solid is
  62578. * not modified.
  62579. * @returns A new CSG solid with solid and empty space switched
  62580. */
  62581. inverse(): CSG;
  62582. /**
  62583. * Inverses the CSG in place
  62584. */
  62585. inverseInPlace(): void;
  62586. /**
  62587. * This is used to keep meshes transformations so they can be restored
  62588. * when we build back a Babylon Mesh
  62589. * NB : All CSG operations are performed in world coordinates
  62590. * @param csg The CSG to copy the transform attributes from
  62591. * @returns This CSG
  62592. */
  62593. copyTransformAttributes(csg: CSG): CSG;
  62594. /**
  62595. * Build Raw mesh from CSG
  62596. * Coordinates here are in world space
  62597. * @param name The name of the mesh geometry
  62598. * @param scene The Scene
  62599. * @param keepSubMeshes Specifies if the submeshes should be kept
  62600. * @returns A new Mesh
  62601. */
  62602. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62603. /**
  62604. * Build Mesh from CSG taking material and transforms into account
  62605. * @param name The name of the Mesh
  62606. * @param material The material of the Mesh
  62607. * @param scene The Scene
  62608. * @param keepSubMeshes Specifies if submeshes should be kept
  62609. * @returns The new Mesh
  62610. */
  62611. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62612. }
  62613. }
  62614. declare module BABYLON {
  62615. /**
  62616. * Class used to create a trail following a mesh
  62617. */
  62618. export class TrailMesh extends Mesh {
  62619. private _generator;
  62620. private _autoStart;
  62621. private _running;
  62622. private _diameter;
  62623. private _length;
  62624. private _sectionPolygonPointsCount;
  62625. private _sectionVectors;
  62626. private _sectionNormalVectors;
  62627. private _beforeRenderObserver;
  62628. /**
  62629. * @constructor
  62630. * @param name The value used by scene.getMeshByName() to do a lookup.
  62631. * @param generator The mesh or transform node to generate a trail.
  62632. * @param scene The scene to add this mesh to.
  62633. * @param diameter Diameter of trailing mesh. Default is 1.
  62634. * @param length Length of trailing mesh. Default is 60.
  62635. * @param autoStart Automatically start trailing mesh. Default true.
  62636. */
  62637. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  62638. /**
  62639. * "TrailMesh"
  62640. * @returns "TrailMesh"
  62641. */
  62642. getClassName(): string;
  62643. private _createMesh;
  62644. /**
  62645. * Start trailing mesh.
  62646. */
  62647. start(): void;
  62648. /**
  62649. * Stop trailing mesh.
  62650. */
  62651. stop(): void;
  62652. /**
  62653. * Update trailing mesh geometry.
  62654. */
  62655. update(): void;
  62656. /**
  62657. * Returns a new TrailMesh object.
  62658. * @param name is a string, the name given to the new mesh
  62659. * @param newGenerator use new generator object for cloned trail mesh
  62660. * @returns a new mesh
  62661. */
  62662. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  62663. /**
  62664. * Serializes this trail mesh
  62665. * @param serializationObject object to write serialization to
  62666. */
  62667. serialize(serializationObject: any): void;
  62668. /**
  62669. * Parses a serialized trail mesh
  62670. * @param parsedMesh the serialized mesh
  62671. * @param scene the scene to create the trail mesh in
  62672. * @returns the created trail mesh
  62673. */
  62674. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  62675. }
  62676. }
  62677. declare module BABYLON {
  62678. /**
  62679. * Class containing static functions to help procedurally build meshes
  62680. */
  62681. export class TiledBoxBuilder {
  62682. /**
  62683. * Creates a box mesh
  62684. * 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)
  62685. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62687. * * 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
  62688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62689. * @param name defines the name of the mesh
  62690. * @param options defines the options used to create the mesh
  62691. * @param scene defines the hosting scene
  62692. * @returns the box mesh
  62693. */
  62694. static CreateTiledBox(name: string, options: {
  62695. pattern?: number;
  62696. width?: number;
  62697. height?: number;
  62698. depth?: number;
  62699. tileSize?: number;
  62700. tileWidth?: number;
  62701. tileHeight?: number;
  62702. alignHorizontal?: number;
  62703. alignVertical?: number;
  62704. faceUV?: Vector4[];
  62705. faceColors?: Color4[];
  62706. sideOrientation?: number;
  62707. updatable?: boolean;
  62708. }, scene?: Nullable<Scene>): Mesh;
  62709. }
  62710. }
  62711. declare module BABYLON {
  62712. /**
  62713. * Class containing static functions to help procedurally build meshes
  62714. */
  62715. export class TorusKnotBuilder {
  62716. /**
  62717. * Creates a torus knot mesh
  62718. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62719. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62720. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62721. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62723. * * 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
  62724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62725. * @param name defines the name of the mesh
  62726. * @param options defines the options used to create the mesh
  62727. * @param scene defines the hosting scene
  62728. * @returns the torus knot mesh
  62729. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62730. */
  62731. static CreateTorusKnot(name: string, options: {
  62732. radius?: number;
  62733. tube?: number;
  62734. radialSegments?: number;
  62735. tubularSegments?: number;
  62736. p?: number;
  62737. q?: number;
  62738. updatable?: boolean;
  62739. sideOrientation?: number;
  62740. frontUVs?: Vector4;
  62741. backUVs?: Vector4;
  62742. }, scene: any): Mesh;
  62743. }
  62744. }
  62745. declare module BABYLON {
  62746. /**
  62747. * Polygon
  62748. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  62749. */
  62750. export class Polygon {
  62751. /**
  62752. * Creates a rectangle
  62753. * @param xmin bottom X coord
  62754. * @param ymin bottom Y coord
  62755. * @param xmax top X coord
  62756. * @param ymax top Y coord
  62757. * @returns points that make the resulting rectation
  62758. */
  62759. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  62760. /**
  62761. * Creates a circle
  62762. * @param radius radius of circle
  62763. * @param cx scale in x
  62764. * @param cy scale in y
  62765. * @param numberOfSides number of sides that make up the circle
  62766. * @returns points that make the resulting circle
  62767. */
  62768. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  62769. /**
  62770. * Creates a polygon from input string
  62771. * @param input Input polygon data
  62772. * @returns the parsed points
  62773. */
  62774. static Parse(input: string): Vector2[];
  62775. /**
  62776. * Starts building a polygon from x and y coordinates
  62777. * @param x x coordinate
  62778. * @param y y coordinate
  62779. * @returns the started path2
  62780. */
  62781. static StartingAt(x: number, y: number): Path2;
  62782. }
  62783. /**
  62784. * Builds a polygon
  62785. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  62786. */
  62787. export class PolygonMeshBuilder {
  62788. private _points;
  62789. private _outlinepoints;
  62790. private _holes;
  62791. private _name;
  62792. private _scene;
  62793. private _epoints;
  62794. private _eholes;
  62795. private _addToepoint;
  62796. /**
  62797. * Babylon reference to the earcut plugin.
  62798. */
  62799. bjsEarcut: any;
  62800. /**
  62801. * Creates a PolygonMeshBuilder
  62802. * @param name name of the builder
  62803. * @param contours Path of the polygon
  62804. * @param scene scene to add to when creating the mesh
  62805. * @param earcutInjection can be used to inject your own earcut reference
  62806. */
  62807. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  62808. /**
  62809. * Adds a whole within the polygon
  62810. * @param hole Array of points defining the hole
  62811. * @returns this
  62812. */
  62813. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62814. /**
  62815. * Creates the polygon
  62816. * @param updatable If the mesh should be updatable
  62817. * @param depth The depth of the mesh created
  62818. * @returns the created mesh
  62819. */
  62820. build(updatable?: boolean, depth?: number): Mesh;
  62821. /**
  62822. * Creates the polygon
  62823. * @param depth The depth of the mesh created
  62824. * @returns the created VertexData
  62825. */
  62826. buildVertexData(depth?: number): VertexData;
  62827. /**
  62828. * Adds a side to the polygon
  62829. * @param positions points that make the polygon
  62830. * @param normals normals of the polygon
  62831. * @param uvs uvs of the polygon
  62832. * @param indices indices of the polygon
  62833. * @param bounds bounds of the polygon
  62834. * @param points points of the polygon
  62835. * @param depth depth of the polygon
  62836. * @param flip flip of the polygon
  62837. */
  62838. private addSide;
  62839. }
  62840. }
  62841. declare module BABYLON {
  62842. /**
  62843. * Class containing static functions to help procedurally build meshes
  62844. */
  62845. export class PolygonBuilder {
  62846. /**
  62847. * Creates a polygon mesh
  62848. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62849. * * 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
  62850. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62851. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62852. * * 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)
  62853. * * Remember you can only change the shape positions, not their number when updating a polygon
  62854. * @param name defines the name of the mesh
  62855. * @param options defines the options used to create the mesh
  62856. * @param scene defines the hosting scene
  62857. * @param earcutInjection can be used to inject your own earcut reference
  62858. * @returns the polygon mesh
  62859. */
  62860. static CreatePolygon(name: string, options: {
  62861. shape: Vector3[];
  62862. holes?: Vector3[][];
  62863. depth?: number;
  62864. faceUV?: Vector4[];
  62865. faceColors?: Color4[];
  62866. updatable?: boolean;
  62867. sideOrientation?: number;
  62868. frontUVs?: Vector4;
  62869. backUVs?: Vector4;
  62870. wrap?: boolean;
  62871. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62872. /**
  62873. * Creates an extruded polygon mesh, with depth in the Y direction.
  62874. * * 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)
  62875. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62876. * @param name defines the name of the mesh
  62877. * @param options defines the options used to create the mesh
  62878. * @param scene defines the hosting scene
  62879. * @param earcutInjection can be used to inject your own earcut reference
  62880. * @returns the polygon mesh
  62881. */
  62882. static ExtrudePolygon(name: string, options: {
  62883. shape: Vector3[];
  62884. holes?: Vector3[][];
  62885. depth?: number;
  62886. faceUV?: Vector4[];
  62887. faceColors?: Color4[];
  62888. updatable?: boolean;
  62889. sideOrientation?: number;
  62890. frontUVs?: Vector4;
  62891. backUVs?: Vector4;
  62892. wrap?: boolean;
  62893. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62894. }
  62895. }
  62896. declare module BABYLON {
  62897. /**
  62898. * Class containing static functions to help procedurally build meshes
  62899. */
  62900. export class LatheBuilder {
  62901. /**
  62902. * Creates lathe mesh.
  62903. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62904. * * 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
  62905. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62906. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62907. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62908. * * 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
  62909. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62910. * * 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
  62911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62912. * * 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
  62913. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62915. * @param name defines the name of the mesh
  62916. * @param options defines the options used to create the mesh
  62917. * @param scene defines the hosting scene
  62918. * @returns the lathe mesh
  62919. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62920. */
  62921. static CreateLathe(name: string, options: {
  62922. shape: Vector3[];
  62923. radius?: number;
  62924. tessellation?: number;
  62925. clip?: number;
  62926. arc?: number;
  62927. closed?: boolean;
  62928. updatable?: boolean;
  62929. sideOrientation?: number;
  62930. frontUVs?: Vector4;
  62931. backUVs?: Vector4;
  62932. cap?: number;
  62933. invertUV?: boolean;
  62934. }, scene?: Nullable<Scene>): Mesh;
  62935. }
  62936. }
  62937. declare module BABYLON {
  62938. /**
  62939. * Class containing static functions to help procedurally build meshes
  62940. */
  62941. export class TiledPlaneBuilder {
  62942. /**
  62943. * Creates a tiled plane mesh
  62944. * * The parameter `pattern` will, depending on value, do nothing or
  62945. * * * flip (reflect about central vertical) alternate tiles across and up
  62946. * * * flip every tile on alternate rows
  62947. * * * rotate (180 degs) alternate tiles across and up
  62948. * * * rotate every tile on alternate rows
  62949. * * * flip and rotate alternate tiles across and up
  62950. * * * flip and rotate every tile on alternate rows
  62951. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62952. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62953. * * 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
  62954. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62955. * * 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)
  62956. * * 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)
  62957. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62958. * @param name defines the name of the mesh
  62959. * @param options defines the options used to create the mesh
  62960. * @param scene defines the hosting scene
  62961. * @returns the box mesh
  62962. */
  62963. static CreateTiledPlane(name: string, options: {
  62964. pattern?: number;
  62965. tileSize?: number;
  62966. tileWidth?: number;
  62967. tileHeight?: number;
  62968. size?: number;
  62969. width?: number;
  62970. height?: number;
  62971. alignHorizontal?: number;
  62972. alignVertical?: number;
  62973. sideOrientation?: number;
  62974. frontUVs?: Vector4;
  62975. backUVs?: Vector4;
  62976. updatable?: boolean;
  62977. }, scene?: Nullable<Scene>): Mesh;
  62978. }
  62979. }
  62980. declare module BABYLON {
  62981. /**
  62982. * Class containing static functions to help procedurally build meshes
  62983. */
  62984. export class TubeBuilder {
  62985. /**
  62986. * Creates a tube mesh.
  62987. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62988. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62989. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62990. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62991. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62992. * * 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)
  62993. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62994. * * 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
  62995. * * 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
  62996. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62997. * * 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
  62998. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62999. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63000. * @param name defines the name of the mesh
  63001. * @param options defines the options used to create the mesh
  63002. * @param scene defines the hosting scene
  63003. * @returns the tube mesh
  63004. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63005. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63006. */
  63007. static CreateTube(name: string, options: {
  63008. path: Vector3[];
  63009. radius?: number;
  63010. tessellation?: number;
  63011. radiusFunction?: {
  63012. (i: number, distance: number): number;
  63013. };
  63014. cap?: number;
  63015. arc?: number;
  63016. updatable?: boolean;
  63017. sideOrientation?: number;
  63018. frontUVs?: Vector4;
  63019. backUVs?: Vector4;
  63020. instance?: Mesh;
  63021. invertUV?: boolean;
  63022. }, scene?: Nullable<Scene>): Mesh;
  63023. }
  63024. }
  63025. declare module BABYLON {
  63026. /**
  63027. * Class containing static functions to help procedurally build meshes
  63028. */
  63029. export class IcoSphereBuilder {
  63030. /**
  63031. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63032. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63033. * * 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`)
  63034. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63035. * * 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
  63036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63037. * * 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
  63038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63039. * @param name defines the name of the mesh
  63040. * @param options defines the options used to create the mesh
  63041. * @param scene defines the hosting scene
  63042. * @returns the icosahedron mesh
  63043. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63044. */
  63045. static CreateIcoSphere(name: string, options: {
  63046. radius?: number;
  63047. radiusX?: number;
  63048. radiusY?: number;
  63049. radiusZ?: number;
  63050. flat?: boolean;
  63051. subdivisions?: number;
  63052. sideOrientation?: number;
  63053. frontUVs?: Vector4;
  63054. backUVs?: Vector4;
  63055. updatable?: boolean;
  63056. }, scene?: Nullable<Scene>): Mesh;
  63057. }
  63058. }
  63059. declare module BABYLON {
  63060. /**
  63061. * Class containing static functions to help procedurally build meshes
  63062. */
  63063. export class DecalBuilder {
  63064. /**
  63065. * Creates a decal mesh.
  63066. * 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
  63067. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63068. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63069. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63070. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63071. * @param name defines the name of the mesh
  63072. * @param sourceMesh defines the mesh where the decal must be applied
  63073. * @param options defines the options used to create the mesh
  63074. * @param scene defines the hosting scene
  63075. * @returns the decal mesh
  63076. * @see https://doc.babylonjs.com/how_to/decals
  63077. */
  63078. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63079. position?: Vector3;
  63080. normal?: Vector3;
  63081. size?: Vector3;
  63082. angle?: number;
  63083. }): Mesh;
  63084. }
  63085. }
  63086. declare module BABYLON {
  63087. /**
  63088. * Class containing static functions to help procedurally build meshes
  63089. */
  63090. export class MeshBuilder {
  63091. /**
  63092. * Creates a box mesh
  63093. * * The parameter `size` sets the size (float) of each box side (default 1)
  63094. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63095. * * 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)
  63096. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63098. * * 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
  63099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63100. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63101. * @param name defines the name of the mesh
  63102. * @param options defines the options used to create the mesh
  63103. * @param scene defines the hosting scene
  63104. * @returns the box mesh
  63105. */
  63106. static CreateBox(name: string, options: {
  63107. size?: number;
  63108. width?: number;
  63109. height?: number;
  63110. depth?: number;
  63111. faceUV?: Vector4[];
  63112. faceColors?: Color4[];
  63113. sideOrientation?: number;
  63114. frontUVs?: Vector4;
  63115. backUVs?: Vector4;
  63116. wrap?: boolean;
  63117. topBaseAt?: number;
  63118. bottomBaseAt?: number;
  63119. updatable?: boolean;
  63120. }, scene?: Nullable<Scene>): Mesh;
  63121. /**
  63122. * Creates a tiled box mesh
  63123. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63125. * @param name defines the name of the mesh
  63126. * @param options defines the options used to create the mesh
  63127. * @param scene defines the hosting scene
  63128. * @returns the tiled box mesh
  63129. */
  63130. static CreateTiledBox(name: string, options: {
  63131. pattern?: number;
  63132. size?: number;
  63133. width?: number;
  63134. height?: number;
  63135. depth: number;
  63136. tileSize?: number;
  63137. tileWidth?: number;
  63138. tileHeight?: number;
  63139. faceUV?: Vector4[];
  63140. faceColors?: Color4[];
  63141. alignHorizontal?: number;
  63142. alignVertical?: number;
  63143. sideOrientation?: number;
  63144. updatable?: boolean;
  63145. }, scene?: Nullable<Scene>): Mesh;
  63146. /**
  63147. * Creates a sphere mesh
  63148. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63149. * * 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`)
  63150. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63151. * * 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
  63152. * * 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)
  63153. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63154. * * 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
  63155. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63156. * @param name defines the name of the mesh
  63157. * @param options defines the options used to create the mesh
  63158. * @param scene defines the hosting scene
  63159. * @returns the sphere mesh
  63160. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63161. */
  63162. static CreateSphere(name: string, options: {
  63163. segments?: number;
  63164. diameter?: number;
  63165. diameterX?: number;
  63166. diameterY?: number;
  63167. diameterZ?: number;
  63168. arc?: number;
  63169. slice?: number;
  63170. sideOrientation?: number;
  63171. frontUVs?: Vector4;
  63172. backUVs?: Vector4;
  63173. updatable?: boolean;
  63174. }, scene?: Nullable<Scene>): Mesh;
  63175. /**
  63176. * Creates a plane polygonal mesh. By default, this is a disc
  63177. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63178. * * 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
  63179. * * 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
  63180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63181. * * 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
  63182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63183. * @param name defines the name of the mesh
  63184. * @param options defines the options used to create the mesh
  63185. * @param scene defines the hosting scene
  63186. * @returns the plane polygonal mesh
  63187. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63188. */
  63189. static CreateDisc(name: string, options: {
  63190. radius?: number;
  63191. tessellation?: number;
  63192. arc?: number;
  63193. updatable?: boolean;
  63194. sideOrientation?: number;
  63195. frontUVs?: Vector4;
  63196. backUVs?: Vector4;
  63197. }, scene?: Nullable<Scene>): Mesh;
  63198. /**
  63199. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63200. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63201. * * 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`)
  63202. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63203. * * 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
  63204. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63205. * * 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
  63206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63207. * @param name defines the name of the mesh
  63208. * @param options defines the options used to create the mesh
  63209. * @param scene defines the hosting scene
  63210. * @returns the icosahedron mesh
  63211. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63212. */
  63213. static CreateIcoSphere(name: string, options: {
  63214. radius?: number;
  63215. radiusX?: number;
  63216. radiusY?: number;
  63217. radiusZ?: number;
  63218. flat?: boolean;
  63219. subdivisions?: number;
  63220. sideOrientation?: number;
  63221. frontUVs?: Vector4;
  63222. backUVs?: Vector4;
  63223. updatable?: boolean;
  63224. }, scene?: Nullable<Scene>): Mesh;
  63225. /**
  63226. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63227. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63228. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63229. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63230. * * 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
  63231. * * 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
  63232. * * 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
  63233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63234. * * 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
  63235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63236. * * 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
  63237. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63238. * * 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
  63239. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63241. * @param name defines the name of the mesh
  63242. * @param options defines the options used to create the mesh
  63243. * @param scene defines the hosting scene
  63244. * @returns the ribbon mesh
  63245. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63246. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63247. */
  63248. static CreateRibbon(name: string, options: {
  63249. pathArray: Vector3[][];
  63250. closeArray?: boolean;
  63251. closePath?: boolean;
  63252. offset?: number;
  63253. updatable?: boolean;
  63254. sideOrientation?: number;
  63255. frontUVs?: Vector4;
  63256. backUVs?: Vector4;
  63257. instance?: Mesh;
  63258. invertUV?: boolean;
  63259. uvs?: Vector2[];
  63260. colors?: Color4[];
  63261. }, scene?: Nullable<Scene>): Mesh;
  63262. /**
  63263. * Creates a cylinder or a cone mesh
  63264. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63265. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63266. * * 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.
  63267. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63268. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63269. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63270. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63271. * * 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).
  63272. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63273. * * 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).
  63274. * * 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
  63275. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63276. * * 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
  63277. * * 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.
  63278. * * If `enclose` is false, a ring surface is one element.
  63279. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63280. * * 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
  63281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63282. * * 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
  63283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63284. * @param name defines the name of the mesh
  63285. * @param options defines the options used to create the mesh
  63286. * @param scene defines the hosting scene
  63287. * @returns the cylinder mesh
  63288. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63289. */
  63290. static CreateCylinder(name: string, options: {
  63291. height?: number;
  63292. diameterTop?: number;
  63293. diameterBottom?: number;
  63294. diameter?: number;
  63295. tessellation?: number;
  63296. subdivisions?: number;
  63297. arc?: number;
  63298. faceColors?: Color4[];
  63299. faceUV?: Vector4[];
  63300. updatable?: boolean;
  63301. hasRings?: boolean;
  63302. enclose?: boolean;
  63303. cap?: number;
  63304. sideOrientation?: number;
  63305. frontUVs?: Vector4;
  63306. backUVs?: Vector4;
  63307. }, scene?: Nullable<Scene>): Mesh;
  63308. /**
  63309. * Creates a torus mesh
  63310. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63311. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63312. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63314. * * 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
  63315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63316. * @param name defines the name of the mesh
  63317. * @param options defines the options used to create the mesh
  63318. * @param scene defines the hosting scene
  63319. * @returns the torus mesh
  63320. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63321. */
  63322. static CreateTorus(name: string, options: {
  63323. diameter?: number;
  63324. thickness?: number;
  63325. tessellation?: number;
  63326. updatable?: boolean;
  63327. sideOrientation?: number;
  63328. frontUVs?: Vector4;
  63329. backUVs?: Vector4;
  63330. }, scene?: Nullable<Scene>): Mesh;
  63331. /**
  63332. * Creates a torus knot mesh
  63333. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63334. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63335. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63336. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63338. * * 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
  63339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63340. * @param name defines the name of the mesh
  63341. * @param options defines the options used to create the mesh
  63342. * @param scene defines the hosting scene
  63343. * @returns the torus knot mesh
  63344. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63345. */
  63346. static CreateTorusKnot(name: string, options: {
  63347. radius?: number;
  63348. tube?: number;
  63349. radialSegments?: number;
  63350. tubularSegments?: number;
  63351. p?: number;
  63352. q?: number;
  63353. updatable?: boolean;
  63354. sideOrientation?: number;
  63355. frontUVs?: Vector4;
  63356. backUVs?: Vector4;
  63357. }, scene?: Nullable<Scene>): Mesh;
  63358. /**
  63359. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63360. * * 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
  63361. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63362. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63363. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63364. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63365. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63366. * * 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
  63367. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63370. * @param name defines the name of the new line system
  63371. * @param options defines the options used to create the line system
  63372. * @param scene defines the hosting scene
  63373. * @returns a new line system mesh
  63374. */
  63375. static CreateLineSystem(name: string, options: {
  63376. lines: Vector3[][];
  63377. updatable?: boolean;
  63378. instance?: Nullable<LinesMesh>;
  63379. colors?: Nullable<Color4[][]>;
  63380. useVertexAlpha?: boolean;
  63381. }, scene: Nullable<Scene>): LinesMesh;
  63382. /**
  63383. * Creates a line mesh
  63384. * 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
  63385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63386. * * The parameter `points` is an array successive Vector3
  63387. * * 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
  63388. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63389. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63390. * * When updating an instance, remember that only point positions can change, not the number of points
  63391. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63393. * @param name defines the name of the new line system
  63394. * @param options defines the options used to create the line system
  63395. * @param scene defines the hosting scene
  63396. * @returns a new line mesh
  63397. */
  63398. static CreateLines(name: string, options: {
  63399. points: Vector3[];
  63400. updatable?: boolean;
  63401. instance?: Nullable<LinesMesh>;
  63402. colors?: Color4[];
  63403. useVertexAlpha?: boolean;
  63404. }, scene?: Nullable<Scene>): LinesMesh;
  63405. /**
  63406. * Creates a dashed line mesh
  63407. * * 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
  63408. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63409. * * The parameter `points` is an array successive Vector3
  63410. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63411. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63412. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63413. * * 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
  63414. * * When updating an instance, remember that only point positions can change, not the number of points
  63415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63416. * @param name defines the name of the mesh
  63417. * @param options defines the options used to create the mesh
  63418. * @param scene defines the hosting scene
  63419. * @returns the dashed line mesh
  63420. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63421. */
  63422. static CreateDashedLines(name: string, options: {
  63423. points: Vector3[];
  63424. dashSize?: number;
  63425. gapSize?: number;
  63426. dashNb?: number;
  63427. updatable?: boolean;
  63428. instance?: LinesMesh;
  63429. }, scene?: Nullable<Scene>): LinesMesh;
  63430. /**
  63431. * 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.
  63432. * * 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.
  63433. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63434. * * 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.
  63435. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63436. * * 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
  63437. * * 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
  63438. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63440. * * 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
  63441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63443. * @param name defines the name of the mesh
  63444. * @param options defines the options used to create the mesh
  63445. * @param scene defines the hosting scene
  63446. * @returns the extruded shape mesh
  63447. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63449. */
  63450. static ExtrudeShape(name: string, options: {
  63451. shape: Vector3[];
  63452. path: Vector3[];
  63453. scale?: number;
  63454. rotation?: number;
  63455. cap?: number;
  63456. updatable?: boolean;
  63457. sideOrientation?: number;
  63458. frontUVs?: Vector4;
  63459. backUVs?: Vector4;
  63460. instance?: Mesh;
  63461. invertUV?: boolean;
  63462. }, scene?: Nullable<Scene>): Mesh;
  63463. /**
  63464. * Creates an custom extruded shape mesh.
  63465. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63466. * * 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.
  63467. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63468. * * 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
  63469. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63470. * * 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
  63471. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63472. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63473. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63474. * * 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
  63475. * * 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
  63476. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63478. * * 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
  63479. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63481. * @param name defines the name of the mesh
  63482. * @param options defines the options used to create the mesh
  63483. * @param scene defines the hosting scene
  63484. * @returns the custom extruded shape mesh
  63485. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63486. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63488. */
  63489. static ExtrudeShapeCustom(name: string, options: {
  63490. shape: Vector3[];
  63491. path: Vector3[];
  63492. scaleFunction?: any;
  63493. rotationFunction?: any;
  63494. ribbonCloseArray?: boolean;
  63495. ribbonClosePath?: boolean;
  63496. cap?: number;
  63497. updatable?: boolean;
  63498. sideOrientation?: number;
  63499. frontUVs?: Vector4;
  63500. backUVs?: Vector4;
  63501. instance?: Mesh;
  63502. invertUV?: boolean;
  63503. }, scene?: Nullable<Scene>): Mesh;
  63504. /**
  63505. * Creates lathe mesh.
  63506. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63507. * * 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
  63508. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63509. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63510. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63511. * * 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
  63512. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63513. * * 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
  63514. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63515. * * 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
  63516. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63518. * @param name defines the name of the mesh
  63519. * @param options defines the options used to create the mesh
  63520. * @param scene defines the hosting scene
  63521. * @returns the lathe mesh
  63522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63523. */
  63524. static CreateLathe(name: string, options: {
  63525. shape: Vector3[];
  63526. radius?: number;
  63527. tessellation?: number;
  63528. clip?: number;
  63529. arc?: number;
  63530. closed?: boolean;
  63531. updatable?: boolean;
  63532. sideOrientation?: number;
  63533. frontUVs?: Vector4;
  63534. backUVs?: Vector4;
  63535. cap?: number;
  63536. invertUV?: boolean;
  63537. }, scene?: Nullable<Scene>): Mesh;
  63538. /**
  63539. * Creates a tiled plane mesh
  63540. * * You can set a limited pattern arrangement with the tiles
  63541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63542. * * 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
  63543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63544. * @param name defines the name of the mesh
  63545. * @param options defines the options used to create the mesh
  63546. * @param scene defines the hosting scene
  63547. * @returns the plane mesh
  63548. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63549. */
  63550. static CreateTiledPlane(name: string, options: {
  63551. pattern?: number;
  63552. tileSize?: number;
  63553. tileWidth?: number;
  63554. tileHeight?: number;
  63555. size?: number;
  63556. width?: number;
  63557. height?: number;
  63558. alignHorizontal?: number;
  63559. alignVertical?: number;
  63560. sideOrientation?: number;
  63561. frontUVs?: Vector4;
  63562. backUVs?: Vector4;
  63563. updatable?: boolean;
  63564. }, scene?: Nullable<Scene>): Mesh;
  63565. /**
  63566. * Creates a plane mesh
  63567. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63568. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63569. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63570. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63571. * * 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
  63572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63573. * @param name defines the name of the mesh
  63574. * @param options defines the options used to create the mesh
  63575. * @param scene defines the hosting scene
  63576. * @returns the plane mesh
  63577. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63578. */
  63579. static CreatePlane(name: string, options: {
  63580. size?: number;
  63581. width?: number;
  63582. height?: number;
  63583. sideOrientation?: number;
  63584. frontUVs?: Vector4;
  63585. backUVs?: Vector4;
  63586. updatable?: boolean;
  63587. sourcePlane?: Plane;
  63588. }, scene?: Nullable<Scene>): Mesh;
  63589. /**
  63590. * Creates a ground mesh
  63591. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63592. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63593. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63594. * @param name defines the name of the mesh
  63595. * @param options defines the options used to create the mesh
  63596. * @param scene defines the hosting scene
  63597. * @returns the ground mesh
  63598. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  63599. */
  63600. static CreateGround(name: string, options: {
  63601. width?: number;
  63602. height?: number;
  63603. subdivisions?: number;
  63604. subdivisionsX?: number;
  63605. subdivisionsY?: number;
  63606. updatable?: boolean;
  63607. }, scene?: Nullable<Scene>): Mesh;
  63608. /**
  63609. * Creates a tiled ground mesh
  63610. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  63611. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  63612. * * 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
  63613. * * 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
  63614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63615. * @param name defines the name of the mesh
  63616. * @param options defines the options used to create the mesh
  63617. * @param scene defines the hosting scene
  63618. * @returns the tiled ground mesh
  63619. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  63620. */
  63621. static CreateTiledGround(name: string, options: {
  63622. xmin: number;
  63623. zmin: number;
  63624. xmax: number;
  63625. zmax: number;
  63626. subdivisions?: {
  63627. w: number;
  63628. h: number;
  63629. };
  63630. precision?: {
  63631. w: number;
  63632. h: number;
  63633. };
  63634. updatable?: boolean;
  63635. }, scene?: Nullable<Scene>): Mesh;
  63636. /**
  63637. * Creates a ground mesh from a height map
  63638. * * The parameter `url` sets the URL of the height map image resource.
  63639. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  63640. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  63641. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  63642. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  63643. * * 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.
  63644. * * 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).
  63645. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  63646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63647. * @param name defines the name of the mesh
  63648. * @param url defines the url to the height map
  63649. * @param options defines the options used to create the mesh
  63650. * @param scene defines the hosting scene
  63651. * @returns the ground mesh
  63652. * @see https://doc.babylonjs.com/babylon101/height_map
  63653. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  63654. */
  63655. static CreateGroundFromHeightMap(name: string, url: string, options: {
  63656. width?: number;
  63657. height?: number;
  63658. subdivisions?: number;
  63659. minHeight?: number;
  63660. maxHeight?: number;
  63661. colorFilter?: Color3;
  63662. alphaFilter?: number;
  63663. updatable?: boolean;
  63664. onReady?: (mesh: GroundMesh) => void;
  63665. }, scene?: Nullable<Scene>): GroundMesh;
  63666. /**
  63667. * Creates a polygon mesh
  63668. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63669. * * 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
  63670. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63672. * * 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)
  63673. * * Remember you can only change the shape positions, not their number when updating a polygon
  63674. * @param name defines the name of the mesh
  63675. * @param options defines the options used to create the mesh
  63676. * @param scene defines the hosting scene
  63677. * @param earcutInjection can be used to inject your own earcut reference
  63678. * @returns the polygon mesh
  63679. */
  63680. static CreatePolygon(name: string, options: {
  63681. shape: Vector3[];
  63682. holes?: Vector3[][];
  63683. depth?: number;
  63684. faceUV?: Vector4[];
  63685. faceColors?: Color4[];
  63686. updatable?: boolean;
  63687. sideOrientation?: number;
  63688. frontUVs?: Vector4;
  63689. backUVs?: Vector4;
  63690. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63691. /**
  63692. * Creates an extruded polygon mesh, with depth in the Y direction.
  63693. * * 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)
  63694. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63695. * @param name defines the name of the mesh
  63696. * @param options defines the options used to create the mesh
  63697. * @param scene defines the hosting scene
  63698. * @param earcutInjection can be used to inject your own earcut reference
  63699. * @returns the polygon mesh
  63700. */
  63701. static ExtrudePolygon(name: string, options: {
  63702. shape: Vector3[];
  63703. holes?: Vector3[][];
  63704. depth?: number;
  63705. faceUV?: Vector4[];
  63706. faceColors?: Color4[];
  63707. updatable?: boolean;
  63708. sideOrientation?: number;
  63709. frontUVs?: Vector4;
  63710. backUVs?: Vector4;
  63711. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63712. /**
  63713. * Creates a tube mesh.
  63714. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63715. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63716. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63717. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63718. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63719. * * 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)
  63720. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63721. * * 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
  63722. * * 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
  63723. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63724. * * 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
  63725. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63727. * @param name defines the name of the mesh
  63728. * @param options defines the options used to create the mesh
  63729. * @param scene defines the hosting scene
  63730. * @returns the tube mesh
  63731. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63732. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63733. */
  63734. static CreateTube(name: string, options: {
  63735. path: Vector3[];
  63736. radius?: number;
  63737. tessellation?: number;
  63738. radiusFunction?: {
  63739. (i: number, distance: number): number;
  63740. };
  63741. cap?: number;
  63742. arc?: number;
  63743. updatable?: boolean;
  63744. sideOrientation?: number;
  63745. frontUVs?: Vector4;
  63746. backUVs?: Vector4;
  63747. instance?: Mesh;
  63748. invertUV?: boolean;
  63749. }, scene?: Nullable<Scene>): Mesh;
  63750. /**
  63751. * Creates a polyhedron mesh
  63752. * * 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
  63753. * * The parameter `size` (positive float, default 1) sets the polygon size
  63754. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  63755. * * 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`
  63756. * * 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
  63757. * * 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)`)
  63758. * * 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
  63759. * * 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
  63760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63761. * * 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
  63762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63763. * @param name defines the name of the mesh
  63764. * @param options defines the options used to create the mesh
  63765. * @param scene defines the hosting scene
  63766. * @returns the polyhedron mesh
  63767. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  63768. */
  63769. static CreatePolyhedron(name: string, options: {
  63770. type?: number;
  63771. size?: number;
  63772. sizeX?: number;
  63773. sizeY?: number;
  63774. sizeZ?: number;
  63775. custom?: any;
  63776. faceUV?: Vector4[];
  63777. faceColors?: Color4[];
  63778. flat?: boolean;
  63779. updatable?: boolean;
  63780. sideOrientation?: number;
  63781. frontUVs?: Vector4;
  63782. backUVs?: Vector4;
  63783. }, scene?: Nullable<Scene>): Mesh;
  63784. /**
  63785. * Creates a decal mesh.
  63786. * 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
  63787. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63788. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63789. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63790. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63791. * @param name defines the name of the mesh
  63792. * @param sourceMesh defines the mesh where the decal must be applied
  63793. * @param options defines the options used to create the mesh
  63794. * @param scene defines the hosting scene
  63795. * @returns the decal mesh
  63796. * @see https://doc.babylonjs.com/how_to/decals
  63797. */
  63798. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63799. position?: Vector3;
  63800. normal?: Vector3;
  63801. size?: Vector3;
  63802. angle?: number;
  63803. }): Mesh;
  63804. }
  63805. }
  63806. declare module BABYLON {
  63807. /**
  63808. * A simplifier interface for future simplification implementations
  63809. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63810. */
  63811. export interface ISimplifier {
  63812. /**
  63813. * Simplification of a given mesh according to the given settings.
  63814. * Since this requires computation, it is assumed that the function runs async.
  63815. * @param settings The settings of the simplification, including quality and distance
  63816. * @param successCallback A callback that will be called after the mesh was simplified.
  63817. * @param errorCallback in case of an error, this callback will be called. optional.
  63818. */
  63819. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63820. }
  63821. /**
  63822. * Expected simplification settings.
  63823. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63824. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63825. */
  63826. export interface ISimplificationSettings {
  63827. /**
  63828. * Gets or sets the expected quality
  63829. */
  63830. quality: number;
  63831. /**
  63832. * Gets or sets the distance when this optimized version should be used
  63833. */
  63834. distance: number;
  63835. /**
  63836. * Gets an already optimized mesh
  63837. */
  63838. optimizeMesh?: boolean;
  63839. }
  63840. /**
  63841. * Class used to specify simplification options
  63842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63843. */
  63844. export class SimplificationSettings implements ISimplificationSettings {
  63845. /** expected quality */
  63846. quality: number;
  63847. /** distance when this optimized version should be used */
  63848. distance: number;
  63849. /** already optimized mesh */
  63850. optimizeMesh?: boolean | undefined;
  63851. /**
  63852. * Creates a SimplificationSettings
  63853. * @param quality expected quality
  63854. * @param distance distance when this optimized version should be used
  63855. * @param optimizeMesh already optimized mesh
  63856. */
  63857. constructor(
  63858. /** expected quality */
  63859. quality: number,
  63860. /** distance when this optimized version should be used */
  63861. distance: number,
  63862. /** already optimized mesh */
  63863. optimizeMesh?: boolean | undefined);
  63864. }
  63865. /**
  63866. * Interface used to define a simplification task
  63867. */
  63868. export interface ISimplificationTask {
  63869. /**
  63870. * Array of settings
  63871. */
  63872. settings: Array<ISimplificationSettings>;
  63873. /**
  63874. * Simplification type
  63875. */
  63876. simplificationType: SimplificationType;
  63877. /**
  63878. * Mesh to simplify
  63879. */
  63880. mesh: Mesh;
  63881. /**
  63882. * Callback called on success
  63883. */
  63884. successCallback?: () => void;
  63885. /**
  63886. * Defines if parallel processing can be used
  63887. */
  63888. parallelProcessing: boolean;
  63889. }
  63890. /**
  63891. * Queue used to order the simplification tasks
  63892. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63893. */
  63894. export class SimplificationQueue {
  63895. private _simplificationArray;
  63896. /**
  63897. * Gets a boolean indicating that the process is still running
  63898. */
  63899. running: boolean;
  63900. /**
  63901. * Creates a new queue
  63902. */
  63903. constructor();
  63904. /**
  63905. * Adds a new simplification task
  63906. * @param task defines a task to add
  63907. */
  63908. addTask(task: ISimplificationTask): void;
  63909. /**
  63910. * Execute next task
  63911. */
  63912. executeNext(): void;
  63913. /**
  63914. * Execute a simplification task
  63915. * @param task defines the task to run
  63916. */
  63917. runSimplification(task: ISimplificationTask): void;
  63918. private getSimplifier;
  63919. }
  63920. /**
  63921. * The implemented types of simplification
  63922. * At the moment only Quadratic Error Decimation is implemented
  63923. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63924. */
  63925. export enum SimplificationType {
  63926. /** Quadratic error decimation */
  63927. QUADRATIC = 0
  63928. }
  63929. /**
  63930. * An implementation of the Quadratic Error simplification algorithm.
  63931. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  63932. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  63933. * @author RaananW
  63934. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63935. */
  63936. export class QuadraticErrorSimplification implements ISimplifier {
  63937. private _mesh;
  63938. private triangles;
  63939. private vertices;
  63940. private references;
  63941. private _reconstructedMesh;
  63942. /** Gets or sets the number pf sync interations */
  63943. syncIterations: number;
  63944. /** Gets or sets the aggressiveness of the simplifier */
  63945. aggressiveness: number;
  63946. /** Gets or sets the number of allowed iterations for decimation */
  63947. decimationIterations: number;
  63948. /** Gets or sets the espilon to use for bounding box computation */
  63949. boundingBoxEpsilon: number;
  63950. /**
  63951. * Creates a new QuadraticErrorSimplification
  63952. * @param _mesh defines the target mesh
  63953. */
  63954. constructor(_mesh: Mesh);
  63955. /**
  63956. * Simplification of a given mesh according to the given settings.
  63957. * Since this requires computation, it is assumed that the function runs async.
  63958. * @param settings The settings of the simplification, including quality and distance
  63959. * @param successCallback A callback that will be called after the mesh was simplified.
  63960. */
  63961. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  63962. private runDecimation;
  63963. private initWithMesh;
  63964. private init;
  63965. private reconstructMesh;
  63966. private initDecimatedMesh;
  63967. private isFlipped;
  63968. private updateTriangles;
  63969. private identifyBorder;
  63970. private updateMesh;
  63971. private vertexError;
  63972. private calculateError;
  63973. }
  63974. }
  63975. declare module BABYLON {
  63976. interface Scene {
  63977. /** @hidden (Backing field) */
  63978. _simplificationQueue: SimplificationQueue;
  63979. /**
  63980. * Gets or sets the simplification queue attached to the scene
  63981. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63982. */
  63983. simplificationQueue: SimplificationQueue;
  63984. }
  63985. interface Mesh {
  63986. /**
  63987. * Simplify the mesh according to the given array of settings.
  63988. * Function will return immediately and will simplify async
  63989. * @param settings a collection of simplification settings
  63990. * @param parallelProcessing should all levels calculate parallel or one after the other
  63991. * @param simplificationType the type of simplification to run
  63992. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63993. * @returns the current mesh
  63994. */
  63995. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63996. }
  63997. /**
  63998. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63999. * created in a scene
  64000. */
  64001. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64002. /**
  64003. * The component name helpfull to identify the component in the list of scene components.
  64004. */
  64005. readonly name: string;
  64006. /**
  64007. * The scene the component belongs to.
  64008. */
  64009. scene: Scene;
  64010. /**
  64011. * Creates a new instance of the component for the given scene
  64012. * @param scene Defines the scene to register the component in
  64013. */
  64014. constructor(scene: Scene);
  64015. /**
  64016. * Registers the component in a given scene
  64017. */
  64018. register(): void;
  64019. /**
  64020. * Rebuilds the elements related to this component in case of
  64021. * context lost for instance.
  64022. */
  64023. rebuild(): void;
  64024. /**
  64025. * Disposes the component and the associated ressources
  64026. */
  64027. dispose(): void;
  64028. private _beforeCameraUpdate;
  64029. }
  64030. }
  64031. declare module BABYLON {
  64032. /**
  64033. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64034. */
  64035. export interface INavigationEnginePlugin {
  64036. /**
  64037. * plugin name
  64038. */
  64039. name: string;
  64040. /**
  64041. * Creates a navigation mesh
  64042. * @param meshes array of all the geometry used to compute the navigatio mesh
  64043. * @param parameters bunch of parameters used to filter geometry
  64044. */
  64045. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64046. /**
  64047. * Create a navigation mesh debug mesh
  64048. * @param scene is where the mesh will be added
  64049. * @returns debug display mesh
  64050. */
  64051. createDebugNavMesh(scene: Scene): Mesh;
  64052. /**
  64053. * Get a navigation mesh constrained position, closest to the parameter position
  64054. * @param position world position
  64055. * @returns the closest point to position constrained by the navigation mesh
  64056. */
  64057. getClosestPoint(position: Vector3): Vector3;
  64058. /**
  64059. * Get a navigation mesh constrained position, closest to the parameter position
  64060. * @param position world position
  64061. * @param result output the closest point to position constrained by the navigation mesh
  64062. */
  64063. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64064. /**
  64065. * Get a navigation mesh constrained position, within a particular radius
  64066. * @param position world position
  64067. * @param maxRadius the maximum distance to the constrained world position
  64068. * @returns the closest point to position constrained by the navigation mesh
  64069. */
  64070. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64071. /**
  64072. * Get a navigation mesh constrained position, within a particular radius
  64073. * @param position world position
  64074. * @param maxRadius the maximum distance to the constrained world position
  64075. * @param result output the closest point to position constrained by the navigation mesh
  64076. */
  64077. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64078. /**
  64079. * Compute the final position from a segment made of destination-position
  64080. * @param position world position
  64081. * @param destination world position
  64082. * @returns the resulting point along the navmesh
  64083. */
  64084. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64085. /**
  64086. * Compute the final position from a segment made of destination-position
  64087. * @param position world position
  64088. * @param destination world position
  64089. * @param result output the resulting point along the navmesh
  64090. */
  64091. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64092. /**
  64093. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64094. * @param start world position
  64095. * @param end world position
  64096. * @returns array containing world position composing the path
  64097. */
  64098. computePath(start: Vector3, end: Vector3): Vector3[];
  64099. /**
  64100. * If this plugin is supported
  64101. * @returns true if plugin is supported
  64102. */
  64103. isSupported(): boolean;
  64104. /**
  64105. * Create a new Crowd so you can add agents
  64106. * @param maxAgents the maximum agent count in the crowd
  64107. * @param maxAgentRadius the maximum radius an agent can have
  64108. * @param scene to attach the crowd to
  64109. * @returns the crowd you can add agents to
  64110. */
  64111. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64112. /**
  64113. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64114. * The queries will try to find a solution within those bounds
  64115. * default is (1,1,1)
  64116. * @param extent x,y,z value that define the extent around the queries point of reference
  64117. */
  64118. setDefaultQueryExtent(extent: Vector3): void;
  64119. /**
  64120. * Get the Bounding box extent specified by setDefaultQueryExtent
  64121. * @returns the box extent values
  64122. */
  64123. getDefaultQueryExtent(): Vector3;
  64124. /**
  64125. * build the navmesh from a previously saved state using getNavmeshData
  64126. * @param data the Uint8Array returned by getNavmeshData
  64127. */
  64128. buildFromNavmeshData(data: Uint8Array): void;
  64129. /**
  64130. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64131. * @returns data the Uint8Array that can be saved and reused
  64132. */
  64133. getNavmeshData(): Uint8Array;
  64134. /**
  64135. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64136. * @param result output the box extent values
  64137. */
  64138. getDefaultQueryExtentToRef(result: Vector3): void;
  64139. /**
  64140. * Release all resources
  64141. */
  64142. dispose(): void;
  64143. }
  64144. /**
  64145. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64146. */
  64147. export interface ICrowd {
  64148. /**
  64149. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64150. * You can attach anything to that node. The node position is updated in the scene update tick.
  64151. * @param pos world position that will be constrained by the navigation mesh
  64152. * @param parameters agent parameters
  64153. * @param transform hooked to the agent that will be update by the scene
  64154. * @returns agent index
  64155. */
  64156. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64157. /**
  64158. * Returns the agent position in world space
  64159. * @param index agent index returned by addAgent
  64160. * @returns world space position
  64161. */
  64162. getAgentPosition(index: number): Vector3;
  64163. /**
  64164. * Gets the agent position result in world space
  64165. * @param index agent index returned by addAgent
  64166. * @param result output world space position
  64167. */
  64168. getAgentPositionToRef(index: number, result: Vector3): void;
  64169. /**
  64170. * Gets the agent velocity in world space
  64171. * @param index agent index returned by addAgent
  64172. * @returns world space velocity
  64173. */
  64174. getAgentVelocity(index: number): Vector3;
  64175. /**
  64176. * Gets the agent velocity result in world space
  64177. * @param index agent index returned by addAgent
  64178. * @param result output world space velocity
  64179. */
  64180. getAgentVelocityToRef(index: number, result: Vector3): void;
  64181. /**
  64182. * remove a particular agent previously created
  64183. * @param index agent index returned by addAgent
  64184. */
  64185. removeAgent(index: number): void;
  64186. /**
  64187. * get the list of all agents attached to this crowd
  64188. * @returns list of agent indices
  64189. */
  64190. getAgents(): number[];
  64191. /**
  64192. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64193. * @param deltaTime in seconds
  64194. */
  64195. update(deltaTime: number): void;
  64196. /**
  64197. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64198. * @param index agent index returned by addAgent
  64199. * @param destination targeted world position
  64200. */
  64201. agentGoto(index: number, destination: Vector3): void;
  64202. /**
  64203. * Teleport the agent to a new position
  64204. * @param index agent index returned by addAgent
  64205. * @param destination targeted world position
  64206. */
  64207. agentTeleport(index: number, destination: Vector3): void;
  64208. /**
  64209. * Update agent parameters
  64210. * @param index agent index returned by addAgent
  64211. * @param parameters agent parameters
  64212. */
  64213. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64214. /**
  64215. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64216. * The queries will try to find a solution within those bounds
  64217. * default is (1,1,1)
  64218. * @param extent x,y,z value that define the extent around the queries point of reference
  64219. */
  64220. setDefaultQueryExtent(extent: Vector3): void;
  64221. /**
  64222. * Get the Bounding box extent specified by setDefaultQueryExtent
  64223. * @returns the box extent values
  64224. */
  64225. getDefaultQueryExtent(): Vector3;
  64226. /**
  64227. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64228. * @param result output the box extent values
  64229. */
  64230. getDefaultQueryExtentToRef(result: Vector3): void;
  64231. /**
  64232. * Release all resources
  64233. */
  64234. dispose(): void;
  64235. }
  64236. /**
  64237. * Configures an agent
  64238. */
  64239. export interface IAgentParameters {
  64240. /**
  64241. * Agent radius. [Limit: >= 0]
  64242. */
  64243. radius: number;
  64244. /**
  64245. * Agent height. [Limit: > 0]
  64246. */
  64247. height: number;
  64248. /**
  64249. * Maximum allowed acceleration. [Limit: >= 0]
  64250. */
  64251. maxAcceleration: number;
  64252. /**
  64253. * Maximum allowed speed. [Limit: >= 0]
  64254. */
  64255. maxSpeed: number;
  64256. /**
  64257. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64258. */
  64259. collisionQueryRange: number;
  64260. /**
  64261. * The path visibility optimization range. [Limit: > 0]
  64262. */
  64263. pathOptimizationRange: number;
  64264. /**
  64265. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64266. */
  64267. separationWeight: number;
  64268. }
  64269. /**
  64270. * Configures the navigation mesh creation
  64271. */
  64272. export interface INavMeshParameters {
  64273. /**
  64274. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64275. */
  64276. cs: number;
  64277. /**
  64278. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64279. */
  64280. ch: number;
  64281. /**
  64282. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64283. */
  64284. walkableSlopeAngle: number;
  64285. /**
  64286. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64287. * be considered walkable. [Limit: >= 3] [Units: vx]
  64288. */
  64289. walkableHeight: number;
  64290. /**
  64291. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64292. */
  64293. walkableClimb: number;
  64294. /**
  64295. * The distance to erode/shrink the walkable area of the heightfield away from
  64296. * obstructions. [Limit: >=0] [Units: vx]
  64297. */
  64298. walkableRadius: number;
  64299. /**
  64300. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64301. */
  64302. maxEdgeLen: number;
  64303. /**
  64304. * The maximum distance a simplfied contour's border edges should deviate
  64305. * the original raw contour. [Limit: >=0] [Units: vx]
  64306. */
  64307. maxSimplificationError: number;
  64308. /**
  64309. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64310. */
  64311. minRegionArea: number;
  64312. /**
  64313. * Any regions with a span count smaller than this value will, if possible,
  64314. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64315. */
  64316. mergeRegionArea: number;
  64317. /**
  64318. * The maximum number of vertices allowed for polygons generated during the
  64319. * contour to polygon conversion process. [Limit: >= 3]
  64320. */
  64321. maxVertsPerPoly: number;
  64322. /**
  64323. * Sets the sampling distance to use when generating the detail mesh.
  64324. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64325. */
  64326. detailSampleDist: number;
  64327. /**
  64328. * The maximum distance the detail mesh surface should deviate from heightfield
  64329. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64330. */
  64331. detailSampleMaxError: number;
  64332. }
  64333. }
  64334. declare module BABYLON {
  64335. /**
  64336. * RecastJS navigation plugin
  64337. */
  64338. export class RecastJSPlugin implements INavigationEnginePlugin {
  64339. /**
  64340. * Reference to the Recast library
  64341. */
  64342. bjsRECAST: any;
  64343. /**
  64344. * plugin name
  64345. */
  64346. name: string;
  64347. /**
  64348. * the first navmesh created. We might extend this to support multiple navmeshes
  64349. */
  64350. navMesh: any;
  64351. /**
  64352. * Initializes the recastJS plugin
  64353. * @param recastInjection can be used to inject your own recast reference
  64354. */
  64355. constructor(recastInjection?: any);
  64356. /**
  64357. * Creates a navigation mesh
  64358. * @param meshes array of all the geometry used to compute the navigatio mesh
  64359. * @param parameters bunch of parameters used to filter geometry
  64360. */
  64361. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64362. /**
  64363. * Create a navigation mesh debug mesh
  64364. * @param scene is where the mesh will be added
  64365. * @returns debug display mesh
  64366. */
  64367. createDebugNavMesh(scene: Scene): Mesh;
  64368. /**
  64369. * Get a navigation mesh constrained position, closest to the parameter position
  64370. * @param position world position
  64371. * @returns the closest point to position constrained by the navigation mesh
  64372. */
  64373. getClosestPoint(position: Vector3): Vector3;
  64374. /**
  64375. * Get a navigation mesh constrained position, closest to the parameter position
  64376. * @param position world position
  64377. * @param result output the closest point to position constrained by the navigation mesh
  64378. */
  64379. getClosestPointToRef(position: Vector3, result: Vector3): void;
  64380. /**
  64381. * Get a navigation mesh constrained position, within a particular radius
  64382. * @param position world position
  64383. * @param maxRadius the maximum distance to the constrained world position
  64384. * @returns the closest point to position constrained by the navigation mesh
  64385. */
  64386. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64387. /**
  64388. * Get a navigation mesh constrained position, within a particular radius
  64389. * @param position world position
  64390. * @param maxRadius the maximum distance to the constrained world position
  64391. * @param result output the closest point to position constrained by the navigation mesh
  64392. */
  64393. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  64394. /**
  64395. * Compute the final position from a segment made of destination-position
  64396. * @param position world position
  64397. * @param destination world position
  64398. * @returns the resulting point along the navmesh
  64399. */
  64400. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64401. /**
  64402. * Compute the final position from a segment made of destination-position
  64403. * @param position world position
  64404. * @param destination world position
  64405. * @param result output the resulting point along the navmesh
  64406. */
  64407. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  64408. /**
  64409. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64410. * @param start world position
  64411. * @param end world position
  64412. * @returns array containing world position composing the path
  64413. */
  64414. computePath(start: Vector3, end: Vector3): Vector3[];
  64415. /**
  64416. * Create a new Crowd so you can add agents
  64417. * @param maxAgents the maximum agent count in the crowd
  64418. * @param maxAgentRadius the maximum radius an agent can have
  64419. * @param scene to attach the crowd to
  64420. * @returns the crowd you can add agents to
  64421. */
  64422. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64423. /**
  64424. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64425. * The queries will try to find a solution within those bounds
  64426. * default is (1,1,1)
  64427. * @param extent x,y,z value that define the extent around the queries point of reference
  64428. */
  64429. setDefaultQueryExtent(extent: Vector3): void;
  64430. /**
  64431. * Get the Bounding box extent specified by setDefaultQueryExtent
  64432. * @returns the box extent values
  64433. */
  64434. getDefaultQueryExtent(): Vector3;
  64435. /**
  64436. * build the navmesh from a previously saved state using getNavmeshData
  64437. * @param data the Uint8Array returned by getNavmeshData
  64438. */
  64439. buildFromNavmeshData(data: Uint8Array): void;
  64440. /**
  64441. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  64442. * @returns data the Uint8Array that can be saved and reused
  64443. */
  64444. getNavmeshData(): Uint8Array;
  64445. /**
  64446. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64447. * @param result output the box extent values
  64448. */
  64449. getDefaultQueryExtentToRef(result: Vector3): void;
  64450. /**
  64451. * Disposes
  64452. */
  64453. dispose(): void;
  64454. /**
  64455. * If this plugin is supported
  64456. * @returns true if plugin is supported
  64457. */
  64458. isSupported(): boolean;
  64459. }
  64460. /**
  64461. * Recast detour crowd implementation
  64462. */
  64463. export class RecastJSCrowd implements ICrowd {
  64464. /**
  64465. * Recast/detour plugin
  64466. */
  64467. bjsRECASTPlugin: RecastJSPlugin;
  64468. /**
  64469. * Link to the detour crowd
  64470. */
  64471. recastCrowd: any;
  64472. /**
  64473. * One transform per agent
  64474. */
  64475. transforms: TransformNode[];
  64476. /**
  64477. * All agents created
  64478. */
  64479. agents: number[];
  64480. /**
  64481. * Link to the scene is kept to unregister the crowd from the scene
  64482. */
  64483. private _scene;
  64484. /**
  64485. * Observer for crowd updates
  64486. */
  64487. private _onBeforeAnimationsObserver;
  64488. /**
  64489. * Constructor
  64490. * @param plugin recastJS plugin
  64491. * @param maxAgents the maximum agent count in the crowd
  64492. * @param maxAgentRadius the maximum radius an agent can have
  64493. * @param scene to attach the crowd to
  64494. * @returns the crowd you can add agents to
  64495. */
  64496. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64497. /**
  64498. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64499. * You can attach anything to that node. The node position is updated in the scene update tick.
  64500. * @param pos world position that will be constrained by the navigation mesh
  64501. * @param parameters agent parameters
  64502. * @param transform hooked to the agent that will be update by the scene
  64503. * @returns agent index
  64504. */
  64505. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64506. /**
  64507. * Returns the agent position in world space
  64508. * @param index agent index returned by addAgent
  64509. * @returns world space position
  64510. */
  64511. getAgentPosition(index: number): Vector3;
  64512. /**
  64513. * Returns the agent position result in world space
  64514. * @param index agent index returned by addAgent
  64515. * @param result output world space position
  64516. */
  64517. getAgentPositionToRef(index: number, result: Vector3): void;
  64518. /**
  64519. * Returns the agent velocity in world space
  64520. * @param index agent index returned by addAgent
  64521. * @returns world space velocity
  64522. */
  64523. getAgentVelocity(index: number): Vector3;
  64524. /**
  64525. * Returns the agent velocity result in world space
  64526. * @param index agent index returned by addAgent
  64527. * @param result output world space velocity
  64528. */
  64529. getAgentVelocityToRef(index: number, result: Vector3): void;
  64530. /**
  64531. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64532. * @param index agent index returned by addAgent
  64533. * @param destination targeted world position
  64534. */
  64535. agentGoto(index: number, destination: Vector3): void;
  64536. /**
  64537. * Teleport the agent to a new position
  64538. * @param index agent index returned by addAgent
  64539. * @param destination targeted world position
  64540. */
  64541. agentTeleport(index: number, destination: Vector3): void;
  64542. /**
  64543. * Update agent parameters
  64544. * @param index agent index returned by addAgent
  64545. * @param parameters agent parameters
  64546. */
  64547. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  64548. /**
  64549. * remove a particular agent previously created
  64550. * @param index agent index returned by addAgent
  64551. */
  64552. removeAgent(index: number): void;
  64553. /**
  64554. * get the list of all agents attached to this crowd
  64555. * @returns list of agent indices
  64556. */
  64557. getAgents(): number[];
  64558. /**
  64559. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64560. * @param deltaTime in seconds
  64561. */
  64562. update(deltaTime: number): void;
  64563. /**
  64564. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64565. * The queries will try to find a solution within those bounds
  64566. * default is (1,1,1)
  64567. * @param extent x,y,z value that define the extent around the queries point of reference
  64568. */
  64569. setDefaultQueryExtent(extent: Vector3): void;
  64570. /**
  64571. * Get the Bounding box extent specified by setDefaultQueryExtent
  64572. * @returns the box extent values
  64573. */
  64574. getDefaultQueryExtent(): Vector3;
  64575. /**
  64576. * Get the Bounding box extent result specified by setDefaultQueryExtent
  64577. * @param result output the box extent values
  64578. */
  64579. getDefaultQueryExtentToRef(result: Vector3): void;
  64580. /**
  64581. * Release all resources
  64582. */
  64583. dispose(): void;
  64584. }
  64585. }
  64586. declare module BABYLON {
  64587. /**
  64588. * Class used to enable access to IndexedDB
  64589. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64590. */
  64591. export class Database implements IOfflineProvider {
  64592. private _callbackManifestChecked;
  64593. private _currentSceneUrl;
  64594. private _db;
  64595. private _enableSceneOffline;
  64596. private _enableTexturesOffline;
  64597. private _manifestVersionFound;
  64598. private _mustUpdateRessources;
  64599. private _hasReachedQuota;
  64600. private _isSupported;
  64601. private _idbFactory;
  64602. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  64603. private static IsUASupportingBlobStorage;
  64604. /**
  64605. * Gets a boolean indicating if Database storate is enabled (off by default)
  64606. */
  64607. static IDBStorageEnabled: boolean;
  64608. /**
  64609. * Gets a boolean indicating if scene must be saved in the database
  64610. */
  64611. get enableSceneOffline(): boolean;
  64612. /**
  64613. * Gets a boolean indicating if textures must be saved in the database
  64614. */
  64615. get enableTexturesOffline(): boolean;
  64616. /**
  64617. * Creates a new Database
  64618. * @param urlToScene defines the url to load the scene
  64619. * @param callbackManifestChecked defines the callback to use when manifest is checked
  64620. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  64621. */
  64622. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  64623. private static _ParseURL;
  64624. private static _ReturnFullUrlLocation;
  64625. private _checkManifestFile;
  64626. /**
  64627. * Open the database and make it available
  64628. * @param successCallback defines the callback to call on success
  64629. * @param errorCallback defines the callback to call on error
  64630. */
  64631. open(successCallback: () => void, errorCallback: () => void): void;
  64632. /**
  64633. * Loads an image from the database
  64634. * @param url defines the url to load from
  64635. * @param image defines the target DOM image
  64636. */
  64637. loadImage(url: string, image: HTMLImageElement): void;
  64638. private _loadImageFromDBAsync;
  64639. private _saveImageIntoDBAsync;
  64640. private _checkVersionFromDB;
  64641. private _loadVersionFromDBAsync;
  64642. private _saveVersionIntoDBAsync;
  64643. /**
  64644. * Loads a file from database
  64645. * @param url defines the URL to load from
  64646. * @param sceneLoaded defines a callback to call on success
  64647. * @param progressCallBack defines a callback to call when progress changed
  64648. * @param errorCallback defines a callback to call on error
  64649. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64650. */
  64651. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64652. private _loadFileAsync;
  64653. private _saveFileAsync;
  64654. /**
  64655. * Validates if xhr data is correct
  64656. * @param xhr defines the request to validate
  64657. * @param dataType defines the expected data type
  64658. * @returns true if data is correct
  64659. */
  64660. private static _ValidateXHRData;
  64661. }
  64662. }
  64663. declare module BABYLON {
  64664. /** @hidden */
  64665. export var gpuUpdateParticlesPixelShader: {
  64666. name: string;
  64667. shader: string;
  64668. };
  64669. }
  64670. declare module BABYLON {
  64671. /** @hidden */
  64672. export var gpuUpdateParticlesVertexShader: {
  64673. name: string;
  64674. shader: string;
  64675. };
  64676. }
  64677. declare module BABYLON {
  64678. /** @hidden */
  64679. export var clipPlaneFragmentDeclaration2: {
  64680. name: string;
  64681. shader: string;
  64682. };
  64683. }
  64684. declare module BABYLON {
  64685. /** @hidden */
  64686. export var gpuRenderParticlesPixelShader: {
  64687. name: string;
  64688. shader: string;
  64689. };
  64690. }
  64691. declare module BABYLON {
  64692. /** @hidden */
  64693. export var clipPlaneVertexDeclaration2: {
  64694. name: string;
  64695. shader: string;
  64696. };
  64697. }
  64698. declare module BABYLON {
  64699. /** @hidden */
  64700. export var gpuRenderParticlesVertexShader: {
  64701. name: string;
  64702. shader: string;
  64703. };
  64704. }
  64705. declare module BABYLON {
  64706. /**
  64707. * This represents a GPU particle system in Babylon
  64708. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  64709. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  64710. */
  64711. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  64712. /**
  64713. * The layer mask we are rendering the particles through.
  64714. */
  64715. layerMask: number;
  64716. private _capacity;
  64717. private _activeCount;
  64718. private _currentActiveCount;
  64719. private _accumulatedCount;
  64720. private _renderEffect;
  64721. private _updateEffect;
  64722. private _buffer0;
  64723. private _buffer1;
  64724. private _spriteBuffer;
  64725. private _updateVAO;
  64726. private _renderVAO;
  64727. private _targetIndex;
  64728. private _sourceBuffer;
  64729. private _targetBuffer;
  64730. private _engine;
  64731. private _currentRenderId;
  64732. private _started;
  64733. private _stopped;
  64734. private _timeDelta;
  64735. private _randomTexture;
  64736. private _randomTexture2;
  64737. private _attributesStrideSize;
  64738. private _updateEffectOptions;
  64739. private _randomTextureSize;
  64740. private _actualFrame;
  64741. private readonly _rawTextureWidth;
  64742. /**
  64743. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  64744. */
  64745. static get IsSupported(): boolean;
  64746. /**
  64747. * An event triggered when the system is disposed.
  64748. */
  64749. onDisposeObservable: Observable<GPUParticleSystem>;
  64750. /**
  64751. * Gets the maximum number of particles active at the same time.
  64752. * @returns The max number of active particles.
  64753. */
  64754. getCapacity(): number;
  64755. /**
  64756. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  64757. * to override the particles.
  64758. */
  64759. forceDepthWrite: boolean;
  64760. /**
  64761. * Gets or set the number of active particles
  64762. */
  64763. get activeParticleCount(): number;
  64764. set activeParticleCount(value: number);
  64765. private _preWarmDone;
  64766. /**
  64767. * Specifies if the particles are updated in emitter local space or world space.
  64768. */
  64769. isLocal: boolean;
  64770. /**
  64771. * Is this system ready to be used/rendered
  64772. * @return true if the system is ready
  64773. */
  64774. isReady(): boolean;
  64775. /**
  64776. * Gets if the system has been started. (Note: this will still be true after stop is called)
  64777. * @returns True if it has been started, otherwise false.
  64778. */
  64779. isStarted(): boolean;
  64780. /**
  64781. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  64782. * @returns True if it has been stopped, otherwise false.
  64783. */
  64784. isStopped(): boolean;
  64785. /**
  64786. * Gets a boolean indicating that the system is stopping
  64787. * @returns true if the system is currently stopping
  64788. */
  64789. isStopping(): boolean;
  64790. /**
  64791. * Gets the number of particles active at the same time.
  64792. * @returns The number of active particles.
  64793. */
  64794. getActiveCount(): number;
  64795. /**
  64796. * Starts the particle system and begins to emit
  64797. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  64798. */
  64799. start(delay?: number): void;
  64800. /**
  64801. * Stops the particle system.
  64802. */
  64803. stop(): void;
  64804. /**
  64805. * Remove all active particles
  64806. */
  64807. reset(): void;
  64808. /**
  64809. * Returns the string "GPUParticleSystem"
  64810. * @returns a string containing the class name
  64811. */
  64812. getClassName(): string;
  64813. private _colorGradientsTexture;
  64814. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  64815. /**
  64816. * Adds a new color gradient
  64817. * @param gradient defines the gradient to use (between 0 and 1)
  64818. * @param color1 defines the color to affect to the specified gradient
  64819. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  64820. * @returns the current particle system
  64821. */
  64822. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  64823. private _refreshColorGradient;
  64824. /** Force the system to rebuild all gradients that need to be resync */
  64825. forceRefreshGradients(): void;
  64826. /**
  64827. * Remove a specific color gradient
  64828. * @param gradient defines the gradient to remove
  64829. * @returns the current particle system
  64830. */
  64831. removeColorGradient(gradient: number): GPUParticleSystem;
  64832. private _angularSpeedGradientsTexture;
  64833. private _sizeGradientsTexture;
  64834. private _velocityGradientsTexture;
  64835. private _limitVelocityGradientsTexture;
  64836. private _dragGradientsTexture;
  64837. private _addFactorGradient;
  64838. /**
  64839. * Adds a new size gradient
  64840. * @param gradient defines the gradient to use (between 0 and 1)
  64841. * @param factor defines the size factor to affect to the specified gradient
  64842. * @returns the current particle system
  64843. */
  64844. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  64845. /**
  64846. * Remove a specific size gradient
  64847. * @param gradient defines the gradient to remove
  64848. * @returns the current particle system
  64849. */
  64850. removeSizeGradient(gradient: number): GPUParticleSystem;
  64851. private _refreshFactorGradient;
  64852. /**
  64853. * Adds a new angular speed gradient
  64854. * @param gradient defines the gradient to use (between 0 and 1)
  64855. * @param factor defines the angular speed to affect to the specified gradient
  64856. * @returns the current particle system
  64857. */
  64858. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  64859. /**
  64860. * Remove a specific angular speed gradient
  64861. * @param gradient defines the gradient to remove
  64862. * @returns the current particle system
  64863. */
  64864. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  64865. /**
  64866. * Adds a new velocity gradient
  64867. * @param gradient defines the gradient to use (between 0 and 1)
  64868. * @param factor defines the velocity to affect to the specified gradient
  64869. * @returns the current particle system
  64870. */
  64871. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64872. /**
  64873. * Remove a specific velocity gradient
  64874. * @param gradient defines the gradient to remove
  64875. * @returns the current particle system
  64876. */
  64877. removeVelocityGradient(gradient: number): GPUParticleSystem;
  64878. /**
  64879. * Adds a new limit velocity gradient
  64880. * @param gradient defines the gradient to use (between 0 and 1)
  64881. * @param factor defines the limit velocity value to affect to the specified gradient
  64882. * @returns the current particle system
  64883. */
  64884. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64885. /**
  64886. * Remove a specific limit velocity gradient
  64887. * @param gradient defines the gradient to remove
  64888. * @returns the current particle system
  64889. */
  64890. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64891. /**
  64892. * Adds a new drag gradient
  64893. * @param gradient defines the gradient to use (between 0 and 1)
  64894. * @param factor defines the drag value to affect to the specified gradient
  64895. * @returns the current particle system
  64896. */
  64897. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64898. /**
  64899. * Remove a specific drag gradient
  64900. * @param gradient defines the gradient to remove
  64901. * @returns the current particle system
  64902. */
  64903. removeDragGradient(gradient: number): GPUParticleSystem;
  64904. /**
  64905. * Not supported by GPUParticleSystem
  64906. * @param gradient defines the gradient to use (between 0 and 1)
  64907. * @param factor defines the emit rate value to affect to the specified gradient
  64908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64909. * @returns the current particle system
  64910. */
  64911. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64912. /**
  64913. * Not supported by GPUParticleSystem
  64914. * @param gradient defines the gradient to remove
  64915. * @returns the current particle system
  64916. */
  64917. removeEmitRateGradient(gradient: number): IParticleSystem;
  64918. /**
  64919. * Not supported by GPUParticleSystem
  64920. * @param gradient defines the gradient to use (between 0 and 1)
  64921. * @param factor defines the start size value to affect to the specified gradient
  64922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64923. * @returns the current particle system
  64924. */
  64925. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64926. /**
  64927. * Not supported by GPUParticleSystem
  64928. * @param gradient defines the gradient to remove
  64929. * @returns the current particle system
  64930. */
  64931. removeStartSizeGradient(gradient: number): IParticleSystem;
  64932. /**
  64933. * Not supported by GPUParticleSystem
  64934. * @param gradient defines the gradient to use (between 0 and 1)
  64935. * @param min defines the color remap minimal range
  64936. * @param max defines the color remap maximal range
  64937. * @returns the current particle system
  64938. */
  64939. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64940. /**
  64941. * Not supported by GPUParticleSystem
  64942. * @param gradient defines the gradient to remove
  64943. * @returns the current particle system
  64944. */
  64945. removeColorRemapGradient(): IParticleSystem;
  64946. /**
  64947. * Not supported by GPUParticleSystem
  64948. * @param gradient defines the gradient to use (between 0 and 1)
  64949. * @param min defines the alpha remap minimal range
  64950. * @param max defines the alpha remap maximal range
  64951. * @returns the current particle system
  64952. */
  64953. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64954. /**
  64955. * Not supported by GPUParticleSystem
  64956. * @param gradient defines the gradient to remove
  64957. * @returns the current particle system
  64958. */
  64959. removeAlphaRemapGradient(): IParticleSystem;
  64960. /**
  64961. * Not supported by GPUParticleSystem
  64962. * @param gradient defines the gradient to use (between 0 and 1)
  64963. * @param color defines the color to affect to the specified gradient
  64964. * @returns the current particle system
  64965. */
  64966. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64967. /**
  64968. * Not supported by GPUParticleSystem
  64969. * @param gradient defines the gradient to remove
  64970. * @returns the current particle system
  64971. */
  64972. removeRampGradient(): IParticleSystem;
  64973. /**
  64974. * Not supported by GPUParticleSystem
  64975. * @returns the list of ramp gradients
  64976. */
  64977. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64978. /**
  64979. * Not supported by GPUParticleSystem
  64980. * Gets or sets a boolean indicating that ramp gradients must be used
  64981. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64982. */
  64983. get useRampGradients(): boolean;
  64984. set useRampGradients(value: boolean);
  64985. /**
  64986. * Not supported by GPUParticleSystem
  64987. * @param gradient defines the gradient to use (between 0 and 1)
  64988. * @param factor defines the life time factor to affect to the specified gradient
  64989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64990. * @returns the current particle system
  64991. */
  64992. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64993. /**
  64994. * Not supported by GPUParticleSystem
  64995. * @param gradient defines the gradient to remove
  64996. * @returns the current particle system
  64997. */
  64998. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64999. /**
  65000. * Instantiates a GPU particle system.
  65001. * 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.
  65002. * @param name The name of the particle system
  65003. * @param options The options used to create the system
  65004. * @param scene The scene the particle system belongs to
  65005. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65006. */
  65007. constructor(name: string, options: Partial<{
  65008. capacity: number;
  65009. randomTextureSize: number;
  65010. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65011. protected _reset(): void;
  65012. private _createUpdateVAO;
  65013. private _createRenderVAO;
  65014. private _initialize;
  65015. /** @hidden */
  65016. _recreateUpdateEffect(): void;
  65017. /** @hidden */
  65018. _recreateRenderEffect(): void;
  65019. /**
  65020. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65021. * @param preWarm defines if we are in the pre-warmimg phase
  65022. */
  65023. animate(preWarm?: boolean): void;
  65024. private _createFactorGradientTexture;
  65025. private _createSizeGradientTexture;
  65026. private _createAngularSpeedGradientTexture;
  65027. private _createVelocityGradientTexture;
  65028. private _createLimitVelocityGradientTexture;
  65029. private _createDragGradientTexture;
  65030. private _createColorGradientTexture;
  65031. /**
  65032. * Renders the particle system in its current state
  65033. * @param preWarm defines if the system should only update the particles but not render them
  65034. * @returns the current number of particles
  65035. */
  65036. render(preWarm?: boolean): number;
  65037. /**
  65038. * Rebuilds the particle system
  65039. */
  65040. rebuild(): void;
  65041. private _releaseBuffers;
  65042. private _releaseVAOs;
  65043. /**
  65044. * Disposes the particle system and free the associated resources
  65045. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65046. */
  65047. dispose(disposeTexture?: boolean): void;
  65048. /**
  65049. * Clones the particle system.
  65050. * @param name The name of the cloned object
  65051. * @param newEmitter The new emitter to use
  65052. * @returns the cloned particle system
  65053. */
  65054. clone(name: string, newEmitter: any): GPUParticleSystem;
  65055. /**
  65056. * Serializes the particle system to a JSON object
  65057. * @param serializeTexture defines if the texture must be serialized as well
  65058. * @returns the JSON object
  65059. */
  65060. serialize(serializeTexture?: boolean): any;
  65061. /**
  65062. * Parses a JSON object to create a GPU particle system.
  65063. * @param parsedParticleSystem The JSON object to parse
  65064. * @param scene The scene to create the particle system in
  65065. * @param rootUrl The root url to use to load external dependencies like texture
  65066. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65067. * @returns the parsed GPU particle system
  65068. */
  65069. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65070. }
  65071. }
  65072. declare module BABYLON {
  65073. /**
  65074. * Represents a set of particle systems working together to create a specific effect
  65075. */
  65076. export class ParticleSystemSet implements IDisposable {
  65077. /**
  65078. * Gets or sets base Assets URL
  65079. */
  65080. static BaseAssetsUrl: string;
  65081. private _emitterCreationOptions;
  65082. private _emitterNode;
  65083. /**
  65084. * Gets the particle system list
  65085. */
  65086. systems: IParticleSystem[];
  65087. /**
  65088. * Gets the emitter node used with this set
  65089. */
  65090. get emitterNode(): Nullable<TransformNode>;
  65091. /**
  65092. * Creates a new emitter mesh as a sphere
  65093. * @param options defines the options used to create the sphere
  65094. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65095. * @param scene defines the hosting scene
  65096. */
  65097. setEmitterAsSphere(options: {
  65098. diameter: number;
  65099. segments: number;
  65100. color: Color3;
  65101. }, renderingGroupId: number, scene: Scene): void;
  65102. /**
  65103. * Starts all particle systems of the set
  65104. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65105. */
  65106. start(emitter?: AbstractMesh): void;
  65107. /**
  65108. * Release all associated resources
  65109. */
  65110. dispose(): void;
  65111. /**
  65112. * Serialize the set into a JSON compatible object
  65113. * @param serializeTexture defines if the texture must be serialized as well
  65114. * @returns a JSON compatible representation of the set
  65115. */
  65116. serialize(serializeTexture?: boolean): any;
  65117. /**
  65118. * Parse a new ParticleSystemSet from a serialized source
  65119. * @param data defines a JSON compatible representation of the set
  65120. * @param scene defines the hosting scene
  65121. * @param gpu defines if we want GPU particles or CPU particles
  65122. * @returns a new ParticleSystemSet
  65123. */
  65124. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65125. }
  65126. }
  65127. declare module BABYLON {
  65128. /**
  65129. * This class is made for on one-liner static method to help creating particle system set.
  65130. */
  65131. export class ParticleHelper {
  65132. /**
  65133. * Gets or sets base Assets URL
  65134. */
  65135. static BaseAssetsUrl: string;
  65136. /** Define the Url to load snippets */
  65137. static SnippetUrl: string;
  65138. /**
  65139. * Create a default particle system that you can tweak
  65140. * @param emitter defines the emitter to use
  65141. * @param capacity defines the system capacity (default is 500 particles)
  65142. * @param scene defines the hosting scene
  65143. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65144. * @returns the new Particle system
  65145. */
  65146. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65147. /**
  65148. * This is the main static method (one-liner) of this helper to create different particle systems
  65149. * @param type This string represents the type to the particle system to create
  65150. * @param scene The scene where the particle system should live
  65151. * @param gpu If the system will use gpu
  65152. * @returns the ParticleSystemSet created
  65153. */
  65154. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65155. /**
  65156. * Static function used to export a particle system to a ParticleSystemSet variable.
  65157. * Please note that the emitter shape is not exported
  65158. * @param systems defines the particle systems to export
  65159. * @returns the created particle system set
  65160. */
  65161. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65162. /**
  65163. * Creates a particle system from a snippet saved in a remote file
  65164. * @param name defines the name of the particle system to create
  65165. * @param url defines the url to load from
  65166. * @param scene defines the hosting scene
  65167. * @param gpu If the system will use gpu
  65168. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65169. * @returns a promise that will resolve to the new particle system
  65170. */
  65171. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65172. /**
  65173. * Creates a particle system from a snippet saved by the particle system editor
  65174. * @param snippetId defines the snippet to load
  65175. * @param scene defines the hosting scene
  65176. * @param gpu If the system will use gpu
  65177. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65178. * @returns a promise that will resolve to the new particle system
  65179. */
  65180. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  65181. }
  65182. }
  65183. declare module BABYLON {
  65184. interface Engine {
  65185. /**
  65186. * Create an effect to use with particle systems.
  65187. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65188. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65189. * @param uniformsNames defines a list of attribute names
  65190. * @param samplers defines an array of string used to represent textures
  65191. * @param defines defines the string containing the defines to use to compile the shaders
  65192. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65193. * @param onCompiled defines a function to call when the effect creation is successful
  65194. * @param onError defines a function to call when the effect creation has failed
  65195. * @returns the new Effect
  65196. */
  65197. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65198. }
  65199. interface Mesh {
  65200. /**
  65201. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65202. * @returns an array of IParticleSystem
  65203. */
  65204. getEmittedParticleSystems(): IParticleSystem[];
  65205. /**
  65206. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65207. * @returns an array of IParticleSystem
  65208. */
  65209. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65210. }
  65211. /**
  65212. * @hidden
  65213. */
  65214. export var _IDoNeedToBeInTheBuild: number;
  65215. }
  65216. declare module BABYLON {
  65217. /** Defines the 4 color options */
  65218. export enum PointColor {
  65219. /** color value */
  65220. Color = 2,
  65221. /** uv value */
  65222. UV = 1,
  65223. /** random value */
  65224. Random = 0,
  65225. /** stated value */
  65226. Stated = 3
  65227. }
  65228. /**
  65229. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65230. * 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.
  65231. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65232. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65233. *
  65234. * Full documentation here : TO BE ENTERED
  65235. */
  65236. export class PointsCloudSystem implements IDisposable {
  65237. /**
  65238. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65239. * Example : var p = SPS.particles[i];
  65240. */
  65241. particles: CloudPoint[];
  65242. /**
  65243. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65244. */
  65245. nbParticles: number;
  65246. /**
  65247. * This a counter for your own usage. It's not set by any SPS functions.
  65248. */
  65249. counter: number;
  65250. /**
  65251. * The PCS name. This name is also given to the underlying mesh.
  65252. */
  65253. name: string;
  65254. /**
  65255. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65256. */
  65257. mesh: Mesh;
  65258. /**
  65259. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65260. * Please read :
  65261. */
  65262. vars: any;
  65263. /**
  65264. * @hidden
  65265. */
  65266. _size: number;
  65267. private _scene;
  65268. private _promises;
  65269. private _positions;
  65270. private _indices;
  65271. private _normals;
  65272. private _colors;
  65273. private _uvs;
  65274. private _indices32;
  65275. private _positions32;
  65276. private _colors32;
  65277. private _uvs32;
  65278. private _updatable;
  65279. private _isVisibilityBoxLocked;
  65280. private _alwaysVisible;
  65281. private _groups;
  65282. private _groupCounter;
  65283. private _computeParticleColor;
  65284. private _computeParticleTexture;
  65285. private _computeParticleRotation;
  65286. private _computeBoundingBox;
  65287. private _isReady;
  65288. /**
  65289. * Creates a PCS (Points Cloud System) object
  65290. * @param name (String) is the PCS name, this will be the underlying mesh name
  65291. * @param pointSize (number) is the size for each point
  65292. * @param scene (Scene) is the scene in which the PCS is added
  65293. * @param options defines the options of the PCS e.g.
  65294. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65295. */
  65296. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65297. updatable?: boolean;
  65298. });
  65299. /**
  65300. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65301. * If no points were added to the PCS, the returned mesh is just a single point.
  65302. * @returns a promise for the created mesh
  65303. */
  65304. buildMeshAsync(): Promise<Mesh>;
  65305. /**
  65306. * @hidden
  65307. */
  65308. private _buildMesh;
  65309. private _addParticle;
  65310. private _randomUnitVector;
  65311. private _getColorIndicesForCoord;
  65312. private _setPointsColorOrUV;
  65313. private _colorFromTexture;
  65314. private _calculateDensity;
  65315. /**
  65316. * Adds points to the PCS in random positions within a unit sphere
  65317. * @param nb (positive integer) the number of particles to be created from this model
  65318. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65319. * @returns the number of groups in the system
  65320. */
  65321. addPoints(nb: number, pointFunction?: any): number;
  65322. /**
  65323. * Adds points to the PCS from the surface of the model shape
  65324. * @param mesh is any Mesh object that will be used as a surface model for the points
  65325. * @param nb (positive integer) the number of particles to be created from this model
  65326. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65327. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65328. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65329. * @returns the number of groups in the system
  65330. */
  65331. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65332. /**
  65333. * Adds points to the PCS inside the model shape
  65334. * @param mesh is any Mesh object that will be used as a surface model for the points
  65335. * @param nb (positive integer) the number of particles to be created from this model
  65336. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65337. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65338. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65339. * @returns the number of groups in the system
  65340. */
  65341. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65342. /**
  65343. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65344. * This method calls `updateParticle()` for each particle of the SPS.
  65345. * For an animated SPS, it is usually called within the render loop.
  65346. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65347. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65348. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65349. * @returns the PCS.
  65350. */
  65351. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65352. /**
  65353. * Disposes the PCS.
  65354. */
  65355. dispose(): void;
  65356. /**
  65357. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65358. * doc :
  65359. * @returns the PCS.
  65360. */
  65361. refreshVisibleSize(): PointsCloudSystem;
  65362. /**
  65363. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65364. * @param size the size (float) of the visibility box
  65365. * note : this doesn't lock the PCS mesh bounding box.
  65366. * doc :
  65367. */
  65368. setVisibilityBox(size: number): void;
  65369. /**
  65370. * Gets whether the PCS is always visible or not
  65371. * doc :
  65372. */
  65373. get isAlwaysVisible(): boolean;
  65374. /**
  65375. * Sets the PCS as always visible or not
  65376. * doc :
  65377. */
  65378. set isAlwaysVisible(val: boolean);
  65379. /**
  65380. * Tells to `setParticles()` to compute the particle rotations or not
  65381. * Default value : false. The PCS is faster when it's set to false
  65382. * Note : particle rotations are only applied to parent particles
  65383. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65384. */
  65385. set computeParticleRotation(val: boolean);
  65386. /**
  65387. * Tells to `setParticles()` to compute the particle colors or not.
  65388. * Default value : true. The PCS is faster when it's set to false.
  65389. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65390. */
  65391. set computeParticleColor(val: boolean);
  65392. set computeParticleTexture(val: boolean);
  65393. /**
  65394. * Gets if `setParticles()` computes the particle colors or not.
  65395. * Default value : false. The PCS is faster when it's set to false.
  65396. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65397. */
  65398. get computeParticleColor(): boolean;
  65399. /**
  65400. * Gets if `setParticles()` computes the particle textures or not.
  65401. * Default value : false. The PCS is faster when it's set to false.
  65402. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65403. */
  65404. get computeParticleTexture(): boolean;
  65405. /**
  65406. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65407. */
  65408. set computeBoundingBox(val: boolean);
  65409. /**
  65410. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65411. */
  65412. get computeBoundingBox(): boolean;
  65413. /**
  65414. * This function does nothing. It may be overwritten to set all the particle first values.
  65415. * The PCS doesn't call this function, you may have to call it by your own.
  65416. * doc :
  65417. */
  65418. initParticles(): void;
  65419. /**
  65420. * This function does nothing. It may be overwritten to recycle a particle
  65421. * The PCS doesn't call this function, you can to call it
  65422. * doc :
  65423. * @param particle The particle to recycle
  65424. * @returns the recycled particle
  65425. */
  65426. recycleParticle(particle: CloudPoint): CloudPoint;
  65427. /**
  65428. * Updates a particle : this function should be overwritten by the user.
  65429. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65430. * doc :
  65431. * @example : just set a particle position or velocity and recycle conditions
  65432. * @param particle The particle to update
  65433. * @returns the updated particle
  65434. */
  65435. updateParticle(particle: CloudPoint): CloudPoint;
  65436. /**
  65437. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65438. * This does nothing and may be overwritten by the user.
  65439. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65440. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65441. * @param update the boolean update value actually passed to setParticles()
  65442. */
  65443. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65444. /**
  65445. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65446. * This will be passed three parameters.
  65447. * This does nothing and may be overwritten by the user.
  65448. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65449. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65450. * @param update the boolean update value actually passed to setParticles()
  65451. */
  65452. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65453. }
  65454. }
  65455. declare module BABYLON {
  65456. /**
  65457. * Represents one particle of a points cloud system.
  65458. */
  65459. export class CloudPoint {
  65460. /**
  65461. * particle global index
  65462. */
  65463. idx: number;
  65464. /**
  65465. * The color of the particle
  65466. */
  65467. color: Nullable<Color4>;
  65468. /**
  65469. * The world space position of the particle.
  65470. */
  65471. position: Vector3;
  65472. /**
  65473. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65474. */
  65475. rotation: Vector3;
  65476. /**
  65477. * The world space rotation quaternion of the particle.
  65478. */
  65479. rotationQuaternion: Nullable<Quaternion>;
  65480. /**
  65481. * The uv of the particle.
  65482. */
  65483. uv: Nullable<Vector2>;
  65484. /**
  65485. * The current speed of the particle.
  65486. */
  65487. velocity: Vector3;
  65488. /**
  65489. * The pivot point in the particle local space.
  65490. */
  65491. pivot: Vector3;
  65492. /**
  65493. * Must the particle be translated from its pivot point in its local space ?
  65494. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65495. * Default : false
  65496. */
  65497. translateFromPivot: boolean;
  65498. /**
  65499. * Index of this particle in the global "positions" array (Internal use)
  65500. * @hidden
  65501. */
  65502. _pos: number;
  65503. /**
  65504. * @hidden Index of this particle in the global "indices" array (Internal use)
  65505. */
  65506. _ind: number;
  65507. /**
  65508. * Group this particle belongs to
  65509. */
  65510. _group: PointsGroup;
  65511. /**
  65512. * Group id of this particle
  65513. */
  65514. groupId: number;
  65515. /**
  65516. * Index of the particle in its group id (Internal use)
  65517. */
  65518. idxInGroup: number;
  65519. /**
  65520. * @hidden Particle BoundingInfo object (Internal use)
  65521. */
  65522. _boundingInfo: BoundingInfo;
  65523. /**
  65524. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65525. */
  65526. _pcs: PointsCloudSystem;
  65527. /**
  65528. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65529. */
  65530. _stillInvisible: boolean;
  65531. /**
  65532. * @hidden Last computed particle rotation matrix
  65533. */
  65534. _rotationMatrix: number[];
  65535. /**
  65536. * Parent particle Id, if any.
  65537. * Default null.
  65538. */
  65539. parentId: Nullable<number>;
  65540. /**
  65541. * @hidden Internal global position in the PCS.
  65542. */
  65543. _globalPosition: Vector3;
  65544. /**
  65545. * Creates a Point Cloud object.
  65546. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65547. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65548. * @param group (PointsGroup) is the group the particle belongs to
  65549. * @param groupId (integer) is the group identifier in the PCS.
  65550. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65551. * @param pcs defines the PCS it is associated to
  65552. */
  65553. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65554. /**
  65555. * get point size
  65556. */
  65557. get size(): Vector3;
  65558. /**
  65559. * Set point size
  65560. */
  65561. set size(scale: Vector3);
  65562. /**
  65563. * Legacy support, changed quaternion to rotationQuaternion
  65564. */
  65565. get quaternion(): Nullable<Quaternion>;
  65566. /**
  65567. * Legacy support, changed quaternion to rotationQuaternion
  65568. */
  65569. set quaternion(q: Nullable<Quaternion>);
  65570. /**
  65571. * Returns a boolean. True if the particle intersects a mesh, else false
  65572. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  65573. * @param target is the object (point or mesh) what the intersection is computed against
  65574. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  65575. * @returns true if it intersects
  65576. */
  65577. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  65578. /**
  65579. * get the rotation matrix of the particle
  65580. * @hidden
  65581. */
  65582. getRotationMatrix(m: Matrix): void;
  65583. }
  65584. /**
  65585. * Represents a group of points in a points cloud system
  65586. * * PCS internal tool, don't use it manually.
  65587. */
  65588. export class PointsGroup {
  65589. /**
  65590. * The group id
  65591. * @hidden
  65592. */
  65593. groupID: number;
  65594. /**
  65595. * image data for group (internal use)
  65596. * @hidden
  65597. */
  65598. _groupImageData: Nullable<ArrayBufferView>;
  65599. /**
  65600. * Image Width (internal use)
  65601. * @hidden
  65602. */
  65603. _groupImgWidth: number;
  65604. /**
  65605. * Image Height (internal use)
  65606. * @hidden
  65607. */
  65608. _groupImgHeight: number;
  65609. /**
  65610. * Custom position function (internal use)
  65611. * @hidden
  65612. */
  65613. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  65614. /**
  65615. * density per facet for surface points
  65616. * @hidden
  65617. */
  65618. _groupDensity: number[];
  65619. /**
  65620. * Only when points are colored by texture carries pointer to texture list array
  65621. * @hidden
  65622. */
  65623. _textureNb: number;
  65624. /**
  65625. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  65626. * PCS internal tool, don't use it manually.
  65627. * @hidden
  65628. */
  65629. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  65630. }
  65631. }
  65632. declare module BABYLON {
  65633. interface Scene {
  65634. /** @hidden (Backing field) */
  65635. _physicsEngine: Nullable<IPhysicsEngine>;
  65636. /** @hidden */
  65637. _physicsTimeAccumulator: number;
  65638. /**
  65639. * Gets the current physics engine
  65640. * @returns a IPhysicsEngine or null if none attached
  65641. */
  65642. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  65643. /**
  65644. * Enables physics to the current scene
  65645. * @param gravity defines the scene's gravity for the physics engine
  65646. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  65647. * @return a boolean indicating if the physics engine was initialized
  65648. */
  65649. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  65650. /**
  65651. * Disables and disposes the physics engine associated with the scene
  65652. */
  65653. disablePhysicsEngine(): void;
  65654. /**
  65655. * Gets a boolean indicating if there is an active physics engine
  65656. * @returns a boolean indicating if there is an active physics engine
  65657. */
  65658. isPhysicsEnabled(): boolean;
  65659. /**
  65660. * Deletes a physics compound impostor
  65661. * @param compound defines the compound to delete
  65662. */
  65663. deleteCompoundImpostor(compound: any): void;
  65664. /**
  65665. * An event triggered when physic simulation is about to be run
  65666. */
  65667. onBeforePhysicsObservable: Observable<Scene>;
  65668. /**
  65669. * An event triggered when physic simulation has been done
  65670. */
  65671. onAfterPhysicsObservable: Observable<Scene>;
  65672. }
  65673. interface AbstractMesh {
  65674. /** @hidden */
  65675. _physicsImpostor: Nullable<PhysicsImpostor>;
  65676. /**
  65677. * Gets or sets impostor used for physic simulation
  65678. * @see http://doc.babylonjs.com/features/physics_engine
  65679. */
  65680. physicsImpostor: Nullable<PhysicsImpostor>;
  65681. /**
  65682. * Gets the current physics impostor
  65683. * @see http://doc.babylonjs.com/features/physics_engine
  65684. * @returns a physics impostor or null
  65685. */
  65686. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  65687. /** Apply a physic impulse to the mesh
  65688. * @param force defines the force to apply
  65689. * @param contactPoint defines where to apply the force
  65690. * @returns the current mesh
  65691. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  65692. */
  65693. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  65694. /**
  65695. * Creates a physic joint between two meshes
  65696. * @param otherMesh defines the other mesh to use
  65697. * @param pivot1 defines the pivot to use on this mesh
  65698. * @param pivot2 defines the pivot to use on the other mesh
  65699. * @param options defines additional options (can be plugin dependent)
  65700. * @returns the current mesh
  65701. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  65702. */
  65703. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  65704. /** @hidden */
  65705. _disposePhysicsObserver: Nullable<Observer<Node>>;
  65706. }
  65707. /**
  65708. * Defines the physics engine scene component responsible to manage a physics engine
  65709. */
  65710. export class PhysicsEngineSceneComponent implements ISceneComponent {
  65711. /**
  65712. * The component name helpful to identify the component in the list of scene components.
  65713. */
  65714. readonly name: string;
  65715. /**
  65716. * The scene the component belongs to.
  65717. */
  65718. scene: Scene;
  65719. /**
  65720. * Creates a new instance of the component for the given scene
  65721. * @param scene Defines the scene to register the component in
  65722. */
  65723. constructor(scene: Scene);
  65724. /**
  65725. * Registers the component in a given scene
  65726. */
  65727. register(): void;
  65728. /**
  65729. * Rebuilds the elements related to this component in case of
  65730. * context lost for instance.
  65731. */
  65732. rebuild(): void;
  65733. /**
  65734. * Disposes the component and the associated ressources
  65735. */
  65736. dispose(): void;
  65737. }
  65738. }
  65739. declare module BABYLON {
  65740. /**
  65741. * A helper for physics simulations
  65742. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65743. */
  65744. export class PhysicsHelper {
  65745. private _scene;
  65746. private _physicsEngine;
  65747. /**
  65748. * Initializes the Physics helper
  65749. * @param scene Babylon.js scene
  65750. */
  65751. constructor(scene: Scene);
  65752. /**
  65753. * Applies a radial explosion impulse
  65754. * @param origin the origin of the explosion
  65755. * @param radiusOrEventOptions the radius or the options of radial explosion
  65756. * @param strength the explosion strength
  65757. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65758. * @returns A physics radial explosion event, or null
  65759. */
  65760. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65761. /**
  65762. * Applies a radial explosion force
  65763. * @param origin the origin of the explosion
  65764. * @param radiusOrEventOptions the radius or the options of radial explosion
  65765. * @param strength the explosion strength
  65766. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65767. * @returns A physics radial explosion event, or null
  65768. */
  65769. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65770. /**
  65771. * Creates a gravitational field
  65772. * @param origin the origin of the explosion
  65773. * @param radiusOrEventOptions the radius or the options of radial explosion
  65774. * @param strength the explosion strength
  65775. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65776. * @returns A physics gravitational field event, or null
  65777. */
  65778. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  65779. /**
  65780. * Creates a physics updraft event
  65781. * @param origin the origin of the updraft
  65782. * @param radiusOrEventOptions the radius or the options of the updraft
  65783. * @param strength the strength of the updraft
  65784. * @param height the height of the updraft
  65785. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  65786. * @returns A physics updraft event, or null
  65787. */
  65788. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  65789. /**
  65790. * Creates a physics vortex event
  65791. * @param origin the of the vortex
  65792. * @param radiusOrEventOptions the radius or the options of the vortex
  65793. * @param strength the strength of the vortex
  65794. * @param height the height of the vortex
  65795. * @returns a Physics vortex event, or null
  65796. * A physics vortex event or null
  65797. */
  65798. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  65799. }
  65800. /**
  65801. * Represents a physics radial explosion event
  65802. */
  65803. class PhysicsRadialExplosionEvent {
  65804. private _scene;
  65805. private _options;
  65806. private _sphere;
  65807. private _dataFetched;
  65808. /**
  65809. * Initializes a radial explosioin event
  65810. * @param _scene BabylonJS scene
  65811. * @param _options The options for the vortex event
  65812. */
  65813. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  65814. /**
  65815. * Returns the data related to the radial explosion event (sphere).
  65816. * @returns The radial explosion event data
  65817. */
  65818. getData(): PhysicsRadialExplosionEventData;
  65819. /**
  65820. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  65821. * @param impostor A physics imposter
  65822. * @param origin the origin of the explosion
  65823. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  65824. */
  65825. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  65826. /**
  65827. * Triggers affecterd impostors callbacks
  65828. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  65829. */
  65830. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  65831. /**
  65832. * Disposes the sphere.
  65833. * @param force Specifies if the sphere should be disposed by force
  65834. */
  65835. dispose(force?: boolean): void;
  65836. /*** Helpers ***/
  65837. private _prepareSphere;
  65838. private _intersectsWithSphere;
  65839. }
  65840. /**
  65841. * Represents a gravitational field event
  65842. */
  65843. class PhysicsGravitationalFieldEvent {
  65844. private _physicsHelper;
  65845. private _scene;
  65846. private _origin;
  65847. private _options;
  65848. private _tickCallback;
  65849. private _sphere;
  65850. private _dataFetched;
  65851. /**
  65852. * Initializes the physics gravitational field event
  65853. * @param _physicsHelper A physics helper
  65854. * @param _scene BabylonJS scene
  65855. * @param _origin The origin position of the gravitational field event
  65856. * @param _options The options for the vortex event
  65857. */
  65858. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65859. /**
  65860. * Returns the data related to the gravitational field event (sphere).
  65861. * @returns A gravitational field event
  65862. */
  65863. getData(): PhysicsGravitationalFieldEventData;
  65864. /**
  65865. * Enables the gravitational field.
  65866. */
  65867. enable(): void;
  65868. /**
  65869. * Disables the gravitational field.
  65870. */
  65871. disable(): void;
  65872. /**
  65873. * Disposes the sphere.
  65874. * @param force The force to dispose from the gravitational field event
  65875. */
  65876. dispose(force?: boolean): void;
  65877. private _tick;
  65878. }
  65879. /**
  65880. * Represents a physics updraft event
  65881. */
  65882. class PhysicsUpdraftEvent {
  65883. private _scene;
  65884. private _origin;
  65885. private _options;
  65886. private _physicsEngine;
  65887. private _originTop;
  65888. private _originDirection;
  65889. private _tickCallback;
  65890. private _cylinder;
  65891. private _cylinderPosition;
  65892. private _dataFetched;
  65893. /**
  65894. * Initializes the physics updraft event
  65895. * @param _scene BabylonJS scene
  65896. * @param _origin The origin position of the updraft
  65897. * @param _options The options for the updraft event
  65898. */
  65899. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65900. /**
  65901. * Returns the data related to the updraft event (cylinder).
  65902. * @returns A physics updraft event
  65903. */
  65904. getData(): PhysicsUpdraftEventData;
  65905. /**
  65906. * Enables the updraft.
  65907. */
  65908. enable(): void;
  65909. /**
  65910. * Disables the updraft.
  65911. */
  65912. disable(): void;
  65913. /**
  65914. * Disposes the cylinder.
  65915. * @param force Specifies if the updraft should be disposed by force
  65916. */
  65917. dispose(force?: boolean): void;
  65918. private getImpostorHitData;
  65919. private _tick;
  65920. /*** Helpers ***/
  65921. private _prepareCylinder;
  65922. private _intersectsWithCylinder;
  65923. }
  65924. /**
  65925. * Represents a physics vortex event
  65926. */
  65927. class PhysicsVortexEvent {
  65928. private _scene;
  65929. private _origin;
  65930. private _options;
  65931. private _physicsEngine;
  65932. private _originTop;
  65933. private _tickCallback;
  65934. private _cylinder;
  65935. private _cylinderPosition;
  65936. private _dataFetched;
  65937. /**
  65938. * Initializes the physics vortex event
  65939. * @param _scene The BabylonJS scene
  65940. * @param _origin The origin position of the vortex
  65941. * @param _options The options for the vortex event
  65942. */
  65943. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65944. /**
  65945. * Returns the data related to the vortex event (cylinder).
  65946. * @returns The physics vortex event data
  65947. */
  65948. getData(): PhysicsVortexEventData;
  65949. /**
  65950. * Enables the vortex.
  65951. */
  65952. enable(): void;
  65953. /**
  65954. * Disables the cortex.
  65955. */
  65956. disable(): void;
  65957. /**
  65958. * Disposes the sphere.
  65959. * @param force
  65960. */
  65961. dispose(force?: boolean): void;
  65962. private getImpostorHitData;
  65963. private _tick;
  65964. /*** Helpers ***/
  65965. private _prepareCylinder;
  65966. private _intersectsWithCylinder;
  65967. }
  65968. /**
  65969. * Options fot the radial explosion event
  65970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65971. */
  65972. export class PhysicsRadialExplosionEventOptions {
  65973. /**
  65974. * The radius of the sphere for the radial explosion.
  65975. */
  65976. radius: number;
  65977. /**
  65978. * The strenth of the explosion.
  65979. */
  65980. strength: number;
  65981. /**
  65982. * The strenght of the force in correspondence to the distance of the affected object
  65983. */
  65984. falloff: PhysicsRadialImpulseFalloff;
  65985. /**
  65986. * Sphere options for the radial explosion.
  65987. */
  65988. sphere: {
  65989. segments: number;
  65990. diameter: number;
  65991. };
  65992. /**
  65993. * Sphere options for the radial explosion.
  65994. */
  65995. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65996. }
  65997. /**
  65998. * Options fot the updraft event
  65999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66000. */
  66001. export class PhysicsUpdraftEventOptions {
  66002. /**
  66003. * The radius of the cylinder for the vortex
  66004. */
  66005. radius: number;
  66006. /**
  66007. * The strenth of the updraft.
  66008. */
  66009. strength: number;
  66010. /**
  66011. * The height of the cylinder for the updraft.
  66012. */
  66013. height: number;
  66014. /**
  66015. * The mode for the the updraft.
  66016. */
  66017. updraftMode: PhysicsUpdraftMode;
  66018. }
  66019. /**
  66020. * Options fot the vortex event
  66021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66022. */
  66023. export class PhysicsVortexEventOptions {
  66024. /**
  66025. * The radius of the cylinder for the vortex
  66026. */
  66027. radius: number;
  66028. /**
  66029. * The strenth of the vortex.
  66030. */
  66031. strength: number;
  66032. /**
  66033. * The height of the cylinder for the vortex.
  66034. */
  66035. height: number;
  66036. /**
  66037. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66038. */
  66039. centripetalForceThreshold: number;
  66040. /**
  66041. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66042. */
  66043. centripetalForceMultiplier: number;
  66044. /**
  66045. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66046. */
  66047. centrifugalForceMultiplier: number;
  66048. /**
  66049. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66050. */
  66051. updraftForceMultiplier: number;
  66052. }
  66053. /**
  66054. * The strenght of the force in correspondence to the distance of the affected object
  66055. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66056. */
  66057. export enum PhysicsRadialImpulseFalloff {
  66058. /** Defines that impulse is constant in strength across it's whole radius */
  66059. Constant = 0,
  66060. /** Defines that impulse gets weaker if it's further from the origin */
  66061. Linear = 1
  66062. }
  66063. /**
  66064. * The strength of the force in correspondence to the distance of the affected object
  66065. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66066. */
  66067. export enum PhysicsUpdraftMode {
  66068. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66069. Center = 0,
  66070. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66071. Perpendicular = 1
  66072. }
  66073. /**
  66074. * Interface for a physics hit data
  66075. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66076. */
  66077. export interface PhysicsHitData {
  66078. /**
  66079. * The force applied at the contact point
  66080. */
  66081. force: Vector3;
  66082. /**
  66083. * The contact point
  66084. */
  66085. contactPoint: Vector3;
  66086. /**
  66087. * The distance from the origin to the contact point
  66088. */
  66089. distanceFromOrigin: number;
  66090. }
  66091. /**
  66092. * Interface for radial explosion event data
  66093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66094. */
  66095. export interface PhysicsRadialExplosionEventData {
  66096. /**
  66097. * A sphere used for the radial explosion event
  66098. */
  66099. sphere: Mesh;
  66100. }
  66101. /**
  66102. * Interface for gravitational field event data
  66103. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66104. */
  66105. export interface PhysicsGravitationalFieldEventData {
  66106. /**
  66107. * A sphere mesh used for the gravitational field event
  66108. */
  66109. sphere: Mesh;
  66110. }
  66111. /**
  66112. * Interface for updraft event data
  66113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66114. */
  66115. export interface PhysicsUpdraftEventData {
  66116. /**
  66117. * A cylinder used for the updraft event
  66118. */
  66119. cylinder: Mesh;
  66120. }
  66121. /**
  66122. * Interface for vortex event data
  66123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66124. */
  66125. export interface PhysicsVortexEventData {
  66126. /**
  66127. * A cylinder used for the vortex event
  66128. */
  66129. cylinder: Mesh;
  66130. }
  66131. /**
  66132. * Interface for an affected physics impostor
  66133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66134. */
  66135. export interface PhysicsAffectedImpostorWithData {
  66136. /**
  66137. * The impostor affected by the effect
  66138. */
  66139. impostor: PhysicsImpostor;
  66140. /**
  66141. * The data about the hit/horce from the explosion
  66142. */
  66143. hitData: PhysicsHitData;
  66144. }
  66145. }
  66146. declare module BABYLON {
  66147. /** @hidden */
  66148. export var blackAndWhitePixelShader: {
  66149. name: string;
  66150. shader: string;
  66151. };
  66152. }
  66153. declare module BABYLON {
  66154. /**
  66155. * Post process used to render in black and white
  66156. */
  66157. export class BlackAndWhitePostProcess extends PostProcess {
  66158. /**
  66159. * Linear about to convert he result to black and white (default: 1)
  66160. */
  66161. degree: number;
  66162. /**
  66163. * Creates a black and white post process
  66164. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66165. * @param name The name of the effect.
  66166. * @param options The required width/height ratio to downsize to before computing the render pass.
  66167. * @param camera The camera to apply the render pass to.
  66168. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66169. * @param engine The engine which the post process will be applied. (default: current engine)
  66170. * @param reusable If the post process can be reused on the same frame. (default: false)
  66171. */
  66172. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66173. }
  66174. }
  66175. declare module BABYLON {
  66176. /**
  66177. * This represents a set of one or more post processes in Babylon.
  66178. * A post process can be used to apply a shader to a texture after it is rendered.
  66179. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66180. */
  66181. export class PostProcessRenderEffect {
  66182. private _postProcesses;
  66183. private _getPostProcesses;
  66184. private _singleInstance;
  66185. private _cameras;
  66186. private _indicesForCamera;
  66187. /**
  66188. * Name of the effect
  66189. * @hidden
  66190. */
  66191. _name: string;
  66192. /**
  66193. * Instantiates a post process render effect.
  66194. * A post process can be used to apply a shader to a texture after it is rendered.
  66195. * @param engine The engine the effect is tied to
  66196. * @param name The name of the effect
  66197. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66198. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66199. */
  66200. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66201. /**
  66202. * Checks if all the post processes in the effect are supported.
  66203. */
  66204. get isSupported(): boolean;
  66205. /**
  66206. * Updates the current state of the effect
  66207. * @hidden
  66208. */
  66209. _update(): void;
  66210. /**
  66211. * Attaches the effect on cameras
  66212. * @param cameras The camera to attach to.
  66213. * @hidden
  66214. */
  66215. _attachCameras(cameras: Camera): void;
  66216. /**
  66217. * Attaches the effect on cameras
  66218. * @param cameras The camera to attach to.
  66219. * @hidden
  66220. */
  66221. _attachCameras(cameras: Camera[]): void;
  66222. /**
  66223. * Detaches the effect on cameras
  66224. * @param cameras The camera to detatch from.
  66225. * @hidden
  66226. */
  66227. _detachCameras(cameras: Camera): void;
  66228. /**
  66229. * Detatches the effect on cameras
  66230. * @param cameras The camera to detatch from.
  66231. * @hidden
  66232. */
  66233. _detachCameras(cameras: Camera[]): void;
  66234. /**
  66235. * Enables the effect on given cameras
  66236. * @param cameras The camera to enable.
  66237. * @hidden
  66238. */
  66239. _enable(cameras: Camera): void;
  66240. /**
  66241. * Enables the effect on given cameras
  66242. * @param cameras The camera to enable.
  66243. * @hidden
  66244. */
  66245. _enable(cameras: Nullable<Camera[]>): void;
  66246. /**
  66247. * Disables the effect on the given cameras
  66248. * @param cameras The camera to disable.
  66249. * @hidden
  66250. */
  66251. _disable(cameras: Camera): void;
  66252. /**
  66253. * Disables the effect on the given cameras
  66254. * @param cameras The camera to disable.
  66255. * @hidden
  66256. */
  66257. _disable(cameras: Nullable<Camera[]>): void;
  66258. /**
  66259. * Gets a list of the post processes contained in the effect.
  66260. * @param camera The camera to get the post processes on.
  66261. * @returns The list of the post processes in the effect.
  66262. */
  66263. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66264. }
  66265. }
  66266. declare module BABYLON {
  66267. /** @hidden */
  66268. export var extractHighlightsPixelShader: {
  66269. name: string;
  66270. shader: string;
  66271. };
  66272. }
  66273. declare module BABYLON {
  66274. /**
  66275. * 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.
  66276. */
  66277. export class ExtractHighlightsPostProcess extends PostProcess {
  66278. /**
  66279. * The luminance threshold, pixels below this value will be set to black.
  66280. */
  66281. threshold: number;
  66282. /** @hidden */
  66283. _exposure: number;
  66284. /**
  66285. * Post process which has the input texture to be used when performing highlight extraction
  66286. * @hidden
  66287. */
  66288. _inputPostProcess: Nullable<PostProcess>;
  66289. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66290. }
  66291. }
  66292. declare module BABYLON {
  66293. /** @hidden */
  66294. export var bloomMergePixelShader: {
  66295. name: string;
  66296. shader: string;
  66297. };
  66298. }
  66299. declare module BABYLON {
  66300. /**
  66301. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66302. */
  66303. export class BloomMergePostProcess extends PostProcess {
  66304. /** Weight of the bloom to be added to the original input. */
  66305. weight: number;
  66306. /**
  66307. * Creates a new instance of @see BloomMergePostProcess
  66308. * @param name The name of the effect.
  66309. * @param originalFromInput Post process which's input will be used for the merge.
  66310. * @param blurred Blurred highlights post process which's output will be used.
  66311. * @param weight Weight of the bloom to be added to the original input.
  66312. * @param options The required width/height ratio to downsize to before computing the render pass.
  66313. * @param camera The camera to apply the render pass to.
  66314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66315. * @param engine The engine which the post process will be applied. (default: current engine)
  66316. * @param reusable If the post process can be reused on the same frame. (default: false)
  66317. * @param textureType Type of textures used when performing the post process. (default: 0)
  66318. * @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)
  66319. */
  66320. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66321. /** Weight of the bloom to be added to the original input. */
  66322. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66323. }
  66324. }
  66325. declare module BABYLON {
  66326. /**
  66327. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66328. */
  66329. export class BloomEffect extends PostProcessRenderEffect {
  66330. private bloomScale;
  66331. /**
  66332. * @hidden Internal
  66333. */
  66334. _effects: Array<PostProcess>;
  66335. /**
  66336. * @hidden Internal
  66337. */
  66338. _downscale: ExtractHighlightsPostProcess;
  66339. private _blurX;
  66340. private _blurY;
  66341. private _merge;
  66342. /**
  66343. * The luminance threshold to find bright areas of the image to bloom.
  66344. */
  66345. get threshold(): number;
  66346. set threshold(value: number);
  66347. /**
  66348. * The strength of the bloom.
  66349. */
  66350. get weight(): number;
  66351. set weight(value: number);
  66352. /**
  66353. * Specifies the size of the bloom blur kernel, relative to the final output size
  66354. */
  66355. get kernel(): number;
  66356. set kernel(value: number);
  66357. /**
  66358. * Creates a new instance of @see BloomEffect
  66359. * @param scene The scene the effect belongs to.
  66360. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66361. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66362. * @param bloomWeight The the strength of bloom.
  66363. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66364. * @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)
  66365. */
  66366. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66367. /**
  66368. * Disposes each of the internal effects for a given camera.
  66369. * @param camera The camera to dispose the effect on.
  66370. */
  66371. disposeEffects(camera: Camera): void;
  66372. /**
  66373. * @hidden Internal
  66374. */
  66375. _updateEffects(): void;
  66376. /**
  66377. * Internal
  66378. * @returns if all the contained post processes are ready.
  66379. * @hidden
  66380. */
  66381. _isReady(): boolean;
  66382. }
  66383. }
  66384. declare module BABYLON {
  66385. /** @hidden */
  66386. export var chromaticAberrationPixelShader: {
  66387. name: string;
  66388. shader: string;
  66389. };
  66390. }
  66391. declare module BABYLON {
  66392. /**
  66393. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66394. */
  66395. export class ChromaticAberrationPostProcess extends PostProcess {
  66396. /**
  66397. * The amount of seperation of rgb channels (default: 30)
  66398. */
  66399. aberrationAmount: number;
  66400. /**
  66401. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66402. */
  66403. radialIntensity: number;
  66404. /**
  66405. * 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))
  66406. */
  66407. direction: Vector2;
  66408. /**
  66409. * 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))
  66410. */
  66411. centerPosition: Vector2;
  66412. /**
  66413. * Creates a new instance ChromaticAberrationPostProcess
  66414. * @param name The name of the effect.
  66415. * @param screenWidth The width of the screen to apply the effect on.
  66416. * @param screenHeight The height of the screen to apply the effect on.
  66417. * @param options The required width/height ratio to downsize to before computing the render pass.
  66418. * @param camera The camera to apply the render pass to.
  66419. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66420. * @param engine The engine which the post process will be applied. (default: current engine)
  66421. * @param reusable If the post process can be reused on the same frame. (default: false)
  66422. * @param textureType Type of textures used when performing the post process. (default: 0)
  66423. * @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)
  66424. */
  66425. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66426. }
  66427. }
  66428. declare module BABYLON {
  66429. /** @hidden */
  66430. export var circleOfConfusionPixelShader: {
  66431. name: string;
  66432. shader: string;
  66433. };
  66434. }
  66435. declare module BABYLON {
  66436. /**
  66437. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66438. */
  66439. export class CircleOfConfusionPostProcess extends PostProcess {
  66440. /**
  66441. * 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.
  66442. */
  66443. lensSize: number;
  66444. /**
  66445. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66446. */
  66447. fStop: number;
  66448. /**
  66449. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66450. */
  66451. focusDistance: number;
  66452. /**
  66453. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66454. */
  66455. focalLength: number;
  66456. private _depthTexture;
  66457. /**
  66458. * Creates a new instance CircleOfConfusionPostProcess
  66459. * @param name The name of the effect.
  66460. * @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.
  66461. * @param options The required width/height ratio to downsize to before computing the render pass.
  66462. * @param camera The camera to apply the render pass to.
  66463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66464. * @param engine The engine which the post process will be applied. (default: current engine)
  66465. * @param reusable If the post process can be reused on the same frame. (default: false)
  66466. * @param textureType Type of textures used when performing the post process. (default: 0)
  66467. * @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)
  66468. */
  66469. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66470. /**
  66471. * 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.
  66472. */
  66473. set depthTexture(value: RenderTargetTexture);
  66474. }
  66475. }
  66476. declare module BABYLON {
  66477. /** @hidden */
  66478. export var colorCorrectionPixelShader: {
  66479. name: string;
  66480. shader: string;
  66481. };
  66482. }
  66483. declare module BABYLON {
  66484. /**
  66485. *
  66486. * This post-process allows the modification of rendered colors by using
  66487. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66488. *
  66489. * The object needs to be provided an url to a texture containing the color
  66490. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66491. * Use an image editing software to tweak the LUT to match your needs.
  66492. *
  66493. * For an example of a color LUT, see here:
  66494. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66495. * For explanations on color grading, see here:
  66496. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66497. *
  66498. */
  66499. export class ColorCorrectionPostProcess extends PostProcess {
  66500. private _colorTableTexture;
  66501. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66502. }
  66503. }
  66504. declare module BABYLON {
  66505. /** @hidden */
  66506. export var convolutionPixelShader: {
  66507. name: string;
  66508. shader: string;
  66509. };
  66510. }
  66511. declare module BABYLON {
  66512. /**
  66513. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66514. * input texture to perform effects such as edge detection or sharpening
  66515. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66516. */
  66517. export class ConvolutionPostProcess extends PostProcess {
  66518. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66519. kernel: number[];
  66520. /**
  66521. * Creates a new instance ConvolutionPostProcess
  66522. * @param name The name of the effect.
  66523. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66524. * @param options The required width/height ratio to downsize to before computing the render pass.
  66525. * @param camera The camera to apply the render pass to.
  66526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66527. * @param engine The engine which the post process will be applied. (default: current engine)
  66528. * @param reusable If the post process can be reused on the same frame. (default: false)
  66529. * @param textureType Type of textures used when performing the post process. (default: 0)
  66530. */
  66531. constructor(name: string,
  66532. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66533. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66534. /**
  66535. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66536. */
  66537. static EdgeDetect0Kernel: number[];
  66538. /**
  66539. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66540. */
  66541. static EdgeDetect1Kernel: number[];
  66542. /**
  66543. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66544. */
  66545. static EdgeDetect2Kernel: number[];
  66546. /**
  66547. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66548. */
  66549. static SharpenKernel: number[];
  66550. /**
  66551. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66552. */
  66553. static EmbossKernel: number[];
  66554. /**
  66555. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66556. */
  66557. static GaussianKernel: number[];
  66558. }
  66559. }
  66560. declare module BABYLON {
  66561. /**
  66562. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  66563. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  66564. * based on samples that have a large difference in distance than the center pixel.
  66565. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  66566. */
  66567. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  66568. direction: Vector2;
  66569. /**
  66570. * Creates a new instance CircleOfConfusionPostProcess
  66571. * @param name The name of the effect.
  66572. * @param scene The scene the effect belongs to.
  66573. * @param direction The direction the blur should be applied.
  66574. * @param kernel The size of the kernel used to blur.
  66575. * @param options The required width/height ratio to downsize to before computing the render pass.
  66576. * @param camera The camera to apply the render pass to.
  66577. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  66578. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  66579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66580. * @param engine The engine which the post process will be applied. (default: current engine)
  66581. * @param reusable If the post process can be reused on the same frame. (default: false)
  66582. * @param textureType Type of textures used when performing the post process. (default: 0)
  66583. * @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)
  66584. */
  66585. 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);
  66586. }
  66587. }
  66588. declare module BABYLON {
  66589. /** @hidden */
  66590. export var depthOfFieldMergePixelShader: {
  66591. name: string;
  66592. shader: string;
  66593. };
  66594. }
  66595. declare module BABYLON {
  66596. /**
  66597. * Options to be set when merging outputs from the default pipeline.
  66598. */
  66599. export class DepthOfFieldMergePostProcessOptions {
  66600. /**
  66601. * The original image to merge on top of
  66602. */
  66603. originalFromInput: PostProcess;
  66604. /**
  66605. * Parameters to perform the merge of the depth of field effect
  66606. */
  66607. depthOfField?: {
  66608. circleOfConfusion: PostProcess;
  66609. blurSteps: Array<PostProcess>;
  66610. };
  66611. /**
  66612. * Parameters to perform the merge of bloom effect
  66613. */
  66614. bloom?: {
  66615. blurred: PostProcess;
  66616. weight: number;
  66617. };
  66618. }
  66619. /**
  66620. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66621. */
  66622. export class DepthOfFieldMergePostProcess extends PostProcess {
  66623. private blurSteps;
  66624. /**
  66625. * Creates a new instance of DepthOfFieldMergePostProcess
  66626. * @param name The name of the effect.
  66627. * @param originalFromInput Post process which's input will be used for the merge.
  66628. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  66629. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  66630. * @param options The required width/height ratio to downsize to before computing the render pass.
  66631. * @param camera The camera to apply the render pass to.
  66632. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66633. * @param engine The engine which the post process will be applied. (default: current engine)
  66634. * @param reusable If the post process can be reused on the same frame. (default: false)
  66635. * @param textureType Type of textures used when performing the post process. (default: 0)
  66636. * @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)
  66637. */
  66638. 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);
  66639. /**
  66640. * Updates the effect with the current post process compile time values and recompiles the shader.
  66641. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66642. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66643. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66644. * @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
  66645. * @param onCompiled Called when the shader has been compiled.
  66646. * @param onError Called if there is an error when compiling a shader.
  66647. */
  66648. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66649. }
  66650. }
  66651. declare module BABYLON {
  66652. /**
  66653. * Specifies the level of max blur that should be applied when using the depth of field effect
  66654. */
  66655. export enum DepthOfFieldEffectBlurLevel {
  66656. /**
  66657. * Subtle blur
  66658. */
  66659. Low = 0,
  66660. /**
  66661. * Medium blur
  66662. */
  66663. Medium = 1,
  66664. /**
  66665. * Large blur
  66666. */
  66667. High = 2
  66668. }
  66669. /**
  66670. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  66671. */
  66672. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  66673. private _circleOfConfusion;
  66674. /**
  66675. * @hidden Internal, blurs from high to low
  66676. */
  66677. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  66678. private _depthOfFieldBlurY;
  66679. private _dofMerge;
  66680. /**
  66681. * @hidden Internal post processes in depth of field effect
  66682. */
  66683. _effects: Array<PostProcess>;
  66684. /**
  66685. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  66686. */
  66687. set focalLength(value: number);
  66688. get focalLength(): number;
  66689. /**
  66690. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66691. */
  66692. set fStop(value: number);
  66693. get fStop(): number;
  66694. /**
  66695. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66696. */
  66697. set focusDistance(value: number);
  66698. get focusDistance(): number;
  66699. /**
  66700. * 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.
  66701. */
  66702. set lensSize(value: number);
  66703. get lensSize(): number;
  66704. /**
  66705. * Creates a new instance DepthOfFieldEffect
  66706. * @param scene The scene the effect belongs to.
  66707. * @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.
  66708. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66709. * @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)
  66710. */
  66711. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  66712. /**
  66713. * Get the current class name of the current effet
  66714. * @returns "DepthOfFieldEffect"
  66715. */
  66716. getClassName(): string;
  66717. /**
  66718. * 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.
  66719. */
  66720. set depthTexture(value: RenderTargetTexture);
  66721. /**
  66722. * Disposes each of the internal effects for a given camera.
  66723. * @param camera The camera to dispose the effect on.
  66724. */
  66725. disposeEffects(camera: Camera): void;
  66726. /**
  66727. * @hidden Internal
  66728. */
  66729. _updateEffects(): void;
  66730. /**
  66731. * Internal
  66732. * @returns if all the contained post processes are ready.
  66733. * @hidden
  66734. */
  66735. _isReady(): boolean;
  66736. }
  66737. }
  66738. declare module BABYLON {
  66739. /** @hidden */
  66740. export var displayPassPixelShader: {
  66741. name: string;
  66742. shader: string;
  66743. };
  66744. }
  66745. declare module BABYLON {
  66746. /**
  66747. * DisplayPassPostProcess which produces an output the same as it's input
  66748. */
  66749. export class DisplayPassPostProcess extends PostProcess {
  66750. /**
  66751. * Creates the DisplayPassPostProcess
  66752. * @param name The name of the effect.
  66753. * @param options The required width/height ratio to downsize to before computing the render pass.
  66754. * @param camera The camera to apply the render pass to.
  66755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66756. * @param engine The engine which the post process will be applied. (default: current engine)
  66757. * @param reusable If the post process can be reused on the same frame. (default: false)
  66758. */
  66759. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66760. }
  66761. }
  66762. declare module BABYLON {
  66763. /** @hidden */
  66764. export var filterPixelShader: {
  66765. name: string;
  66766. shader: string;
  66767. };
  66768. }
  66769. declare module BABYLON {
  66770. /**
  66771. * Applies a kernel filter to the image
  66772. */
  66773. export class FilterPostProcess extends PostProcess {
  66774. /** The matrix to be applied to the image */
  66775. kernelMatrix: Matrix;
  66776. /**
  66777. *
  66778. * @param name The name of the effect.
  66779. * @param kernelMatrix The matrix to be applied to the image
  66780. * @param options The required width/height ratio to downsize to before computing the render pass.
  66781. * @param camera The camera to apply the render pass to.
  66782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66783. * @param engine The engine which the post process will be applied. (default: current engine)
  66784. * @param reusable If the post process can be reused on the same frame. (default: false)
  66785. */
  66786. constructor(name: string,
  66787. /** The matrix to be applied to the image */
  66788. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66789. }
  66790. }
  66791. declare module BABYLON {
  66792. /** @hidden */
  66793. export var fxaaPixelShader: {
  66794. name: string;
  66795. shader: string;
  66796. };
  66797. }
  66798. declare module BABYLON {
  66799. /** @hidden */
  66800. export var fxaaVertexShader: {
  66801. name: string;
  66802. shader: string;
  66803. };
  66804. }
  66805. declare module BABYLON {
  66806. /**
  66807. * Fxaa post process
  66808. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66809. */
  66810. export class FxaaPostProcess extends PostProcess {
  66811. /** @hidden */
  66812. texelWidth: number;
  66813. /** @hidden */
  66814. texelHeight: number;
  66815. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66816. private _getDefines;
  66817. }
  66818. }
  66819. declare module BABYLON {
  66820. /** @hidden */
  66821. export var grainPixelShader: {
  66822. name: string;
  66823. shader: string;
  66824. };
  66825. }
  66826. declare module BABYLON {
  66827. /**
  66828. * The GrainPostProcess adds noise to the image at mid luminance levels
  66829. */
  66830. export class GrainPostProcess extends PostProcess {
  66831. /**
  66832. * The intensity of the grain added (default: 30)
  66833. */
  66834. intensity: number;
  66835. /**
  66836. * If the grain should be randomized on every frame
  66837. */
  66838. animated: boolean;
  66839. /**
  66840. * Creates a new instance of @see GrainPostProcess
  66841. * @param name The name of the effect.
  66842. * @param options The required width/height ratio to downsize to before computing the render pass.
  66843. * @param camera The camera to apply the render pass to.
  66844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66845. * @param engine The engine which the post process will be applied. (default: current engine)
  66846. * @param reusable If the post process can be reused on the same frame. (default: false)
  66847. * @param textureType Type of textures used when performing the post process. (default: 0)
  66848. * @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)
  66849. */
  66850. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66851. }
  66852. }
  66853. declare module BABYLON {
  66854. /** @hidden */
  66855. export var highlightsPixelShader: {
  66856. name: string;
  66857. shader: string;
  66858. };
  66859. }
  66860. declare module BABYLON {
  66861. /**
  66862. * Extracts highlights from the image
  66863. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66864. */
  66865. export class HighlightsPostProcess extends PostProcess {
  66866. /**
  66867. * Extracts highlights from the image
  66868. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66869. * @param name The name of the effect.
  66870. * @param options The required width/height ratio to downsize to before computing the render pass.
  66871. * @param camera The camera to apply the render pass to.
  66872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66873. * @param engine The engine which the post process will be applied. (default: current engine)
  66874. * @param reusable If the post process can be reused on the same frame. (default: false)
  66875. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66876. */
  66877. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66878. }
  66879. }
  66880. declare module BABYLON {
  66881. /** @hidden */
  66882. export var mrtFragmentDeclaration: {
  66883. name: string;
  66884. shader: string;
  66885. };
  66886. }
  66887. declare module BABYLON {
  66888. /** @hidden */
  66889. export var geometryPixelShader: {
  66890. name: string;
  66891. shader: string;
  66892. };
  66893. }
  66894. declare module BABYLON {
  66895. /** @hidden */
  66896. export var geometryVertexShader: {
  66897. name: string;
  66898. shader: string;
  66899. };
  66900. }
  66901. declare module BABYLON {
  66902. /** @hidden */
  66903. interface ISavedTransformationMatrix {
  66904. world: Matrix;
  66905. viewProjection: Matrix;
  66906. }
  66907. /**
  66908. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66909. */
  66910. export class GeometryBufferRenderer {
  66911. /**
  66912. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66913. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66914. */
  66915. static readonly POSITION_TEXTURE_TYPE: number;
  66916. /**
  66917. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66918. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66919. */
  66920. static readonly VELOCITY_TEXTURE_TYPE: number;
  66921. /**
  66922. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  66923. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  66924. */
  66925. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  66926. /**
  66927. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66928. * in order to compute objects velocities when enableVelocity is set to "true"
  66929. * @hidden
  66930. */
  66931. _previousTransformationMatrices: {
  66932. [index: number]: ISavedTransformationMatrix;
  66933. };
  66934. /**
  66935. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66936. * in order to compute objects velocities when enableVelocity is set to "true"
  66937. * @hidden
  66938. */
  66939. _previousBonesTransformationMatrices: {
  66940. [index: number]: Float32Array;
  66941. };
  66942. /**
  66943. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66944. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66945. */
  66946. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66947. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  66948. renderTransparentMeshes: boolean;
  66949. private _scene;
  66950. private _multiRenderTarget;
  66951. private _ratio;
  66952. private _enablePosition;
  66953. private _enableVelocity;
  66954. private _enableReflectivity;
  66955. private _positionIndex;
  66956. private _velocityIndex;
  66957. private _reflectivityIndex;
  66958. protected _effect: Effect;
  66959. protected _cachedDefines: string;
  66960. /**
  66961. * Set the render list (meshes to be rendered) used in the G buffer.
  66962. */
  66963. set renderList(meshes: Mesh[]);
  66964. /**
  66965. * Gets wether or not G buffer are supported by the running hardware.
  66966. * This requires draw buffer supports
  66967. */
  66968. get isSupported(): boolean;
  66969. /**
  66970. * Returns the index of the given texture type in the G-Buffer textures array
  66971. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66972. * @returns the index of the given texture type in the G-Buffer textures array
  66973. */
  66974. getTextureIndex(textureType: number): number;
  66975. /**
  66976. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66977. */
  66978. get enablePosition(): boolean;
  66979. /**
  66980. * Sets whether or not objects positions are enabled for the G buffer.
  66981. */
  66982. set enablePosition(enable: boolean);
  66983. /**
  66984. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66985. */
  66986. get enableVelocity(): boolean;
  66987. /**
  66988. * Sets wether or not objects velocities are enabled for the G buffer.
  66989. */
  66990. set enableVelocity(enable: boolean);
  66991. /**
  66992. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  66993. */
  66994. get enableReflectivity(): boolean;
  66995. /**
  66996. * Sets wether or not objects roughness are enabled for the G buffer.
  66997. */
  66998. set enableReflectivity(enable: boolean);
  66999. /**
  67000. * Gets the scene associated with the buffer.
  67001. */
  67002. get scene(): Scene;
  67003. /**
  67004. * Gets the ratio used by the buffer during its creation.
  67005. * How big is the buffer related to the main canvas.
  67006. */
  67007. get ratio(): number;
  67008. /** @hidden */
  67009. static _SceneComponentInitialization: (scene: Scene) => void;
  67010. /**
  67011. * Creates a new G Buffer for the scene
  67012. * @param scene The scene the buffer belongs to
  67013. * @param ratio How big is the buffer related to the main canvas.
  67014. */
  67015. constructor(scene: Scene, ratio?: number);
  67016. /**
  67017. * Checks wether everything is ready to render a submesh to the G buffer.
  67018. * @param subMesh the submesh to check readiness for
  67019. * @param useInstances is the mesh drawn using instance or not
  67020. * @returns true if ready otherwise false
  67021. */
  67022. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67023. /**
  67024. * Gets the current underlying G Buffer.
  67025. * @returns the buffer
  67026. */
  67027. getGBuffer(): MultiRenderTarget;
  67028. /**
  67029. * Gets the number of samples used to render the buffer (anti aliasing).
  67030. */
  67031. get samples(): number;
  67032. /**
  67033. * Sets the number of samples used to render the buffer (anti aliasing).
  67034. */
  67035. set samples(value: number);
  67036. /**
  67037. * Disposes the renderer and frees up associated resources.
  67038. */
  67039. dispose(): void;
  67040. protected _createRenderTargets(): void;
  67041. private _copyBonesTransformationMatrices;
  67042. }
  67043. }
  67044. declare module BABYLON {
  67045. interface Scene {
  67046. /** @hidden (Backing field) */
  67047. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67048. /**
  67049. * Gets or Sets the current geometry buffer associated to the scene.
  67050. */
  67051. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67052. /**
  67053. * Enables a GeometryBufferRender and associates it with the scene
  67054. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67055. * @returns the GeometryBufferRenderer
  67056. */
  67057. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67058. /**
  67059. * Disables the GeometryBufferRender associated with the scene
  67060. */
  67061. disableGeometryBufferRenderer(): void;
  67062. }
  67063. /**
  67064. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67065. * in several rendering techniques.
  67066. */
  67067. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67068. /**
  67069. * The component name helpful to identify the component in the list of scene components.
  67070. */
  67071. readonly name: string;
  67072. /**
  67073. * The scene the component belongs to.
  67074. */
  67075. scene: Scene;
  67076. /**
  67077. * Creates a new instance of the component for the given scene
  67078. * @param scene Defines the scene to register the component in
  67079. */
  67080. constructor(scene: Scene);
  67081. /**
  67082. * Registers the component in a given scene
  67083. */
  67084. register(): void;
  67085. /**
  67086. * Rebuilds the elements related to this component in case of
  67087. * context lost for instance.
  67088. */
  67089. rebuild(): void;
  67090. /**
  67091. * Disposes the component and the associated ressources
  67092. */
  67093. dispose(): void;
  67094. private _gatherRenderTargets;
  67095. }
  67096. }
  67097. declare module BABYLON {
  67098. /** @hidden */
  67099. export var motionBlurPixelShader: {
  67100. name: string;
  67101. shader: string;
  67102. };
  67103. }
  67104. declare module BABYLON {
  67105. /**
  67106. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67107. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67108. * As an example, all you have to do is to create the post-process:
  67109. * var mb = new BABYLON.MotionBlurPostProcess(
  67110. * 'mb', // The name of the effect.
  67111. * scene, // The scene containing the objects to blur according to their velocity.
  67112. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67113. * camera // The camera to apply the render pass to.
  67114. * );
  67115. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67116. */
  67117. export class MotionBlurPostProcess extends PostProcess {
  67118. /**
  67119. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67120. */
  67121. motionStrength: number;
  67122. /**
  67123. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67124. */
  67125. get motionBlurSamples(): number;
  67126. /**
  67127. * Sets the number of iterations to be used for motion blur quality
  67128. */
  67129. set motionBlurSamples(samples: number);
  67130. private _motionBlurSamples;
  67131. private _geometryBufferRenderer;
  67132. /**
  67133. * Creates a new instance MotionBlurPostProcess
  67134. * @param name The name of the effect.
  67135. * @param scene The scene containing the objects to blur according to their velocity.
  67136. * @param options The required width/height ratio to downsize to before computing the render pass.
  67137. * @param camera The camera to apply the render pass to.
  67138. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67139. * @param engine The engine which the post process will be applied. (default: current engine)
  67140. * @param reusable If the post process can be reused on the same frame. (default: false)
  67141. * @param textureType Type of textures used when performing the post process. (default: 0)
  67142. * @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)
  67143. */
  67144. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67145. /**
  67146. * Excludes the given skinned mesh from computing bones velocities.
  67147. * 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.
  67148. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67149. */
  67150. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67151. /**
  67152. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67153. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67154. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67155. */
  67156. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67157. /**
  67158. * Disposes the post process.
  67159. * @param camera The camera to dispose the post process on.
  67160. */
  67161. dispose(camera?: Camera): void;
  67162. }
  67163. }
  67164. declare module BABYLON {
  67165. /** @hidden */
  67166. export var refractionPixelShader: {
  67167. name: string;
  67168. shader: string;
  67169. };
  67170. }
  67171. declare module BABYLON {
  67172. /**
  67173. * Post process which applies a refractin texture
  67174. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67175. */
  67176. export class RefractionPostProcess extends PostProcess {
  67177. /** the base color of the refraction (used to taint the rendering) */
  67178. color: Color3;
  67179. /** simulated refraction depth */
  67180. depth: number;
  67181. /** the coefficient of the base color (0 to remove base color tainting) */
  67182. colorLevel: number;
  67183. private _refTexture;
  67184. private _ownRefractionTexture;
  67185. /**
  67186. * Gets or sets the refraction texture
  67187. * Please note that you are responsible for disposing the texture if you set it manually
  67188. */
  67189. get refractionTexture(): Texture;
  67190. set refractionTexture(value: Texture);
  67191. /**
  67192. * Initializes the RefractionPostProcess
  67193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67194. * @param name The name of the effect.
  67195. * @param refractionTextureUrl Url of the refraction texture to use
  67196. * @param color the base color of the refraction (used to taint the rendering)
  67197. * @param depth simulated refraction depth
  67198. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67199. * @param camera The camera to apply the render pass to.
  67200. * @param options The required width/height ratio to downsize to before computing the render pass.
  67201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67202. * @param engine The engine which the post process will be applied. (default: current engine)
  67203. * @param reusable If the post process can be reused on the same frame. (default: false)
  67204. */
  67205. constructor(name: string, refractionTextureUrl: string,
  67206. /** the base color of the refraction (used to taint the rendering) */
  67207. color: Color3,
  67208. /** simulated refraction depth */
  67209. depth: number,
  67210. /** the coefficient of the base color (0 to remove base color tainting) */
  67211. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67212. /**
  67213. * Disposes of the post process
  67214. * @param camera Camera to dispose post process on
  67215. */
  67216. dispose(camera: Camera): void;
  67217. }
  67218. }
  67219. declare module BABYLON {
  67220. /** @hidden */
  67221. export var sharpenPixelShader: {
  67222. name: string;
  67223. shader: string;
  67224. };
  67225. }
  67226. declare module BABYLON {
  67227. /**
  67228. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67229. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67230. */
  67231. export class SharpenPostProcess extends PostProcess {
  67232. /**
  67233. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67234. */
  67235. colorAmount: number;
  67236. /**
  67237. * How much sharpness should be applied (default: 0.3)
  67238. */
  67239. edgeAmount: number;
  67240. /**
  67241. * Creates a new instance ConvolutionPostProcess
  67242. * @param name The name of the effect.
  67243. * @param options The required width/height ratio to downsize to before computing the render pass.
  67244. * @param camera The camera to apply the render pass to.
  67245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67246. * @param engine The engine which the post process will be applied. (default: current engine)
  67247. * @param reusable If the post process can be reused on the same frame. (default: false)
  67248. * @param textureType Type of textures used when performing the post process. (default: 0)
  67249. * @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)
  67250. */
  67251. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67252. }
  67253. }
  67254. declare module BABYLON {
  67255. /**
  67256. * PostProcessRenderPipeline
  67257. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67258. */
  67259. export class PostProcessRenderPipeline {
  67260. private engine;
  67261. private _renderEffects;
  67262. private _renderEffectsForIsolatedPass;
  67263. /**
  67264. * List of inspectable custom properties (used by the Inspector)
  67265. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67266. */
  67267. inspectableCustomProperties: IInspectable[];
  67268. /**
  67269. * @hidden
  67270. */
  67271. protected _cameras: Camera[];
  67272. /** @hidden */
  67273. _name: string;
  67274. /**
  67275. * Gets pipeline name
  67276. */
  67277. get name(): string;
  67278. /** Gets the list of attached cameras */
  67279. get cameras(): Camera[];
  67280. /**
  67281. * Initializes a PostProcessRenderPipeline
  67282. * @param engine engine to add the pipeline to
  67283. * @param name name of the pipeline
  67284. */
  67285. constructor(engine: Engine, name: string);
  67286. /**
  67287. * Gets the class name
  67288. * @returns "PostProcessRenderPipeline"
  67289. */
  67290. getClassName(): string;
  67291. /**
  67292. * If all the render effects in the pipeline are supported
  67293. */
  67294. get isSupported(): boolean;
  67295. /**
  67296. * Adds an effect to the pipeline
  67297. * @param renderEffect the effect to add
  67298. */
  67299. addEffect(renderEffect: PostProcessRenderEffect): void;
  67300. /** @hidden */
  67301. _rebuild(): void;
  67302. /** @hidden */
  67303. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67304. /** @hidden */
  67305. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67306. /** @hidden */
  67307. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67308. /** @hidden */
  67309. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67310. /** @hidden */
  67311. _attachCameras(cameras: Camera, unique: boolean): void;
  67312. /** @hidden */
  67313. _attachCameras(cameras: Camera[], unique: boolean): void;
  67314. /** @hidden */
  67315. _detachCameras(cameras: Camera): void;
  67316. /** @hidden */
  67317. _detachCameras(cameras: Nullable<Camera[]>): void;
  67318. /** @hidden */
  67319. _update(): void;
  67320. /** @hidden */
  67321. _reset(): void;
  67322. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67323. /**
  67324. * Disposes of the pipeline
  67325. */
  67326. dispose(): void;
  67327. }
  67328. }
  67329. declare module BABYLON {
  67330. /**
  67331. * PostProcessRenderPipelineManager class
  67332. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67333. */
  67334. export class PostProcessRenderPipelineManager {
  67335. private _renderPipelines;
  67336. /**
  67337. * Initializes a PostProcessRenderPipelineManager
  67338. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67339. */
  67340. constructor();
  67341. /**
  67342. * Gets the list of supported render pipelines
  67343. */
  67344. get supportedPipelines(): PostProcessRenderPipeline[];
  67345. /**
  67346. * Adds a pipeline to the manager
  67347. * @param renderPipeline The pipeline to add
  67348. */
  67349. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67350. /**
  67351. * Attaches a camera to the pipeline
  67352. * @param renderPipelineName The name of the pipeline to attach to
  67353. * @param cameras the camera to attach
  67354. * @param unique if the camera can be attached multiple times to the pipeline
  67355. */
  67356. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67357. /**
  67358. * Detaches a camera from the pipeline
  67359. * @param renderPipelineName The name of the pipeline to detach from
  67360. * @param cameras the camera to detach
  67361. */
  67362. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67363. /**
  67364. * Enables an effect by name on a pipeline
  67365. * @param renderPipelineName the name of the pipeline to enable the effect in
  67366. * @param renderEffectName the name of the effect to enable
  67367. * @param cameras the cameras that the effect should be enabled on
  67368. */
  67369. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67370. /**
  67371. * Disables an effect by name on a pipeline
  67372. * @param renderPipelineName the name of the pipeline to disable the effect in
  67373. * @param renderEffectName the name of the effect to disable
  67374. * @param cameras the cameras that the effect should be disabled on
  67375. */
  67376. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67377. /**
  67378. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67379. */
  67380. update(): void;
  67381. /** @hidden */
  67382. _rebuild(): void;
  67383. /**
  67384. * Disposes of the manager and pipelines
  67385. */
  67386. dispose(): void;
  67387. }
  67388. }
  67389. declare module BABYLON {
  67390. interface Scene {
  67391. /** @hidden (Backing field) */
  67392. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67393. /**
  67394. * Gets the postprocess render pipeline manager
  67395. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67396. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67397. */
  67398. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67399. }
  67400. /**
  67401. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67402. */
  67403. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67404. /**
  67405. * The component name helpfull to identify the component in the list of scene components.
  67406. */
  67407. readonly name: string;
  67408. /**
  67409. * The scene the component belongs to.
  67410. */
  67411. scene: Scene;
  67412. /**
  67413. * Creates a new instance of the component for the given scene
  67414. * @param scene Defines the scene to register the component in
  67415. */
  67416. constructor(scene: Scene);
  67417. /**
  67418. * Registers the component in a given scene
  67419. */
  67420. register(): void;
  67421. /**
  67422. * Rebuilds the elements related to this component in case of
  67423. * context lost for instance.
  67424. */
  67425. rebuild(): void;
  67426. /**
  67427. * Disposes the component and the associated ressources
  67428. */
  67429. dispose(): void;
  67430. private _gatherRenderTargets;
  67431. }
  67432. }
  67433. declare module BABYLON {
  67434. /**
  67435. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67436. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67437. */
  67438. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67439. private _scene;
  67440. private _camerasToBeAttached;
  67441. /**
  67442. * ID of the sharpen post process,
  67443. */
  67444. private readonly SharpenPostProcessId;
  67445. /**
  67446. * @ignore
  67447. * ID of the image processing post process;
  67448. */
  67449. readonly ImageProcessingPostProcessId: string;
  67450. /**
  67451. * @ignore
  67452. * ID of the Fast Approximate Anti-Aliasing post process;
  67453. */
  67454. readonly FxaaPostProcessId: string;
  67455. /**
  67456. * ID of the chromatic aberration post process,
  67457. */
  67458. private readonly ChromaticAberrationPostProcessId;
  67459. /**
  67460. * ID of the grain post process
  67461. */
  67462. private readonly GrainPostProcessId;
  67463. /**
  67464. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67465. */
  67466. sharpen: SharpenPostProcess;
  67467. private _sharpenEffect;
  67468. private bloom;
  67469. /**
  67470. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67471. */
  67472. depthOfField: DepthOfFieldEffect;
  67473. /**
  67474. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67475. */
  67476. fxaa: FxaaPostProcess;
  67477. /**
  67478. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67479. */
  67480. imageProcessing: ImageProcessingPostProcess;
  67481. /**
  67482. * Chromatic aberration post process which will shift rgb colors in the image
  67483. */
  67484. chromaticAberration: ChromaticAberrationPostProcess;
  67485. private _chromaticAberrationEffect;
  67486. /**
  67487. * Grain post process which add noise to the image
  67488. */
  67489. grain: GrainPostProcess;
  67490. private _grainEffect;
  67491. /**
  67492. * Glow post process which adds a glow to emissive areas of the image
  67493. */
  67494. private _glowLayer;
  67495. /**
  67496. * Animations which can be used to tweak settings over a period of time
  67497. */
  67498. animations: Animation[];
  67499. private _imageProcessingConfigurationObserver;
  67500. private _sharpenEnabled;
  67501. private _bloomEnabled;
  67502. private _depthOfFieldEnabled;
  67503. private _depthOfFieldBlurLevel;
  67504. private _fxaaEnabled;
  67505. private _imageProcessingEnabled;
  67506. private _defaultPipelineTextureType;
  67507. private _bloomScale;
  67508. private _chromaticAberrationEnabled;
  67509. private _grainEnabled;
  67510. private _buildAllowed;
  67511. /**
  67512. * Gets active scene
  67513. */
  67514. get scene(): Scene;
  67515. /**
  67516. * Enable or disable the sharpen process from the pipeline
  67517. */
  67518. set sharpenEnabled(enabled: boolean);
  67519. get sharpenEnabled(): boolean;
  67520. private _resizeObserver;
  67521. private _hardwareScaleLevel;
  67522. private _bloomKernel;
  67523. /**
  67524. * Specifies the size of the bloom blur kernel, relative to the final output size
  67525. */
  67526. get bloomKernel(): number;
  67527. set bloomKernel(value: number);
  67528. /**
  67529. * Specifies the weight of the bloom in the final rendering
  67530. */
  67531. private _bloomWeight;
  67532. /**
  67533. * Specifies the luma threshold for the area that will be blurred by the bloom
  67534. */
  67535. private _bloomThreshold;
  67536. private _hdr;
  67537. /**
  67538. * The strength of the bloom.
  67539. */
  67540. set bloomWeight(value: number);
  67541. get bloomWeight(): number;
  67542. /**
  67543. * The strength of the bloom.
  67544. */
  67545. set bloomThreshold(value: number);
  67546. get bloomThreshold(): number;
  67547. /**
  67548. * The scale of the bloom, lower value will provide better performance.
  67549. */
  67550. set bloomScale(value: number);
  67551. get bloomScale(): number;
  67552. /**
  67553. * Enable or disable the bloom from the pipeline
  67554. */
  67555. set bloomEnabled(enabled: boolean);
  67556. get bloomEnabled(): boolean;
  67557. private _rebuildBloom;
  67558. /**
  67559. * If the depth of field is enabled.
  67560. */
  67561. get depthOfFieldEnabled(): boolean;
  67562. set depthOfFieldEnabled(enabled: boolean);
  67563. /**
  67564. * Blur level of the depth of field effect. (Higher blur will effect performance)
  67565. */
  67566. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  67567. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  67568. /**
  67569. * If the anti aliasing is enabled.
  67570. */
  67571. set fxaaEnabled(enabled: boolean);
  67572. get fxaaEnabled(): boolean;
  67573. private _samples;
  67574. /**
  67575. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67576. */
  67577. set samples(sampleCount: number);
  67578. get samples(): number;
  67579. /**
  67580. * If image processing is enabled.
  67581. */
  67582. set imageProcessingEnabled(enabled: boolean);
  67583. get imageProcessingEnabled(): boolean;
  67584. /**
  67585. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  67586. */
  67587. set glowLayerEnabled(enabled: boolean);
  67588. get glowLayerEnabled(): boolean;
  67589. /**
  67590. * Gets the glow layer (or null if not defined)
  67591. */
  67592. get glowLayer(): Nullable<GlowLayer>;
  67593. /**
  67594. * Enable or disable the chromaticAberration process from the pipeline
  67595. */
  67596. set chromaticAberrationEnabled(enabled: boolean);
  67597. get chromaticAberrationEnabled(): boolean;
  67598. /**
  67599. * Enable or disable the grain process from the pipeline
  67600. */
  67601. set grainEnabled(enabled: boolean);
  67602. get grainEnabled(): boolean;
  67603. /**
  67604. * @constructor
  67605. * @param name - The rendering pipeline name (default: "")
  67606. * @param hdr - If high dynamic range textures should be used (default: true)
  67607. * @param scene - The scene linked to this pipeline (default: the last created scene)
  67608. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  67609. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  67610. */
  67611. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  67612. /**
  67613. * Get the class name
  67614. * @returns "DefaultRenderingPipeline"
  67615. */
  67616. getClassName(): string;
  67617. /**
  67618. * Force the compilation of the entire pipeline.
  67619. */
  67620. prepare(): void;
  67621. private _hasCleared;
  67622. private _prevPostProcess;
  67623. private _prevPrevPostProcess;
  67624. private _setAutoClearAndTextureSharing;
  67625. private _depthOfFieldSceneObserver;
  67626. private _buildPipeline;
  67627. private _disposePostProcesses;
  67628. /**
  67629. * Adds a camera to the pipeline
  67630. * @param camera the camera to be added
  67631. */
  67632. addCamera(camera: Camera): void;
  67633. /**
  67634. * Removes a camera from the pipeline
  67635. * @param camera the camera to remove
  67636. */
  67637. removeCamera(camera: Camera): void;
  67638. /**
  67639. * Dispose of the pipeline and stop all post processes
  67640. */
  67641. dispose(): void;
  67642. /**
  67643. * Serialize the rendering pipeline (Used when exporting)
  67644. * @returns the serialized object
  67645. */
  67646. serialize(): any;
  67647. /**
  67648. * Parse the serialized pipeline
  67649. * @param source Source pipeline.
  67650. * @param scene The scene to load the pipeline to.
  67651. * @param rootUrl The URL of the serialized pipeline.
  67652. * @returns An instantiated pipeline from the serialized object.
  67653. */
  67654. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  67655. }
  67656. }
  67657. declare module BABYLON {
  67658. /** @hidden */
  67659. export var lensHighlightsPixelShader: {
  67660. name: string;
  67661. shader: string;
  67662. };
  67663. }
  67664. declare module BABYLON {
  67665. /** @hidden */
  67666. export var depthOfFieldPixelShader: {
  67667. name: string;
  67668. shader: string;
  67669. };
  67670. }
  67671. declare module BABYLON {
  67672. /**
  67673. * BABYLON.JS Chromatic Aberration GLSL Shader
  67674. * Author: Olivier Guyot
  67675. * Separates very slightly R, G and B colors on the edges of the screen
  67676. * Inspired by Francois Tarlier & Martins Upitis
  67677. */
  67678. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67679. /**
  67680. * @ignore
  67681. * The chromatic aberration PostProcess id in the pipeline
  67682. */
  67683. LensChromaticAberrationEffect: string;
  67684. /**
  67685. * @ignore
  67686. * The highlights enhancing PostProcess id in the pipeline
  67687. */
  67688. HighlightsEnhancingEffect: string;
  67689. /**
  67690. * @ignore
  67691. * The depth-of-field PostProcess id in the pipeline
  67692. */
  67693. LensDepthOfFieldEffect: string;
  67694. private _scene;
  67695. private _depthTexture;
  67696. private _grainTexture;
  67697. private _chromaticAberrationPostProcess;
  67698. private _highlightsPostProcess;
  67699. private _depthOfFieldPostProcess;
  67700. private _edgeBlur;
  67701. private _grainAmount;
  67702. private _chromaticAberration;
  67703. private _distortion;
  67704. private _highlightsGain;
  67705. private _highlightsThreshold;
  67706. private _dofDistance;
  67707. private _dofAperture;
  67708. private _dofDarken;
  67709. private _dofPentagon;
  67710. private _blurNoise;
  67711. /**
  67712. * @constructor
  67713. *
  67714. * Effect parameters are as follow:
  67715. * {
  67716. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67717. * edge_blur: number; // from 0 to x (1 for realism)
  67718. * distortion: number; // from 0 to x (1 for realism)
  67719. * grain_amount: number; // from 0 to 1
  67720. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67721. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67722. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67723. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67724. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67725. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67726. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67727. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67728. * }
  67729. * Note: if an effect parameter is unset, effect is disabled
  67730. *
  67731. * @param name The rendering pipeline name
  67732. * @param parameters - An object containing all parameters (see above)
  67733. * @param scene The scene linked to this pipeline
  67734. * @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)
  67735. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67736. */
  67737. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67738. /**
  67739. * Get the class name
  67740. * @returns "LensRenderingPipeline"
  67741. */
  67742. getClassName(): string;
  67743. /**
  67744. * Gets associated scene
  67745. */
  67746. get scene(): Scene;
  67747. /**
  67748. * Gets or sets the edge blur
  67749. */
  67750. get edgeBlur(): number;
  67751. set edgeBlur(value: number);
  67752. /**
  67753. * Gets or sets the grain amount
  67754. */
  67755. get grainAmount(): number;
  67756. set grainAmount(value: number);
  67757. /**
  67758. * Gets or sets the chromatic aberration amount
  67759. */
  67760. get chromaticAberration(): number;
  67761. set chromaticAberration(value: number);
  67762. /**
  67763. * Gets or sets the depth of field aperture
  67764. */
  67765. get dofAperture(): number;
  67766. set dofAperture(value: number);
  67767. /**
  67768. * Gets or sets the edge distortion
  67769. */
  67770. get edgeDistortion(): number;
  67771. set edgeDistortion(value: number);
  67772. /**
  67773. * Gets or sets the depth of field distortion
  67774. */
  67775. get dofDistortion(): number;
  67776. set dofDistortion(value: number);
  67777. /**
  67778. * Gets or sets the darken out of focus amount
  67779. */
  67780. get darkenOutOfFocus(): number;
  67781. set darkenOutOfFocus(value: number);
  67782. /**
  67783. * Gets or sets a boolean indicating if blur noise is enabled
  67784. */
  67785. get blurNoise(): boolean;
  67786. set blurNoise(value: boolean);
  67787. /**
  67788. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67789. */
  67790. get pentagonBokeh(): boolean;
  67791. set pentagonBokeh(value: boolean);
  67792. /**
  67793. * Gets or sets the highlight grain amount
  67794. */
  67795. get highlightsGain(): number;
  67796. set highlightsGain(value: number);
  67797. /**
  67798. * Gets or sets the highlight threshold
  67799. */
  67800. get highlightsThreshold(): number;
  67801. set highlightsThreshold(value: number);
  67802. /**
  67803. * Sets the amount of blur at the edges
  67804. * @param amount blur amount
  67805. */
  67806. setEdgeBlur(amount: number): void;
  67807. /**
  67808. * Sets edge blur to 0
  67809. */
  67810. disableEdgeBlur(): void;
  67811. /**
  67812. * Sets the amout of grain
  67813. * @param amount Amount of grain
  67814. */
  67815. setGrainAmount(amount: number): void;
  67816. /**
  67817. * Set grain amount to 0
  67818. */
  67819. disableGrain(): void;
  67820. /**
  67821. * Sets the chromatic aberration amount
  67822. * @param amount amount of chromatic aberration
  67823. */
  67824. setChromaticAberration(amount: number): void;
  67825. /**
  67826. * Sets chromatic aberration amount to 0
  67827. */
  67828. disableChromaticAberration(): void;
  67829. /**
  67830. * Sets the EdgeDistortion amount
  67831. * @param amount amount of EdgeDistortion
  67832. */
  67833. setEdgeDistortion(amount: number): void;
  67834. /**
  67835. * Sets edge distortion to 0
  67836. */
  67837. disableEdgeDistortion(): void;
  67838. /**
  67839. * Sets the FocusDistance amount
  67840. * @param amount amount of FocusDistance
  67841. */
  67842. setFocusDistance(amount: number): void;
  67843. /**
  67844. * Disables depth of field
  67845. */
  67846. disableDepthOfField(): void;
  67847. /**
  67848. * Sets the Aperture amount
  67849. * @param amount amount of Aperture
  67850. */
  67851. setAperture(amount: number): void;
  67852. /**
  67853. * Sets the DarkenOutOfFocus amount
  67854. * @param amount amount of DarkenOutOfFocus
  67855. */
  67856. setDarkenOutOfFocus(amount: number): void;
  67857. private _pentagonBokehIsEnabled;
  67858. /**
  67859. * Creates a pentagon bokeh effect
  67860. */
  67861. enablePentagonBokeh(): void;
  67862. /**
  67863. * Disables the pentagon bokeh effect
  67864. */
  67865. disablePentagonBokeh(): void;
  67866. /**
  67867. * Enables noise blur
  67868. */
  67869. enableNoiseBlur(): void;
  67870. /**
  67871. * Disables noise blur
  67872. */
  67873. disableNoiseBlur(): void;
  67874. /**
  67875. * Sets the HighlightsGain amount
  67876. * @param amount amount of HighlightsGain
  67877. */
  67878. setHighlightsGain(amount: number): void;
  67879. /**
  67880. * Sets the HighlightsThreshold amount
  67881. * @param amount amount of HighlightsThreshold
  67882. */
  67883. setHighlightsThreshold(amount: number): void;
  67884. /**
  67885. * Disables highlights
  67886. */
  67887. disableHighlights(): void;
  67888. /**
  67889. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67890. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67891. */
  67892. dispose(disableDepthRender?: boolean): void;
  67893. private _createChromaticAberrationPostProcess;
  67894. private _createHighlightsPostProcess;
  67895. private _createDepthOfFieldPostProcess;
  67896. private _createGrainTexture;
  67897. }
  67898. }
  67899. declare module BABYLON {
  67900. /** @hidden */
  67901. export var ssao2PixelShader: {
  67902. name: string;
  67903. shader: string;
  67904. };
  67905. }
  67906. declare module BABYLON {
  67907. /** @hidden */
  67908. export var ssaoCombinePixelShader: {
  67909. name: string;
  67910. shader: string;
  67911. };
  67912. }
  67913. declare module BABYLON {
  67914. /**
  67915. * Render pipeline to produce ssao effect
  67916. */
  67917. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67918. /**
  67919. * @ignore
  67920. * The PassPostProcess id in the pipeline that contains the original scene color
  67921. */
  67922. SSAOOriginalSceneColorEffect: string;
  67923. /**
  67924. * @ignore
  67925. * The SSAO PostProcess id in the pipeline
  67926. */
  67927. SSAORenderEffect: string;
  67928. /**
  67929. * @ignore
  67930. * The horizontal blur PostProcess id in the pipeline
  67931. */
  67932. SSAOBlurHRenderEffect: string;
  67933. /**
  67934. * @ignore
  67935. * The vertical blur PostProcess id in the pipeline
  67936. */
  67937. SSAOBlurVRenderEffect: string;
  67938. /**
  67939. * @ignore
  67940. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67941. */
  67942. SSAOCombineRenderEffect: string;
  67943. /**
  67944. * The output strength of the SSAO post-process. Default value is 1.0.
  67945. */
  67946. totalStrength: number;
  67947. /**
  67948. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67949. */
  67950. maxZ: number;
  67951. /**
  67952. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67953. */
  67954. minZAspect: number;
  67955. private _samples;
  67956. /**
  67957. * Number of samples used for the SSAO calculations. Default value is 8
  67958. */
  67959. set samples(n: number);
  67960. get samples(): number;
  67961. private _textureSamples;
  67962. /**
  67963. * Number of samples to use for antialiasing
  67964. */
  67965. set textureSamples(n: number);
  67966. get textureSamples(): number;
  67967. /**
  67968. * Ratio object used for SSAO ratio and blur ratio
  67969. */
  67970. private _ratio;
  67971. /**
  67972. * Dynamically generated sphere sampler.
  67973. */
  67974. private _sampleSphere;
  67975. /**
  67976. * Blur filter offsets
  67977. */
  67978. private _samplerOffsets;
  67979. private _expensiveBlur;
  67980. /**
  67981. * If bilateral blur should be used
  67982. */
  67983. set expensiveBlur(b: boolean);
  67984. get expensiveBlur(): boolean;
  67985. /**
  67986. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  67987. */
  67988. radius: number;
  67989. /**
  67990. * The base color of the SSAO post-process
  67991. * The final result is "base + ssao" between [0, 1]
  67992. */
  67993. base: number;
  67994. /**
  67995. * Support test.
  67996. */
  67997. static get IsSupported(): boolean;
  67998. private _scene;
  67999. private _depthTexture;
  68000. private _normalTexture;
  68001. private _randomTexture;
  68002. private _originalColorPostProcess;
  68003. private _ssaoPostProcess;
  68004. private _blurHPostProcess;
  68005. private _blurVPostProcess;
  68006. private _ssaoCombinePostProcess;
  68007. /**
  68008. * Gets active scene
  68009. */
  68010. get scene(): Scene;
  68011. /**
  68012. * @constructor
  68013. * @param name The rendering pipeline name
  68014. * @param scene The scene linked to this pipeline
  68015. * @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 }
  68016. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68017. */
  68018. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68019. /**
  68020. * Get the class name
  68021. * @returns "SSAO2RenderingPipeline"
  68022. */
  68023. getClassName(): string;
  68024. /**
  68025. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68026. */
  68027. dispose(disableGeometryBufferRenderer?: boolean): void;
  68028. private _createBlurPostProcess;
  68029. /** @hidden */
  68030. _rebuild(): void;
  68031. private _bits;
  68032. private _radicalInverse_VdC;
  68033. private _hammersley;
  68034. private _hemisphereSample_uniform;
  68035. private _generateHemisphere;
  68036. private _createSSAOPostProcess;
  68037. private _createSSAOCombinePostProcess;
  68038. private _createRandomTexture;
  68039. /**
  68040. * Serialize the rendering pipeline (Used when exporting)
  68041. * @returns the serialized object
  68042. */
  68043. serialize(): any;
  68044. /**
  68045. * Parse the serialized pipeline
  68046. * @param source Source pipeline.
  68047. * @param scene The scene to load the pipeline to.
  68048. * @param rootUrl The URL of the serialized pipeline.
  68049. * @returns An instantiated pipeline from the serialized object.
  68050. */
  68051. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68052. }
  68053. }
  68054. declare module BABYLON {
  68055. /** @hidden */
  68056. export var ssaoPixelShader: {
  68057. name: string;
  68058. shader: string;
  68059. };
  68060. }
  68061. declare module BABYLON {
  68062. /**
  68063. * Render pipeline to produce ssao effect
  68064. */
  68065. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68066. /**
  68067. * @ignore
  68068. * The PassPostProcess id in the pipeline that contains the original scene color
  68069. */
  68070. SSAOOriginalSceneColorEffect: string;
  68071. /**
  68072. * @ignore
  68073. * The SSAO PostProcess id in the pipeline
  68074. */
  68075. SSAORenderEffect: string;
  68076. /**
  68077. * @ignore
  68078. * The horizontal blur PostProcess id in the pipeline
  68079. */
  68080. SSAOBlurHRenderEffect: string;
  68081. /**
  68082. * @ignore
  68083. * The vertical blur PostProcess id in the pipeline
  68084. */
  68085. SSAOBlurVRenderEffect: string;
  68086. /**
  68087. * @ignore
  68088. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68089. */
  68090. SSAOCombineRenderEffect: string;
  68091. /**
  68092. * The output strength of the SSAO post-process. Default value is 1.0.
  68093. */
  68094. totalStrength: number;
  68095. /**
  68096. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68097. */
  68098. radius: number;
  68099. /**
  68100. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68101. * Must not be equal to fallOff and superior to fallOff.
  68102. * Default value is 0.0075
  68103. */
  68104. area: number;
  68105. /**
  68106. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68107. * Must not be equal to area and inferior to area.
  68108. * Default value is 0.000001
  68109. */
  68110. fallOff: number;
  68111. /**
  68112. * The base color of the SSAO post-process
  68113. * The final result is "base + ssao" between [0, 1]
  68114. */
  68115. base: number;
  68116. private _scene;
  68117. private _depthTexture;
  68118. private _randomTexture;
  68119. private _originalColorPostProcess;
  68120. private _ssaoPostProcess;
  68121. private _blurHPostProcess;
  68122. private _blurVPostProcess;
  68123. private _ssaoCombinePostProcess;
  68124. private _firstUpdate;
  68125. /**
  68126. * Gets active scene
  68127. */
  68128. get scene(): Scene;
  68129. /**
  68130. * @constructor
  68131. * @param name - The rendering pipeline name
  68132. * @param scene - The scene linked to this pipeline
  68133. * @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 }
  68134. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68135. */
  68136. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68137. /**
  68138. * Get the class name
  68139. * @returns "SSAORenderingPipeline"
  68140. */
  68141. getClassName(): string;
  68142. /**
  68143. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68144. */
  68145. dispose(disableDepthRender?: boolean): void;
  68146. private _createBlurPostProcess;
  68147. /** @hidden */
  68148. _rebuild(): void;
  68149. private _createSSAOPostProcess;
  68150. private _createSSAOCombinePostProcess;
  68151. private _createRandomTexture;
  68152. }
  68153. }
  68154. declare module BABYLON {
  68155. /** @hidden */
  68156. export var screenSpaceReflectionPixelShader: {
  68157. name: string;
  68158. shader: string;
  68159. };
  68160. }
  68161. declare module BABYLON {
  68162. /**
  68163. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  68164. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  68165. */
  68166. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  68167. /**
  68168. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  68169. */
  68170. threshold: number;
  68171. /**
  68172. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  68173. */
  68174. strength: number;
  68175. /**
  68176. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  68177. */
  68178. reflectionSpecularFalloffExponent: number;
  68179. /**
  68180. * 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]
  68181. */
  68182. step: number;
  68183. /**
  68184. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  68185. */
  68186. roughnessFactor: number;
  68187. private _geometryBufferRenderer;
  68188. private _enableSmoothReflections;
  68189. private _reflectionSamples;
  68190. private _smoothSteps;
  68191. /**
  68192. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  68193. * @param name The name of the effect.
  68194. * @param scene The scene containing the objects to calculate reflections.
  68195. * @param options The required width/height ratio to downsize to before computing the render pass.
  68196. * @param camera The camera to apply the render pass to.
  68197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68198. * @param engine The engine which the post process will be applied. (default: current engine)
  68199. * @param reusable If the post process can be reused on the same frame. (default: false)
  68200. * @param textureType Type of textures used when performing the post process. (default: 0)
  68201. * @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)
  68202. */
  68203. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68204. /**
  68205. * Gets wether or not smoothing reflections is enabled.
  68206. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68207. */
  68208. get enableSmoothReflections(): boolean;
  68209. /**
  68210. * Sets wether or not smoothing reflections is enabled.
  68211. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  68212. */
  68213. set enableSmoothReflections(enabled: boolean);
  68214. /**
  68215. * Gets the number of samples taken while computing reflections. More samples count is high,
  68216. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68217. */
  68218. get reflectionSamples(): number;
  68219. /**
  68220. * Sets the number of samples taken while computing reflections. More samples count is high,
  68221. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  68222. */
  68223. set reflectionSamples(samples: number);
  68224. /**
  68225. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  68226. * more the post-process will require GPU power and can generate a drop in FPS.
  68227. * Default value (5.0) work pretty well in all cases but can be adjusted.
  68228. */
  68229. get smoothSteps(): number;
  68230. set smoothSteps(steps: number);
  68231. private _updateEffectDefines;
  68232. }
  68233. }
  68234. declare module BABYLON {
  68235. /** @hidden */
  68236. export var standardPixelShader: {
  68237. name: string;
  68238. shader: string;
  68239. };
  68240. }
  68241. declare module BABYLON {
  68242. /**
  68243. * Standard rendering pipeline
  68244. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68245. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68246. */
  68247. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68248. /**
  68249. * Public members
  68250. */
  68251. /**
  68252. * Post-process which contains the original scene color before the pipeline applies all the effects
  68253. */
  68254. originalPostProcess: Nullable<PostProcess>;
  68255. /**
  68256. * Post-process used to down scale an image x4
  68257. */
  68258. downSampleX4PostProcess: Nullable<PostProcess>;
  68259. /**
  68260. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68261. */
  68262. brightPassPostProcess: Nullable<PostProcess>;
  68263. /**
  68264. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68265. */
  68266. blurHPostProcesses: PostProcess[];
  68267. /**
  68268. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68269. */
  68270. blurVPostProcesses: PostProcess[];
  68271. /**
  68272. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68273. */
  68274. textureAdderPostProcess: Nullable<PostProcess>;
  68275. /**
  68276. * Post-process used to create volumetric lighting effect
  68277. */
  68278. volumetricLightPostProcess: Nullable<PostProcess>;
  68279. /**
  68280. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68281. */
  68282. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68283. /**
  68284. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68285. */
  68286. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68287. /**
  68288. * Post-process used to merge the volumetric light effect and the real scene color
  68289. */
  68290. volumetricLightMergePostProces: Nullable<PostProcess>;
  68291. /**
  68292. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68293. */
  68294. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68295. /**
  68296. * Base post-process used to calculate the average luminance of the final image for HDR
  68297. */
  68298. luminancePostProcess: Nullable<PostProcess>;
  68299. /**
  68300. * Post-processes used to create down sample post-processes in order to get
  68301. * the average luminance of the final image for HDR
  68302. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68303. */
  68304. luminanceDownSamplePostProcesses: PostProcess[];
  68305. /**
  68306. * Post-process used to create a HDR effect (light adaptation)
  68307. */
  68308. hdrPostProcess: Nullable<PostProcess>;
  68309. /**
  68310. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68311. */
  68312. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68313. /**
  68314. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68315. */
  68316. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68317. /**
  68318. * Post-process used to merge the final HDR post-process and the real scene color
  68319. */
  68320. hdrFinalPostProcess: Nullable<PostProcess>;
  68321. /**
  68322. * Post-process used to create a lens flare effect
  68323. */
  68324. lensFlarePostProcess: Nullable<PostProcess>;
  68325. /**
  68326. * Post-process that merges the result of the lens flare post-process and the real scene color
  68327. */
  68328. lensFlareComposePostProcess: Nullable<PostProcess>;
  68329. /**
  68330. * Post-process used to create a motion blur effect
  68331. */
  68332. motionBlurPostProcess: Nullable<PostProcess>;
  68333. /**
  68334. * Post-process used to create a depth of field effect
  68335. */
  68336. depthOfFieldPostProcess: Nullable<PostProcess>;
  68337. /**
  68338. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68339. */
  68340. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68341. /**
  68342. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  68343. */
  68344. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  68345. /**
  68346. * Represents the brightness threshold in order to configure the illuminated surfaces
  68347. */
  68348. brightThreshold: number;
  68349. /**
  68350. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68351. */
  68352. blurWidth: number;
  68353. /**
  68354. * Sets if the blur for highlighted surfaces must be only horizontal
  68355. */
  68356. horizontalBlur: boolean;
  68357. /**
  68358. * Gets the overall exposure used by the pipeline
  68359. */
  68360. get exposure(): number;
  68361. /**
  68362. * Sets the overall exposure used by the pipeline
  68363. */
  68364. set exposure(value: number);
  68365. /**
  68366. * Texture used typically to simulate "dirty" on camera lens
  68367. */
  68368. lensTexture: Nullable<Texture>;
  68369. /**
  68370. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68371. */
  68372. volumetricLightCoefficient: number;
  68373. /**
  68374. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68375. */
  68376. volumetricLightPower: number;
  68377. /**
  68378. * Used the set the blur intensity to smooth the volumetric lights
  68379. */
  68380. volumetricLightBlurScale: number;
  68381. /**
  68382. * Light (spot or directional) used to generate the volumetric lights rays
  68383. * The source light must have a shadow generate so the pipeline can get its
  68384. * depth map
  68385. */
  68386. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68387. /**
  68388. * For eye adaptation, represents the minimum luminance the eye can see
  68389. */
  68390. hdrMinimumLuminance: number;
  68391. /**
  68392. * For eye adaptation, represents the decrease luminance speed
  68393. */
  68394. hdrDecreaseRate: number;
  68395. /**
  68396. * For eye adaptation, represents the increase luminance speed
  68397. */
  68398. hdrIncreaseRate: number;
  68399. /**
  68400. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68401. */
  68402. get hdrAutoExposure(): boolean;
  68403. /**
  68404. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68405. */
  68406. set hdrAutoExposure(value: boolean);
  68407. /**
  68408. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68409. */
  68410. lensColorTexture: Nullable<Texture>;
  68411. /**
  68412. * The overall strengh for the lens flare effect
  68413. */
  68414. lensFlareStrength: number;
  68415. /**
  68416. * Dispersion coefficient for lens flare ghosts
  68417. */
  68418. lensFlareGhostDispersal: number;
  68419. /**
  68420. * Main lens flare halo width
  68421. */
  68422. lensFlareHaloWidth: number;
  68423. /**
  68424. * Based on the lens distortion effect, defines how much the lens flare result
  68425. * is distorted
  68426. */
  68427. lensFlareDistortionStrength: number;
  68428. /**
  68429. * Configures the blur intensity used for for lens flare (halo)
  68430. */
  68431. lensFlareBlurWidth: number;
  68432. /**
  68433. * Lens star texture must be used to simulate rays on the flares and is available
  68434. * in the documentation
  68435. */
  68436. lensStarTexture: Nullable<Texture>;
  68437. /**
  68438. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68439. * flare effect by taking account of the dirt texture
  68440. */
  68441. lensFlareDirtTexture: Nullable<Texture>;
  68442. /**
  68443. * Represents the focal length for the depth of field effect
  68444. */
  68445. depthOfFieldDistance: number;
  68446. /**
  68447. * Represents the blur intensity for the blurred part of the depth of field effect
  68448. */
  68449. depthOfFieldBlurWidth: number;
  68450. /**
  68451. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68452. */
  68453. get motionStrength(): number;
  68454. /**
  68455. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68456. */
  68457. set motionStrength(strength: number);
  68458. /**
  68459. * Gets wether or not the motion blur post-process is object based or screen based.
  68460. */
  68461. get objectBasedMotionBlur(): boolean;
  68462. /**
  68463. * Sets wether or not the motion blur post-process should be object based or screen based
  68464. */
  68465. set objectBasedMotionBlur(value: boolean);
  68466. /**
  68467. * List of animations for the pipeline (IAnimatable implementation)
  68468. */
  68469. animations: Animation[];
  68470. /**
  68471. * Private members
  68472. */
  68473. private _scene;
  68474. private _currentDepthOfFieldSource;
  68475. private _basePostProcess;
  68476. private _fixedExposure;
  68477. private _currentExposure;
  68478. private _hdrAutoExposure;
  68479. private _hdrCurrentLuminance;
  68480. private _motionStrength;
  68481. private _isObjectBasedMotionBlur;
  68482. private _floatTextureType;
  68483. private _camerasToBeAttached;
  68484. private _ratio;
  68485. private _bloomEnabled;
  68486. private _depthOfFieldEnabled;
  68487. private _vlsEnabled;
  68488. private _lensFlareEnabled;
  68489. private _hdrEnabled;
  68490. private _motionBlurEnabled;
  68491. private _fxaaEnabled;
  68492. private _screenSpaceReflectionsEnabled;
  68493. private _motionBlurSamples;
  68494. private _volumetricLightStepsCount;
  68495. private _samples;
  68496. /**
  68497. * @ignore
  68498. * Specifies if the bloom pipeline is enabled
  68499. */
  68500. get BloomEnabled(): boolean;
  68501. set BloomEnabled(enabled: boolean);
  68502. /**
  68503. * @ignore
  68504. * Specifies if the depth of field pipeline is enabed
  68505. */
  68506. get DepthOfFieldEnabled(): boolean;
  68507. set DepthOfFieldEnabled(enabled: boolean);
  68508. /**
  68509. * @ignore
  68510. * Specifies if the lens flare pipeline is enabed
  68511. */
  68512. get LensFlareEnabled(): boolean;
  68513. set LensFlareEnabled(enabled: boolean);
  68514. /**
  68515. * @ignore
  68516. * Specifies if the HDR pipeline is enabled
  68517. */
  68518. get HDREnabled(): boolean;
  68519. set HDREnabled(enabled: boolean);
  68520. /**
  68521. * @ignore
  68522. * Specifies if the volumetric lights scattering effect is enabled
  68523. */
  68524. get VLSEnabled(): boolean;
  68525. set VLSEnabled(enabled: boolean);
  68526. /**
  68527. * @ignore
  68528. * Specifies if the motion blur effect is enabled
  68529. */
  68530. get MotionBlurEnabled(): boolean;
  68531. set MotionBlurEnabled(enabled: boolean);
  68532. /**
  68533. * Specifies if anti-aliasing is enabled
  68534. */
  68535. get fxaaEnabled(): boolean;
  68536. set fxaaEnabled(enabled: boolean);
  68537. /**
  68538. * Specifies if screen space reflections are enabled.
  68539. */
  68540. get screenSpaceReflectionsEnabled(): boolean;
  68541. set screenSpaceReflectionsEnabled(enabled: boolean);
  68542. /**
  68543. * Specifies the number of steps used to calculate the volumetric lights
  68544. * Typically in interval [50, 200]
  68545. */
  68546. get volumetricLightStepsCount(): number;
  68547. set volumetricLightStepsCount(count: number);
  68548. /**
  68549. * Specifies the number of samples used for the motion blur effect
  68550. * Typically in interval [16, 64]
  68551. */
  68552. get motionBlurSamples(): number;
  68553. set motionBlurSamples(samples: number);
  68554. /**
  68555. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68556. */
  68557. get samples(): number;
  68558. set samples(sampleCount: number);
  68559. /**
  68560. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68561. * @constructor
  68562. * @param name The rendering pipeline name
  68563. * @param scene The scene linked to this pipeline
  68564. * @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)
  68565. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  68566. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68567. */
  68568. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  68569. private _buildPipeline;
  68570. private _createDownSampleX4PostProcess;
  68571. private _createBrightPassPostProcess;
  68572. private _createBlurPostProcesses;
  68573. private _createTextureAdderPostProcess;
  68574. private _createVolumetricLightPostProcess;
  68575. private _createLuminancePostProcesses;
  68576. private _createHdrPostProcess;
  68577. private _createLensFlarePostProcess;
  68578. private _createDepthOfFieldPostProcess;
  68579. private _createMotionBlurPostProcess;
  68580. private _getDepthTexture;
  68581. private _disposePostProcesses;
  68582. /**
  68583. * Dispose of the pipeline and stop all post processes
  68584. */
  68585. dispose(): void;
  68586. /**
  68587. * Serialize the rendering pipeline (Used when exporting)
  68588. * @returns the serialized object
  68589. */
  68590. serialize(): any;
  68591. /**
  68592. * Parse the serialized pipeline
  68593. * @param source Source pipeline.
  68594. * @param scene The scene to load the pipeline to.
  68595. * @param rootUrl The URL of the serialized pipeline.
  68596. * @returns An instantiated pipeline from the serialized object.
  68597. */
  68598. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  68599. /**
  68600. * Luminance steps
  68601. */
  68602. static LuminanceSteps: number;
  68603. }
  68604. }
  68605. declare module BABYLON {
  68606. /** @hidden */
  68607. export var stereoscopicInterlacePixelShader: {
  68608. name: string;
  68609. shader: string;
  68610. };
  68611. }
  68612. declare module BABYLON {
  68613. /**
  68614. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  68615. */
  68616. export class StereoscopicInterlacePostProcessI extends PostProcess {
  68617. private _stepSize;
  68618. private _passedProcess;
  68619. /**
  68620. * Initializes a StereoscopicInterlacePostProcessI
  68621. * @param name The name of the effect.
  68622. * @param rigCameras The rig cameras to be appled to the post process
  68623. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  68624. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  68625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68626. * @param engine The engine which the post process will be applied. (default: current engine)
  68627. * @param reusable If the post process can be reused on the same frame. (default: false)
  68628. */
  68629. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68630. }
  68631. /**
  68632. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  68633. */
  68634. export class StereoscopicInterlacePostProcess extends PostProcess {
  68635. private _stepSize;
  68636. private _passedProcess;
  68637. /**
  68638. * Initializes a StereoscopicInterlacePostProcess
  68639. * @param name The name of the effect.
  68640. * @param rigCameras The rig cameras to be appled to the post process
  68641. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  68642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68643. * @param engine The engine which the post process will be applied. (default: current engine)
  68644. * @param reusable If the post process can be reused on the same frame. (default: false)
  68645. */
  68646. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68647. }
  68648. }
  68649. declare module BABYLON {
  68650. /** @hidden */
  68651. export var tonemapPixelShader: {
  68652. name: string;
  68653. shader: string;
  68654. };
  68655. }
  68656. declare module BABYLON {
  68657. /** Defines operator used for tonemapping */
  68658. export enum TonemappingOperator {
  68659. /** Hable */
  68660. Hable = 0,
  68661. /** Reinhard */
  68662. Reinhard = 1,
  68663. /** HejiDawson */
  68664. HejiDawson = 2,
  68665. /** Photographic */
  68666. Photographic = 3
  68667. }
  68668. /**
  68669. * Defines a post process to apply tone mapping
  68670. */
  68671. export class TonemapPostProcess extends PostProcess {
  68672. private _operator;
  68673. /** Defines the required exposure adjustement */
  68674. exposureAdjustment: number;
  68675. /**
  68676. * Creates a new TonemapPostProcess
  68677. * @param name defines the name of the postprocess
  68678. * @param _operator defines the operator to use
  68679. * @param exposureAdjustment defines the required exposure adjustement
  68680. * @param camera defines the camera to use (can be null)
  68681. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  68682. * @param engine defines the hosting engine (can be ignore if camera is set)
  68683. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  68684. */
  68685. constructor(name: string, _operator: TonemappingOperator,
  68686. /** Defines the required exposure adjustement */
  68687. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  68688. }
  68689. }
  68690. declare module BABYLON {
  68691. /** @hidden */
  68692. export var volumetricLightScatteringPixelShader: {
  68693. name: string;
  68694. shader: string;
  68695. };
  68696. }
  68697. declare module BABYLON {
  68698. /** @hidden */
  68699. export var volumetricLightScatteringPassVertexShader: {
  68700. name: string;
  68701. shader: string;
  68702. };
  68703. }
  68704. declare module BABYLON {
  68705. /** @hidden */
  68706. export var volumetricLightScatteringPassPixelShader: {
  68707. name: string;
  68708. shader: string;
  68709. };
  68710. }
  68711. declare module BABYLON {
  68712. /**
  68713. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  68714. */
  68715. export class VolumetricLightScatteringPostProcess extends PostProcess {
  68716. private _volumetricLightScatteringPass;
  68717. private _volumetricLightScatteringRTT;
  68718. private _viewPort;
  68719. private _screenCoordinates;
  68720. private _cachedDefines;
  68721. /**
  68722. * If not undefined, the mesh position is computed from the attached node position
  68723. */
  68724. attachedNode: {
  68725. position: Vector3;
  68726. };
  68727. /**
  68728. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68729. */
  68730. customMeshPosition: Vector3;
  68731. /**
  68732. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68733. */
  68734. useCustomMeshPosition: boolean;
  68735. /**
  68736. * If the post-process should inverse the light scattering direction
  68737. */
  68738. invert: boolean;
  68739. /**
  68740. * The internal mesh used by the post-process
  68741. */
  68742. mesh: Mesh;
  68743. /**
  68744. * @hidden
  68745. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68746. */
  68747. get useDiffuseColor(): boolean;
  68748. set useDiffuseColor(useDiffuseColor: boolean);
  68749. /**
  68750. * Array containing the excluded meshes not rendered in the internal pass
  68751. */
  68752. excludedMeshes: AbstractMesh[];
  68753. /**
  68754. * Controls the overall intensity of the post-process
  68755. */
  68756. exposure: number;
  68757. /**
  68758. * Dissipates each sample's contribution in range [0, 1]
  68759. */
  68760. decay: number;
  68761. /**
  68762. * Controls the overall intensity of each sample
  68763. */
  68764. weight: number;
  68765. /**
  68766. * Controls the density of each sample
  68767. */
  68768. density: number;
  68769. /**
  68770. * @constructor
  68771. * @param name The post-process name
  68772. * @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)
  68773. * @param camera The camera that the post-process will be attached to
  68774. * @param mesh The mesh used to create the light scattering
  68775. * @param samples The post-process quality, default 100
  68776. * @param samplingModeThe post-process filtering mode
  68777. * @param engine The babylon engine
  68778. * @param reusable If the post-process is reusable
  68779. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68780. */
  68781. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68782. /**
  68783. * Returns the string "VolumetricLightScatteringPostProcess"
  68784. * @returns "VolumetricLightScatteringPostProcess"
  68785. */
  68786. getClassName(): string;
  68787. private _isReady;
  68788. /**
  68789. * Sets the new light position for light scattering effect
  68790. * @param position The new custom light position
  68791. */
  68792. setCustomMeshPosition(position: Vector3): void;
  68793. /**
  68794. * Returns the light position for light scattering effect
  68795. * @return Vector3 The custom light position
  68796. */
  68797. getCustomMeshPosition(): Vector3;
  68798. /**
  68799. * Disposes the internal assets and detaches the post-process from the camera
  68800. */
  68801. dispose(camera: Camera): void;
  68802. /**
  68803. * Returns the render target texture used by the post-process
  68804. * @return the render target texture used by the post-process
  68805. */
  68806. getPass(): RenderTargetTexture;
  68807. private _meshExcluded;
  68808. private _createPass;
  68809. private _updateMeshScreenCoordinates;
  68810. /**
  68811. * Creates a default mesh for the Volumeric Light Scattering post-process
  68812. * @param name The mesh name
  68813. * @param scene The scene where to create the mesh
  68814. * @return the default mesh
  68815. */
  68816. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68817. }
  68818. }
  68819. declare module BABYLON {
  68820. interface Scene {
  68821. /** @hidden (Backing field) */
  68822. _boundingBoxRenderer: BoundingBoxRenderer;
  68823. /** @hidden (Backing field) */
  68824. _forceShowBoundingBoxes: boolean;
  68825. /**
  68826. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68827. */
  68828. forceShowBoundingBoxes: boolean;
  68829. /**
  68830. * Gets the bounding box renderer associated with the scene
  68831. * @returns a BoundingBoxRenderer
  68832. */
  68833. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68834. }
  68835. interface AbstractMesh {
  68836. /** @hidden (Backing field) */
  68837. _showBoundingBox: boolean;
  68838. /**
  68839. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68840. */
  68841. showBoundingBox: boolean;
  68842. }
  68843. /**
  68844. * Component responsible of rendering the bounding box of the meshes in a scene.
  68845. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68846. */
  68847. export class BoundingBoxRenderer implements ISceneComponent {
  68848. /**
  68849. * The component name helpfull to identify the component in the list of scene components.
  68850. */
  68851. readonly name: string;
  68852. /**
  68853. * The scene the component belongs to.
  68854. */
  68855. scene: Scene;
  68856. /**
  68857. * Color of the bounding box lines placed in front of an object
  68858. */
  68859. frontColor: Color3;
  68860. /**
  68861. * Color of the bounding box lines placed behind an object
  68862. */
  68863. backColor: Color3;
  68864. /**
  68865. * Defines if the renderer should show the back lines or not
  68866. */
  68867. showBackLines: boolean;
  68868. /**
  68869. * Observable raised before rendering a bounding box
  68870. */
  68871. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  68872. /**
  68873. * Observable raised after rendering a bounding box
  68874. */
  68875. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  68876. /**
  68877. * @hidden
  68878. */
  68879. renderList: SmartArray<BoundingBox>;
  68880. private _colorShader;
  68881. private _vertexBuffers;
  68882. private _indexBuffer;
  68883. private _fillIndexBuffer;
  68884. private _fillIndexData;
  68885. /**
  68886. * Instantiates a new bounding box renderer in a scene.
  68887. * @param scene the scene the renderer renders in
  68888. */
  68889. constructor(scene: Scene);
  68890. /**
  68891. * Registers the component in a given scene
  68892. */
  68893. register(): void;
  68894. private _evaluateSubMesh;
  68895. private _activeMesh;
  68896. private _prepareRessources;
  68897. private _createIndexBuffer;
  68898. /**
  68899. * Rebuilds the elements related to this component in case of
  68900. * context lost for instance.
  68901. */
  68902. rebuild(): void;
  68903. /**
  68904. * @hidden
  68905. */
  68906. reset(): void;
  68907. /**
  68908. * Render the bounding boxes of a specific rendering group
  68909. * @param renderingGroupId defines the rendering group to render
  68910. */
  68911. render(renderingGroupId: number): void;
  68912. /**
  68913. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68914. * @param mesh Define the mesh to render the occlusion bounding box for
  68915. */
  68916. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68917. /**
  68918. * Dispose and release the resources attached to this renderer.
  68919. */
  68920. dispose(): void;
  68921. }
  68922. }
  68923. declare module BABYLON {
  68924. interface Scene {
  68925. /** @hidden (Backing field) */
  68926. _depthRenderer: {
  68927. [id: string]: DepthRenderer;
  68928. };
  68929. /**
  68930. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  68931. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  68932. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68933. * @returns the created depth renderer
  68934. */
  68935. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  68936. /**
  68937. * Disables a depth renderer for a given camera
  68938. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  68939. */
  68940. disableDepthRenderer(camera?: Nullable<Camera>): void;
  68941. }
  68942. /**
  68943. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  68944. * in several rendering techniques.
  68945. */
  68946. export class DepthRendererSceneComponent implements ISceneComponent {
  68947. /**
  68948. * The component name helpfull to identify the component in the list of scene components.
  68949. */
  68950. readonly name: string;
  68951. /**
  68952. * The scene the component belongs to.
  68953. */
  68954. scene: Scene;
  68955. /**
  68956. * Creates a new instance of the component for the given scene
  68957. * @param scene Defines the scene to register the component in
  68958. */
  68959. constructor(scene: Scene);
  68960. /**
  68961. * Registers the component in a given scene
  68962. */
  68963. register(): void;
  68964. /**
  68965. * Rebuilds the elements related to this component in case of
  68966. * context lost for instance.
  68967. */
  68968. rebuild(): void;
  68969. /**
  68970. * Disposes the component and the associated ressources
  68971. */
  68972. dispose(): void;
  68973. private _gatherRenderTargets;
  68974. private _gatherActiveCameraRenderTargets;
  68975. }
  68976. }
  68977. declare module BABYLON {
  68978. /** @hidden */
  68979. export var outlinePixelShader: {
  68980. name: string;
  68981. shader: string;
  68982. };
  68983. }
  68984. declare module BABYLON {
  68985. /** @hidden */
  68986. export var outlineVertexShader: {
  68987. name: string;
  68988. shader: string;
  68989. };
  68990. }
  68991. declare module BABYLON {
  68992. interface Scene {
  68993. /** @hidden */
  68994. _outlineRenderer: OutlineRenderer;
  68995. /**
  68996. * Gets the outline renderer associated with the scene
  68997. * @returns a OutlineRenderer
  68998. */
  68999. getOutlineRenderer(): OutlineRenderer;
  69000. }
  69001. interface AbstractMesh {
  69002. /** @hidden (Backing field) */
  69003. _renderOutline: boolean;
  69004. /**
  69005. * Gets or sets a boolean indicating if the outline must be rendered as well
  69006. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69007. */
  69008. renderOutline: boolean;
  69009. /** @hidden (Backing field) */
  69010. _renderOverlay: boolean;
  69011. /**
  69012. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69013. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69014. */
  69015. renderOverlay: boolean;
  69016. }
  69017. /**
  69018. * This class is responsible to draw bothe outline/overlay of meshes.
  69019. * It should not be used directly but through the available method on mesh.
  69020. */
  69021. export class OutlineRenderer implements ISceneComponent {
  69022. /**
  69023. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69024. */
  69025. private static _StencilReference;
  69026. /**
  69027. * The name of the component. Each component must have a unique name.
  69028. */
  69029. name: string;
  69030. /**
  69031. * The scene the component belongs to.
  69032. */
  69033. scene: Scene;
  69034. /**
  69035. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69036. */
  69037. zOffset: number;
  69038. private _engine;
  69039. private _effect;
  69040. private _cachedDefines;
  69041. private _savedDepthWrite;
  69042. /**
  69043. * Instantiates a new outline renderer. (There could be only one per scene).
  69044. * @param scene Defines the scene it belongs to
  69045. */
  69046. constructor(scene: Scene);
  69047. /**
  69048. * Register the component to one instance of a scene.
  69049. */
  69050. register(): void;
  69051. /**
  69052. * Rebuilds the elements related to this component in case of
  69053. * context lost for instance.
  69054. */
  69055. rebuild(): void;
  69056. /**
  69057. * Disposes the component and the associated ressources.
  69058. */
  69059. dispose(): void;
  69060. /**
  69061. * Renders the outline in the canvas.
  69062. * @param subMesh Defines the sumesh to render
  69063. * @param batch Defines the batch of meshes in case of instances
  69064. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69065. */
  69066. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69067. /**
  69068. * Returns whether or not the outline renderer is ready for a given submesh.
  69069. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69070. * @param subMesh Defines the submesh to check readyness for
  69071. * @param useInstances Defines wheter wee are trying to render instances or not
  69072. * @returns true if ready otherwise false
  69073. */
  69074. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69075. private _beforeRenderingMesh;
  69076. private _afterRenderingMesh;
  69077. }
  69078. }
  69079. declare module BABYLON {
  69080. /**
  69081. * Defines the basic options interface of a Sprite Frame Source Size.
  69082. */
  69083. export interface ISpriteJSONSpriteSourceSize {
  69084. /**
  69085. * number of the original width of the Frame
  69086. */
  69087. w: number;
  69088. /**
  69089. * number of the original height of the Frame
  69090. */
  69091. h: number;
  69092. }
  69093. /**
  69094. * Defines the basic options interface of a Sprite Frame Data.
  69095. */
  69096. export interface ISpriteJSONSpriteFrameData {
  69097. /**
  69098. * number of the x offset of the Frame
  69099. */
  69100. x: number;
  69101. /**
  69102. * number of the y offset of the Frame
  69103. */
  69104. y: number;
  69105. /**
  69106. * number of the width of the Frame
  69107. */
  69108. w: number;
  69109. /**
  69110. * number of the height of the Frame
  69111. */
  69112. h: number;
  69113. }
  69114. /**
  69115. * Defines the basic options interface of a JSON Sprite.
  69116. */
  69117. export interface ISpriteJSONSprite {
  69118. /**
  69119. * string name of the Frame
  69120. */
  69121. filename: string;
  69122. /**
  69123. * ISpriteJSONSpriteFrame basic object of the frame data
  69124. */
  69125. frame: ISpriteJSONSpriteFrameData;
  69126. /**
  69127. * boolean to flag is the frame was rotated.
  69128. */
  69129. rotated: boolean;
  69130. /**
  69131. * boolean to flag is the frame was trimmed.
  69132. */
  69133. trimmed: boolean;
  69134. /**
  69135. * ISpriteJSONSpriteFrame basic object of the source data
  69136. */
  69137. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69138. /**
  69139. * ISpriteJSONSpriteFrame basic object of the source data
  69140. */
  69141. sourceSize: ISpriteJSONSpriteSourceSize;
  69142. }
  69143. /**
  69144. * Defines the basic options interface of a JSON atlas.
  69145. */
  69146. export interface ISpriteJSONAtlas {
  69147. /**
  69148. * Array of objects that contain the frame data.
  69149. */
  69150. frames: Array<ISpriteJSONSprite>;
  69151. /**
  69152. * object basic object containing the sprite meta data.
  69153. */
  69154. meta?: object;
  69155. }
  69156. }
  69157. declare module BABYLON {
  69158. /** @hidden */
  69159. export var spriteMapPixelShader: {
  69160. name: string;
  69161. shader: string;
  69162. };
  69163. }
  69164. declare module BABYLON {
  69165. /** @hidden */
  69166. export var spriteMapVertexShader: {
  69167. name: string;
  69168. shader: string;
  69169. };
  69170. }
  69171. declare module BABYLON {
  69172. /**
  69173. * Defines the basic options interface of a SpriteMap
  69174. */
  69175. export interface ISpriteMapOptions {
  69176. /**
  69177. * Vector2 of the number of cells in the grid.
  69178. */
  69179. stageSize?: Vector2;
  69180. /**
  69181. * Vector2 of the size of the output plane in World Units.
  69182. */
  69183. outputSize?: Vector2;
  69184. /**
  69185. * Vector3 of the position of the output plane in World Units.
  69186. */
  69187. outputPosition?: Vector3;
  69188. /**
  69189. * Vector3 of the rotation of the output plane.
  69190. */
  69191. outputRotation?: Vector3;
  69192. /**
  69193. * number of layers that the system will reserve in resources.
  69194. */
  69195. layerCount?: number;
  69196. /**
  69197. * number of max animation frames a single cell will reserve in resources.
  69198. */
  69199. maxAnimationFrames?: number;
  69200. /**
  69201. * number cell index of the base tile when the system compiles.
  69202. */
  69203. baseTile?: number;
  69204. /**
  69205. * boolean flip the sprite after its been repositioned by the framing data.
  69206. */
  69207. flipU?: boolean;
  69208. /**
  69209. * Vector3 scalar of the global RGB values of the SpriteMap.
  69210. */
  69211. colorMultiply?: Vector3;
  69212. }
  69213. /**
  69214. * Defines the IDisposable interface in order to be cleanable from resources.
  69215. */
  69216. export interface ISpriteMap extends IDisposable {
  69217. /**
  69218. * String name of the SpriteMap.
  69219. */
  69220. name: string;
  69221. /**
  69222. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  69223. */
  69224. atlasJSON: ISpriteJSONAtlas;
  69225. /**
  69226. * Texture of the SpriteMap.
  69227. */
  69228. spriteSheet: Texture;
  69229. /**
  69230. * The parameters to initialize the SpriteMap with.
  69231. */
  69232. options: ISpriteMapOptions;
  69233. }
  69234. /**
  69235. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69236. */
  69237. export class SpriteMap implements ISpriteMap {
  69238. /** The Name of the spriteMap */
  69239. name: string;
  69240. /** The JSON file with the frame and meta data */
  69241. atlasJSON: ISpriteJSONAtlas;
  69242. /** The systems Sprite Sheet Texture */
  69243. spriteSheet: Texture;
  69244. /** Arguments passed with the Constructor */
  69245. options: ISpriteMapOptions;
  69246. /** Public Sprite Storage array, parsed from atlasJSON */
  69247. sprites: Array<ISpriteJSONSprite>;
  69248. /** Returns the Number of Sprites in the System */
  69249. get spriteCount(): number;
  69250. /** Returns the Position of Output Plane*/
  69251. get position(): Vector3;
  69252. /** Returns the Position of Output Plane*/
  69253. set position(v: Vector3);
  69254. /** Returns the Rotation of Output Plane*/
  69255. get rotation(): Vector3;
  69256. /** Returns the Rotation of Output Plane*/
  69257. set rotation(v: Vector3);
  69258. /** Sets the AnimationMap*/
  69259. get animationMap(): RawTexture;
  69260. /** Sets the AnimationMap*/
  69261. set animationMap(v: RawTexture);
  69262. /** Scene that the SpriteMap was created in */
  69263. private _scene;
  69264. /** Texture Buffer of Float32 that holds tile frame data*/
  69265. private _frameMap;
  69266. /** Texture Buffers of Float32 that holds tileMap data*/
  69267. private _tileMaps;
  69268. /** Texture Buffer of Float32 that holds Animation Data*/
  69269. private _animationMap;
  69270. /** Custom ShaderMaterial Central to the System*/
  69271. private _material;
  69272. /** Custom ShaderMaterial Central to the System*/
  69273. private _output;
  69274. /** Systems Time Ticker*/
  69275. private _time;
  69276. /**
  69277. * Creates a new SpriteMap
  69278. * @param name defines the SpriteMaps Name
  69279. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69280. * @param spriteSheet is the Texture that the Sprites are on.
  69281. * @param options a basic deployment configuration
  69282. * @param scene The Scene that the map is deployed on
  69283. */
  69284. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69285. /**
  69286. * Returns tileID location
  69287. * @returns Vector2 the cell position ID
  69288. */
  69289. getTileID(): Vector2;
  69290. /**
  69291. * Gets the UV location of the mouse over the SpriteMap.
  69292. * @returns Vector2 the UV position of the mouse interaction
  69293. */
  69294. getMousePosition(): Vector2;
  69295. /**
  69296. * Creates the "frame" texture Buffer
  69297. * -------------------------------------
  69298. * Structure of frames
  69299. * "filename": "Falling-Water-2.png",
  69300. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69301. * "rotated": true,
  69302. * "trimmed": true,
  69303. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69304. * "sourceSize": {"w":32,"h":32}
  69305. * @returns RawTexture of the frameMap
  69306. */
  69307. private _createFrameBuffer;
  69308. /**
  69309. * Creates the tileMap texture Buffer
  69310. * @param buffer normally and array of numbers, or a false to generate from scratch
  69311. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69312. * @returns RawTexture of the tileMap
  69313. */
  69314. private _createTileBuffer;
  69315. /**
  69316. * Modifies the data of the tileMaps
  69317. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69318. * @param pos is the iVector2 Coordinates of the Tile
  69319. * @param tile The SpriteIndex of the new Tile
  69320. */
  69321. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69322. /**
  69323. * Creates the animationMap texture Buffer
  69324. * @param buffer normally and array of numbers, or a false to generate from scratch
  69325. * @returns RawTexture of the animationMap
  69326. */
  69327. private _createTileAnimationBuffer;
  69328. /**
  69329. * Modifies the data of the animationMap
  69330. * @param cellID is the Index of the Sprite
  69331. * @param _frame is the target Animation frame
  69332. * @param toCell is the Target Index of the next frame of the animation
  69333. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69334. * @param speed is a global scalar of the time variable on the map.
  69335. */
  69336. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69337. /**
  69338. * Exports the .tilemaps file
  69339. */
  69340. saveTileMaps(): void;
  69341. /**
  69342. * Imports the .tilemaps file
  69343. * @param url of the .tilemaps file
  69344. */
  69345. loadTileMaps(url: string): void;
  69346. /**
  69347. * Release associated resources
  69348. */
  69349. dispose(): void;
  69350. }
  69351. }
  69352. declare module BABYLON {
  69353. /**
  69354. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69355. * @see http://doc.babylonjs.com/babylon101/sprites
  69356. */
  69357. export class SpritePackedManager extends SpriteManager {
  69358. /** defines the packed manager's name */
  69359. name: string;
  69360. /**
  69361. * Creates a new sprite manager from a packed sprite sheet
  69362. * @param name defines the manager's name
  69363. * @param imgUrl defines the sprite sheet url
  69364. * @param capacity defines the maximum allowed number of sprites
  69365. * @param scene defines the hosting scene
  69366. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69367. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69368. * @param samplingMode defines the smapling mode to use with spritesheet
  69369. * @param fromPacked set to true; do not alter
  69370. */
  69371. constructor(
  69372. /** defines the packed manager's name */
  69373. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69374. }
  69375. }
  69376. declare module BABYLON {
  69377. /**
  69378. * Defines the list of states available for a task inside a AssetsManager
  69379. */
  69380. export enum AssetTaskState {
  69381. /**
  69382. * Initialization
  69383. */
  69384. INIT = 0,
  69385. /**
  69386. * Running
  69387. */
  69388. RUNNING = 1,
  69389. /**
  69390. * Done
  69391. */
  69392. DONE = 2,
  69393. /**
  69394. * Error
  69395. */
  69396. ERROR = 3
  69397. }
  69398. /**
  69399. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69400. */
  69401. export abstract class AbstractAssetTask {
  69402. /**
  69403. * Task name
  69404. */ name: string;
  69405. /**
  69406. * Callback called when the task is successful
  69407. */
  69408. onSuccess: (task: any) => void;
  69409. /**
  69410. * Callback called when the task is not successful
  69411. */
  69412. onError: (task: any, message?: string, exception?: any) => void;
  69413. /**
  69414. * Creates a new AssetsManager
  69415. * @param name defines the name of the task
  69416. */
  69417. constructor(
  69418. /**
  69419. * Task name
  69420. */ name: string);
  69421. private _isCompleted;
  69422. private _taskState;
  69423. private _errorObject;
  69424. /**
  69425. * Get if the task is completed
  69426. */
  69427. get isCompleted(): boolean;
  69428. /**
  69429. * Gets the current state of the task
  69430. */
  69431. get taskState(): AssetTaskState;
  69432. /**
  69433. * Gets the current error object (if task is in error)
  69434. */
  69435. get errorObject(): {
  69436. message?: string;
  69437. exception?: any;
  69438. };
  69439. /**
  69440. * Internal only
  69441. * @hidden
  69442. */
  69443. _setErrorObject(message?: string, exception?: any): void;
  69444. /**
  69445. * Execute the current task
  69446. * @param scene defines the scene where you want your assets to be loaded
  69447. * @param onSuccess is a callback called when the task is successfully executed
  69448. * @param onError is a callback called if an error occurs
  69449. */
  69450. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69451. /**
  69452. * Execute the current task
  69453. * @param scene defines the scene where you want your assets to be loaded
  69454. * @param onSuccess is a callback called when the task is successfully executed
  69455. * @param onError is a callback called if an error occurs
  69456. */
  69457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69458. /**
  69459. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69460. * This can be used with failed tasks that have the reason for failure fixed.
  69461. */
  69462. reset(): void;
  69463. private onErrorCallback;
  69464. private onDoneCallback;
  69465. }
  69466. /**
  69467. * Define the interface used by progress events raised during assets loading
  69468. */
  69469. export interface IAssetsProgressEvent {
  69470. /**
  69471. * Defines the number of remaining tasks to process
  69472. */
  69473. remainingCount: number;
  69474. /**
  69475. * Defines the total number of tasks
  69476. */
  69477. totalCount: number;
  69478. /**
  69479. * Defines the task that was just processed
  69480. */
  69481. task: AbstractAssetTask;
  69482. }
  69483. /**
  69484. * Class used to share progress information about assets loading
  69485. */
  69486. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69487. /**
  69488. * Defines the number of remaining tasks to process
  69489. */
  69490. remainingCount: number;
  69491. /**
  69492. * Defines the total number of tasks
  69493. */
  69494. totalCount: number;
  69495. /**
  69496. * Defines the task that was just processed
  69497. */
  69498. task: AbstractAssetTask;
  69499. /**
  69500. * Creates a AssetsProgressEvent
  69501. * @param remainingCount defines the number of remaining tasks to process
  69502. * @param totalCount defines the total number of tasks
  69503. * @param task defines the task that was just processed
  69504. */
  69505. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69506. }
  69507. /**
  69508. * Define a task used by AssetsManager to load meshes
  69509. */
  69510. export class MeshAssetTask extends AbstractAssetTask {
  69511. /**
  69512. * Defines the name of the task
  69513. */
  69514. name: string;
  69515. /**
  69516. * Defines the list of mesh's names you want to load
  69517. */
  69518. meshesNames: any;
  69519. /**
  69520. * Defines the root url to use as a base to load your meshes and associated resources
  69521. */
  69522. rootUrl: string;
  69523. /**
  69524. * Defines the filename or File of the scene to load from
  69525. */
  69526. sceneFilename: string | File;
  69527. /**
  69528. * Gets the list of loaded meshes
  69529. */
  69530. loadedMeshes: Array<AbstractMesh>;
  69531. /**
  69532. * Gets the list of loaded particle systems
  69533. */
  69534. loadedParticleSystems: Array<IParticleSystem>;
  69535. /**
  69536. * Gets the list of loaded skeletons
  69537. */
  69538. loadedSkeletons: Array<Skeleton>;
  69539. /**
  69540. * Gets the list of loaded animation groups
  69541. */
  69542. loadedAnimationGroups: Array<AnimationGroup>;
  69543. /**
  69544. * Callback called when the task is successful
  69545. */
  69546. onSuccess: (task: MeshAssetTask) => void;
  69547. /**
  69548. * Callback called when the task is successful
  69549. */
  69550. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69551. /**
  69552. * Creates a new MeshAssetTask
  69553. * @param name defines the name of the task
  69554. * @param meshesNames defines the list of mesh's names you want to load
  69555. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69556. * @param sceneFilename defines the filename or File of the scene to load from
  69557. */
  69558. constructor(
  69559. /**
  69560. * Defines the name of the task
  69561. */
  69562. name: string,
  69563. /**
  69564. * Defines the list of mesh's names you want to load
  69565. */
  69566. meshesNames: any,
  69567. /**
  69568. * Defines the root url to use as a base to load your meshes and associated resources
  69569. */
  69570. rootUrl: string,
  69571. /**
  69572. * Defines the filename or File of the scene to load from
  69573. */
  69574. sceneFilename: string | File);
  69575. /**
  69576. * Execute the current task
  69577. * @param scene defines the scene where you want your assets to be loaded
  69578. * @param onSuccess is a callback called when the task is successfully executed
  69579. * @param onError is a callback called if an error occurs
  69580. */
  69581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69582. }
  69583. /**
  69584. * Define a task used by AssetsManager to load text content
  69585. */
  69586. export class TextFileAssetTask extends AbstractAssetTask {
  69587. /**
  69588. * Defines the name of the task
  69589. */
  69590. name: string;
  69591. /**
  69592. * Defines the location of the file to load
  69593. */
  69594. url: string;
  69595. /**
  69596. * Gets the loaded text string
  69597. */
  69598. text: string;
  69599. /**
  69600. * Callback called when the task is successful
  69601. */
  69602. onSuccess: (task: TextFileAssetTask) => void;
  69603. /**
  69604. * Callback called when the task is successful
  69605. */
  69606. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69607. /**
  69608. * Creates a new TextFileAssetTask object
  69609. * @param name defines the name of the task
  69610. * @param url defines the location of the file to load
  69611. */
  69612. constructor(
  69613. /**
  69614. * Defines the name of the task
  69615. */
  69616. name: string,
  69617. /**
  69618. * Defines the location of the file to load
  69619. */
  69620. url: string);
  69621. /**
  69622. * Execute the current task
  69623. * @param scene defines the scene where you want your assets to be loaded
  69624. * @param onSuccess is a callback called when the task is successfully executed
  69625. * @param onError is a callback called if an error occurs
  69626. */
  69627. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69628. }
  69629. /**
  69630. * Define a task used by AssetsManager to load binary data
  69631. */
  69632. export class BinaryFileAssetTask extends AbstractAssetTask {
  69633. /**
  69634. * Defines the name of the task
  69635. */
  69636. name: string;
  69637. /**
  69638. * Defines the location of the file to load
  69639. */
  69640. url: string;
  69641. /**
  69642. * Gets the lodaded data (as an array buffer)
  69643. */
  69644. data: ArrayBuffer;
  69645. /**
  69646. * Callback called when the task is successful
  69647. */
  69648. onSuccess: (task: BinaryFileAssetTask) => void;
  69649. /**
  69650. * Callback called when the task is successful
  69651. */
  69652. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69653. /**
  69654. * Creates a new BinaryFileAssetTask object
  69655. * @param name defines the name of the new task
  69656. * @param url defines the location of the file to load
  69657. */
  69658. constructor(
  69659. /**
  69660. * Defines the name of the task
  69661. */
  69662. name: string,
  69663. /**
  69664. * Defines the location of the file to load
  69665. */
  69666. url: string);
  69667. /**
  69668. * Execute the current task
  69669. * @param scene defines the scene where you want your assets to be loaded
  69670. * @param onSuccess is a callback called when the task is successfully executed
  69671. * @param onError is a callback called if an error occurs
  69672. */
  69673. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69674. }
  69675. /**
  69676. * Define a task used by AssetsManager to load images
  69677. */
  69678. export class ImageAssetTask extends AbstractAssetTask {
  69679. /**
  69680. * Defines the name of the task
  69681. */
  69682. name: string;
  69683. /**
  69684. * Defines the location of the image to load
  69685. */
  69686. url: string;
  69687. /**
  69688. * Gets the loaded images
  69689. */
  69690. image: HTMLImageElement;
  69691. /**
  69692. * Callback called when the task is successful
  69693. */
  69694. onSuccess: (task: ImageAssetTask) => void;
  69695. /**
  69696. * Callback called when the task is successful
  69697. */
  69698. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69699. /**
  69700. * Creates a new ImageAssetTask
  69701. * @param name defines the name of the task
  69702. * @param url defines the location of the image to load
  69703. */
  69704. constructor(
  69705. /**
  69706. * Defines the name of the task
  69707. */
  69708. name: string,
  69709. /**
  69710. * Defines the location of the image to load
  69711. */
  69712. url: string);
  69713. /**
  69714. * Execute the current task
  69715. * @param scene defines the scene where you want your assets to be loaded
  69716. * @param onSuccess is a callback called when the task is successfully executed
  69717. * @param onError is a callback called if an error occurs
  69718. */
  69719. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69720. }
  69721. /**
  69722. * Defines the interface used by texture loading tasks
  69723. */
  69724. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69725. /**
  69726. * Gets the loaded texture
  69727. */
  69728. texture: TEX;
  69729. }
  69730. /**
  69731. * Define a task used by AssetsManager to load 2D textures
  69732. */
  69733. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69734. /**
  69735. * Defines the name of the task
  69736. */
  69737. name: string;
  69738. /**
  69739. * Defines the location of the file to load
  69740. */
  69741. url: string;
  69742. /**
  69743. * Defines if mipmap should not be generated (default is false)
  69744. */
  69745. noMipmap?: boolean | undefined;
  69746. /**
  69747. * Defines if texture must be inverted on Y axis (default is true)
  69748. */
  69749. invertY: boolean;
  69750. /**
  69751. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69752. */
  69753. samplingMode: number;
  69754. /**
  69755. * Gets the loaded texture
  69756. */
  69757. texture: Texture;
  69758. /**
  69759. * Callback called when the task is successful
  69760. */
  69761. onSuccess: (task: TextureAssetTask) => void;
  69762. /**
  69763. * Callback called when the task is successful
  69764. */
  69765. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69766. /**
  69767. * Creates a new TextureAssetTask object
  69768. * @param name defines the name of the task
  69769. * @param url defines the location of the file to load
  69770. * @param noMipmap defines if mipmap should not be generated (default is false)
  69771. * @param invertY defines if texture must be inverted on Y axis (default is true)
  69772. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69773. */
  69774. constructor(
  69775. /**
  69776. * Defines the name of the task
  69777. */
  69778. name: string,
  69779. /**
  69780. * Defines the location of the file to load
  69781. */
  69782. url: string,
  69783. /**
  69784. * Defines if mipmap should not be generated (default is false)
  69785. */
  69786. noMipmap?: boolean | undefined,
  69787. /**
  69788. * Defines if texture must be inverted on Y axis (default is true)
  69789. */
  69790. invertY?: boolean,
  69791. /**
  69792. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69793. */
  69794. samplingMode?: number);
  69795. /**
  69796. * Execute the current task
  69797. * @param scene defines the scene where you want your assets to be loaded
  69798. * @param onSuccess is a callback called when the task is successfully executed
  69799. * @param onError is a callback called if an error occurs
  69800. */
  69801. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69802. }
  69803. /**
  69804. * Define a task used by AssetsManager to load cube textures
  69805. */
  69806. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69807. /**
  69808. * Defines the name of the task
  69809. */
  69810. name: string;
  69811. /**
  69812. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69813. */
  69814. url: string;
  69815. /**
  69816. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69817. */
  69818. extensions?: string[] | undefined;
  69819. /**
  69820. * Defines if mipmaps should not be generated (default is false)
  69821. */
  69822. noMipmap?: boolean | undefined;
  69823. /**
  69824. * Defines the explicit list of files (undefined by default)
  69825. */
  69826. files?: string[] | undefined;
  69827. /**
  69828. * Gets the loaded texture
  69829. */
  69830. texture: CubeTexture;
  69831. /**
  69832. * Callback called when the task is successful
  69833. */
  69834. onSuccess: (task: CubeTextureAssetTask) => void;
  69835. /**
  69836. * Callback called when the task is successful
  69837. */
  69838. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69839. /**
  69840. * Creates a new CubeTextureAssetTask
  69841. * @param name defines the name of the task
  69842. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69843. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69844. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69845. * @param files defines the explicit list of files (undefined by default)
  69846. */
  69847. constructor(
  69848. /**
  69849. * Defines the name of the task
  69850. */
  69851. name: string,
  69852. /**
  69853. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69854. */
  69855. url: string,
  69856. /**
  69857. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69858. */
  69859. extensions?: string[] | undefined,
  69860. /**
  69861. * Defines if mipmaps should not be generated (default is false)
  69862. */
  69863. noMipmap?: boolean | undefined,
  69864. /**
  69865. * Defines the explicit list of files (undefined by default)
  69866. */
  69867. files?: string[] | undefined);
  69868. /**
  69869. * Execute the current task
  69870. * @param scene defines the scene where you want your assets to be loaded
  69871. * @param onSuccess is a callback called when the task is successfully executed
  69872. * @param onError is a callback called if an error occurs
  69873. */
  69874. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69875. }
  69876. /**
  69877. * Define a task used by AssetsManager to load HDR cube textures
  69878. */
  69879. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  69880. /**
  69881. * Defines the name of the task
  69882. */
  69883. name: string;
  69884. /**
  69885. * Defines the location of the file to load
  69886. */
  69887. url: string;
  69888. /**
  69889. * Defines the desired size (the more it increases the longer the generation will be)
  69890. */
  69891. size: number;
  69892. /**
  69893. * Defines if mipmaps should not be generated (default is false)
  69894. */
  69895. noMipmap: boolean;
  69896. /**
  69897. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69898. */
  69899. generateHarmonics: boolean;
  69900. /**
  69901. * 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)
  69902. */
  69903. gammaSpace: boolean;
  69904. /**
  69905. * Internal Use Only
  69906. */
  69907. reserved: boolean;
  69908. /**
  69909. * Gets the loaded texture
  69910. */
  69911. texture: HDRCubeTexture;
  69912. /**
  69913. * Callback called when the task is successful
  69914. */
  69915. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  69916. /**
  69917. * Callback called when the task is successful
  69918. */
  69919. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  69920. /**
  69921. * Creates a new HDRCubeTextureAssetTask object
  69922. * @param name defines the name of the task
  69923. * @param url defines the location of the file to load
  69924. * @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.
  69925. * @param noMipmap defines if mipmaps should not be generated (default is false)
  69926. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69927. * @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)
  69928. * @param reserved Internal use only
  69929. */
  69930. constructor(
  69931. /**
  69932. * Defines the name of the task
  69933. */
  69934. name: string,
  69935. /**
  69936. * Defines the location of the file to load
  69937. */
  69938. url: string,
  69939. /**
  69940. * Defines the desired size (the more it increases the longer the generation will be)
  69941. */
  69942. size: number,
  69943. /**
  69944. * Defines if mipmaps should not be generated (default is false)
  69945. */
  69946. noMipmap?: boolean,
  69947. /**
  69948. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  69949. */
  69950. generateHarmonics?: boolean,
  69951. /**
  69952. * 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)
  69953. */
  69954. gammaSpace?: boolean,
  69955. /**
  69956. * Internal Use Only
  69957. */
  69958. reserved?: boolean);
  69959. /**
  69960. * Execute the current task
  69961. * @param scene defines the scene where you want your assets to be loaded
  69962. * @param onSuccess is a callback called when the task is successfully executed
  69963. * @param onError is a callback called if an error occurs
  69964. */
  69965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69966. }
  69967. /**
  69968. * Define a task used by AssetsManager to load Equirectangular cube textures
  69969. */
  69970. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  69971. /**
  69972. * Defines the name of the task
  69973. */
  69974. name: string;
  69975. /**
  69976. * Defines the location of the file to load
  69977. */
  69978. url: string;
  69979. /**
  69980. * Defines the desired size (the more it increases the longer the generation will be)
  69981. */
  69982. size: number;
  69983. /**
  69984. * Defines if mipmaps should not be generated (default is false)
  69985. */
  69986. noMipmap: boolean;
  69987. /**
  69988. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  69989. * but the standard material would require them in Gamma space) (default is true)
  69990. */
  69991. gammaSpace: boolean;
  69992. /**
  69993. * Gets the loaded texture
  69994. */
  69995. texture: EquiRectangularCubeTexture;
  69996. /**
  69997. * Callback called when the task is successful
  69998. */
  69999. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70000. /**
  70001. * Callback called when the task is successful
  70002. */
  70003. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70004. /**
  70005. * Creates a new EquiRectangularCubeTextureAssetTask object
  70006. * @param name defines the name of the task
  70007. * @param url defines the location of the file to load
  70008. * @param size defines the desired size (the more it increases the longer the generation will be)
  70009. * If the size is omitted this implies you are using a preprocessed cubemap.
  70010. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70011. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70012. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70013. * (default is true)
  70014. */
  70015. constructor(
  70016. /**
  70017. * Defines the name of the task
  70018. */
  70019. name: string,
  70020. /**
  70021. * Defines the location of the file to load
  70022. */
  70023. url: string,
  70024. /**
  70025. * Defines the desired size (the more it increases the longer the generation will be)
  70026. */
  70027. size: number,
  70028. /**
  70029. * Defines if mipmaps should not be generated (default is false)
  70030. */
  70031. noMipmap?: boolean,
  70032. /**
  70033. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70034. * but the standard material would require them in Gamma space) (default is true)
  70035. */
  70036. gammaSpace?: boolean);
  70037. /**
  70038. * Execute the current task
  70039. * @param scene defines the scene where you want your assets to be loaded
  70040. * @param onSuccess is a callback called when the task is successfully executed
  70041. * @param onError is a callback called if an error occurs
  70042. */
  70043. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70044. }
  70045. /**
  70046. * This class can be used to easily import assets into a scene
  70047. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70048. */
  70049. export class AssetsManager {
  70050. private _scene;
  70051. private _isLoading;
  70052. protected _tasks: AbstractAssetTask[];
  70053. protected _waitingTasksCount: number;
  70054. protected _totalTasksCount: number;
  70055. /**
  70056. * Callback called when all tasks are processed
  70057. */
  70058. onFinish: (tasks: AbstractAssetTask[]) => void;
  70059. /**
  70060. * Callback called when a task is successful
  70061. */
  70062. onTaskSuccess: (task: AbstractAssetTask) => void;
  70063. /**
  70064. * Callback called when a task had an error
  70065. */
  70066. onTaskError: (task: AbstractAssetTask) => void;
  70067. /**
  70068. * Callback called when a task is done (whatever the result is)
  70069. */
  70070. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70071. /**
  70072. * Observable called when all tasks are processed
  70073. */
  70074. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70075. /**
  70076. * Observable called when a task had an error
  70077. */
  70078. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70079. /**
  70080. * Observable called when all tasks were executed
  70081. */
  70082. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70083. /**
  70084. * Observable called when a task is done (whatever the result is)
  70085. */
  70086. onProgressObservable: Observable<IAssetsProgressEvent>;
  70087. /**
  70088. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70089. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70090. */
  70091. useDefaultLoadingScreen: boolean;
  70092. /**
  70093. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70094. * when all assets have been downloaded.
  70095. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70096. */
  70097. autoHideLoadingUI: boolean;
  70098. /**
  70099. * Creates a new AssetsManager
  70100. * @param scene defines the scene to work on
  70101. */
  70102. constructor(scene: Scene);
  70103. /**
  70104. * Add a MeshAssetTask to the list of active tasks
  70105. * @param taskName defines the name of the new task
  70106. * @param meshesNames defines the name of meshes to load
  70107. * @param rootUrl defines the root url to use to locate files
  70108. * @param sceneFilename defines the filename of the scene file
  70109. * @returns a new MeshAssetTask object
  70110. */
  70111. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70112. /**
  70113. * Add a TextFileAssetTask to the list of active tasks
  70114. * @param taskName defines the name of the new task
  70115. * @param url defines the url of the file to load
  70116. * @returns a new TextFileAssetTask object
  70117. */
  70118. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70119. /**
  70120. * Add a BinaryFileAssetTask to the list of active tasks
  70121. * @param taskName defines the name of the new task
  70122. * @param url defines the url of the file to load
  70123. * @returns a new BinaryFileAssetTask object
  70124. */
  70125. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70126. /**
  70127. * Add a ImageAssetTask to the list of active tasks
  70128. * @param taskName defines the name of the new task
  70129. * @param url defines the url of the file to load
  70130. * @returns a new ImageAssetTask object
  70131. */
  70132. addImageTask(taskName: string, url: string): ImageAssetTask;
  70133. /**
  70134. * Add a TextureAssetTask to the list of active tasks
  70135. * @param taskName defines the name of the new task
  70136. * @param url defines the url of the file to load
  70137. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70138. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70139. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70140. * @returns a new TextureAssetTask object
  70141. */
  70142. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70143. /**
  70144. * Add a CubeTextureAssetTask to the list of active tasks
  70145. * @param taskName defines the name of the new task
  70146. * @param url defines the url of the file to load
  70147. * @param extensions defines the extension to use to load the cube map (can be null)
  70148. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70149. * @param files defines the list of files to load (can be null)
  70150. * @returns a new CubeTextureAssetTask object
  70151. */
  70152. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70153. /**
  70154. *
  70155. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70156. * @param taskName defines the name of the new task
  70157. * @param url defines the url of the file to load
  70158. * @param size defines the size you want for the cubemap (can be null)
  70159. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70160. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70161. * @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)
  70162. * @param reserved Internal use only
  70163. * @returns a new HDRCubeTextureAssetTask object
  70164. */
  70165. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70166. /**
  70167. *
  70168. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70169. * @param taskName defines the name of the new task
  70170. * @param url defines the url of the file to load
  70171. * @param size defines the size you want for the cubemap (can be null)
  70172. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70173. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70174. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70175. * @returns a new EquiRectangularCubeTextureAssetTask object
  70176. */
  70177. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70178. /**
  70179. * Remove a task from the assets manager.
  70180. * @param task the task to remove
  70181. */
  70182. removeTask(task: AbstractAssetTask): void;
  70183. private _decreaseWaitingTasksCount;
  70184. private _runTask;
  70185. /**
  70186. * Reset the AssetsManager and remove all tasks
  70187. * @return the current instance of the AssetsManager
  70188. */
  70189. reset(): AssetsManager;
  70190. /**
  70191. * Start the loading process
  70192. * @return the current instance of the AssetsManager
  70193. */
  70194. load(): AssetsManager;
  70195. /**
  70196. * Start the loading process as an async operation
  70197. * @return a promise returning the list of failed tasks
  70198. */
  70199. loadAsync(): Promise<void>;
  70200. }
  70201. }
  70202. declare module BABYLON {
  70203. /**
  70204. * Wrapper class for promise with external resolve and reject.
  70205. */
  70206. export class Deferred<T> {
  70207. /**
  70208. * The promise associated with this deferred object.
  70209. */
  70210. readonly promise: Promise<T>;
  70211. private _resolve;
  70212. private _reject;
  70213. /**
  70214. * The resolve method of the promise associated with this deferred object.
  70215. */
  70216. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  70217. /**
  70218. * The reject method of the promise associated with this deferred object.
  70219. */
  70220. get reject(): (reason?: any) => void;
  70221. /**
  70222. * Constructor for this deferred object.
  70223. */
  70224. constructor();
  70225. }
  70226. }
  70227. declare module BABYLON {
  70228. /**
  70229. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70230. */
  70231. export class MeshExploder {
  70232. private _centerMesh;
  70233. private _meshes;
  70234. private _meshesOrigins;
  70235. private _toCenterVectors;
  70236. private _scaledDirection;
  70237. private _newPosition;
  70238. private _centerPosition;
  70239. /**
  70240. * Explodes meshes from a center mesh.
  70241. * @param meshes The meshes to explode.
  70242. * @param centerMesh The mesh to be center of explosion.
  70243. */
  70244. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70245. private _setCenterMesh;
  70246. /**
  70247. * Get class name
  70248. * @returns "MeshExploder"
  70249. */
  70250. getClassName(): string;
  70251. /**
  70252. * "Exploded meshes"
  70253. * @returns Array of meshes with the centerMesh at index 0.
  70254. */
  70255. getMeshes(): Array<Mesh>;
  70256. /**
  70257. * Explodes meshes giving a specific direction
  70258. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70259. */
  70260. explode(direction?: number): void;
  70261. }
  70262. }
  70263. declare module BABYLON {
  70264. /**
  70265. * Class used to help managing file picking and drag'n'drop
  70266. */
  70267. export class FilesInput {
  70268. /**
  70269. * List of files ready to be loaded
  70270. */
  70271. static get FilesToLoad(): {
  70272. [key: string]: File;
  70273. };
  70274. /**
  70275. * Callback called when a file is processed
  70276. */
  70277. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70278. private _engine;
  70279. private _currentScene;
  70280. private _sceneLoadedCallback;
  70281. private _progressCallback;
  70282. private _additionalRenderLoopLogicCallback;
  70283. private _textureLoadingCallback;
  70284. private _startingProcessingFilesCallback;
  70285. private _onReloadCallback;
  70286. private _errorCallback;
  70287. private _elementToMonitor;
  70288. private _sceneFileToLoad;
  70289. private _filesToLoad;
  70290. /**
  70291. * Creates a new FilesInput
  70292. * @param engine defines the rendering engine
  70293. * @param scene defines the hosting scene
  70294. * @param sceneLoadedCallback callback called when scene is loaded
  70295. * @param progressCallback callback called to track progress
  70296. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70297. * @param textureLoadingCallback callback called when a texture is loading
  70298. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70299. * @param onReloadCallback callback called when a reload is requested
  70300. * @param errorCallback callback call if an error occurs
  70301. */
  70302. 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);
  70303. private _dragEnterHandler;
  70304. private _dragOverHandler;
  70305. private _dropHandler;
  70306. /**
  70307. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70308. * @param elementToMonitor defines the DOM element to track
  70309. */
  70310. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70311. /**
  70312. * Release all associated resources
  70313. */
  70314. dispose(): void;
  70315. private renderFunction;
  70316. private drag;
  70317. private drop;
  70318. private _traverseFolder;
  70319. private _processFiles;
  70320. /**
  70321. * Load files from a drop event
  70322. * @param event defines the drop event to use as source
  70323. */
  70324. loadFiles(event: any): void;
  70325. private _processReload;
  70326. /**
  70327. * Reload the current scene from the loaded files
  70328. */
  70329. reload(): void;
  70330. }
  70331. }
  70332. declare module BABYLON {
  70333. /**
  70334. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70335. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70336. */
  70337. export class SceneOptimization {
  70338. /**
  70339. * Defines the priority of this optimization (0 by default which means first in the list)
  70340. */
  70341. priority: number;
  70342. /**
  70343. * Gets a string describing the action executed by the current optimization
  70344. * @returns description string
  70345. */
  70346. getDescription(): string;
  70347. /**
  70348. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70349. * @param scene defines the current scene where to apply this optimization
  70350. * @param optimizer defines the current optimizer
  70351. * @returns true if everything that can be done was applied
  70352. */
  70353. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70354. /**
  70355. * Creates the SceneOptimization object
  70356. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70357. * @param desc defines the description associated with the optimization
  70358. */
  70359. constructor(
  70360. /**
  70361. * Defines the priority of this optimization (0 by default which means first in the list)
  70362. */
  70363. priority?: number);
  70364. }
  70365. /**
  70366. * Defines an optimization used to reduce the size of render target textures
  70367. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70368. */
  70369. export class TextureOptimization extends SceneOptimization {
  70370. /**
  70371. * Defines the priority of this optimization (0 by default which means first in the list)
  70372. */
  70373. priority: number;
  70374. /**
  70375. * 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
  70376. */
  70377. maximumSize: number;
  70378. /**
  70379. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70380. */
  70381. step: number;
  70382. /**
  70383. * Gets a string describing the action executed by the current optimization
  70384. * @returns description string
  70385. */
  70386. getDescription(): string;
  70387. /**
  70388. * Creates the TextureOptimization object
  70389. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70390. * @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
  70391. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70392. */
  70393. constructor(
  70394. /**
  70395. * Defines the priority of this optimization (0 by default which means first in the list)
  70396. */
  70397. priority?: number,
  70398. /**
  70399. * 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
  70400. */
  70401. maximumSize?: number,
  70402. /**
  70403. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70404. */
  70405. step?: number);
  70406. /**
  70407. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70408. * @param scene defines the current scene where to apply this optimization
  70409. * @param optimizer defines the current optimizer
  70410. * @returns true if everything that can be done was applied
  70411. */
  70412. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70413. }
  70414. /**
  70415. * Defines an optimization used to increase or decrease the rendering resolution
  70416. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70417. */
  70418. export class HardwareScalingOptimization extends SceneOptimization {
  70419. /**
  70420. * Defines the priority of this optimization (0 by default which means first in the list)
  70421. */
  70422. priority: number;
  70423. /**
  70424. * Defines the maximum scale to use (2 by default)
  70425. */
  70426. maximumScale: number;
  70427. /**
  70428. * Defines the step to use between two passes (0.5 by default)
  70429. */
  70430. step: number;
  70431. private _currentScale;
  70432. private _directionOffset;
  70433. /**
  70434. * Gets a string describing the action executed by the current optimization
  70435. * @return description string
  70436. */
  70437. getDescription(): string;
  70438. /**
  70439. * Creates the HardwareScalingOptimization object
  70440. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70441. * @param maximumScale defines the maximum scale to use (2 by default)
  70442. * @param step defines the step to use between two passes (0.5 by default)
  70443. */
  70444. constructor(
  70445. /**
  70446. * Defines the priority of this optimization (0 by default which means first in the list)
  70447. */
  70448. priority?: number,
  70449. /**
  70450. * Defines the maximum scale to use (2 by default)
  70451. */
  70452. maximumScale?: number,
  70453. /**
  70454. * Defines the step to use between two passes (0.5 by default)
  70455. */
  70456. step?: number);
  70457. /**
  70458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70459. * @param scene defines the current scene where to apply this optimization
  70460. * @param optimizer defines the current optimizer
  70461. * @returns true if everything that can be done was applied
  70462. */
  70463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70464. }
  70465. /**
  70466. * Defines an optimization used to remove shadows
  70467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70468. */
  70469. export class ShadowsOptimization extends SceneOptimization {
  70470. /**
  70471. * Gets a string describing the action executed by the current optimization
  70472. * @return description string
  70473. */
  70474. getDescription(): string;
  70475. /**
  70476. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70477. * @param scene defines the current scene where to apply this optimization
  70478. * @param optimizer defines the current optimizer
  70479. * @returns true if everything that can be done was applied
  70480. */
  70481. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70482. }
  70483. /**
  70484. * Defines an optimization used to turn post-processes off
  70485. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70486. */
  70487. export class PostProcessesOptimization extends SceneOptimization {
  70488. /**
  70489. * Gets a string describing the action executed by the current optimization
  70490. * @return description string
  70491. */
  70492. getDescription(): string;
  70493. /**
  70494. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70495. * @param scene defines the current scene where to apply this optimization
  70496. * @param optimizer defines the current optimizer
  70497. * @returns true if everything that can be done was applied
  70498. */
  70499. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70500. }
  70501. /**
  70502. * Defines an optimization used to turn lens flares off
  70503. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70504. */
  70505. export class LensFlaresOptimization extends SceneOptimization {
  70506. /**
  70507. * Gets a string describing the action executed by the current optimization
  70508. * @return description string
  70509. */
  70510. getDescription(): string;
  70511. /**
  70512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70513. * @param scene defines the current scene where to apply this optimization
  70514. * @param optimizer defines the current optimizer
  70515. * @returns true if everything that can be done was applied
  70516. */
  70517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70518. }
  70519. /**
  70520. * Defines an optimization based on user defined callback.
  70521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70522. */
  70523. export class CustomOptimization extends SceneOptimization {
  70524. /**
  70525. * Callback called to apply the custom optimization.
  70526. */
  70527. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70528. /**
  70529. * Callback called to get custom description
  70530. */
  70531. onGetDescription: () => string;
  70532. /**
  70533. * Gets a string describing the action executed by the current optimization
  70534. * @returns description string
  70535. */
  70536. getDescription(): string;
  70537. /**
  70538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70539. * @param scene defines the current scene where to apply this optimization
  70540. * @param optimizer defines the current optimizer
  70541. * @returns true if everything that can be done was applied
  70542. */
  70543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70544. }
  70545. /**
  70546. * Defines an optimization used to turn particles off
  70547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70548. */
  70549. export class ParticlesOptimization extends SceneOptimization {
  70550. /**
  70551. * Gets a string describing the action executed by the current optimization
  70552. * @return description string
  70553. */
  70554. getDescription(): string;
  70555. /**
  70556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70557. * @param scene defines the current scene where to apply this optimization
  70558. * @param optimizer defines the current optimizer
  70559. * @returns true if everything that can be done was applied
  70560. */
  70561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70562. }
  70563. /**
  70564. * Defines an optimization used to turn render targets off
  70565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70566. */
  70567. export class RenderTargetsOptimization extends SceneOptimization {
  70568. /**
  70569. * Gets a string describing the action executed by the current optimization
  70570. * @return description string
  70571. */
  70572. getDescription(): string;
  70573. /**
  70574. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70575. * @param scene defines the current scene where to apply this optimization
  70576. * @param optimizer defines the current optimizer
  70577. * @returns true if everything that can be done was applied
  70578. */
  70579. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70580. }
  70581. /**
  70582. * Defines an optimization used to merge meshes with compatible materials
  70583. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70584. */
  70585. export class MergeMeshesOptimization extends SceneOptimization {
  70586. private static _UpdateSelectionTree;
  70587. /**
  70588. * Gets or sets a boolean which defines if optimization octree has to be updated
  70589. */
  70590. static get UpdateSelectionTree(): boolean;
  70591. /**
  70592. * Gets or sets a boolean which defines if optimization octree has to be updated
  70593. */
  70594. static set UpdateSelectionTree(value: boolean);
  70595. /**
  70596. * Gets a string describing the action executed by the current optimization
  70597. * @return description string
  70598. */
  70599. getDescription(): string;
  70600. private _canBeMerged;
  70601. /**
  70602. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70603. * @param scene defines the current scene where to apply this optimization
  70604. * @param optimizer defines the current optimizer
  70605. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70606. * @returns true if everything that can be done was applied
  70607. */
  70608. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70609. }
  70610. /**
  70611. * Defines a list of options used by SceneOptimizer
  70612. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70613. */
  70614. export class SceneOptimizerOptions {
  70615. /**
  70616. * Defines the target frame rate to reach (60 by default)
  70617. */
  70618. targetFrameRate: number;
  70619. /**
  70620. * Defines the interval between two checkes (2000ms by default)
  70621. */
  70622. trackerDuration: number;
  70623. /**
  70624. * Gets the list of optimizations to apply
  70625. */
  70626. optimizations: SceneOptimization[];
  70627. /**
  70628. * Creates a new list of options used by SceneOptimizer
  70629. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70630. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70631. */
  70632. constructor(
  70633. /**
  70634. * Defines the target frame rate to reach (60 by default)
  70635. */
  70636. targetFrameRate?: number,
  70637. /**
  70638. * Defines the interval between two checkes (2000ms by default)
  70639. */
  70640. trackerDuration?: number);
  70641. /**
  70642. * Add a new optimization
  70643. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70644. * @returns the current SceneOptimizerOptions
  70645. */
  70646. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70647. /**
  70648. * Add a new custom optimization
  70649. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70650. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70651. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70652. * @returns the current SceneOptimizerOptions
  70653. */
  70654. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70655. /**
  70656. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70657. * @param targetFrameRate defines the target frame rate (60 by default)
  70658. * @returns a SceneOptimizerOptions object
  70659. */
  70660. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70661. /**
  70662. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70663. * @param targetFrameRate defines the target frame rate (60 by default)
  70664. * @returns a SceneOptimizerOptions object
  70665. */
  70666. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70667. /**
  70668. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70669. * @param targetFrameRate defines the target frame rate (60 by default)
  70670. * @returns a SceneOptimizerOptions object
  70671. */
  70672. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70673. }
  70674. /**
  70675. * Class used to run optimizations in order to reach a target frame rate
  70676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70677. */
  70678. export class SceneOptimizer implements IDisposable {
  70679. private _isRunning;
  70680. private _options;
  70681. private _scene;
  70682. private _currentPriorityLevel;
  70683. private _targetFrameRate;
  70684. private _trackerDuration;
  70685. private _currentFrameRate;
  70686. private _sceneDisposeObserver;
  70687. private _improvementMode;
  70688. /**
  70689. * Defines an observable called when the optimizer reaches the target frame rate
  70690. */
  70691. onSuccessObservable: Observable<SceneOptimizer>;
  70692. /**
  70693. * Defines an observable called when the optimizer enables an optimization
  70694. */
  70695. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70696. /**
  70697. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70698. */
  70699. onFailureObservable: Observable<SceneOptimizer>;
  70700. /**
  70701. * Gets a boolean indicating if the optimizer is in improvement mode
  70702. */
  70703. get isInImprovementMode(): boolean;
  70704. /**
  70705. * Gets the current priority level (0 at start)
  70706. */
  70707. get currentPriorityLevel(): number;
  70708. /**
  70709. * Gets the current frame rate checked by the SceneOptimizer
  70710. */
  70711. get currentFrameRate(): number;
  70712. /**
  70713. * Gets or sets the current target frame rate (60 by default)
  70714. */
  70715. get targetFrameRate(): number;
  70716. /**
  70717. * Gets or sets the current target frame rate (60 by default)
  70718. */
  70719. set targetFrameRate(value: number);
  70720. /**
  70721. * Gets or sets the current interval between two checks (every 2000ms by default)
  70722. */
  70723. get trackerDuration(): number;
  70724. /**
  70725. * Gets or sets the current interval between two checks (every 2000ms by default)
  70726. */
  70727. set trackerDuration(value: number);
  70728. /**
  70729. * Gets the list of active optimizations
  70730. */
  70731. get optimizations(): SceneOptimization[];
  70732. /**
  70733. * Creates a new SceneOptimizer
  70734. * @param scene defines the scene to work on
  70735. * @param options defines the options to use with the SceneOptimizer
  70736. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70737. * @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)
  70738. */
  70739. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70740. /**
  70741. * Stops the current optimizer
  70742. */
  70743. stop(): void;
  70744. /**
  70745. * Reset the optimizer to initial step (current priority level = 0)
  70746. */
  70747. reset(): void;
  70748. /**
  70749. * Start the optimizer. By default it will try to reach a specific framerate
  70750. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70751. */
  70752. start(): void;
  70753. private _checkCurrentState;
  70754. /**
  70755. * Release all resources
  70756. */
  70757. dispose(): void;
  70758. /**
  70759. * Helper function to create a SceneOptimizer with one single line of code
  70760. * @param scene defines the scene to work on
  70761. * @param options defines the options to use with the SceneOptimizer
  70762. * @param onSuccess defines a callback to call on success
  70763. * @param onFailure defines a callback to call on failure
  70764. * @returns the new SceneOptimizer object
  70765. */
  70766. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70767. }
  70768. }
  70769. declare module BABYLON {
  70770. /**
  70771. * Class used to serialize a scene into a string
  70772. */
  70773. export class SceneSerializer {
  70774. /**
  70775. * Clear cache used by a previous serialization
  70776. */
  70777. static ClearCache(): void;
  70778. /**
  70779. * Serialize a scene into a JSON compatible object
  70780. * @param scene defines the scene to serialize
  70781. * @returns a JSON compatible object
  70782. */
  70783. static Serialize(scene: Scene): any;
  70784. /**
  70785. * Serialize a mesh into a JSON compatible object
  70786. * @param toSerialize defines the mesh to serialize
  70787. * @param withParents defines if parents must be serialized as well
  70788. * @param withChildren defines if children must be serialized as well
  70789. * @returns a JSON compatible object
  70790. */
  70791. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70792. }
  70793. }
  70794. declare module BABYLON {
  70795. /**
  70796. * Class used to host texture specific utilities
  70797. */
  70798. export class TextureTools {
  70799. /**
  70800. * Uses the GPU to create a copy texture rescaled at a given size
  70801. * @param texture Texture to copy from
  70802. * @param width defines the desired width
  70803. * @param height defines the desired height
  70804. * @param useBilinearMode defines if bilinear mode has to be used
  70805. * @return the generated texture
  70806. */
  70807. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70808. }
  70809. }
  70810. declare module BABYLON {
  70811. /**
  70812. * This represents the different options available for the video capture.
  70813. */
  70814. export interface VideoRecorderOptions {
  70815. /** Defines the mime type of the video. */
  70816. mimeType: string;
  70817. /** Defines the FPS the video should be recorded at. */
  70818. fps: number;
  70819. /** Defines the chunk size for the recording data. */
  70820. recordChunckSize: number;
  70821. /** The audio tracks to attach to the recording. */
  70822. audioTracks?: MediaStreamTrack[];
  70823. }
  70824. /**
  70825. * This can help with recording videos from BabylonJS.
  70826. * This is based on the available WebRTC functionalities of the browser.
  70827. *
  70828. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  70829. */
  70830. export class VideoRecorder {
  70831. private static readonly _defaultOptions;
  70832. /**
  70833. * Returns whether or not the VideoRecorder is available in your browser.
  70834. * @param engine Defines the Babylon Engine.
  70835. * @returns true if supported otherwise false.
  70836. */
  70837. static IsSupported(engine: Engine): boolean;
  70838. private readonly _options;
  70839. private _canvas;
  70840. private _mediaRecorder;
  70841. private _recordedChunks;
  70842. private _fileName;
  70843. private _resolve;
  70844. private _reject;
  70845. /**
  70846. * True when a recording is already in progress.
  70847. */
  70848. get isRecording(): boolean;
  70849. /**
  70850. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  70851. * @param engine Defines the BabylonJS Engine you wish to record.
  70852. * @param options Defines options that can be used to customize the capture.
  70853. */
  70854. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  70855. /**
  70856. * Stops the current recording before the default capture timeout passed in the startRecording function.
  70857. */
  70858. stopRecording(): void;
  70859. /**
  70860. * Starts recording the canvas for a max duration specified in parameters.
  70861. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  70862. * If null no automatic download will start and you can rely on the promise to get the data back.
  70863. * @param maxDuration Defines the maximum recording time in seconds.
  70864. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  70865. * @return A promise callback at the end of the recording with the video data in Blob.
  70866. */
  70867. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  70868. /**
  70869. * Releases internal resources used during the recording.
  70870. */
  70871. dispose(): void;
  70872. private _handleDataAvailable;
  70873. private _handleError;
  70874. private _handleStop;
  70875. }
  70876. }
  70877. declare module BABYLON {
  70878. /**
  70879. * Class containing a set of static utilities functions for screenshots
  70880. */
  70881. export class ScreenshotTools {
  70882. /**
  70883. * Captures a screenshot of the current rendering
  70884. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70885. * @param engine defines the rendering engine
  70886. * @param camera defines the source camera
  70887. * @param size This parameter can be set to a single number or to an object with the
  70888. * following (optional) properties: precision, width, height. If a single number is passed,
  70889. * it will be used for both width and height. If an object is passed, the screenshot size
  70890. * will be derived from the parameters. The precision property is a multiplier allowing
  70891. * rendering at a higher or lower resolution
  70892. * @param successCallback defines the callback receives a single parameter which contains the
  70893. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70894. * src parameter of an <img> to display it
  70895. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70896. * Check your browser for supported MIME types
  70897. */
  70898. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  70899. /**
  70900. * Captures a screenshot of the current rendering
  70901. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70902. * @param engine defines the rendering engine
  70903. * @param camera defines the source camera
  70904. * @param size This parameter can be set to a single number or to an object with the
  70905. * following (optional) properties: precision, width, height. If a single number is passed,
  70906. * it will be used for both width and height. If an object is passed, the screenshot size
  70907. * will be derived from the parameters. The precision property is a multiplier allowing
  70908. * rendering at a higher or lower resolution
  70909. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  70910. * Check your browser for supported MIME types
  70911. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70912. * to the src parameter of an <img> to display it
  70913. */
  70914. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  70915. /**
  70916. * Generates an image screenshot from the specified camera.
  70917. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70918. * @param engine The engine to use for rendering
  70919. * @param camera The camera to use for rendering
  70920. * @param size This parameter can be set to a single number or to an object with the
  70921. * following (optional) properties: precision, width, height. If a single number is passed,
  70922. * it will be used for both width and height. If an object is passed, the screenshot size
  70923. * will be derived from the parameters. The precision property is a multiplier allowing
  70924. * rendering at a higher or lower resolution
  70925. * @param successCallback The callback receives a single parameter which contains the
  70926. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  70927. * src parameter of an <img> to display it
  70928. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70929. * Check your browser for supported MIME types
  70930. * @param samples Texture samples (default: 1)
  70931. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70932. * @param fileName A name for for the downloaded file.
  70933. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70934. */
  70935. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  70936. /**
  70937. * Generates an image screenshot from the specified camera.
  70938. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  70939. * @param engine The engine to use for rendering
  70940. * @param camera The camera to use for rendering
  70941. * @param size This parameter can be set to a single number or to an object with the
  70942. * following (optional) properties: precision, width, height. If a single number is passed,
  70943. * it will be used for both width and height. If an object is passed, the screenshot size
  70944. * will be derived from the parameters. The precision property is a multiplier allowing
  70945. * rendering at a higher or lower resolution
  70946. * @param mimeType The MIME type of the screenshot image (default: image/png).
  70947. * Check your browser for supported MIME types
  70948. * @param samples Texture samples (default: 1)
  70949. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  70950. * @param fileName A name for for the downloaded file.
  70951. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  70952. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  70953. * to the src parameter of an <img> to display it
  70954. */
  70955. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  70956. /**
  70957. * Gets height and width for screenshot size
  70958. * @private
  70959. */
  70960. private static _getScreenshotSize;
  70961. }
  70962. }
  70963. declare module BABYLON {
  70964. /**
  70965. * Interface for a data buffer
  70966. */
  70967. export interface IDataBuffer {
  70968. /**
  70969. * Reads bytes from the data buffer.
  70970. * @param byteOffset The byte offset to read
  70971. * @param byteLength The byte length to read
  70972. * @returns A promise that resolves when the bytes are read
  70973. */
  70974. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  70975. /**
  70976. * The byte length of the buffer.
  70977. */
  70978. readonly byteLength: number;
  70979. }
  70980. /**
  70981. * Utility class for reading from a data buffer
  70982. */
  70983. export class DataReader {
  70984. /**
  70985. * The data buffer associated with this data reader.
  70986. */
  70987. readonly buffer: IDataBuffer;
  70988. /**
  70989. * The current byte offset from the beginning of the data buffer.
  70990. */
  70991. byteOffset: number;
  70992. private _dataView;
  70993. private _dataByteOffset;
  70994. /**
  70995. * Constructor
  70996. * @param buffer The buffer to read
  70997. */
  70998. constructor(buffer: IDataBuffer);
  70999. /**
  71000. * Loads the given byte length.
  71001. * @param byteLength The byte length to load
  71002. * @returns A promise that resolves when the load is complete
  71003. */
  71004. loadAsync(byteLength: number): Promise<void>;
  71005. /**
  71006. * Read a unsigned 32-bit integer from the currently loaded data range.
  71007. * @returns The 32-bit integer read
  71008. */
  71009. readUint32(): number;
  71010. /**
  71011. * Read a byte array from the currently loaded data range.
  71012. * @param byteLength The byte length to read
  71013. * @returns The byte array read
  71014. */
  71015. readUint8Array(byteLength: number): Uint8Array;
  71016. /**
  71017. * Read a string from the currently loaded data range.
  71018. * @param byteLength The byte length to read
  71019. * @returns The string read
  71020. */
  71021. readString(byteLength: number): string;
  71022. /**
  71023. * Skips the given byte length the currently loaded data range.
  71024. * @param byteLength The byte length to skip
  71025. */
  71026. skipBytes(byteLength: number): void;
  71027. }
  71028. }
  71029. declare module BABYLON {
  71030. /**
  71031. * Class for storing data to local storage if available or in-memory storage otherwise
  71032. */
  71033. export class DataStorage {
  71034. private static _Storage;
  71035. private static _GetStorage;
  71036. /**
  71037. * Reads a string from the data storage
  71038. * @param key The key to read
  71039. * @param defaultValue The value if the key doesn't exist
  71040. * @returns The string value
  71041. */
  71042. static ReadString(key: string, defaultValue: string): string;
  71043. /**
  71044. * Writes a string to the data storage
  71045. * @param key The key to write
  71046. * @param value The value to write
  71047. */
  71048. static WriteString(key: string, value: string): void;
  71049. /**
  71050. * Reads a boolean from the data storage
  71051. * @param key The key to read
  71052. * @param defaultValue The value if the key doesn't exist
  71053. * @returns The boolean value
  71054. */
  71055. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  71056. /**
  71057. * Writes a boolean to the data storage
  71058. * @param key The key to write
  71059. * @param value The value to write
  71060. */
  71061. static WriteBoolean(key: string, value: boolean): void;
  71062. /**
  71063. * Reads a number from the data storage
  71064. * @param key The key to read
  71065. * @param defaultValue The value if the key doesn't exist
  71066. * @returns The number value
  71067. */
  71068. static ReadNumber(key: string, defaultValue: number): number;
  71069. /**
  71070. * Writes a number to the data storage
  71071. * @param key The key to write
  71072. * @param value The value to write
  71073. */
  71074. static WriteNumber(key: string, value: number): void;
  71075. }
  71076. }
  71077. declare module BABYLON {
  71078. /**
  71079. * Options used for hit testing
  71080. */
  71081. export interface IWebXRLegacyHitTestOptions {
  71082. /**
  71083. * Only test when user interacted with the scene. Default - hit test every frame
  71084. */
  71085. testOnPointerDownOnly?: boolean;
  71086. /**
  71087. * The node to use to transform the local results to world coordinates
  71088. */
  71089. worldParentNode?: TransformNode;
  71090. }
  71091. /**
  71092. * Interface defining the babylon result of raycasting/hit-test
  71093. */
  71094. export interface IWebXRLegacyHitResult {
  71095. /**
  71096. * Transformation matrix that can be applied to a node that will put it in the hit point location
  71097. */
  71098. transformationMatrix: Matrix;
  71099. /**
  71100. * The native hit test result
  71101. */
  71102. xrHitResult: XRHitResult | XRHitTestResult;
  71103. }
  71104. /**
  71105. * The currently-working hit-test module.
  71106. * Hit test (or Ray-casting) is used to interact with the real world.
  71107. * For further information read here - https://github.com/immersive-web/hit-test
  71108. */
  71109. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  71110. /**
  71111. * options to use when constructing this feature
  71112. */
  71113. readonly options: IWebXRLegacyHitTestOptions;
  71114. private _direction;
  71115. private _mat;
  71116. private _onSelectEnabled;
  71117. private _origin;
  71118. /**
  71119. * The module's name
  71120. */
  71121. static readonly Name: string;
  71122. /**
  71123. * The (Babylon) version of this module.
  71124. * This is an integer representing the implementation version.
  71125. * This number does not correspond to the WebXR specs version
  71126. */
  71127. static readonly Version: number;
  71128. /**
  71129. * Populated with the last native XR Hit Results
  71130. */
  71131. lastNativeXRHitResults: XRHitResult[];
  71132. /**
  71133. * Triggered when new babylon (transformed) hit test results are available
  71134. */
  71135. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  71136. /**
  71137. * Creates a new instance of the (legacy version) hit test feature
  71138. * @param _xrSessionManager an instance of WebXRSessionManager
  71139. * @param options options to use when constructing this feature
  71140. */
  71141. constructor(_xrSessionManager: WebXRSessionManager,
  71142. /**
  71143. * options to use when constructing this feature
  71144. */
  71145. options?: IWebXRLegacyHitTestOptions);
  71146. /**
  71147. * execute a hit test with an XR Ray
  71148. *
  71149. * @param xrSession a native xrSession that will execute this hit test
  71150. * @param xrRay the ray (position and direction) to use for ray-casting
  71151. * @param referenceSpace native XR reference space to use for the hit-test
  71152. * @param filter filter function that will filter the results
  71153. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71154. */
  71155. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  71156. /**
  71157. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  71158. * @param event the (select) event to use to select with
  71159. * @param referenceSpace the reference space to use for this hit test
  71160. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  71161. */
  71162. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  71163. /**
  71164. * attach this feature
  71165. * Will usually be called by the features manager
  71166. *
  71167. * @returns true if successful.
  71168. */
  71169. attach(): boolean;
  71170. /**
  71171. * detach this feature.
  71172. * Will usually be called by the features manager
  71173. *
  71174. * @returns true if successful.
  71175. */
  71176. detach(): boolean;
  71177. /**
  71178. * Dispose this feature and all of the resources attached
  71179. */
  71180. dispose(): void;
  71181. protected _onXRFrame(frame: XRFrame): void;
  71182. private _onHitTestResults;
  71183. private _onSelect;
  71184. }
  71185. }
  71186. declare module BABYLON {
  71187. /**
  71188. * Options used in the plane detector module
  71189. */
  71190. export interface IWebXRPlaneDetectorOptions {
  71191. /**
  71192. * The node to use to transform the local results to world coordinates
  71193. */
  71194. worldParentNode?: TransformNode;
  71195. }
  71196. /**
  71197. * A babylon interface for a WebXR plane.
  71198. * A Plane is actually a polygon, built from N points in space
  71199. *
  71200. * Supported in chrome 79, not supported in canary 81 ATM
  71201. */
  71202. export interface IWebXRPlane {
  71203. /**
  71204. * a babylon-assigned ID for this polygon
  71205. */
  71206. id: number;
  71207. /**
  71208. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  71209. */
  71210. polygonDefinition: Array<Vector3>;
  71211. /**
  71212. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  71213. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  71214. */
  71215. transformationMatrix: Matrix;
  71216. /**
  71217. * the native xr-plane object
  71218. */
  71219. xrPlane: XRPlane;
  71220. }
  71221. /**
  71222. * The plane detector is used to detect planes in the real world when in AR
  71223. * For more information see https://github.com/immersive-web/real-world-geometry/
  71224. */
  71225. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  71226. private _options;
  71227. private _detectedPlanes;
  71228. private _enabled;
  71229. private _lastFrameDetected;
  71230. /**
  71231. * The module's name
  71232. */
  71233. static readonly Name: string;
  71234. /**
  71235. * The (Babylon) version of this module.
  71236. * This is an integer representing the implementation version.
  71237. * This number does not correspond to the WebXR specs version
  71238. */
  71239. static readonly Version: number;
  71240. /**
  71241. * Observers registered here will be executed when a new plane was added to the session
  71242. */
  71243. onPlaneAddedObservable: Observable<IWebXRPlane>;
  71244. /**
  71245. * Observers registered here will be executed when a plane is no longer detected in the session
  71246. */
  71247. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  71248. /**
  71249. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  71250. * This can execute N times every frame
  71251. */
  71252. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  71253. /**
  71254. * construct a new Plane Detector
  71255. * @param _xrSessionManager an instance of xr Session manager
  71256. * @param _options configuration to use when constructing this feature
  71257. */
  71258. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  71259. /**
  71260. * Dispose this feature and all of the resources attached
  71261. */
  71262. dispose(): void;
  71263. protected _onXRFrame(frame: XRFrame): void;
  71264. private _init;
  71265. private _updatePlaneWithXRPlane;
  71266. /**
  71267. * avoiding using Array.find for global support.
  71268. * @param xrPlane the plane to find in the array
  71269. */
  71270. private findIndexInPlaneArray;
  71271. }
  71272. }
  71273. declare module BABYLON {
  71274. /**
  71275. * Configuration options of the anchor system
  71276. */
  71277. export interface IWebXRAnchorSystemOptions {
  71278. /**
  71279. * Should a new anchor be added every time a select event is triggered
  71280. */
  71281. addAnchorOnSelect?: boolean;
  71282. /**
  71283. * should the anchor system use plane detection.
  71284. * If set to true, the plane-detection feature should be set using setPlaneDetector
  71285. */
  71286. usePlaneDetection?: boolean;
  71287. /**
  71288. * a node that will be used to convert local to world coordinates
  71289. */
  71290. worldParentNode?: TransformNode;
  71291. }
  71292. /**
  71293. * A babylon container for an XR Anchor
  71294. */
  71295. export interface IWebXRAnchor {
  71296. /**
  71297. * A babylon-assigned ID for this anchor
  71298. */
  71299. id: number;
  71300. /**
  71301. * Transformation matrix to apply to an object attached to this anchor
  71302. */
  71303. transformationMatrix: Matrix;
  71304. /**
  71305. * The native anchor object
  71306. */
  71307. xrAnchor: XRAnchor;
  71308. }
  71309. /**
  71310. * An implementation of the anchor system of WebXR.
  71311. * Note that the current documented implementation is not available in any browser. Future implementations
  71312. * will use the frame to create an anchor and not the session or a detected plane
  71313. * For further information see https://github.com/immersive-web/anchors/
  71314. */
  71315. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  71316. private _options;
  71317. private _enabled;
  71318. private _hitTestModule;
  71319. private _lastFrameDetected;
  71320. private _onSelect;
  71321. private _planeDetector;
  71322. private _trackedAnchors;
  71323. /**
  71324. * The module's name
  71325. */
  71326. static readonly Name: string;
  71327. /**
  71328. * The (Babylon) version of this module.
  71329. * This is an integer representing the implementation version.
  71330. * This number does not correspond to the WebXR specs version
  71331. */
  71332. static readonly Version: number;
  71333. /**
  71334. * Observers registered here will be executed when a new anchor was added to the session
  71335. */
  71336. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  71337. /**
  71338. * Observers registered here will be executed when an anchor was removed from the session
  71339. */
  71340. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  71341. /**
  71342. * Observers registered here will be executed when an existing anchor updates
  71343. * This can execute N times every frame
  71344. */
  71345. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  71346. /**
  71347. * constructs a new anchor system
  71348. * @param _xrSessionManager an instance of WebXRSessionManager
  71349. * @param _options configuration object for this feature
  71350. */
  71351. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  71352. /**
  71353. * Add anchor at a specific XR point.
  71354. *
  71355. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  71356. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  71357. * @returns a promise the fulfills when the anchor was created
  71358. */
  71359. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  71360. /**
  71361. * attach this feature
  71362. * Will usually be called by the features manager
  71363. *
  71364. * @returns true if successful.
  71365. */
  71366. attach(): boolean;
  71367. /**
  71368. * detach this feature.
  71369. * Will usually be called by the features manager
  71370. *
  71371. * @returns true if successful.
  71372. */
  71373. detach(): boolean;
  71374. /**
  71375. * Dispose this feature and all of the resources attached
  71376. */
  71377. dispose(): void;
  71378. /**
  71379. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  71380. * @param hitTestModule the hit-test module to use.
  71381. */
  71382. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  71383. /**
  71384. * set the plane detector to use in order to create anchors from frames
  71385. * @param planeDetector the plane-detector module to use
  71386. * @param enable enable plane-anchors. default is true
  71387. */
  71388. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  71389. protected _onXRFrame(frame: XRFrame): void;
  71390. /**
  71391. * avoiding using Array.find for global support.
  71392. * @param xrAnchor the plane to find in the array
  71393. */
  71394. private _findIndexInAnchorArray;
  71395. private _updateAnchorWithXRFrame;
  71396. }
  71397. }
  71398. declare module BABYLON {
  71399. /**
  71400. * Options interface for the background remover plugin
  71401. */
  71402. export interface IWebXRBackgroundRemoverOptions {
  71403. /**
  71404. * Further background meshes to disable when entering AR
  71405. */
  71406. backgroundMeshes?: AbstractMesh[];
  71407. /**
  71408. * flags to configure the removal of the environment helper.
  71409. * If not set, the entire background will be removed. If set, flags should be set as well.
  71410. */
  71411. environmentHelperRemovalFlags?: {
  71412. /**
  71413. * Should the skybox be removed (default false)
  71414. */
  71415. skyBox?: boolean;
  71416. /**
  71417. * Should the ground be removed (default false)
  71418. */
  71419. ground?: boolean;
  71420. };
  71421. /**
  71422. * don't disable the environment helper
  71423. */
  71424. ignoreEnvironmentHelper?: boolean;
  71425. }
  71426. /**
  71427. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  71428. */
  71429. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  71430. /**
  71431. * read-only options to be used in this module
  71432. */
  71433. readonly options: IWebXRBackgroundRemoverOptions;
  71434. /**
  71435. * The module's name
  71436. */
  71437. static readonly Name: string;
  71438. /**
  71439. * The (Babylon) version of this module.
  71440. * This is an integer representing the implementation version.
  71441. * This number does not correspond to the WebXR specs version
  71442. */
  71443. static readonly Version: number;
  71444. /**
  71445. * registered observers will be triggered when the background state changes
  71446. */
  71447. onBackgroundStateChangedObservable: Observable<boolean>;
  71448. /**
  71449. * constructs a new background remover module
  71450. * @param _xrSessionManager the session manager for this module
  71451. * @param options read-only options to be used in this module
  71452. */
  71453. constructor(_xrSessionManager: WebXRSessionManager,
  71454. /**
  71455. * read-only options to be used in this module
  71456. */
  71457. options?: IWebXRBackgroundRemoverOptions);
  71458. /**
  71459. * attach this feature
  71460. * Will usually be called by the features manager
  71461. *
  71462. * @returns true if successful.
  71463. */
  71464. attach(): boolean;
  71465. /**
  71466. * detach this feature.
  71467. * Will usually be called by the features manager
  71468. *
  71469. * @returns true if successful.
  71470. */
  71471. detach(): boolean;
  71472. /**
  71473. * Dispose this feature and all of the resources attached
  71474. */
  71475. dispose(): void;
  71476. protected _onXRFrame(_xrFrame: XRFrame): void;
  71477. private _setBackgroundState;
  71478. }
  71479. }
  71480. declare module BABYLON {
  71481. /**
  71482. * Options for the controller physics feature
  71483. */
  71484. export class IWebXRControllerPhysicsOptions {
  71485. /**
  71486. * Should the headset get its own impostor
  71487. */
  71488. enableHeadsetImpostor?: boolean;
  71489. /**
  71490. * Optional parameters for the headset impostor
  71491. */
  71492. headsetImpostorParams?: {
  71493. /**
  71494. * The type of impostor to create. Default is sphere
  71495. */
  71496. impostorType: number;
  71497. /**
  71498. * the size of the impostor. Defaults to 10cm
  71499. */
  71500. impostorSize?: number | {
  71501. width: number;
  71502. height: number;
  71503. depth: number;
  71504. };
  71505. /**
  71506. * Friction definitions
  71507. */
  71508. friction?: number;
  71509. /**
  71510. * Restitution
  71511. */
  71512. restitution?: number;
  71513. };
  71514. /**
  71515. * The physics properties of the future impostors
  71516. */
  71517. physicsProperties?: {
  71518. /**
  71519. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  71520. * Note that this requires a physics engine that supports mesh impostors!
  71521. */
  71522. useControllerMesh?: boolean;
  71523. /**
  71524. * The type of impostor to create. Default is sphere
  71525. */
  71526. impostorType?: number;
  71527. /**
  71528. * the size of the impostor. Defaults to 10cm
  71529. */
  71530. impostorSize?: number | {
  71531. width: number;
  71532. height: number;
  71533. depth: number;
  71534. };
  71535. /**
  71536. * Friction definitions
  71537. */
  71538. friction?: number;
  71539. /**
  71540. * Restitution
  71541. */
  71542. restitution?: number;
  71543. };
  71544. /**
  71545. * the xr input to use with this pointer selection
  71546. */
  71547. xrInput: WebXRInput;
  71548. }
  71549. /**
  71550. * Add physics impostor to your webxr controllers,
  71551. * including naive calculation of their linear and angular velocity
  71552. */
  71553. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  71554. private readonly _options;
  71555. private _attachController;
  71556. private _controllers;
  71557. private _debugMode;
  71558. private _delta;
  71559. private _headsetImpostor?;
  71560. private _headsetMesh?;
  71561. private _lastTimestamp;
  71562. private _tmpQuaternion;
  71563. private _tmpVector;
  71564. /**
  71565. * The module's name
  71566. */
  71567. static readonly Name: string;
  71568. /**
  71569. * The (Babylon) version of this module.
  71570. * This is an integer representing the implementation version.
  71571. * This number does not correspond to the webxr specs version
  71572. */
  71573. static readonly Version: number;
  71574. /**
  71575. * Construct a new Controller Physics Feature
  71576. * @param _xrSessionManager the corresponding xr session manager
  71577. * @param _options options to create this feature with
  71578. */
  71579. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  71580. /**
  71581. * @hidden
  71582. * enable debugging - will show console outputs and the impostor mesh
  71583. */
  71584. _enablePhysicsDebug(): void;
  71585. /**
  71586. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  71587. * @param xrController the controller to add
  71588. */
  71589. addController(xrController: WebXRInputSource): void;
  71590. /**
  71591. * attach this feature
  71592. * Will usually be called by the features manager
  71593. *
  71594. * @returns true if successful.
  71595. */
  71596. attach(): boolean;
  71597. /**
  71598. * detach this feature.
  71599. * Will usually be called by the features manager
  71600. *
  71601. * @returns true if successful.
  71602. */
  71603. detach(): boolean;
  71604. /**
  71605. * Get the headset impostor, if enabled
  71606. * @returns the impostor
  71607. */
  71608. getHeadsetImpostor(): PhysicsImpostor | undefined;
  71609. /**
  71610. * Get the physics impostor of a specific controller.
  71611. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  71612. * @param controller the controller or the controller id of which to get the impostor
  71613. * @returns the impostor or null
  71614. */
  71615. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  71616. /**
  71617. * Update the physics properties provided in the constructor
  71618. * @param newProperties the new properties object
  71619. */
  71620. setPhysicsProperties(newProperties: {
  71621. impostorType?: number;
  71622. impostorSize?: number | {
  71623. width: number;
  71624. height: number;
  71625. depth: number;
  71626. };
  71627. friction?: number;
  71628. restitution?: number;
  71629. }): void;
  71630. protected _onXRFrame(_xrFrame: any): void;
  71631. private _detachController;
  71632. }
  71633. }
  71634. declare module BABYLON {
  71635. /**
  71636. * Options used for hit testing (version 2)
  71637. */
  71638. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  71639. /**
  71640. * Do not create a permanent hit test. Will usually be used when only
  71641. * transient inputs are needed.
  71642. */
  71643. disablePermanentHitTest?: boolean;
  71644. /**
  71645. * Enable transient (for example touch-based) hit test inspections
  71646. */
  71647. enableTransientHitTest?: boolean;
  71648. /**
  71649. * Offset ray for the permanent hit test
  71650. */
  71651. offsetRay?: Vector3;
  71652. /**
  71653. * Offset ray for the transient hit test
  71654. */
  71655. transientOffsetRay?: Vector3;
  71656. /**
  71657. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  71658. */
  71659. useReferenceSpace?: boolean;
  71660. }
  71661. /**
  71662. * Interface defining the babylon result of hit-test
  71663. */
  71664. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  71665. /**
  71666. * The input source that generated this hit test (if transient)
  71667. */
  71668. inputSource?: XRInputSource;
  71669. /**
  71670. * Is this a transient hit test
  71671. */
  71672. isTransient?: boolean;
  71673. /**
  71674. * Position of the hit test result
  71675. */
  71676. position: Vector3;
  71677. /**
  71678. * Rotation of the hit test result
  71679. */
  71680. rotationQuaternion: Quaternion;
  71681. }
  71682. /**
  71683. * The currently-working hit-test module.
  71684. * Hit test (or Ray-casting) is used to interact with the real world.
  71685. * For further information read here - https://github.com/immersive-web/hit-test
  71686. *
  71687. * Tested on chrome (mobile) 80.
  71688. */
  71689. export class WebXRHitTest extends WebXRAbstractFeature {
  71690. /**
  71691. * options to use when constructing this feature
  71692. */
  71693. readonly options: IWebXRHitTestOptions;
  71694. private _tmpMat;
  71695. private _tmpPos;
  71696. private _tmpQuat;
  71697. private _transientXrHitTestSource;
  71698. private _xrHitTestSource;
  71699. private initHitTestSource;
  71700. /**
  71701. * The module's name
  71702. */
  71703. static readonly Name: string;
  71704. /**
  71705. * The (Babylon) version of this module.
  71706. * This is an integer representing the implementation version.
  71707. * This number does not correspond to the WebXR specs version
  71708. */
  71709. static readonly Version: number;
  71710. /**
  71711. * When set to true, each hit test will have its own position/rotation objects
  71712. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  71713. * the developers will clone them or copy them as they see fit.
  71714. */
  71715. autoCloneTransformation: boolean;
  71716. /**
  71717. * Populated with the last native XR Hit Results
  71718. */
  71719. lastNativeXRHitResults: XRHitResult[];
  71720. /**
  71721. * Triggered when new babylon (transformed) hit test results are available
  71722. */
  71723. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  71724. /**
  71725. * Use this to temporarily pause hit test checks.
  71726. */
  71727. paused: boolean;
  71728. /**
  71729. * Creates a new instance of the hit test feature
  71730. * @param _xrSessionManager an instance of WebXRSessionManager
  71731. * @param options options to use when constructing this feature
  71732. */
  71733. constructor(_xrSessionManager: WebXRSessionManager,
  71734. /**
  71735. * options to use when constructing this feature
  71736. */
  71737. options?: IWebXRHitTestOptions);
  71738. /**
  71739. * attach this feature
  71740. * Will usually be called by the features manager
  71741. *
  71742. * @returns true if successful.
  71743. */
  71744. attach(): boolean;
  71745. /**
  71746. * detach this feature.
  71747. * Will usually be called by the features manager
  71748. *
  71749. * @returns true if successful.
  71750. */
  71751. detach(): boolean;
  71752. /**
  71753. * Dispose this feature and all of the resources attached
  71754. */
  71755. dispose(): void;
  71756. protected _onXRFrame(frame: XRFrame): void;
  71757. private _processWebXRHitTestResult;
  71758. }
  71759. }
  71760. declare module BABYLON {
  71761. /**
  71762. * The motion controller class for all microsoft mixed reality controllers
  71763. */
  71764. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  71765. protected readonly _mapping: {
  71766. defaultButton: {
  71767. valueNodeName: string;
  71768. unpressedNodeName: string;
  71769. pressedNodeName: string;
  71770. };
  71771. defaultAxis: {
  71772. valueNodeName: string;
  71773. minNodeName: string;
  71774. maxNodeName: string;
  71775. };
  71776. buttons: {
  71777. "xr-standard-trigger": {
  71778. rootNodeName: string;
  71779. componentProperty: string;
  71780. states: string[];
  71781. };
  71782. "xr-standard-squeeze": {
  71783. rootNodeName: string;
  71784. componentProperty: string;
  71785. states: string[];
  71786. };
  71787. "xr-standard-touchpad": {
  71788. rootNodeName: string;
  71789. labelAnchorNodeName: string;
  71790. touchPointNodeName: string;
  71791. };
  71792. "xr-standard-thumbstick": {
  71793. rootNodeName: string;
  71794. componentProperty: string;
  71795. states: string[];
  71796. };
  71797. };
  71798. axes: {
  71799. "xr-standard-touchpad": {
  71800. "x-axis": {
  71801. rootNodeName: string;
  71802. };
  71803. "y-axis": {
  71804. rootNodeName: string;
  71805. };
  71806. };
  71807. "xr-standard-thumbstick": {
  71808. "x-axis": {
  71809. rootNodeName: string;
  71810. };
  71811. "y-axis": {
  71812. rootNodeName: string;
  71813. };
  71814. };
  71815. };
  71816. };
  71817. /**
  71818. * The base url used to load the left and right controller models
  71819. */
  71820. static MODEL_BASE_URL: string;
  71821. /**
  71822. * The name of the left controller model file
  71823. */
  71824. static MODEL_LEFT_FILENAME: string;
  71825. /**
  71826. * The name of the right controller model file
  71827. */
  71828. static MODEL_RIGHT_FILENAME: string;
  71829. profileId: string;
  71830. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71831. protected _getFilenameAndPath(): {
  71832. filename: string;
  71833. path: string;
  71834. };
  71835. protected _getModelLoadingConstraints(): boolean;
  71836. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71837. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71838. protected _updateModel(): void;
  71839. }
  71840. }
  71841. declare module BABYLON {
  71842. /**
  71843. * The motion controller class for oculus touch (quest, rift).
  71844. * This class supports legacy mapping as well the standard xr mapping
  71845. */
  71846. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  71847. private _forceLegacyControllers;
  71848. private _modelRootNode;
  71849. /**
  71850. * The base url used to load the left and right controller models
  71851. */
  71852. static MODEL_BASE_URL: string;
  71853. /**
  71854. * The name of the left controller model file
  71855. */
  71856. static MODEL_LEFT_FILENAME: string;
  71857. /**
  71858. * The name of the right controller model file
  71859. */
  71860. static MODEL_RIGHT_FILENAME: string;
  71861. /**
  71862. * Base Url for the Quest controller model.
  71863. */
  71864. static QUEST_MODEL_BASE_URL: string;
  71865. profileId: string;
  71866. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  71867. protected _getFilenameAndPath(): {
  71868. filename: string;
  71869. path: string;
  71870. };
  71871. protected _getModelLoadingConstraints(): boolean;
  71872. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71873. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71874. protected _updateModel(): void;
  71875. /**
  71876. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  71877. * between the touch and touch 2.
  71878. */
  71879. private _isQuest;
  71880. }
  71881. }
  71882. declare module BABYLON {
  71883. /**
  71884. * The motion controller class for the standard HTC-Vive controllers
  71885. */
  71886. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  71887. private _modelRootNode;
  71888. /**
  71889. * The base url used to load the left and right controller models
  71890. */
  71891. static MODEL_BASE_URL: string;
  71892. /**
  71893. * File name for the controller model.
  71894. */
  71895. static MODEL_FILENAME: string;
  71896. profileId: string;
  71897. /**
  71898. * Create a new Vive motion controller object
  71899. * @param scene the scene to use to create this controller
  71900. * @param gamepadObject the corresponding gamepad object
  71901. * @param handedness the handedness of the controller
  71902. */
  71903. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  71904. protected _getFilenameAndPath(): {
  71905. filename: string;
  71906. path: string;
  71907. };
  71908. protected _getModelLoadingConstraints(): boolean;
  71909. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  71910. protected _setRootMesh(meshes: AbstractMesh[]): void;
  71911. protected _updateModel(): void;
  71912. }
  71913. }
  71914. declare module BABYLON {
  71915. /**
  71916. * A cursor which tracks a point on a path
  71917. */
  71918. export class PathCursor {
  71919. private path;
  71920. /**
  71921. * Stores path cursor callbacks for when an onchange event is triggered
  71922. */
  71923. private _onchange;
  71924. /**
  71925. * The value of the path cursor
  71926. */
  71927. value: number;
  71928. /**
  71929. * The animation array of the path cursor
  71930. */
  71931. animations: Animation[];
  71932. /**
  71933. * Initializes the path cursor
  71934. * @param path The path to track
  71935. */
  71936. constructor(path: Path2);
  71937. /**
  71938. * Gets the cursor point on the path
  71939. * @returns A point on the path cursor at the cursor location
  71940. */
  71941. getPoint(): Vector3;
  71942. /**
  71943. * Moves the cursor ahead by the step amount
  71944. * @param step The amount to move the cursor forward
  71945. * @returns This path cursor
  71946. */
  71947. moveAhead(step?: number): PathCursor;
  71948. /**
  71949. * Moves the cursor behind by the step amount
  71950. * @param step The amount to move the cursor back
  71951. * @returns This path cursor
  71952. */
  71953. moveBack(step?: number): PathCursor;
  71954. /**
  71955. * Moves the cursor by the step amount
  71956. * If the step amount is greater than one, an exception is thrown
  71957. * @param step The amount to move the cursor
  71958. * @returns This path cursor
  71959. */
  71960. move(step: number): PathCursor;
  71961. /**
  71962. * Ensures that the value is limited between zero and one
  71963. * @returns This path cursor
  71964. */
  71965. private ensureLimits;
  71966. /**
  71967. * Runs onchange callbacks on change (used by the animation engine)
  71968. * @returns This path cursor
  71969. */
  71970. private raiseOnChange;
  71971. /**
  71972. * Executes a function on change
  71973. * @param f A path cursor onchange callback
  71974. * @returns This path cursor
  71975. */
  71976. onchange(f: (cursor: PathCursor) => void): PathCursor;
  71977. }
  71978. }
  71979. declare module BABYLON {
  71980. /** @hidden */
  71981. export var blurPixelShader: {
  71982. name: string;
  71983. shader: string;
  71984. };
  71985. }
  71986. declare module BABYLON {
  71987. /** @hidden */
  71988. export var pointCloudVertexDeclaration: {
  71989. name: string;
  71990. shader: string;
  71991. };
  71992. }
  71993. // Mixins
  71994. interface Window {
  71995. mozIndexedDB: IDBFactory;
  71996. webkitIndexedDB: IDBFactory;
  71997. msIndexedDB: IDBFactory;
  71998. webkitURL: typeof URL;
  71999. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  72000. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  72001. WebGLRenderingContext: WebGLRenderingContext;
  72002. MSGesture: MSGesture;
  72003. CANNON: any;
  72004. AudioContext: AudioContext;
  72005. webkitAudioContext: AudioContext;
  72006. PointerEvent: any;
  72007. Math: Math;
  72008. Uint8Array: Uint8ArrayConstructor;
  72009. Float32Array: Float32ArrayConstructor;
  72010. mozURL: typeof URL;
  72011. msURL: typeof URL;
  72012. VRFrameData: any; // WebVR, from specs 1.1
  72013. DracoDecoderModule: any;
  72014. setImmediate(handler: (...args: any[]) => void): number;
  72015. }
  72016. interface HTMLCanvasElement {
  72017. requestPointerLock(): void;
  72018. msRequestPointerLock?(): void;
  72019. mozRequestPointerLock?(): void;
  72020. webkitRequestPointerLock?(): void;
  72021. /** Track wether a record is in progress */
  72022. isRecording: boolean;
  72023. /** Capture Stream method defined by some browsers */
  72024. captureStream(fps?: number): MediaStream;
  72025. }
  72026. interface CanvasRenderingContext2D {
  72027. msImageSmoothingEnabled: boolean;
  72028. }
  72029. interface MouseEvent {
  72030. mozMovementX: number;
  72031. mozMovementY: number;
  72032. webkitMovementX: number;
  72033. webkitMovementY: number;
  72034. msMovementX: number;
  72035. msMovementY: number;
  72036. }
  72037. interface Navigator {
  72038. mozGetVRDevices: (any: any) => any;
  72039. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72040. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72041. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  72042. webkitGetGamepads(): Gamepad[];
  72043. msGetGamepads(): Gamepad[];
  72044. webkitGamepads(): Gamepad[];
  72045. }
  72046. interface HTMLVideoElement {
  72047. mozSrcObject: any;
  72048. }
  72049. interface Math {
  72050. fround(x: number): number;
  72051. imul(a: number, b: number): number;
  72052. }
  72053. interface WebGLRenderingContext {
  72054. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  72055. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  72056. vertexAttribDivisor(index: number, divisor: number): void;
  72057. createVertexArray(): any;
  72058. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  72059. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  72060. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  72061. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  72062. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  72063. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  72064. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  72065. // Queries
  72066. createQuery(): WebGLQuery;
  72067. deleteQuery(query: WebGLQuery): void;
  72068. beginQuery(target: number, query: WebGLQuery): void;
  72069. endQuery(target: number): void;
  72070. getQueryParameter(query: WebGLQuery, pname: number): any;
  72071. getQuery(target: number, pname: number): any;
  72072. MAX_SAMPLES: number;
  72073. RGBA8: number;
  72074. READ_FRAMEBUFFER: number;
  72075. DRAW_FRAMEBUFFER: number;
  72076. UNIFORM_BUFFER: number;
  72077. HALF_FLOAT_OES: number;
  72078. RGBA16F: number;
  72079. RGBA32F: number;
  72080. R32F: number;
  72081. RG32F: number;
  72082. RGB32F: number;
  72083. R16F: number;
  72084. RG16F: number;
  72085. RGB16F: number;
  72086. RED: number;
  72087. RG: number;
  72088. R8: number;
  72089. RG8: number;
  72090. UNSIGNED_INT_24_8: number;
  72091. DEPTH24_STENCIL8: number;
  72092. MIN: number;
  72093. MAX: number;
  72094. /* Multiple Render Targets */
  72095. drawBuffers(buffers: number[]): void;
  72096. readBuffer(src: number): void;
  72097. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  72098. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  72099. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  72100. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  72101. // Occlusion Query
  72102. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  72103. ANY_SAMPLES_PASSED: number;
  72104. QUERY_RESULT_AVAILABLE: number;
  72105. QUERY_RESULT: number;
  72106. }
  72107. interface WebGLProgram {
  72108. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  72109. }
  72110. interface EXT_disjoint_timer_query {
  72111. QUERY_COUNTER_BITS_EXT: number;
  72112. TIME_ELAPSED_EXT: number;
  72113. TIMESTAMP_EXT: number;
  72114. GPU_DISJOINT_EXT: number;
  72115. QUERY_RESULT_EXT: number;
  72116. QUERY_RESULT_AVAILABLE_EXT: number;
  72117. queryCounterEXT(query: WebGLQuery, target: number): void;
  72118. createQueryEXT(): WebGLQuery;
  72119. beginQueryEXT(target: number, query: WebGLQuery): void;
  72120. endQueryEXT(target: number): void;
  72121. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  72122. deleteQueryEXT(query: WebGLQuery): void;
  72123. }
  72124. interface WebGLUniformLocation {
  72125. _currentState: any;
  72126. }
  72127. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  72128. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  72129. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  72130. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72131. interface WebGLRenderingContext {
  72132. readonly RASTERIZER_DISCARD: number;
  72133. readonly DEPTH_COMPONENT24: number;
  72134. readonly TEXTURE_3D: number;
  72135. readonly TEXTURE_2D_ARRAY: number;
  72136. readonly TEXTURE_COMPARE_FUNC: number;
  72137. readonly TEXTURE_COMPARE_MODE: number;
  72138. readonly COMPARE_REF_TO_TEXTURE: number;
  72139. readonly TEXTURE_WRAP_R: number;
  72140. readonly HALF_FLOAT: number;
  72141. readonly RGB8: number;
  72142. readonly RED_INTEGER: number;
  72143. readonly RG_INTEGER: number;
  72144. readonly RGB_INTEGER: number;
  72145. readonly RGBA_INTEGER: number;
  72146. readonly R8_SNORM: number;
  72147. readonly RG8_SNORM: number;
  72148. readonly RGB8_SNORM: number;
  72149. readonly RGBA8_SNORM: number;
  72150. readonly R8I: number;
  72151. readonly RG8I: number;
  72152. readonly RGB8I: number;
  72153. readonly RGBA8I: number;
  72154. readonly R8UI: number;
  72155. readonly RG8UI: number;
  72156. readonly RGB8UI: number;
  72157. readonly RGBA8UI: number;
  72158. readonly R16I: number;
  72159. readonly RG16I: number;
  72160. readonly RGB16I: number;
  72161. readonly RGBA16I: number;
  72162. readonly R16UI: number;
  72163. readonly RG16UI: number;
  72164. readonly RGB16UI: number;
  72165. readonly RGBA16UI: number;
  72166. readonly R32I: number;
  72167. readonly RG32I: number;
  72168. readonly RGB32I: number;
  72169. readonly RGBA32I: number;
  72170. readonly R32UI: number;
  72171. readonly RG32UI: number;
  72172. readonly RGB32UI: number;
  72173. readonly RGBA32UI: number;
  72174. readonly RGB10_A2UI: number;
  72175. readonly R11F_G11F_B10F: number;
  72176. readonly RGB9_E5: number;
  72177. readonly RGB10_A2: number;
  72178. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  72179. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  72180. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  72181. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72182. readonly DEPTH_COMPONENT32F: number;
  72183. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  72184. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  72185. 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;
  72186. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  72187. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  72188. readonly TRANSFORM_FEEDBACK: number;
  72189. readonly INTERLEAVED_ATTRIBS: number;
  72190. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  72191. createTransformFeedback(): WebGLTransformFeedback;
  72192. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  72193. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  72194. beginTransformFeedback(primitiveMode: number): void;
  72195. endTransformFeedback(): void;
  72196. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  72197. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72198. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72199. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  72200. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  72201. }
  72202. interface ImageBitmap {
  72203. readonly width: number;
  72204. readonly height: number;
  72205. close(): void;
  72206. }
  72207. interface WebGLQuery extends WebGLObject {
  72208. }
  72209. declare var WebGLQuery: {
  72210. prototype: WebGLQuery;
  72211. new(): WebGLQuery;
  72212. };
  72213. interface WebGLSampler extends WebGLObject {
  72214. }
  72215. declare var WebGLSampler: {
  72216. prototype: WebGLSampler;
  72217. new(): WebGLSampler;
  72218. };
  72219. interface WebGLSync extends WebGLObject {
  72220. }
  72221. declare var WebGLSync: {
  72222. prototype: WebGLSync;
  72223. new(): WebGLSync;
  72224. };
  72225. interface WebGLTransformFeedback extends WebGLObject {
  72226. }
  72227. declare var WebGLTransformFeedback: {
  72228. prototype: WebGLTransformFeedback;
  72229. new(): WebGLTransformFeedback;
  72230. };
  72231. interface WebGLVertexArrayObject extends WebGLObject {
  72232. }
  72233. declare var WebGLVertexArrayObject: {
  72234. prototype: WebGLVertexArrayObject;
  72235. new(): WebGLVertexArrayObject;
  72236. };
  72237. // Type definitions for WebVR API
  72238. // Project: https://w3c.github.io/webvr/
  72239. // Definitions by: six a <https://github.com/lostfictions>
  72240. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  72241. interface VRDisplay extends EventTarget {
  72242. /**
  72243. * Dictionary of capabilities describing the VRDisplay.
  72244. */
  72245. readonly capabilities: VRDisplayCapabilities;
  72246. /**
  72247. * z-depth defining the far plane of the eye view frustum
  72248. * enables mapping of values in the render target depth
  72249. * attachment to scene coordinates. Initially set to 10000.0.
  72250. */
  72251. depthFar: number;
  72252. /**
  72253. * z-depth defining the near plane of the eye view frustum
  72254. * enables mapping of values in the render target depth
  72255. * attachment to scene coordinates. Initially set to 0.01.
  72256. */
  72257. depthNear: number;
  72258. /**
  72259. * An identifier for this distinct VRDisplay. Used as an
  72260. * association point in the Gamepad API.
  72261. */
  72262. readonly displayId: number;
  72263. /**
  72264. * A display name, a user-readable name identifying it.
  72265. */
  72266. readonly displayName: string;
  72267. readonly isConnected: boolean;
  72268. readonly isPresenting: boolean;
  72269. /**
  72270. * If this VRDisplay supports room-scale experiences, the optional
  72271. * stage attribute contains details on the room-scale parameters.
  72272. */
  72273. readonly stageParameters: VRStageParameters | null;
  72274. /**
  72275. * Passing the value returned by `requestAnimationFrame` to
  72276. * `cancelAnimationFrame` will unregister the callback.
  72277. * @param handle Define the hanle of the request to cancel
  72278. */
  72279. cancelAnimationFrame(handle: number): void;
  72280. /**
  72281. * Stops presenting to the VRDisplay.
  72282. * @returns a promise to know when it stopped
  72283. */
  72284. exitPresent(): Promise<void>;
  72285. /**
  72286. * Return the current VREyeParameters for the given eye.
  72287. * @param whichEye Define the eye we want the parameter for
  72288. * @returns the eye parameters
  72289. */
  72290. getEyeParameters(whichEye: string): VREyeParameters;
  72291. /**
  72292. * Populates the passed VRFrameData with the information required to render
  72293. * the current frame.
  72294. * @param frameData Define the data structure to populate
  72295. * @returns true if ok otherwise false
  72296. */
  72297. getFrameData(frameData: VRFrameData): boolean;
  72298. /**
  72299. * Get the layers currently being presented.
  72300. * @returns the list of VR layers
  72301. */
  72302. getLayers(): VRLayer[];
  72303. /**
  72304. * Return a VRPose containing the future predicted pose of the VRDisplay
  72305. * when the current frame will be presented. The value returned will not
  72306. * change until JavaScript has returned control to the browser.
  72307. *
  72308. * The VRPose will contain the position, orientation, velocity,
  72309. * and acceleration of each of these properties.
  72310. * @returns the pose object
  72311. */
  72312. getPose(): VRPose;
  72313. /**
  72314. * Return the current instantaneous pose of the VRDisplay, with no
  72315. * prediction applied.
  72316. * @returns the current instantaneous pose
  72317. */
  72318. getImmediatePose(): VRPose;
  72319. /**
  72320. * The callback passed to `requestAnimationFrame` will be called
  72321. * any time a new frame should be rendered. When the VRDisplay is
  72322. * presenting the callback will be called at the native refresh
  72323. * rate of the HMD. When not presenting this function acts
  72324. * identically to how window.requestAnimationFrame acts. Content should
  72325. * make no assumptions of frame rate or vsync behavior as the HMD runs
  72326. * asynchronously from other displays and at differing refresh rates.
  72327. * @param callback Define the eaction to run next frame
  72328. * @returns the request handle it
  72329. */
  72330. requestAnimationFrame(callback: FrameRequestCallback): number;
  72331. /**
  72332. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  72333. * Repeat calls while already presenting will update the VRLayers being displayed.
  72334. * @param layers Define the list of layer to present
  72335. * @returns a promise to know when the request has been fulfilled
  72336. */
  72337. requestPresent(layers: VRLayer[]): Promise<void>;
  72338. /**
  72339. * Reset the pose for this display, treating its current position and
  72340. * orientation as the "origin/zero" values. VRPose.position,
  72341. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  72342. * updated when calling resetPose(). This should be called in only
  72343. * sitting-space experiences.
  72344. */
  72345. resetPose(): void;
  72346. /**
  72347. * The VRLayer provided to the VRDisplay will be captured and presented
  72348. * in the HMD. Calling this function has the same effect on the source
  72349. * canvas as any other operation that uses its source image, and canvases
  72350. * created without preserveDrawingBuffer set to true will be cleared.
  72351. * @param pose Define the pose to submit
  72352. */
  72353. submitFrame(pose?: VRPose): void;
  72354. }
  72355. declare var VRDisplay: {
  72356. prototype: VRDisplay;
  72357. new(): VRDisplay;
  72358. };
  72359. interface VRLayer {
  72360. leftBounds?: number[] | Float32Array | null;
  72361. rightBounds?: number[] | Float32Array | null;
  72362. source?: HTMLCanvasElement | null;
  72363. }
  72364. interface VRDisplayCapabilities {
  72365. readonly canPresent: boolean;
  72366. readonly hasExternalDisplay: boolean;
  72367. readonly hasOrientation: boolean;
  72368. readonly hasPosition: boolean;
  72369. readonly maxLayers: number;
  72370. }
  72371. interface VREyeParameters {
  72372. /** @deprecated */
  72373. readonly fieldOfView: VRFieldOfView;
  72374. readonly offset: Float32Array;
  72375. readonly renderHeight: number;
  72376. readonly renderWidth: number;
  72377. }
  72378. interface VRFieldOfView {
  72379. readonly downDegrees: number;
  72380. readonly leftDegrees: number;
  72381. readonly rightDegrees: number;
  72382. readonly upDegrees: number;
  72383. }
  72384. interface VRFrameData {
  72385. readonly leftProjectionMatrix: Float32Array;
  72386. readonly leftViewMatrix: Float32Array;
  72387. readonly pose: VRPose;
  72388. readonly rightProjectionMatrix: Float32Array;
  72389. readonly rightViewMatrix: Float32Array;
  72390. readonly timestamp: number;
  72391. }
  72392. interface VRPose {
  72393. readonly angularAcceleration: Float32Array | null;
  72394. readonly angularVelocity: Float32Array | null;
  72395. readonly linearAcceleration: Float32Array | null;
  72396. readonly linearVelocity: Float32Array | null;
  72397. readonly orientation: Float32Array | null;
  72398. readonly position: Float32Array | null;
  72399. readonly timestamp: number;
  72400. }
  72401. interface VRStageParameters {
  72402. sittingToStandingTransform?: Float32Array;
  72403. sizeX?: number;
  72404. sizeY?: number;
  72405. }
  72406. interface Navigator {
  72407. getVRDisplays(): Promise<VRDisplay[]>;
  72408. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  72409. }
  72410. interface Window {
  72411. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  72412. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  72413. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  72414. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72415. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  72416. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  72417. }
  72418. interface Gamepad {
  72419. readonly displayId: number;
  72420. }
  72421. type XRSessionMode =
  72422. | "inline"
  72423. | "immersive-vr"
  72424. | "immersive-ar";
  72425. type XRReferenceSpaceType =
  72426. | "viewer"
  72427. | "local"
  72428. | "local-floor"
  72429. | "bounded-floor"
  72430. | "unbounded";
  72431. type XREnvironmentBlendMode =
  72432. | "opaque"
  72433. | "additive"
  72434. | "alpha-blend";
  72435. type XRVisibilityState =
  72436. | "visible"
  72437. | "visible-blurred"
  72438. | "hidden";
  72439. type XRHandedness =
  72440. | "none"
  72441. | "left"
  72442. | "right";
  72443. type XRTargetRayMode =
  72444. | "gaze"
  72445. | "tracked-pointer"
  72446. | "screen";
  72447. type XREye =
  72448. | "none"
  72449. | "left"
  72450. | "right";
  72451. type XREventType =
  72452. | "devicechange"
  72453. | "visibilitychange"
  72454. | "end"
  72455. | "inputsourceschange"
  72456. | "select"
  72457. | "selectstart"
  72458. | "selectend"
  72459. | "squeeze"
  72460. | "squeezestart"
  72461. | "squeezeend"
  72462. | "reset";
  72463. interface XRSpace extends EventTarget {
  72464. }
  72465. interface XRRenderState {
  72466. depthNear?: number;
  72467. depthFar?: number;
  72468. inlineVerticalFieldOfView?: number;
  72469. baseLayer?: XRWebGLLayer;
  72470. }
  72471. interface XRInputSource {
  72472. handedness: XRHandedness;
  72473. targetRayMode: XRTargetRayMode;
  72474. targetRaySpace: XRSpace;
  72475. gripSpace: XRSpace | undefined;
  72476. gamepad: Gamepad | undefined;
  72477. profiles: Array<string>;
  72478. }
  72479. interface XRSessionInit {
  72480. optionalFeatures?: string[];
  72481. requiredFeatures?: string[];
  72482. }
  72483. interface XRSession extends XRAnchorCreator {
  72484. addEventListener: Function;
  72485. removeEventListener: Function;
  72486. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  72487. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  72488. requestAnimationFrame: Function;
  72489. end(): Promise<void>;
  72490. renderState: XRRenderState;
  72491. inputSources: Array<XRInputSource>;
  72492. // hit test
  72493. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  72494. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  72495. // legacy AR hit test
  72496. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72497. // legacy plane detection
  72498. updateWorldTrackingState(options: {
  72499. planeDetectionState?: { enabled: boolean; }
  72500. }): void;
  72501. }
  72502. interface XRReferenceSpace extends XRSpace {
  72503. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  72504. onreset: any;
  72505. }
  72506. type XRPlaneSet = Set<XRPlane>;
  72507. type XRAnchorSet = Set<XRAnchor>;
  72508. interface XRFrame {
  72509. session: XRSession;
  72510. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  72511. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  72512. // AR
  72513. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  72514. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  72515. // Anchors
  72516. trackedAnchors?: XRAnchorSet;
  72517. // Planes
  72518. worldInformation: {
  72519. detectedPlanes?: XRPlaneSet;
  72520. };
  72521. }
  72522. interface XRViewerPose extends XRPose {
  72523. views: Array<XRView>;
  72524. }
  72525. interface XRPose {
  72526. transform: XRRigidTransform;
  72527. emulatedPosition: boolean;
  72528. }
  72529. interface XRWebGLLayerOptions {
  72530. antialias?: boolean;
  72531. depth?: boolean;
  72532. stencil?: boolean;
  72533. alpha?: boolean;
  72534. multiview?: boolean;
  72535. framebufferScaleFactor?: number;
  72536. }
  72537. declare var XRWebGLLayer: {
  72538. prototype: XRWebGLLayer;
  72539. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  72540. };
  72541. interface XRWebGLLayer {
  72542. framebuffer: WebGLFramebuffer;
  72543. framebufferWidth: number;
  72544. framebufferHeight: number;
  72545. getViewport: Function;
  72546. }
  72547. declare class XRRigidTransform {
  72548. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  72549. position: DOMPointReadOnly;
  72550. orientation: DOMPointReadOnly;
  72551. matrix: Float32Array;
  72552. inverse: XRRigidTransform;
  72553. }
  72554. interface XRView {
  72555. eye: XREye;
  72556. projectionMatrix: Float32Array;
  72557. transform: XRRigidTransform;
  72558. }
  72559. interface XRInputSourceChangeEvent {
  72560. session: XRSession;
  72561. removed: Array<XRInputSource>;
  72562. added: Array<XRInputSource>;
  72563. }
  72564. interface XRInputSourceEvent extends Event {
  72565. readonly frame: XRFrame;
  72566. readonly inputSource: XRInputSource;
  72567. }
  72568. // Experimental(er) features
  72569. declare class XRRay {
  72570. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  72571. origin: DOMPointReadOnly;
  72572. direction: DOMPointReadOnly;
  72573. matrix: Float32Array;
  72574. }
  72575. declare enum XRHitTestTrackableType {
  72576. "point",
  72577. "plane"
  72578. }
  72579. interface XRHitResult {
  72580. hitMatrix: Float32Array;
  72581. }
  72582. interface XRTransientInputHitTestResult {
  72583. readonly inputSource: XRInputSource;
  72584. readonly results: Array<XRHitTestResult>;
  72585. }
  72586. interface XRHitTestResult {
  72587. getPose(baseSpace: XRSpace): XRPose | undefined;
  72588. }
  72589. interface XRHitTestSource {
  72590. cancel(): void;
  72591. }
  72592. interface XRTransientInputHitTestSource {
  72593. cancel(): void;
  72594. }
  72595. interface XRHitTestOptionsInit {
  72596. space: XRSpace;
  72597. entityTypes?: Array<XRHitTestTrackableType>;
  72598. offsetRay?: XRRay;
  72599. }
  72600. interface XRTransientInputHitTestOptionsInit {
  72601. profile: string;
  72602. entityTypes?: Array<XRHitTestTrackableType>;
  72603. offsetRay?: XRRay;
  72604. }
  72605. interface XRAnchor {
  72606. // remove?
  72607. id?: string;
  72608. anchorSpace: XRSpace;
  72609. lastChangedTime: number;
  72610. detach(): void;
  72611. }
  72612. interface XRPlane extends XRAnchorCreator {
  72613. orientation: "Horizontal" | "Vertical";
  72614. planeSpace: XRSpace;
  72615. polygon: Array<DOMPointReadOnly>;
  72616. lastChangedTime: number;
  72617. }
  72618. interface XRAnchorCreator {
  72619. // AR Anchors
  72620. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  72621. }
  72622. /**
  72623. * @ignore
  72624. */
  72625. declare module BABYLON.GLTF2.Exporter {
  72626. }
  72627. /**
  72628. * @ignore
  72629. */
  72630. declare module BABYLON.GLTF1 {
  72631. }
  72632. declare module BABYLON.GUI {
  72633. /**
  72634. * Class used to specific a value and its associated unit
  72635. */
  72636. export class ValueAndUnit {
  72637. /** defines the unit to store */
  72638. unit: number;
  72639. /** defines a boolean indicating if the value can be negative */
  72640. negativeValueAllowed: boolean;
  72641. private _value;
  72642. private _originalUnit;
  72643. /**
  72644. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  72645. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  72646. */
  72647. ignoreAdaptiveScaling: boolean;
  72648. /**
  72649. * Creates a new ValueAndUnit
  72650. * @param value defines the value to store
  72651. * @param unit defines the unit to store
  72652. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  72653. */
  72654. constructor(value: number,
  72655. /** defines the unit to store */
  72656. unit?: number,
  72657. /** defines a boolean indicating if the value can be negative */
  72658. negativeValueAllowed?: boolean);
  72659. /** Gets a boolean indicating if the value is a percentage */
  72660. get isPercentage(): boolean;
  72661. /** Gets a boolean indicating if the value is store as pixel */
  72662. get isPixel(): boolean;
  72663. /** Gets direct internal value */
  72664. get internalValue(): number;
  72665. /**
  72666. * Gets value as pixel
  72667. * @param host defines the root host
  72668. * @param refValue defines the reference value for percentages
  72669. * @returns the value as pixel
  72670. */
  72671. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  72672. /**
  72673. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  72674. * @param value defines the value to store
  72675. * @param unit defines the unit to store
  72676. * @returns the current ValueAndUnit
  72677. */
  72678. updateInPlace(value: number, unit?: number): ValueAndUnit;
  72679. /**
  72680. * Gets the value accordingly to its unit
  72681. * @param host defines the root host
  72682. * @returns the value
  72683. */
  72684. getValue(host: AdvancedDynamicTexture): number;
  72685. /**
  72686. * Gets a string representation of the value
  72687. * @param host defines the root host
  72688. * @param decimals defines an optional number of decimals to display
  72689. * @returns a string
  72690. */
  72691. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  72692. /**
  72693. * Store a value parsed from a string
  72694. * @param source defines the source string
  72695. * @returns true if the value was successfully parsed
  72696. */
  72697. fromString(source: string | number): boolean;
  72698. private static _Regex;
  72699. private static _UNITMODE_PERCENTAGE;
  72700. private static _UNITMODE_PIXEL;
  72701. /** UNITMODE_PERCENTAGE */
  72702. static get UNITMODE_PERCENTAGE(): number;
  72703. /** UNITMODE_PIXEL */
  72704. static get UNITMODE_PIXEL(): number;
  72705. }
  72706. }
  72707. declare module BABYLON.GUI {
  72708. /**
  72709. * Define a style used by control to automatically setup properties based on a template.
  72710. * Only support font related properties so far
  72711. */
  72712. export class Style implements BABYLON.IDisposable {
  72713. private _fontFamily;
  72714. private _fontStyle;
  72715. private _fontWeight;
  72716. /** @hidden */
  72717. _host: AdvancedDynamicTexture;
  72718. /** @hidden */
  72719. _fontSize: ValueAndUnit;
  72720. /**
  72721. * BABYLON.Observable raised when the style values are changed
  72722. */
  72723. onChangedObservable: BABYLON.Observable<Style>;
  72724. /**
  72725. * Creates a new style object
  72726. * @param host defines the AdvancedDynamicTexture which hosts this style
  72727. */
  72728. constructor(host: AdvancedDynamicTexture);
  72729. /**
  72730. * Gets or sets the font size
  72731. */
  72732. get fontSize(): string | number;
  72733. set fontSize(value: string | number);
  72734. /**
  72735. * Gets or sets the font family
  72736. */
  72737. get fontFamily(): string;
  72738. set fontFamily(value: string);
  72739. /**
  72740. * Gets or sets the font style
  72741. */
  72742. get fontStyle(): string;
  72743. set fontStyle(value: string);
  72744. /** Gets or sets font weight */
  72745. get fontWeight(): string;
  72746. set fontWeight(value: string);
  72747. /** Dispose all associated resources */
  72748. dispose(): void;
  72749. }
  72750. }
  72751. declare module BABYLON.GUI {
  72752. /**
  72753. * Class used to transport BABYLON.Vector2 information for pointer events
  72754. */
  72755. export class Vector2WithInfo extends BABYLON.Vector2 {
  72756. /** defines the current mouse button index */
  72757. buttonIndex: number;
  72758. /**
  72759. * Creates a new Vector2WithInfo
  72760. * @param source defines the vector2 data to transport
  72761. * @param buttonIndex defines the current mouse button index
  72762. */
  72763. constructor(source: BABYLON.Vector2,
  72764. /** defines the current mouse button index */
  72765. buttonIndex?: number);
  72766. }
  72767. /** Class used to provide 2D matrix features */
  72768. export class Matrix2D {
  72769. /** Gets the internal array of 6 floats used to store matrix data */
  72770. m: Float32Array;
  72771. /**
  72772. * Creates a new matrix
  72773. * @param m00 defines value for (0, 0)
  72774. * @param m01 defines value for (0, 1)
  72775. * @param m10 defines value for (1, 0)
  72776. * @param m11 defines value for (1, 1)
  72777. * @param m20 defines value for (2, 0)
  72778. * @param m21 defines value for (2, 1)
  72779. */
  72780. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  72781. /**
  72782. * Fills the matrix from direct values
  72783. * @param m00 defines value for (0, 0)
  72784. * @param m01 defines value for (0, 1)
  72785. * @param m10 defines value for (1, 0)
  72786. * @param m11 defines value for (1, 1)
  72787. * @param m20 defines value for (2, 0)
  72788. * @param m21 defines value for (2, 1)
  72789. * @returns the current modified matrix
  72790. */
  72791. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  72792. /**
  72793. * Gets matrix determinant
  72794. * @returns the determinant
  72795. */
  72796. determinant(): number;
  72797. /**
  72798. * Inverses the matrix and stores it in a target matrix
  72799. * @param result defines the target matrix
  72800. * @returns the current matrix
  72801. */
  72802. invertToRef(result: Matrix2D): Matrix2D;
  72803. /**
  72804. * Multiplies the current matrix with another one
  72805. * @param other defines the second operand
  72806. * @param result defines the target matrix
  72807. * @returns the current matrix
  72808. */
  72809. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  72810. /**
  72811. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  72812. * @param x defines the x coordinate to transform
  72813. * @param y defines the x coordinate to transform
  72814. * @param result defines the target vector2
  72815. * @returns the current matrix
  72816. */
  72817. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  72818. /**
  72819. * Creates an identity matrix
  72820. * @returns a new matrix
  72821. */
  72822. static Identity(): Matrix2D;
  72823. /**
  72824. * Creates a translation matrix and stores it in a target matrix
  72825. * @param x defines the x coordinate of the translation
  72826. * @param y defines the y coordinate of the translation
  72827. * @param result defines the target matrix
  72828. */
  72829. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  72830. /**
  72831. * Creates a scaling matrix and stores it in a target matrix
  72832. * @param x defines the x coordinate of the scaling
  72833. * @param y defines the y coordinate of the scaling
  72834. * @param result defines the target matrix
  72835. */
  72836. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  72837. /**
  72838. * Creates a rotation matrix and stores it in a target matrix
  72839. * @param angle defines the rotation angle
  72840. * @param result defines the target matrix
  72841. */
  72842. static RotationToRef(angle: number, result: Matrix2D): void;
  72843. private static _TempPreTranslationMatrix;
  72844. private static _TempPostTranslationMatrix;
  72845. private static _TempRotationMatrix;
  72846. private static _TempScalingMatrix;
  72847. private static _TempCompose0;
  72848. private static _TempCompose1;
  72849. private static _TempCompose2;
  72850. /**
  72851. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  72852. * @param tx defines the x coordinate of the translation
  72853. * @param ty defines the y coordinate of the translation
  72854. * @param angle defines the rotation angle
  72855. * @param scaleX defines the x coordinate of the scaling
  72856. * @param scaleY defines the y coordinate of the scaling
  72857. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  72858. * @param result defines the target matrix
  72859. */
  72860. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  72861. }
  72862. }
  72863. declare module BABYLON.GUI {
  72864. /**
  72865. * Class used to store 2D control sizes
  72866. */
  72867. export class Measure {
  72868. /** defines left coordinate */
  72869. left: number;
  72870. /** defines top coordinate */
  72871. top: number;
  72872. /** defines width dimension */
  72873. width: number;
  72874. /** defines height dimension */
  72875. height: number;
  72876. /**
  72877. * Creates a new measure
  72878. * @param left defines left coordinate
  72879. * @param top defines top coordinate
  72880. * @param width defines width dimension
  72881. * @param height defines height dimension
  72882. */
  72883. constructor(
  72884. /** defines left coordinate */
  72885. left: number,
  72886. /** defines top coordinate */
  72887. top: number,
  72888. /** defines width dimension */
  72889. width: number,
  72890. /** defines height dimension */
  72891. height: number);
  72892. /**
  72893. * Copy from another measure
  72894. * @param other defines the other measure to copy from
  72895. */
  72896. copyFrom(other: Measure): void;
  72897. /**
  72898. * Copy from a group of 4 floats
  72899. * @param left defines left coordinate
  72900. * @param top defines top coordinate
  72901. * @param width defines width dimension
  72902. * @param height defines height dimension
  72903. */
  72904. copyFromFloats(left: number, top: number, width: number, height: number): void;
  72905. /**
  72906. * Computes the axis aligned bounding box measure for two given measures
  72907. * @param a Input measure
  72908. * @param b Input measure
  72909. * @param result the resulting bounding measure
  72910. */
  72911. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  72912. /**
  72913. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  72914. * @param transform the matrix to transform the measure before computing the AABB
  72915. * @param result the resulting AABB
  72916. */
  72917. transformToRef(transform: Matrix2D, result: Measure): void;
  72918. /**
  72919. * Check equality between this measure and another one
  72920. * @param other defines the other measures
  72921. * @returns true if both measures are equals
  72922. */
  72923. isEqualsTo(other: Measure): boolean;
  72924. /**
  72925. * Creates an empty measure
  72926. * @returns a new measure
  72927. */
  72928. static Empty(): Measure;
  72929. }
  72930. }
  72931. declare module BABYLON.GUI {
  72932. /**
  72933. * Interface used to define a control that can receive focus
  72934. */
  72935. export interface IFocusableControl {
  72936. /**
  72937. * Function called when the control receives the focus
  72938. */
  72939. onFocus(): void;
  72940. /**
  72941. * Function called when the control loses the focus
  72942. */
  72943. onBlur(): void;
  72944. /**
  72945. * Function called to let the control handle keyboard events
  72946. * @param evt defines the current keyboard event
  72947. */
  72948. processKeyboard(evt: KeyboardEvent): void;
  72949. /**
  72950. * Function called to get the list of controls that should not steal the focus from this control
  72951. * @returns an array of controls
  72952. */
  72953. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72954. }
  72955. /**
  72956. * Class used to create texture to support 2D GUI elements
  72957. * @see http://doc.babylonjs.com/how_to/gui
  72958. */
  72959. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  72960. private _isDirty;
  72961. private _renderObserver;
  72962. private _resizeObserver;
  72963. private _preKeyboardObserver;
  72964. private _pointerMoveObserver;
  72965. private _pointerObserver;
  72966. private _canvasPointerOutObserver;
  72967. private _background;
  72968. /** @hidden */
  72969. _rootContainer: Container;
  72970. /** @hidden */
  72971. _lastPickedControl: Control;
  72972. /** @hidden */
  72973. _lastControlOver: {
  72974. [pointerId: number]: Control;
  72975. };
  72976. /** @hidden */
  72977. _lastControlDown: {
  72978. [pointerId: number]: Control;
  72979. };
  72980. /** @hidden */
  72981. _capturingControl: {
  72982. [pointerId: number]: Control;
  72983. };
  72984. /** @hidden */
  72985. _shouldBlockPointer: boolean;
  72986. /** @hidden */
  72987. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  72988. /** @hidden */
  72989. _linkedControls: Control[];
  72990. private _isFullscreen;
  72991. private _fullscreenViewport;
  72992. private _idealWidth;
  72993. private _idealHeight;
  72994. private _useSmallestIdeal;
  72995. private _renderAtIdealSize;
  72996. private _focusedControl;
  72997. private _blockNextFocusCheck;
  72998. private _renderScale;
  72999. private _rootElement;
  73000. private _cursorChanged;
  73001. private _defaultMousePointerId;
  73002. /** @hidden */
  73003. _numLayoutCalls: number;
  73004. /** Gets the number of layout calls made the last time the ADT has been rendered */
  73005. get numLayoutCalls(): number;
  73006. /** @hidden */
  73007. _numRenderCalls: number;
  73008. /** Gets the number of render calls made the last time the ADT has been rendered */
  73009. get numRenderCalls(): number;
  73010. /**
  73011. * Define type to string to ensure compatibility across browsers
  73012. * Safari doesn't support DataTransfer constructor
  73013. */
  73014. private _clipboardData;
  73015. /**
  73016. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  73017. */
  73018. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  73019. /**
  73020. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  73021. */
  73022. onControlPickedObservable: BABYLON.Observable<Control>;
  73023. /**
  73024. * BABYLON.Observable event triggered before layout is evaluated
  73025. */
  73026. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73027. /**
  73028. * BABYLON.Observable event triggered after the layout was evaluated
  73029. */
  73030. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73031. /**
  73032. * BABYLON.Observable event triggered before the texture is rendered
  73033. */
  73034. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73035. /**
  73036. * BABYLON.Observable event triggered after the texture was rendered
  73037. */
  73038. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  73039. /**
  73040. * Gets or sets a boolean defining if alpha is stored as premultiplied
  73041. */
  73042. premulAlpha: boolean;
  73043. /**
  73044. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  73045. * Useful when you want more antialiasing
  73046. */
  73047. get renderScale(): number;
  73048. set renderScale(value: number);
  73049. /** Gets or sets the background color */
  73050. get background(): string;
  73051. set background(value: string);
  73052. /**
  73053. * Gets or sets the ideal width used to design controls.
  73054. * The GUI will then rescale everything accordingly
  73055. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73056. */
  73057. get idealWidth(): number;
  73058. set idealWidth(value: number);
  73059. /**
  73060. * Gets or sets the ideal height used to design controls.
  73061. * The GUI will then rescale everything accordingly
  73062. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73063. */
  73064. get idealHeight(): number;
  73065. set idealHeight(value: number);
  73066. /**
  73067. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  73068. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73069. */
  73070. get useSmallestIdeal(): boolean;
  73071. set useSmallestIdeal(value: boolean);
  73072. /**
  73073. * Gets or sets a boolean indicating if adaptive scaling must be used
  73074. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73075. */
  73076. get renderAtIdealSize(): boolean;
  73077. set renderAtIdealSize(value: boolean);
  73078. /**
  73079. * Gets the ratio used when in "ideal mode"
  73080. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  73081. * */
  73082. get idealRatio(): number;
  73083. /**
  73084. * Gets the underlying layer used to render the texture when in fullscreen mode
  73085. */
  73086. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  73087. /**
  73088. * Gets the root container control
  73089. */
  73090. get rootContainer(): Container;
  73091. /**
  73092. * Returns an array containing the root container.
  73093. * This is mostly used to let the Inspector introspects the ADT
  73094. * @returns an array containing the rootContainer
  73095. */
  73096. getChildren(): Array<Container>;
  73097. /**
  73098. * Will return all controls that are inside this texture
  73099. * @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
  73100. * @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
  73101. * @return all child controls
  73102. */
  73103. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73104. /**
  73105. * Gets or sets the current focused control
  73106. */
  73107. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  73108. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  73109. /**
  73110. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  73111. */
  73112. get isForeground(): boolean;
  73113. set isForeground(value: boolean);
  73114. /**
  73115. * Gets or set information about clipboardData
  73116. */
  73117. get clipboardData(): string;
  73118. set clipboardData(value: string);
  73119. /**
  73120. * Creates a new AdvancedDynamicTexture
  73121. * @param name defines the name of the texture
  73122. * @param width defines the width of the texture
  73123. * @param height defines the height of the texture
  73124. * @param scene defines the hosting scene
  73125. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  73126. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  73127. */
  73128. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  73129. /**
  73130. * Get the current class name of the texture useful for serialization or dynamic coding.
  73131. * @returns "AdvancedDynamicTexture"
  73132. */
  73133. getClassName(): string;
  73134. /**
  73135. * Function used to execute a function on all controls
  73136. * @param func defines the function to execute
  73137. * @param container defines the container where controls belong. If null the root container will be used
  73138. */
  73139. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  73140. private _useInvalidateRectOptimization;
  73141. /**
  73142. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  73143. */
  73144. get useInvalidateRectOptimization(): boolean;
  73145. set useInvalidateRectOptimization(value: boolean);
  73146. private _invalidatedRectangle;
  73147. /**
  73148. * Invalidates a rectangle area on the gui texture
  73149. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  73150. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  73151. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  73152. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  73153. */
  73154. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  73155. /**
  73156. * Marks the texture as dirty forcing a complete update
  73157. */
  73158. markAsDirty(): void;
  73159. /**
  73160. * Helper function used to create a new style
  73161. * @returns a new style
  73162. * @see http://doc.babylonjs.com/how_to/gui#styles
  73163. */
  73164. createStyle(): Style;
  73165. /**
  73166. * Adds a new control to the root container
  73167. * @param control defines the control to add
  73168. * @returns the current texture
  73169. */
  73170. addControl(control: Control): AdvancedDynamicTexture;
  73171. /**
  73172. * Removes a control from the root container
  73173. * @param control defines the control to remove
  73174. * @returns the current texture
  73175. */
  73176. removeControl(control: Control): AdvancedDynamicTexture;
  73177. /**
  73178. * Release all resources
  73179. */
  73180. dispose(): void;
  73181. private _onResize;
  73182. /** @hidden */
  73183. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  73184. /**
  73185. * Get screen coordinates for a vector3
  73186. * @param position defines the position to project
  73187. * @param worldMatrix defines the world matrix to use
  73188. * @returns the projected position
  73189. */
  73190. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  73191. private _checkUpdate;
  73192. private _clearMeasure;
  73193. private _render;
  73194. /** @hidden */
  73195. _changeCursor(cursor: string): void;
  73196. /** @hidden */
  73197. _registerLastControlDown(control: Control, pointerId: number): void;
  73198. private _doPicking;
  73199. /** @hidden */
  73200. _cleanControlAfterRemovalFromList(list: {
  73201. [pointerId: number]: Control;
  73202. }, control: Control): void;
  73203. /** @hidden */
  73204. _cleanControlAfterRemoval(control: Control): void;
  73205. /** Attach to all scene events required to support pointer events */
  73206. attach(): void;
  73207. /** @hidden */
  73208. private onClipboardCopy;
  73209. /** @hidden */
  73210. private onClipboardCut;
  73211. /** @hidden */
  73212. private onClipboardPaste;
  73213. /**
  73214. * Register the clipboard Events onto the canvas
  73215. */
  73216. registerClipboardEvents(): void;
  73217. /**
  73218. * Unregister the clipboard Events from the canvas
  73219. */
  73220. unRegisterClipboardEvents(): void;
  73221. /**
  73222. * Connect the texture to a hosting mesh to enable interactions
  73223. * @param mesh defines the mesh to attach to
  73224. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  73225. */
  73226. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  73227. /**
  73228. * Move the focus to a specific control
  73229. * @param control defines the control which will receive the focus
  73230. */
  73231. moveFocusToControl(control: IFocusableControl): void;
  73232. private _manageFocus;
  73233. private _attachToOnPointerOut;
  73234. /**
  73235. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  73236. * @param mesh defines the mesh which will receive the texture
  73237. * @param width defines the texture width (1024 by default)
  73238. * @param height defines the texture height (1024 by default)
  73239. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  73240. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  73241. * @returns a new AdvancedDynamicTexture
  73242. */
  73243. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  73244. /**
  73245. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  73246. * In this mode the texture will rely on a layer for its rendering.
  73247. * This allows it to be treated like any other layer.
  73248. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  73249. * LayerMask is set through advancedTexture.layer.layerMask
  73250. * @param name defines name for the texture
  73251. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  73252. * @param scene defines the hsoting scene
  73253. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  73254. * @returns a new AdvancedDynamicTexture
  73255. */
  73256. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  73257. }
  73258. }
  73259. declare module BABYLON.GUI {
  73260. /**
  73261. * Root class used for all 2D controls
  73262. * @see http://doc.babylonjs.com/how_to/gui#controls
  73263. */
  73264. export class Control {
  73265. /** defines the name of the control */
  73266. name?: string | undefined;
  73267. /**
  73268. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  73269. */
  73270. static AllowAlphaInheritance: boolean;
  73271. private _alpha;
  73272. private _alphaSet;
  73273. private _zIndex;
  73274. /** @hidden */
  73275. _host: AdvancedDynamicTexture;
  73276. /** Gets or sets the control parent */
  73277. parent: BABYLON.Nullable<Container>;
  73278. /** @hidden */
  73279. _currentMeasure: Measure;
  73280. private _fontFamily;
  73281. private _fontStyle;
  73282. private _fontWeight;
  73283. private _fontSize;
  73284. private _font;
  73285. /** @hidden */
  73286. _width: ValueAndUnit;
  73287. /** @hidden */
  73288. _height: ValueAndUnit;
  73289. /** @hidden */
  73290. protected _fontOffset: {
  73291. ascent: number;
  73292. height: number;
  73293. descent: number;
  73294. };
  73295. private _color;
  73296. private _style;
  73297. private _styleObserver;
  73298. /** @hidden */
  73299. protected _horizontalAlignment: number;
  73300. /** @hidden */
  73301. protected _verticalAlignment: number;
  73302. /** @hidden */
  73303. protected _isDirty: boolean;
  73304. /** @hidden */
  73305. protected _wasDirty: boolean;
  73306. /** @hidden */
  73307. _tempParentMeasure: Measure;
  73308. /** @hidden */
  73309. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  73310. /** @hidden */
  73311. protected _cachedParentMeasure: Measure;
  73312. private _paddingLeft;
  73313. private _paddingRight;
  73314. private _paddingTop;
  73315. private _paddingBottom;
  73316. /** @hidden */
  73317. _left: ValueAndUnit;
  73318. /** @hidden */
  73319. _top: ValueAndUnit;
  73320. private _scaleX;
  73321. private _scaleY;
  73322. private _rotation;
  73323. private _transformCenterX;
  73324. private _transformCenterY;
  73325. /** @hidden */
  73326. _transformMatrix: Matrix2D;
  73327. /** @hidden */
  73328. protected _invertTransformMatrix: Matrix2D;
  73329. /** @hidden */
  73330. protected _transformedPosition: BABYLON.Vector2;
  73331. private _isMatrixDirty;
  73332. private _cachedOffsetX;
  73333. private _cachedOffsetY;
  73334. private _isVisible;
  73335. private _isHighlighted;
  73336. /** @hidden */
  73337. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  73338. private _fontSet;
  73339. private _dummyVector2;
  73340. private _downCount;
  73341. private _enterCount;
  73342. private _doNotRender;
  73343. private _downPointerIds;
  73344. protected _isEnabled: boolean;
  73345. protected _disabledColor: string;
  73346. protected _disabledColorItem: string;
  73347. /** @hidden */
  73348. protected _rebuildLayout: boolean;
  73349. /** @hidden */
  73350. _customData: any;
  73351. /** @hidden */
  73352. _isClipped: boolean;
  73353. /** @hidden */
  73354. _automaticSize: boolean;
  73355. /** @hidden */
  73356. _tag: any;
  73357. /**
  73358. * 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
  73359. */
  73360. uniqueId: number;
  73361. /**
  73362. * Gets or sets an object used to store user defined information for the node
  73363. */
  73364. metadata: any;
  73365. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  73366. isHitTestVisible: boolean;
  73367. /** Gets or sets a boolean indicating if the control can block pointer events */
  73368. isPointerBlocker: boolean;
  73369. /** Gets or sets a boolean indicating if the control can be focusable */
  73370. isFocusInvisible: boolean;
  73371. /**
  73372. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  73373. * 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
  73374. */
  73375. clipChildren: boolean;
  73376. /**
  73377. * Gets or sets a boolean indicating that control content must be clipped
  73378. * 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
  73379. */
  73380. clipContent: boolean;
  73381. /**
  73382. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  73383. */
  73384. useBitmapCache: boolean;
  73385. private _cacheData;
  73386. private _shadowOffsetX;
  73387. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  73388. get shadowOffsetX(): number;
  73389. set shadowOffsetX(value: number);
  73390. private _shadowOffsetY;
  73391. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  73392. get shadowOffsetY(): number;
  73393. set shadowOffsetY(value: number);
  73394. private _shadowBlur;
  73395. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  73396. get shadowBlur(): number;
  73397. set shadowBlur(value: number);
  73398. private _shadowColor;
  73399. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  73400. get shadowColor(): string;
  73401. set shadowColor(value: string);
  73402. /** Gets or sets the cursor to use when the control is hovered */
  73403. hoverCursor: string;
  73404. /** @hidden */
  73405. protected _linkOffsetX: ValueAndUnit;
  73406. /** @hidden */
  73407. protected _linkOffsetY: ValueAndUnit;
  73408. /** Gets the control type name */
  73409. get typeName(): string;
  73410. /**
  73411. * Get the current class name of the control.
  73412. * @returns current class name
  73413. */
  73414. getClassName(): string;
  73415. /**
  73416. * An event triggered when pointer wheel is scrolled
  73417. */
  73418. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  73419. /**
  73420. * An event triggered when the pointer move over the control.
  73421. */
  73422. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  73423. /**
  73424. * An event triggered when the pointer move out of the control.
  73425. */
  73426. onPointerOutObservable: BABYLON.Observable<Control>;
  73427. /**
  73428. * An event triggered when the pointer taps the control
  73429. */
  73430. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  73431. /**
  73432. * An event triggered when pointer up
  73433. */
  73434. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  73435. /**
  73436. * An event triggered when a control is clicked on
  73437. */
  73438. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  73439. /**
  73440. * An event triggered when pointer enters the control
  73441. */
  73442. onPointerEnterObservable: BABYLON.Observable<Control>;
  73443. /**
  73444. * An event triggered when the control is marked as dirty
  73445. */
  73446. onDirtyObservable: BABYLON.Observable<Control>;
  73447. /**
  73448. * An event triggered before drawing the control
  73449. */
  73450. onBeforeDrawObservable: BABYLON.Observable<Control>;
  73451. /**
  73452. * An event triggered after the control was drawn
  73453. */
  73454. onAfterDrawObservable: BABYLON.Observable<Control>;
  73455. /**
  73456. * An event triggered when the control has been disposed
  73457. */
  73458. onDisposeObservable: BABYLON.Observable<Control>;
  73459. /**
  73460. * Get the hosting AdvancedDynamicTexture
  73461. */
  73462. get host(): AdvancedDynamicTexture;
  73463. /** Gets or set information about font offsets (used to render and align text) */
  73464. get fontOffset(): {
  73465. ascent: number;
  73466. height: number;
  73467. descent: number;
  73468. };
  73469. set fontOffset(offset: {
  73470. ascent: number;
  73471. height: number;
  73472. descent: number;
  73473. });
  73474. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  73475. get alpha(): number;
  73476. set alpha(value: number);
  73477. /**
  73478. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  73479. */
  73480. get isHighlighted(): boolean;
  73481. set isHighlighted(value: boolean);
  73482. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  73483. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73484. */
  73485. get scaleX(): number;
  73486. set scaleX(value: number);
  73487. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  73488. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73489. */
  73490. get scaleY(): number;
  73491. set scaleY(value: number);
  73492. /** Gets or sets the rotation angle (0 by default)
  73493. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73494. */
  73495. get rotation(): number;
  73496. set rotation(value: number);
  73497. /** Gets or sets the transformation center on Y axis (0 by default)
  73498. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73499. */
  73500. get transformCenterY(): number;
  73501. set transformCenterY(value: number);
  73502. /** Gets or sets the transformation center on X axis (0 by default)
  73503. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  73504. */
  73505. get transformCenterX(): number;
  73506. set transformCenterX(value: number);
  73507. /**
  73508. * Gets or sets the horizontal alignment
  73509. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73510. */
  73511. get horizontalAlignment(): number;
  73512. set horizontalAlignment(value: number);
  73513. /**
  73514. * Gets or sets the vertical alignment
  73515. * @see http://doc.babylonjs.com/how_to/gui#alignments
  73516. */
  73517. get verticalAlignment(): number;
  73518. set verticalAlignment(value: number);
  73519. /**
  73520. * Gets or sets control width
  73521. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73522. */
  73523. get width(): string | number;
  73524. set width(value: string | number);
  73525. /**
  73526. * Gets or sets the control width in pixel
  73527. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73528. */
  73529. get widthInPixels(): number;
  73530. set widthInPixels(value: number);
  73531. /**
  73532. * Gets or sets control height
  73533. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73534. */
  73535. get height(): string | number;
  73536. set height(value: string | number);
  73537. /**
  73538. * Gets or sets control height in pixel
  73539. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73540. */
  73541. get heightInPixels(): number;
  73542. set heightInPixels(value: number);
  73543. /** Gets or set font family */
  73544. get fontFamily(): string;
  73545. set fontFamily(value: string);
  73546. /** Gets or sets font style */
  73547. get fontStyle(): string;
  73548. set fontStyle(value: string);
  73549. /** Gets or sets font weight */
  73550. get fontWeight(): string;
  73551. set fontWeight(value: string);
  73552. /**
  73553. * Gets or sets style
  73554. * @see http://doc.babylonjs.com/how_to/gui#styles
  73555. */
  73556. get style(): BABYLON.Nullable<Style>;
  73557. set style(value: BABYLON.Nullable<Style>);
  73558. /** @hidden */
  73559. get _isFontSizeInPercentage(): boolean;
  73560. /** Gets or sets font size in pixels */
  73561. get fontSizeInPixels(): number;
  73562. set fontSizeInPixels(value: number);
  73563. /** Gets or sets font size */
  73564. get fontSize(): string | number;
  73565. set fontSize(value: string | number);
  73566. /** Gets or sets foreground color */
  73567. get color(): string;
  73568. set color(value: string);
  73569. /** Gets or sets z index which is used to reorder controls on the z axis */
  73570. get zIndex(): number;
  73571. set zIndex(value: number);
  73572. /** Gets or sets a boolean indicating if the control can be rendered */
  73573. get notRenderable(): boolean;
  73574. set notRenderable(value: boolean);
  73575. /** Gets or sets a boolean indicating if the control is visible */
  73576. get isVisible(): boolean;
  73577. set isVisible(value: boolean);
  73578. /** Gets a boolean indicating that the control needs to update its rendering */
  73579. get isDirty(): boolean;
  73580. /**
  73581. * Gets the current linked mesh (or null if none)
  73582. */
  73583. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73584. /**
  73585. * Gets or sets a value indicating the padding to use on the left of the control
  73586. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73587. */
  73588. get paddingLeft(): string | number;
  73589. set paddingLeft(value: string | number);
  73590. /**
  73591. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  73592. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73593. */
  73594. get paddingLeftInPixels(): number;
  73595. set paddingLeftInPixels(value: number);
  73596. /**
  73597. * Gets or sets a value indicating the padding to use on the right of the control
  73598. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73599. */
  73600. get paddingRight(): string | number;
  73601. set paddingRight(value: string | number);
  73602. /**
  73603. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  73604. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73605. */
  73606. get paddingRightInPixels(): number;
  73607. set paddingRightInPixels(value: number);
  73608. /**
  73609. * Gets or sets a value indicating the padding to use on the top of the control
  73610. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73611. */
  73612. get paddingTop(): string | number;
  73613. set paddingTop(value: string | number);
  73614. /**
  73615. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  73616. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73617. */
  73618. get paddingTopInPixels(): number;
  73619. set paddingTopInPixels(value: number);
  73620. /**
  73621. * Gets or sets a value indicating the padding to use on the bottom of the control
  73622. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73623. */
  73624. get paddingBottom(): string | number;
  73625. set paddingBottom(value: string | number);
  73626. /**
  73627. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  73628. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73629. */
  73630. get paddingBottomInPixels(): number;
  73631. set paddingBottomInPixels(value: number);
  73632. /**
  73633. * Gets or sets a value indicating the left coordinate of the control
  73634. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73635. */
  73636. get left(): string | number;
  73637. set left(value: string | number);
  73638. /**
  73639. * Gets or sets a value indicating the left coordinate in pixels of the control
  73640. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73641. */
  73642. get leftInPixels(): number;
  73643. set leftInPixels(value: number);
  73644. /**
  73645. * Gets or sets a value indicating the top coordinate of the control
  73646. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73647. */
  73648. get top(): string | number;
  73649. set top(value: string | number);
  73650. /**
  73651. * Gets or sets a value indicating the top coordinate in pixels of the control
  73652. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73653. */
  73654. get topInPixels(): number;
  73655. set topInPixels(value: number);
  73656. /**
  73657. * Gets or sets a value indicating the offset on X axis to the linked mesh
  73658. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73659. */
  73660. get linkOffsetX(): string | number;
  73661. set linkOffsetX(value: string | number);
  73662. /**
  73663. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  73664. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73665. */
  73666. get linkOffsetXInPixels(): number;
  73667. set linkOffsetXInPixels(value: number);
  73668. /**
  73669. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  73670. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73671. */
  73672. get linkOffsetY(): string | number;
  73673. set linkOffsetY(value: string | number);
  73674. /**
  73675. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  73676. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73677. */
  73678. get linkOffsetYInPixels(): number;
  73679. set linkOffsetYInPixels(value: number);
  73680. /** Gets the center coordinate on X axis */
  73681. get centerX(): number;
  73682. /** Gets the center coordinate on Y axis */
  73683. get centerY(): number;
  73684. /** Gets or sets if control is Enabled*/
  73685. get isEnabled(): boolean;
  73686. set isEnabled(value: boolean);
  73687. /** Gets or sets background color of control if it's disabled*/
  73688. get disabledColor(): string;
  73689. set disabledColor(value: string);
  73690. /** Gets or sets front color of control if it's disabled*/
  73691. get disabledColorItem(): string;
  73692. set disabledColorItem(value: string);
  73693. /**
  73694. * Creates a new control
  73695. * @param name defines the name of the control
  73696. */
  73697. constructor(
  73698. /** defines the name of the control */
  73699. name?: string | undefined);
  73700. /** @hidden */
  73701. protected _getTypeName(): string;
  73702. /**
  73703. * Gets the first ascendant in the hierarchy of the given type
  73704. * @param className defines the required type
  73705. * @returns the ascendant or null if not found
  73706. */
  73707. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  73708. /** @hidden */
  73709. _resetFontCache(): void;
  73710. /**
  73711. * Determines if a container is an ascendant of the current control
  73712. * @param container defines the container to look for
  73713. * @returns true if the container is one of the ascendant of the control
  73714. */
  73715. isAscendant(container: Control): boolean;
  73716. /**
  73717. * Gets coordinates in local control space
  73718. * @param globalCoordinates defines the coordinates to transform
  73719. * @returns the new coordinates in local space
  73720. */
  73721. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73722. /**
  73723. * Gets coordinates in local control space
  73724. * @param globalCoordinates defines the coordinates to transform
  73725. * @param result defines the target vector2 where to store the result
  73726. * @returns the current control
  73727. */
  73728. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  73729. /**
  73730. * Gets coordinates in parent local control space
  73731. * @param globalCoordinates defines the coordinates to transform
  73732. * @returns the new coordinates in parent local space
  73733. */
  73734. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  73735. /**
  73736. * Move the current control to a vector3 position projected onto the screen.
  73737. * @param position defines the target position
  73738. * @param scene defines the hosting scene
  73739. */
  73740. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  73741. /**
  73742. * Will store all controls that have this control as ascendant in a given array
  73743. * @param results defines the array where to store the descendants
  73744. * @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
  73745. * @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
  73746. */
  73747. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73748. /**
  73749. * Will return all controls that have this control as ascendant
  73750. * @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
  73751. * @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
  73752. * @return all child controls
  73753. */
  73754. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  73755. /**
  73756. * Link current control with a target mesh
  73757. * @param mesh defines the mesh to link with
  73758. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  73759. */
  73760. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  73761. /** @hidden */
  73762. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  73763. /** @hidden */
  73764. _offsetLeft(offset: number): void;
  73765. /** @hidden */
  73766. _offsetTop(offset: number): void;
  73767. /** @hidden */
  73768. _markMatrixAsDirty(): void;
  73769. /** @hidden */
  73770. _flagDescendantsAsMatrixDirty(): void;
  73771. /** @hidden */
  73772. _intersectsRect(rect: Measure): boolean;
  73773. /** @hidden */
  73774. protected invalidateRect(): void;
  73775. /** @hidden */
  73776. _markAsDirty(force?: boolean): void;
  73777. /** @hidden */
  73778. _markAllAsDirty(): void;
  73779. /** @hidden */
  73780. _link(host: AdvancedDynamicTexture): void;
  73781. /** @hidden */
  73782. protected _transform(context?: CanvasRenderingContext2D): void;
  73783. /** @hidden */
  73784. _renderHighlight(context: CanvasRenderingContext2D): void;
  73785. /** @hidden */
  73786. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73787. /** @hidden */
  73788. protected _applyStates(context: CanvasRenderingContext2D): void;
  73789. /** @hidden */
  73790. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73791. /** @hidden */
  73792. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73793. protected _evaluateClippingState(parentMeasure: Measure): void;
  73794. /** @hidden */
  73795. _measure(): void;
  73796. /** @hidden */
  73797. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73798. /** @hidden */
  73799. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73800. /** @hidden */
  73801. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73802. /** @hidden */
  73803. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73804. private static _ClipMeasure;
  73805. private _tmpMeasureA;
  73806. private _clip;
  73807. /** @hidden */
  73808. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  73809. /** @hidden */
  73810. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73811. /**
  73812. * Tests if a given coordinates belong to the current control
  73813. * @param x defines x coordinate to test
  73814. * @param y defines y coordinate to test
  73815. * @returns true if the coordinates are inside the control
  73816. */
  73817. contains(x: number, y: number): boolean;
  73818. /** @hidden */
  73819. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73820. /** @hidden */
  73821. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73822. /** @hidden */
  73823. _onPointerEnter(target: Control): boolean;
  73824. /** @hidden */
  73825. _onPointerOut(target: Control, force?: boolean): void;
  73826. /** @hidden */
  73827. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73828. /** @hidden */
  73829. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73830. /** @hidden */
  73831. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73832. /** @hidden */
  73833. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  73834. /** @hidden */
  73835. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73836. private _prepareFont;
  73837. /** Releases associated resources */
  73838. dispose(): void;
  73839. private static _HORIZONTAL_ALIGNMENT_LEFT;
  73840. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  73841. private static _HORIZONTAL_ALIGNMENT_CENTER;
  73842. private static _VERTICAL_ALIGNMENT_TOP;
  73843. private static _VERTICAL_ALIGNMENT_BOTTOM;
  73844. private static _VERTICAL_ALIGNMENT_CENTER;
  73845. /** HORIZONTAL_ALIGNMENT_LEFT */
  73846. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  73847. /** HORIZONTAL_ALIGNMENT_RIGHT */
  73848. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  73849. /** HORIZONTAL_ALIGNMENT_CENTER */
  73850. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  73851. /** VERTICAL_ALIGNMENT_TOP */
  73852. static get VERTICAL_ALIGNMENT_TOP(): number;
  73853. /** VERTICAL_ALIGNMENT_BOTTOM */
  73854. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  73855. /** VERTICAL_ALIGNMENT_CENTER */
  73856. static get VERTICAL_ALIGNMENT_CENTER(): number;
  73857. private static _FontHeightSizes;
  73858. /** @hidden */
  73859. static _GetFontOffset(font: string): {
  73860. ascent: number;
  73861. height: number;
  73862. descent: number;
  73863. };
  73864. /**
  73865. * Creates a stack panel that can be used to render headers
  73866. * @param control defines the control to associate with the header
  73867. * @param text defines the text of the header
  73868. * @param size defines the size of the header
  73869. * @param options defines options used to configure the header
  73870. * @returns a new StackPanel
  73871. * @ignore
  73872. * @hidden
  73873. */
  73874. static AddHeader: (control: Control, text: string, size: string | number, options: {
  73875. isHorizontal: boolean;
  73876. controlFirst: boolean;
  73877. }) => any;
  73878. /** @hidden */
  73879. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  73880. }
  73881. }
  73882. declare module BABYLON.GUI {
  73883. /**
  73884. * Root class for 2D containers
  73885. * @see http://doc.babylonjs.com/how_to/gui#containers
  73886. */
  73887. export class Container extends Control {
  73888. name?: string | undefined;
  73889. /** @hidden */
  73890. _children: Control[];
  73891. /** @hidden */
  73892. protected _measureForChildren: Measure;
  73893. /** @hidden */
  73894. protected _background: string;
  73895. /** @hidden */
  73896. protected _adaptWidthToChildren: boolean;
  73897. /** @hidden */
  73898. protected _adaptHeightToChildren: boolean;
  73899. /**
  73900. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  73901. */
  73902. logLayoutCycleErrors: boolean;
  73903. /**
  73904. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  73905. */
  73906. maxLayoutCycle: number;
  73907. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  73908. get adaptHeightToChildren(): boolean;
  73909. set adaptHeightToChildren(value: boolean);
  73910. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  73911. get adaptWidthToChildren(): boolean;
  73912. set adaptWidthToChildren(value: boolean);
  73913. /** Gets or sets background color */
  73914. get background(): string;
  73915. set background(value: string);
  73916. /** Gets the list of children */
  73917. get children(): Control[];
  73918. /**
  73919. * Creates a new Container
  73920. * @param name defines the name of the container
  73921. */
  73922. constructor(name?: string | undefined);
  73923. protected _getTypeName(): string;
  73924. _flagDescendantsAsMatrixDirty(): void;
  73925. /**
  73926. * Gets a child using its name
  73927. * @param name defines the child name to look for
  73928. * @returns the child control if found
  73929. */
  73930. getChildByName(name: string): BABYLON.Nullable<Control>;
  73931. /**
  73932. * Gets a child using its type and its name
  73933. * @param name defines the child name to look for
  73934. * @param type defines the child type to look for
  73935. * @returns the child control if found
  73936. */
  73937. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  73938. /**
  73939. * Search for a specific control in children
  73940. * @param control defines the control to look for
  73941. * @returns true if the control is in child list
  73942. */
  73943. containsControl(control: Control): boolean;
  73944. /**
  73945. * Adds a new control to the current container
  73946. * @param control defines the control to add
  73947. * @returns the current container
  73948. */
  73949. addControl(control: BABYLON.Nullable<Control>): Container;
  73950. /**
  73951. * Removes all controls from the current container
  73952. * @returns the current container
  73953. */
  73954. clearControls(): Container;
  73955. /**
  73956. * Removes a control from the current container
  73957. * @param control defines the control to remove
  73958. * @returns the current container
  73959. */
  73960. removeControl(control: Control): Container;
  73961. /** @hidden */
  73962. _reOrderControl(control: Control): void;
  73963. /** @hidden */
  73964. _offsetLeft(offset: number): void;
  73965. /** @hidden */
  73966. _offsetTop(offset: number): void;
  73967. /** @hidden */
  73968. _markAllAsDirty(): void;
  73969. /** @hidden */
  73970. protected _localDraw(context: CanvasRenderingContext2D): void;
  73971. /** @hidden */
  73972. _link(host: AdvancedDynamicTexture): void;
  73973. /** @hidden */
  73974. protected _beforeLayout(): void;
  73975. /** @hidden */
  73976. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73977. /** @hidden */
  73978. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73979. protected _postMeasure(): void;
  73980. /** @hidden */
  73981. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73982. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  73983. /** @hidden */
  73984. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  73985. /** @hidden */
  73986. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73987. /** Releases associated resources */
  73988. dispose(): void;
  73989. }
  73990. }
  73991. declare module BABYLON.GUI {
  73992. /** Class used to create rectangle container */
  73993. export class Rectangle extends Container {
  73994. name?: string | undefined;
  73995. private _thickness;
  73996. private _cornerRadius;
  73997. /** Gets or sets border thickness */
  73998. get thickness(): number;
  73999. set thickness(value: number);
  74000. /** Gets or sets the corner radius angle */
  74001. get cornerRadius(): number;
  74002. set cornerRadius(value: number);
  74003. /**
  74004. * Creates a new Rectangle
  74005. * @param name defines the control name
  74006. */
  74007. constructor(name?: string | undefined);
  74008. protected _getTypeName(): string;
  74009. protected _localDraw(context: CanvasRenderingContext2D): void;
  74010. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74011. private _drawRoundedRect;
  74012. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74013. }
  74014. }
  74015. declare module BABYLON.GUI {
  74016. /**
  74017. * Enum that determines the text-wrapping mode to use.
  74018. */
  74019. export enum TextWrapping {
  74020. /**
  74021. * Clip the text when it's larger than Control.width; this is the default mode.
  74022. */
  74023. Clip = 0,
  74024. /**
  74025. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  74026. */
  74027. WordWrap = 1,
  74028. /**
  74029. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  74030. */
  74031. Ellipsis = 2
  74032. }
  74033. /**
  74034. * Class used to create text block control
  74035. */
  74036. export class TextBlock extends Control {
  74037. /**
  74038. * Defines the name of the control
  74039. */
  74040. name?: string | undefined;
  74041. private _text;
  74042. private _textWrapping;
  74043. private _textHorizontalAlignment;
  74044. private _textVerticalAlignment;
  74045. private _lines;
  74046. private _resizeToFit;
  74047. private _lineSpacing;
  74048. private _outlineWidth;
  74049. private _outlineColor;
  74050. /**
  74051. * An event triggered after the text is changed
  74052. */
  74053. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  74054. /**
  74055. * An event triggered after the text was broken up into lines
  74056. */
  74057. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  74058. /**
  74059. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  74060. */
  74061. get lines(): any[];
  74062. /**
  74063. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74064. */
  74065. get resizeToFit(): boolean;
  74066. /**
  74067. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  74068. */
  74069. set resizeToFit(value: boolean);
  74070. /**
  74071. * Gets or sets a boolean indicating if text must be wrapped
  74072. */
  74073. get textWrapping(): TextWrapping | boolean;
  74074. /**
  74075. * Gets or sets a boolean indicating if text must be wrapped
  74076. */
  74077. set textWrapping(value: TextWrapping | boolean);
  74078. /**
  74079. * Gets or sets text to display
  74080. */
  74081. get text(): string;
  74082. /**
  74083. * Gets or sets text to display
  74084. */
  74085. set text(value: string);
  74086. /**
  74087. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74088. */
  74089. get textHorizontalAlignment(): number;
  74090. /**
  74091. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  74092. */
  74093. set textHorizontalAlignment(value: number);
  74094. /**
  74095. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74096. */
  74097. get textVerticalAlignment(): number;
  74098. /**
  74099. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  74100. */
  74101. set textVerticalAlignment(value: number);
  74102. /**
  74103. * Gets or sets line spacing value
  74104. */
  74105. set lineSpacing(value: string | number);
  74106. /**
  74107. * Gets or sets line spacing value
  74108. */
  74109. get lineSpacing(): string | number;
  74110. /**
  74111. * Gets or sets outlineWidth of the text to display
  74112. */
  74113. get outlineWidth(): number;
  74114. /**
  74115. * Gets or sets outlineWidth of the text to display
  74116. */
  74117. set outlineWidth(value: number);
  74118. /**
  74119. * Gets or sets outlineColor of the text to display
  74120. */
  74121. get outlineColor(): string;
  74122. /**
  74123. * Gets or sets outlineColor of the text to display
  74124. */
  74125. set outlineColor(value: string);
  74126. /**
  74127. * Creates a new TextBlock object
  74128. * @param name defines the name of the control
  74129. * @param text defines the text to display (emptry string by default)
  74130. */
  74131. constructor(
  74132. /**
  74133. * Defines the name of the control
  74134. */
  74135. name?: string | undefined, text?: string);
  74136. protected _getTypeName(): string;
  74137. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74138. private _drawText;
  74139. /** @hidden */
  74140. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74141. protected _applyStates(context: CanvasRenderingContext2D): void;
  74142. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  74143. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  74144. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  74145. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  74146. protected _renderLines(context: CanvasRenderingContext2D): void;
  74147. /**
  74148. * Given a width constraint applied on the text block, find the expected height
  74149. * @returns expected height
  74150. */
  74151. computeExpectedHeight(): number;
  74152. dispose(): void;
  74153. }
  74154. }
  74155. declare module BABYLON.GUI {
  74156. /**
  74157. * Class used to create 2D images
  74158. */
  74159. export class Image extends Control {
  74160. name?: string | undefined;
  74161. private _workingCanvas;
  74162. private _domImage;
  74163. private _imageWidth;
  74164. private _imageHeight;
  74165. private _loaded;
  74166. private _stretch;
  74167. private _source;
  74168. private _autoScale;
  74169. private _sourceLeft;
  74170. private _sourceTop;
  74171. private _sourceWidth;
  74172. private _sourceHeight;
  74173. private _svgAttributesComputationCompleted;
  74174. private _isSVG;
  74175. private _cellWidth;
  74176. private _cellHeight;
  74177. private _cellId;
  74178. private _populateNinePatchSlicesFromImage;
  74179. private _sliceLeft;
  74180. private _sliceRight;
  74181. private _sliceTop;
  74182. private _sliceBottom;
  74183. private _detectPointerOnOpaqueOnly;
  74184. /**
  74185. * BABYLON.Observable notified when the content is loaded
  74186. */
  74187. onImageLoadedObservable: BABYLON.Observable<Image>;
  74188. /**
  74189. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  74190. */
  74191. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  74192. /**
  74193. * Gets a boolean indicating that the content is loaded
  74194. */
  74195. get isLoaded(): boolean;
  74196. /**
  74197. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  74198. */
  74199. get populateNinePatchSlicesFromImage(): boolean;
  74200. set populateNinePatchSlicesFromImage(value: boolean);
  74201. /**
  74202. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  74203. * Beware using this as this will comsume more memory as the image has to be stored twice
  74204. */
  74205. get detectPointerOnOpaqueOnly(): boolean;
  74206. set detectPointerOnOpaqueOnly(value: boolean);
  74207. /**
  74208. * Gets or sets the left value for slicing (9-patch)
  74209. */
  74210. get sliceLeft(): number;
  74211. set sliceLeft(value: number);
  74212. /**
  74213. * Gets or sets the right value for slicing (9-patch)
  74214. */
  74215. get sliceRight(): number;
  74216. set sliceRight(value: number);
  74217. /**
  74218. * Gets or sets the top value for slicing (9-patch)
  74219. */
  74220. get sliceTop(): number;
  74221. set sliceTop(value: number);
  74222. /**
  74223. * Gets or sets the bottom value for slicing (9-patch)
  74224. */
  74225. get sliceBottom(): number;
  74226. set sliceBottom(value: number);
  74227. /**
  74228. * Gets or sets the left coordinate in the source image
  74229. */
  74230. get sourceLeft(): number;
  74231. set sourceLeft(value: number);
  74232. /**
  74233. * Gets or sets the top coordinate in the source image
  74234. */
  74235. get sourceTop(): number;
  74236. set sourceTop(value: number);
  74237. /**
  74238. * Gets or sets the width to capture in the source image
  74239. */
  74240. get sourceWidth(): number;
  74241. set sourceWidth(value: number);
  74242. /**
  74243. * Gets or sets the height to capture in the source image
  74244. */
  74245. get sourceHeight(): number;
  74246. set sourceHeight(value: number);
  74247. /** Indicates if the format of the image is SVG */
  74248. get isSVG(): boolean;
  74249. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  74250. get svgAttributesComputationCompleted(): boolean;
  74251. /**
  74252. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  74253. * @see http://doc.babylonjs.com/how_to/gui#image
  74254. */
  74255. get autoScale(): boolean;
  74256. set autoScale(value: boolean);
  74257. /** Gets or sets the streching mode used by the image */
  74258. get stretch(): number;
  74259. set stretch(value: number);
  74260. /** @hidden */
  74261. _rotate90(n: number, preserveProperties?: boolean): Image;
  74262. private _handleRotationForSVGImage;
  74263. private _rotate90SourceProperties;
  74264. /**
  74265. * Gets or sets the internal DOM image used to render the control
  74266. */
  74267. set domImage(value: HTMLImageElement);
  74268. get domImage(): HTMLImageElement;
  74269. private _onImageLoaded;
  74270. private _extractNinePatchSliceDataFromImage;
  74271. /**
  74272. * Gets or sets image source url
  74273. */
  74274. set source(value: BABYLON.Nullable<string>);
  74275. /**
  74276. * Checks for svg document with icon id present
  74277. */
  74278. private _svgCheck;
  74279. /**
  74280. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  74281. * given external svg file and icon id
  74282. */
  74283. private _getSVGAttribs;
  74284. /**
  74285. * Gets or sets the cell width to use when animation sheet is enabled
  74286. * @see http://doc.babylonjs.com/how_to/gui#image
  74287. */
  74288. get cellWidth(): number;
  74289. set cellWidth(value: number);
  74290. /**
  74291. * Gets or sets the cell height to use when animation sheet is enabled
  74292. * @see http://doc.babylonjs.com/how_to/gui#image
  74293. */
  74294. get cellHeight(): number;
  74295. set cellHeight(value: number);
  74296. /**
  74297. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  74298. * @see http://doc.babylonjs.com/how_to/gui#image
  74299. */
  74300. get cellId(): number;
  74301. set cellId(value: number);
  74302. /**
  74303. * Creates a new Image
  74304. * @param name defines the control name
  74305. * @param url defines the image url
  74306. */
  74307. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  74308. /**
  74309. * Tests if a given coordinates belong to the current control
  74310. * @param x defines x coordinate to test
  74311. * @param y defines y coordinate to test
  74312. * @returns true if the coordinates are inside the control
  74313. */
  74314. contains(x: number, y: number): boolean;
  74315. protected _getTypeName(): string;
  74316. /** Force the control to synchronize with its content */
  74317. synchronizeSizeWithContent(): void;
  74318. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74319. private _prepareWorkingCanvasForOpaqueDetection;
  74320. private _drawImage;
  74321. _draw(context: CanvasRenderingContext2D): void;
  74322. private _renderCornerPatch;
  74323. private _renderNinePatch;
  74324. dispose(): void;
  74325. /** STRETCH_NONE */
  74326. static readonly STRETCH_NONE: number;
  74327. /** STRETCH_FILL */
  74328. static readonly STRETCH_FILL: number;
  74329. /** STRETCH_UNIFORM */
  74330. static readonly STRETCH_UNIFORM: number;
  74331. /** STRETCH_EXTEND */
  74332. static readonly STRETCH_EXTEND: number;
  74333. /** NINE_PATCH */
  74334. static readonly STRETCH_NINE_PATCH: number;
  74335. }
  74336. }
  74337. declare module BABYLON.GUI {
  74338. /**
  74339. * Class used to create 2D buttons
  74340. */
  74341. export class Button extends Rectangle {
  74342. name?: string | undefined;
  74343. /**
  74344. * Function called to generate a pointer enter animation
  74345. */
  74346. pointerEnterAnimation: () => void;
  74347. /**
  74348. * Function called to generate a pointer out animation
  74349. */
  74350. pointerOutAnimation: () => void;
  74351. /**
  74352. * Function called to generate a pointer down animation
  74353. */
  74354. pointerDownAnimation: () => void;
  74355. /**
  74356. * Function called to generate a pointer up animation
  74357. */
  74358. pointerUpAnimation: () => void;
  74359. /**
  74360. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  74361. */
  74362. delegatePickingToChildren: boolean;
  74363. private _image;
  74364. /**
  74365. * Returns the image part of the button (if any)
  74366. */
  74367. get image(): BABYLON.Nullable<Image>;
  74368. private _textBlock;
  74369. /**
  74370. * Returns the image part of the button (if any)
  74371. */
  74372. get textBlock(): BABYLON.Nullable<TextBlock>;
  74373. /**
  74374. * Creates a new Button
  74375. * @param name defines the name of the button
  74376. */
  74377. constructor(name?: string | undefined);
  74378. protected _getTypeName(): string;
  74379. /** @hidden */
  74380. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  74381. /** @hidden */
  74382. _onPointerEnter(target: Control): boolean;
  74383. /** @hidden */
  74384. _onPointerOut(target: Control, force?: boolean): void;
  74385. /** @hidden */
  74386. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74387. /** @hidden */
  74388. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74389. /**
  74390. * Creates a new button made with an image and a text
  74391. * @param name defines the name of the button
  74392. * @param text defines the text of the button
  74393. * @param imageUrl defines the url of the image
  74394. * @returns a new Button
  74395. */
  74396. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  74397. /**
  74398. * Creates a new button made with an image
  74399. * @param name defines the name of the button
  74400. * @param imageUrl defines the url of the image
  74401. * @returns a new Button
  74402. */
  74403. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  74404. /**
  74405. * Creates a new button made with a text
  74406. * @param name defines the name of the button
  74407. * @param text defines the text of the button
  74408. * @returns a new Button
  74409. */
  74410. static CreateSimpleButton(name: string, text: string): Button;
  74411. /**
  74412. * Creates a new button made with an image and a centered text
  74413. * @param name defines the name of the button
  74414. * @param text defines the text of the button
  74415. * @param imageUrl defines the url of the image
  74416. * @returns a new Button
  74417. */
  74418. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  74419. }
  74420. }
  74421. declare module BABYLON.GUI {
  74422. /**
  74423. * Class used to create a 2D stack panel container
  74424. */
  74425. export class StackPanel extends Container {
  74426. name?: string | undefined;
  74427. private _isVertical;
  74428. private _manualWidth;
  74429. private _manualHeight;
  74430. private _doNotTrackManualChanges;
  74431. /**
  74432. * Gets or sets a boolean indicating that layou warnings should be ignored
  74433. */
  74434. ignoreLayoutWarnings: boolean;
  74435. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  74436. get isVertical(): boolean;
  74437. set isVertical(value: boolean);
  74438. /**
  74439. * Gets or sets panel width.
  74440. * This value should not be set when in horizontal mode as it will be computed automatically
  74441. */
  74442. set width(value: string | number);
  74443. get width(): string | number;
  74444. /**
  74445. * Gets or sets panel height.
  74446. * This value should not be set when in vertical mode as it will be computed automatically
  74447. */
  74448. set height(value: string | number);
  74449. get height(): string | number;
  74450. /**
  74451. * Creates a new StackPanel
  74452. * @param name defines control name
  74453. */
  74454. constructor(name?: string | undefined);
  74455. protected _getTypeName(): string;
  74456. /** @hidden */
  74457. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74458. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74459. protected _postMeasure(): void;
  74460. }
  74461. }
  74462. declare module BABYLON.GUI {
  74463. /**
  74464. * Class used to represent a 2D checkbox
  74465. */
  74466. export class Checkbox extends Control {
  74467. name?: string | undefined;
  74468. private _isChecked;
  74469. private _background;
  74470. private _checkSizeRatio;
  74471. private _thickness;
  74472. /** Gets or sets border thickness */
  74473. get thickness(): number;
  74474. set thickness(value: number);
  74475. /**
  74476. * BABYLON.Observable raised when isChecked property changes
  74477. */
  74478. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  74479. /** Gets or sets a value indicating the ratio between overall size and check size */
  74480. get checkSizeRatio(): number;
  74481. set checkSizeRatio(value: number);
  74482. /** Gets or sets background color */
  74483. get background(): string;
  74484. set background(value: string);
  74485. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  74486. get isChecked(): boolean;
  74487. set isChecked(value: boolean);
  74488. /**
  74489. * Creates a new CheckBox
  74490. * @param name defines the control name
  74491. */
  74492. constructor(name?: string | undefined);
  74493. protected _getTypeName(): string;
  74494. /** @hidden */
  74495. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74496. /** @hidden */
  74497. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74498. /**
  74499. * Utility function to easily create a checkbox with a header
  74500. * @param title defines the label to use for the header
  74501. * @param onValueChanged defines the callback to call when value changes
  74502. * @returns a StackPanel containing the checkbox and a textBlock
  74503. */
  74504. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  74505. }
  74506. }
  74507. declare module BABYLON.GUI {
  74508. /**
  74509. * Class used to store key control properties
  74510. */
  74511. export class KeyPropertySet {
  74512. /** Width */
  74513. width?: string;
  74514. /** Height */
  74515. height?: string;
  74516. /** Left padding */
  74517. paddingLeft?: string;
  74518. /** Right padding */
  74519. paddingRight?: string;
  74520. /** Top padding */
  74521. paddingTop?: string;
  74522. /** Bottom padding */
  74523. paddingBottom?: string;
  74524. /** Foreground color */
  74525. color?: string;
  74526. /** Background color */
  74527. background?: string;
  74528. }
  74529. /**
  74530. * Class used to create virtual keyboard
  74531. */
  74532. export class VirtualKeyboard extends StackPanel {
  74533. /** BABYLON.Observable raised when a key is pressed */
  74534. onKeyPressObservable: BABYLON.Observable<string>;
  74535. /** Gets or sets default key button width */
  74536. defaultButtonWidth: string;
  74537. /** Gets or sets default key button height */
  74538. defaultButtonHeight: string;
  74539. /** Gets or sets default key button left padding */
  74540. defaultButtonPaddingLeft: string;
  74541. /** Gets or sets default key button right padding */
  74542. defaultButtonPaddingRight: string;
  74543. /** Gets or sets default key button top padding */
  74544. defaultButtonPaddingTop: string;
  74545. /** Gets or sets default key button bottom padding */
  74546. defaultButtonPaddingBottom: string;
  74547. /** Gets or sets default key button foreground color */
  74548. defaultButtonColor: string;
  74549. /** Gets or sets default key button background color */
  74550. defaultButtonBackground: string;
  74551. /** Gets or sets shift button foreground color */
  74552. shiftButtonColor: string;
  74553. /** Gets or sets shift button thickness*/
  74554. selectedShiftThickness: number;
  74555. /** Gets shift key state */
  74556. shiftState: number;
  74557. protected _getTypeName(): string;
  74558. private _createKey;
  74559. /**
  74560. * Adds a new row of keys
  74561. * @param keys defines the list of keys to add
  74562. * @param propertySets defines the associated property sets
  74563. */
  74564. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  74565. /**
  74566. * Set the shift key to a specific state
  74567. * @param shiftState defines the new shift state
  74568. */
  74569. applyShiftState(shiftState: number): void;
  74570. private _currentlyConnectedInputText;
  74571. private _connectedInputTexts;
  74572. private _onKeyPressObserver;
  74573. /** Gets the input text control currently attached to the keyboard */
  74574. get connectedInputText(): BABYLON.Nullable<InputText>;
  74575. /**
  74576. * Connects the keyboard with an input text control
  74577. *
  74578. * @param input defines the target control
  74579. */
  74580. connect(input: InputText): void;
  74581. /**
  74582. * Disconnects the keyboard from connected InputText controls
  74583. *
  74584. * @param input optionally defines a target control, otherwise all are disconnected
  74585. */
  74586. disconnect(input?: InputText): void;
  74587. private _removeConnectedInputObservables;
  74588. /**
  74589. * Release all resources
  74590. */
  74591. dispose(): void;
  74592. /**
  74593. * Creates a new keyboard using a default layout
  74594. *
  74595. * @param name defines control name
  74596. * @returns a new VirtualKeyboard
  74597. */
  74598. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  74599. }
  74600. }
  74601. declare module BABYLON.GUI {
  74602. /**
  74603. * Class used to create input text control
  74604. */
  74605. export class InputText extends Control implements IFocusableControl {
  74606. name?: string | undefined;
  74607. private _text;
  74608. private _placeholderText;
  74609. private _background;
  74610. private _focusedBackground;
  74611. private _focusedColor;
  74612. private _placeholderColor;
  74613. private _thickness;
  74614. private _margin;
  74615. private _autoStretchWidth;
  74616. private _maxWidth;
  74617. private _isFocused;
  74618. private _blinkTimeout;
  74619. private _blinkIsEven;
  74620. private _cursorOffset;
  74621. private _scrollLeft;
  74622. private _textWidth;
  74623. private _clickedCoordinate;
  74624. private _deadKey;
  74625. private _addKey;
  74626. private _currentKey;
  74627. private _isTextHighlightOn;
  74628. private _textHighlightColor;
  74629. private _highligherOpacity;
  74630. private _highlightedText;
  74631. private _startHighlightIndex;
  74632. private _endHighlightIndex;
  74633. private _cursorIndex;
  74634. private _onFocusSelectAll;
  74635. private _isPointerDown;
  74636. private _onClipboardObserver;
  74637. private _onPointerDblTapObserver;
  74638. /** @hidden */
  74639. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  74640. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  74641. promptMessage: string;
  74642. /** Force disable prompt on mobile device */
  74643. disableMobilePrompt: boolean;
  74644. /** BABYLON.Observable raised when the text changes */
  74645. onTextChangedObservable: BABYLON.Observable<InputText>;
  74646. /** BABYLON.Observable raised just before an entered character is to be added */
  74647. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  74648. /** BABYLON.Observable raised when the control gets the focus */
  74649. onFocusObservable: BABYLON.Observable<InputText>;
  74650. /** BABYLON.Observable raised when the control loses the focus */
  74651. onBlurObservable: BABYLON.Observable<InputText>;
  74652. /**Observable raised when the text is highlighted */
  74653. onTextHighlightObservable: BABYLON.Observable<InputText>;
  74654. /**Observable raised when copy event is triggered */
  74655. onTextCopyObservable: BABYLON.Observable<InputText>;
  74656. /** BABYLON.Observable raised when cut event is triggered */
  74657. onTextCutObservable: BABYLON.Observable<InputText>;
  74658. /** BABYLON.Observable raised when paste event is triggered */
  74659. onTextPasteObservable: BABYLON.Observable<InputText>;
  74660. /** BABYLON.Observable raised when a key event was processed */
  74661. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  74662. /** Gets or sets the maximum width allowed by the control */
  74663. get maxWidth(): string | number;
  74664. /** Gets the maximum width allowed by the control in pixels */
  74665. get maxWidthInPixels(): number;
  74666. set maxWidth(value: string | number);
  74667. /** Gets or sets the text highlighter transparency; default: 0.4 */
  74668. get highligherOpacity(): number;
  74669. set highligherOpacity(value: number);
  74670. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  74671. get onFocusSelectAll(): boolean;
  74672. set onFocusSelectAll(value: boolean);
  74673. /** Gets or sets the text hightlight color */
  74674. get textHighlightColor(): string;
  74675. set textHighlightColor(value: string);
  74676. /** Gets or sets control margin */
  74677. get margin(): string;
  74678. /** Gets control margin in pixels */
  74679. get marginInPixels(): number;
  74680. set margin(value: string);
  74681. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  74682. get autoStretchWidth(): boolean;
  74683. set autoStretchWidth(value: boolean);
  74684. /** Gets or sets border thickness */
  74685. get thickness(): number;
  74686. set thickness(value: number);
  74687. /** Gets or sets the background color when focused */
  74688. get focusedBackground(): string;
  74689. set focusedBackground(value: string);
  74690. /** Gets or sets the background color when focused */
  74691. get focusedColor(): string;
  74692. set focusedColor(value: string);
  74693. /** Gets or sets the background color */
  74694. get background(): string;
  74695. set background(value: string);
  74696. /** Gets or sets the placeholder color */
  74697. get placeholderColor(): string;
  74698. set placeholderColor(value: string);
  74699. /** Gets or sets the text displayed when the control is empty */
  74700. get placeholderText(): string;
  74701. set placeholderText(value: string);
  74702. /** Gets or sets the dead key flag */
  74703. get deadKey(): boolean;
  74704. set deadKey(flag: boolean);
  74705. /** Gets or sets the highlight text */
  74706. get highlightedText(): string;
  74707. set highlightedText(text: string);
  74708. /** Gets or sets if the current key should be added */
  74709. get addKey(): boolean;
  74710. set addKey(flag: boolean);
  74711. /** Gets or sets the value of the current key being entered */
  74712. get currentKey(): string;
  74713. set currentKey(key: string);
  74714. /** Gets or sets the text displayed in the control */
  74715. get text(): string;
  74716. set text(value: string);
  74717. /** Gets or sets control width */
  74718. get width(): string | number;
  74719. set width(value: string | number);
  74720. /**
  74721. * Creates a new InputText
  74722. * @param name defines the control name
  74723. * @param text defines the text of the control
  74724. */
  74725. constructor(name?: string | undefined, text?: string);
  74726. /** @hidden */
  74727. onBlur(): void;
  74728. /** @hidden */
  74729. onFocus(): void;
  74730. protected _getTypeName(): string;
  74731. /**
  74732. * Function called to get the list of controls that should not steal the focus from this control
  74733. * @returns an array of controls
  74734. */
  74735. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  74736. /** @hidden */
  74737. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  74738. /** @hidden */
  74739. private _updateValueFromCursorIndex;
  74740. /** @hidden */
  74741. private _processDblClick;
  74742. /** @hidden */
  74743. private _selectAllText;
  74744. /**
  74745. * Handles the keyboard event
  74746. * @param evt Defines the KeyboardEvent
  74747. */
  74748. processKeyboard(evt: KeyboardEvent): void;
  74749. /** @hidden */
  74750. private _onCopyText;
  74751. /** @hidden */
  74752. private _onCutText;
  74753. /** @hidden */
  74754. private _onPasteText;
  74755. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74756. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74757. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74758. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74759. protected _beforeRenderText(text: string): string;
  74760. dispose(): void;
  74761. }
  74762. }
  74763. declare module BABYLON.GUI {
  74764. /**
  74765. * Class used to create a 2D grid container
  74766. */
  74767. export class Grid extends Container {
  74768. name?: string | undefined;
  74769. private _rowDefinitions;
  74770. private _columnDefinitions;
  74771. private _cells;
  74772. private _childControls;
  74773. /**
  74774. * Gets the number of columns
  74775. */
  74776. get columnCount(): number;
  74777. /**
  74778. * Gets the number of rows
  74779. */
  74780. get rowCount(): number;
  74781. /** Gets the list of children */
  74782. get children(): Control[];
  74783. /** Gets the list of cells (e.g. the containers) */
  74784. get cells(): {
  74785. [key: string]: Container;
  74786. };
  74787. /**
  74788. * Gets the definition of a specific row
  74789. * @param index defines the index of the row
  74790. * @returns the row definition
  74791. */
  74792. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74793. /**
  74794. * Gets the definition of a specific column
  74795. * @param index defines the index of the column
  74796. * @returns the column definition
  74797. */
  74798. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  74799. /**
  74800. * Adds a new row to the grid
  74801. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74802. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  74803. * @returns the current grid
  74804. */
  74805. addRowDefinition(height: number, isPixel?: boolean): Grid;
  74806. /**
  74807. * Adds a new column to the grid
  74808. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74809. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74810. * @returns the current grid
  74811. */
  74812. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  74813. /**
  74814. * Update a row definition
  74815. * @param index defines the index of the row to update
  74816. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  74817. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  74818. * @returns the current grid
  74819. */
  74820. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  74821. /**
  74822. * Update a column definition
  74823. * @param index defines the index of the column to update
  74824. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  74825. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  74826. * @returns the current grid
  74827. */
  74828. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  74829. /**
  74830. * Gets the list of children stored in a specific cell
  74831. * @param row defines the row to check
  74832. * @param column defines the column to check
  74833. * @returns the list of controls
  74834. */
  74835. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  74836. /**
  74837. * Gets a string representing the child cell info (row x column)
  74838. * @param child defines the control to get info from
  74839. * @returns a string containing the child cell info (row x column)
  74840. */
  74841. getChildCellInfo(child: Control): string;
  74842. private _removeCell;
  74843. private _offsetCell;
  74844. /**
  74845. * Remove a column definition at specified index
  74846. * @param index defines the index of the column to remove
  74847. * @returns the current grid
  74848. */
  74849. removeColumnDefinition(index: number): Grid;
  74850. /**
  74851. * Remove a row definition at specified index
  74852. * @param index defines the index of the row to remove
  74853. * @returns the current grid
  74854. */
  74855. removeRowDefinition(index: number): Grid;
  74856. /**
  74857. * Adds a new control to the current grid
  74858. * @param control defines the control to add
  74859. * @param row defines the row where to add the control (0 by default)
  74860. * @param column defines the column where to add the control (0 by default)
  74861. * @returns the current grid
  74862. */
  74863. addControl(control: Control, row?: number, column?: number): Grid;
  74864. /**
  74865. * Removes a control from the current container
  74866. * @param control defines the control to remove
  74867. * @returns the current container
  74868. */
  74869. removeControl(control: Control): Container;
  74870. /**
  74871. * Creates a new Grid
  74872. * @param name defines control name
  74873. */
  74874. constructor(name?: string | undefined);
  74875. protected _getTypeName(): string;
  74876. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  74877. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74878. _flagDescendantsAsMatrixDirty(): void;
  74879. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74880. /** Releases associated resources */
  74881. dispose(): void;
  74882. }
  74883. }
  74884. declare module BABYLON.GUI {
  74885. /** Class used to create color pickers */
  74886. export class ColorPicker extends Control {
  74887. name?: string | undefined;
  74888. private static _Epsilon;
  74889. private _colorWheelCanvas;
  74890. private _value;
  74891. private _tmpColor;
  74892. private _pointerStartedOnSquare;
  74893. private _pointerStartedOnWheel;
  74894. private _squareLeft;
  74895. private _squareTop;
  74896. private _squareSize;
  74897. private _h;
  74898. private _s;
  74899. private _v;
  74900. private _lastPointerDownID;
  74901. /**
  74902. * BABYLON.Observable raised when the value changes
  74903. */
  74904. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  74905. /** Gets or sets the color of the color picker */
  74906. get value(): BABYLON.Color3;
  74907. set value(value: BABYLON.Color3);
  74908. /**
  74909. * Gets or sets control width
  74910. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74911. */
  74912. get width(): string | number;
  74913. set width(value: string | number);
  74914. /**
  74915. * Gets or sets control height
  74916. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  74917. */
  74918. get height(): string | number;
  74919. /** Gets or sets control height */
  74920. set height(value: string | number);
  74921. /** Gets or sets control size */
  74922. get size(): string | number;
  74923. set size(value: string | number);
  74924. /**
  74925. * Creates a new ColorPicker
  74926. * @param name defines the control name
  74927. */
  74928. constructor(name?: string | undefined);
  74929. protected _getTypeName(): string;
  74930. /** @hidden */
  74931. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74932. private _updateSquareProps;
  74933. private _drawGradientSquare;
  74934. private _drawCircle;
  74935. private _createColorWheelCanvas;
  74936. /** @hidden */
  74937. _draw(context: CanvasRenderingContext2D): void;
  74938. private _pointerIsDown;
  74939. private _updateValueFromPointer;
  74940. private _isPointOnSquare;
  74941. private _isPointOnWheel;
  74942. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74943. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  74944. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74945. /**
  74946. * This function expands the color picker by creating a color picker dialog with manual
  74947. * color value input and the ability to save colors into an array to be used later in
  74948. * subsequent launches of the dialogue.
  74949. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  74950. * @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.
  74951. * @returns picked color as a hex string and the saved colors array as hex strings.
  74952. */
  74953. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  74954. pickerWidth?: string;
  74955. pickerHeight?: string;
  74956. headerHeight?: string;
  74957. lastColor?: string;
  74958. swatchLimit?: number;
  74959. numSwatchesPerLine?: number;
  74960. savedColors?: Array<string>;
  74961. }): Promise<{
  74962. savedColors?: string[];
  74963. pickedColor: string;
  74964. }>;
  74965. }
  74966. }
  74967. declare module BABYLON.GUI {
  74968. /** Class used to create 2D ellipse containers */
  74969. export class Ellipse extends Container {
  74970. name?: string | undefined;
  74971. private _thickness;
  74972. /** Gets or sets border thickness */
  74973. get thickness(): number;
  74974. set thickness(value: number);
  74975. /**
  74976. * Creates a new Ellipse
  74977. * @param name defines the control name
  74978. */
  74979. constructor(name?: string | undefined);
  74980. protected _getTypeName(): string;
  74981. protected _localDraw(context: CanvasRenderingContext2D): void;
  74982. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74983. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  74984. }
  74985. }
  74986. declare module BABYLON.GUI {
  74987. /**
  74988. * Class used to create a password control
  74989. */
  74990. export class InputPassword extends InputText {
  74991. protected _beforeRenderText(text: string): string;
  74992. }
  74993. }
  74994. declare module BABYLON.GUI {
  74995. /** Class used to render 2D lines */
  74996. export class Line extends Control {
  74997. name?: string | undefined;
  74998. private _lineWidth;
  74999. private _x1;
  75000. private _y1;
  75001. private _x2;
  75002. private _y2;
  75003. private _dash;
  75004. private _connectedControl;
  75005. private _connectedControlDirtyObserver;
  75006. /** Gets or sets the dash pattern */
  75007. get dash(): Array<number>;
  75008. set dash(value: Array<number>);
  75009. /** Gets or sets the control connected with the line end */
  75010. get connectedControl(): Control;
  75011. set connectedControl(value: Control);
  75012. /** Gets or sets start coordinates on X axis */
  75013. get x1(): string | number;
  75014. set x1(value: string | number);
  75015. /** Gets or sets start coordinates on Y axis */
  75016. get y1(): string | number;
  75017. set y1(value: string | number);
  75018. /** Gets or sets end coordinates on X axis */
  75019. get x2(): string | number;
  75020. set x2(value: string | number);
  75021. /** Gets or sets end coordinates on Y axis */
  75022. get y2(): string | number;
  75023. set y2(value: string | number);
  75024. /** Gets or sets line width */
  75025. get lineWidth(): number;
  75026. set lineWidth(value: number);
  75027. /** Gets or sets horizontal alignment */
  75028. set horizontalAlignment(value: number);
  75029. /** Gets or sets vertical alignment */
  75030. set verticalAlignment(value: number);
  75031. private get _effectiveX2();
  75032. private get _effectiveY2();
  75033. /**
  75034. * Creates a new Line
  75035. * @param name defines the control name
  75036. */
  75037. constructor(name?: string | undefined);
  75038. protected _getTypeName(): string;
  75039. _draw(context: CanvasRenderingContext2D): void;
  75040. _measure(): void;
  75041. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75042. /**
  75043. * Move one end of the line given 3D cartesian coordinates.
  75044. * @param position Targeted world position
  75045. * @param scene BABYLON.Scene
  75046. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75047. */
  75048. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  75049. /**
  75050. * Move one end of the line to a position in screen absolute space.
  75051. * @param projectedPosition Position in screen absolute space (X, Y)
  75052. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  75053. */
  75054. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  75055. }
  75056. }
  75057. declare module BABYLON.GUI {
  75058. /**
  75059. * Class used to store a point for a MultiLine object.
  75060. * The point can be pure 2D coordinates, a mesh or a control
  75061. */
  75062. export class MultiLinePoint {
  75063. private _multiLine;
  75064. private _x;
  75065. private _y;
  75066. private _control;
  75067. private _mesh;
  75068. private _controlObserver;
  75069. private _meshObserver;
  75070. /** @hidden */
  75071. _point: BABYLON.Vector2;
  75072. /**
  75073. * Creates a new MultiLinePoint
  75074. * @param multiLine defines the source MultiLine object
  75075. */
  75076. constructor(multiLine: MultiLine);
  75077. /** Gets or sets x coordinate */
  75078. get x(): string | number;
  75079. set x(value: string | number);
  75080. /** Gets or sets y coordinate */
  75081. get y(): string | number;
  75082. set y(value: string | number);
  75083. /** Gets or sets the control associated with this point */
  75084. get control(): BABYLON.Nullable<Control>;
  75085. set control(value: BABYLON.Nullable<Control>);
  75086. /** Gets or sets the mesh associated with this point */
  75087. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  75088. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  75089. /** Resets links */
  75090. resetLinks(): void;
  75091. /**
  75092. * Gets a translation vector
  75093. * @returns the translation vector
  75094. */
  75095. translate(): BABYLON.Vector2;
  75096. private _translatePoint;
  75097. /** Release associated resources */
  75098. dispose(): void;
  75099. }
  75100. }
  75101. declare module BABYLON.GUI {
  75102. /**
  75103. * Class used to create multi line control
  75104. */
  75105. export class MultiLine extends Control {
  75106. name?: string | undefined;
  75107. private _lineWidth;
  75108. private _dash;
  75109. private _points;
  75110. private _minX;
  75111. private _minY;
  75112. private _maxX;
  75113. private _maxY;
  75114. /**
  75115. * Creates a new MultiLine
  75116. * @param name defines the control name
  75117. */
  75118. constructor(name?: string | undefined);
  75119. /** Gets or sets dash pattern */
  75120. get dash(): Array<number>;
  75121. set dash(value: Array<number>);
  75122. /**
  75123. * Gets point stored at specified index
  75124. * @param index defines the index to look for
  75125. * @returns the requested point if found
  75126. */
  75127. getAt(index: number): MultiLinePoint;
  75128. /** Function called when a point is updated */
  75129. onPointUpdate: () => void;
  75130. /**
  75131. * Adds new points to the point collection
  75132. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  75133. * @returns the list of created MultiLinePoint
  75134. */
  75135. add(...items: (AbstractMesh | Control | {
  75136. x: string | number;
  75137. y: string | number;
  75138. })[]): MultiLinePoint[];
  75139. /**
  75140. * Adds a new point to the point collection
  75141. * @param item defines the item (mesh, control or 2d coordiantes) to add
  75142. * @returns the created MultiLinePoint
  75143. */
  75144. push(item?: (AbstractMesh | Control | {
  75145. x: string | number;
  75146. y: string | number;
  75147. })): MultiLinePoint;
  75148. /**
  75149. * Remove a specific value or point from the active point collection
  75150. * @param value defines the value or point to remove
  75151. */
  75152. remove(value: number | MultiLinePoint): void;
  75153. /**
  75154. * Resets this object to initial state (no point)
  75155. */
  75156. reset(): void;
  75157. /**
  75158. * Resets all links
  75159. */
  75160. resetLinks(): void;
  75161. /** Gets or sets line width */
  75162. get lineWidth(): number;
  75163. set lineWidth(value: number);
  75164. set horizontalAlignment(value: number);
  75165. set verticalAlignment(value: number);
  75166. protected _getTypeName(): string;
  75167. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75168. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75169. _measure(): void;
  75170. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75171. dispose(): void;
  75172. }
  75173. }
  75174. declare module BABYLON.GUI {
  75175. /**
  75176. * Class used to create radio button controls
  75177. */
  75178. export class RadioButton extends Control {
  75179. name?: string | undefined;
  75180. private _isChecked;
  75181. private _background;
  75182. private _checkSizeRatio;
  75183. private _thickness;
  75184. /** Gets or sets border thickness */
  75185. get thickness(): number;
  75186. set thickness(value: number);
  75187. /** Gets or sets group name */
  75188. group: string;
  75189. /** BABYLON.Observable raised when isChecked is changed */
  75190. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  75191. /** Gets or sets a value indicating the ratio between overall size and check size */
  75192. get checkSizeRatio(): number;
  75193. set checkSizeRatio(value: number);
  75194. /** Gets or sets background color */
  75195. get background(): string;
  75196. set background(value: string);
  75197. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  75198. get isChecked(): boolean;
  75199. set isChecked(value: boolean);
  75200. /**
  75201. * Creates a new RadioButton
  75202. * @param name defines the control name
  75203. */
  75204. constructor(name?: string | undefined);
  75205. protected _getTypeName(): string;
  75206. _draw(context: CanvasRenderingContext2D): void;
  75207. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75208. /**
  75209. * Utility function to easily create a radio button with a header
  75210. * @param title defines the label to use for the header
  75211. * @param group defines the group to use for the radio button
  75212. * @param isChecked defines the initial state of the radio button
  75213. * @param onValueChanged defines the callback to call when value changes
  75214. * @returns a StackPanel containing the radio button and a textBlock
  75215. */
  75216. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  75217. }
  75218. }
  75219. declare module BABYLON.GUI {
  75220. /**
  75221. * Class used to create slider controls
  75222. */
  75223. export class BaseSlider extends Control {
  75224. name?: string | undefined;
  75225. protected _thumbWidth: ValueAndUnit;
  75226. private _minimum;
  75227. private _maximum;
  75228. private _value;
  75229. private _isVertical;
  75230. protected _barOffset: ValueAndUnit;
  75231. private _isThumbClamped;
  75232. protected _displayThumb: boolean;
  75233. private _step;
  75234. private _lastPointerDownID;
  75235. protected _effectiveBarOffset: number;
  75236. protected _renderLeft: number;
  75237. protected _renderTop: number;
  75238. protected _renderWidth: number;
  75239. protected _renderHeight: number;
  75240. protected _backgroundBoxLength: number;
  75241. protected _backgroundBoxThickness: number;
  75242. protected _effectiveThumbThickness: number;
  75243. /** BABYLON.Observable raised when the sldier value changes */
  75244. onValueChangedObservable: BABYLON.Observable<number>;
  75245. /** Gets or sets a boolean indicating if the thumb must be rendered */
  75246. get displayThumb(): boolean;
  75247. set displayThumb(value: boolean);
  75248. /** Gets or sets a step to apply to values (0 by default) */
  75249. get step(): number;
  75250. set step(value: number);
  75251. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  75252. get barOffset(): string | number;
  75253. /** Gets main bar offset in pixels*/
  75254. get barOffsetInPixels(): number;
  75255. set barOffset(value: string | number);
  75256. /** Gets or sets thumb width */
  75257. get thumbWidth(): string | number;
  75258. /** Gets thumb width in pixels */
  75259. get thumbWidthInPixels(): number;
  75260. set thumbWidth(value: string | number);
  75261. /** Gets or sets minimum value */
  75262. get minimum(): number;
  75263. set minimum(value: number);
  75264. /** Gets or sets maximum value */
  75265. get maximum(): number;
  75266. set maximum(value: number);
  75267. /** Gets or sets current value */
  75268. get value(): number;
  75269. set value(value: number);
  75270. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  75271. get isVertical(): boolean;
  75272. set isVertical(value: boolean);
  75273. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  75274. get isThumbClamped(): boolean;
  75275. set isThumbClamped(value: boolean);
  75276. /**
  75277. * Creates a new BaseSlider
  75278. * @param name defines the control name
  75279. */
  75280. constructor(name?: string | undefined);
  75281. protected _getTypeName(): string;
  75282. protected _getThumbPosition(): number;
  75283. protected _getThumbThickness(type: string): number;
  75284. protected _prepareRenderingData(type: string): void;
  75285. private _pointerIsDown;
  75286. /** @hidden */
  75287. protected _updateValueFromPointer(x: number, y: number): void;
  75288. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75289. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  75290. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  75291. }
  75292. }
  75293. declare module BABYLON.GUI {
  75294. /**
  75295. * Class used to create slider controls
  75296. */
  75297. export class Slider extends BaseSlider {
  75298. name?: string | undefined;
  75299. private _background;
  75300. private _borderColor;
  75301. private _isThumbCircle;
  75302. protected _displayValueBar: boolean;
  75303. /** Gets or sets a boolean indicating if the value bar must be rendered */
  75304. get displayValueBar(): boolean;
  75305. set displayValueBar(value: boolean);
  75306. /** Gets or sets border color */
  75307. get borderColor(): string;
  75308. set borderColor(value: string);
  75309. /** Gets or sets background color */
  75310. get background(): string;
  75311. set background(value: string);
  75312. /** Gets or sets a boolean indicating if the thumb should be round or square */
  75313. get isThumbCircle(): boolean;
  75314. set isThumbCircle(value: boolean);
  75315. /**
  75316. * Creates a new Slider
  75317. * @param name defines the control name
  75318. */
  75319. constructor(name?: string | undefined);
  75320. protected _getTypeName(): string;
  75321. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75322. }
  75323. }
  75324. declare module BABYLON.GUI {
  75325. /** Class used to create a RadioGroup
  75326. * which contains groups of radio buttons
  75327. */
  75328. export class SelectorGroup {
  75329. /** name of SelectorGroup */
  75330. name: string;
  75331. private _groupPanel;
  75332. private _selectors;
  75333. private _groupHeader;
  75334. /**
  75335. * Creates a new SelectorGroup
  75336. * @param name of group, used as a group heading
  75337. */
  75338. constructor(
  75339. /** name of SelectorGroup */
  75340. name: string);
  75341. /** Gets the groupPanel of the SelectorGroup */
  75342. get groupPanel(): StackPanel;
  75343. /** Gets the selectors array */
  75344. get selectors(): StackPanel[];
  75345. /** Gets and sets the group header */
  75346. get header(): string;
  75347. set header(label: string);
  75348. /** @hidden */
  75349. private _addGroupHeader;
  75350. /** @hidden*/
  75351. _getSelector(selectorNb: number): StackPanel | undefined;
  75352. /** Removes the selector at the given position
  75353. * @param selectorNb the position of the selector within the group
  75354. */
  75355. removeSelector(selectorNb: number): void;
  75356. }
  75357. /** Class used to create a CheckboxGroup
  75358. * which contains groups of checkbox buttons
  75359. */
  75360. export class CheckboxGroup extends SelectorGroup {
  75361. /** Adds a checkbox as a control
  75362. * @param text is the label for the selector
  75363. * @param func is the function called when the Selector is checked
  75364. * @param checked is true when Selector is checked
  75365. */
  75366. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  75367. /** @hidden */
  75368. _setSelectorLabel(selectorNb: number, label: string): void;
  75369. /** @hidden */
  75370. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75371. /** @hidden */
  75372. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75373. /** @hidden */
  75374. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75375. }
  75376. /** Class used to create a RadioGroup
  75377. * which contains groups of radio buttons
  75378. */
  75379. export class RadioGroup extends SelectorGroup {
  75380. private _selectNb;
  75381. /** Adds a radio button as a control
  75382. * @param label is the label for the selector
  75383. * @param func is the function called when the Selector is checked
  75384. * @param checked is true when Selector is checked
  75385. */
  75386. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  75387. /** @hidden */
  75388. _setSelectorLabel(selectorNb: number, label: string): void;
  75389. /** @hidden */
  75390. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75391. /** @hidden */
  75392. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75393. /** @hidden */
  75394. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75395. }
  75396. /** Class used to create a SliderGroup
  75397. * which contains groups of slider buttons
  75398. */
  75399. export class SliderGroup extends SelectorGroup {
  75400. /**
  75401. * Adds a slider to the SelectorGroup
  75402. * @param label is the label for the SliderBar
  75403. * @param func is the function called when the Slider moves
  75404. * @param unit is a string describing the units used, eg degrees or metres
  75405. * @param min is the minimum value for the Slider
  75406. * @param max is the maximum value for the Slider
  75407. * @param value is the start value for the Slider between min and max
  75408. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  75409. */
  75410. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  75411. /** @hidden */
  75412. _setSelectorLabel(selectorNb: number, label: string): void;
  75413. /** @hidden */
  75414. _setSelectorLabelColor(selectorNb: number, color: string): void;
  75415. /** @hidden */
  75416. _setSelectorButtonColor(selectorNb: number, color: string): void;
  75417. /** @hidden */
  75418. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  75419. }
  75420. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  75421. * @see http://doc.babylonjs.com/how_to/selector
  75422. */
  75423. export class SelectionPanel extends Rectangle {
  75424. /** name of SelectionPanel */
  75425. name: string;
  75426. /** an array of SelectionGroups */
  75427. groups: SelectorGroup[];
  75428. private _panel;
  75429. private _buttonColor;
  75430. private _buttonBackground;
  75431. private _headerColor;
  75432. private _barColor;
  75433. private _barHeight;
  75434. private _spacerHeight;
  75435. private _labelColor;
  75436. private _groups;
  75437. private _bars;
  75438. /**
  75439. * Creates a new SelectionPanel
  75440. * @param name of SelectionPanel
  75441. * @param groups is an array of SelectionGroups
  75442. */
  75443. constructor(
  75444. /** name of SelectionPanel */
  75445. name: string,
  75446. /** an array of SelectionGroups */
  75447. groups?: SelectorGroup[]);
  75448. protected _getTypeName(): string;
  75449. /** Gets or sets the headerColor */
  75450. get headerColor(): string;
  75451. set headerColor(color: string);
  75452. private _setHeaderColor;
  75453. /** Gets or sets the button color */
  75454. get buttonColor(): string;
  75455. set buttonColor(color: string);
  75456. private _setbuttonColor;
  75457. /** Gets or sets the label color */
  75458. get labelColor(): string;
  75459. set labelColor(color: string);
  75460. private _setLabelColor;
  75461. /** Gets or sets the button background */
  75462. get buttonBackground(): string;
  75463. set buttonBackground(color: string);
  75464. private _setButtonBackground;
  75465. /** Gets or sets the color of separator bar */
  75466. get barColor(): string;
  75467. set barColor(color: string);
  75468. private _setBarColor;
  75469. /** Gets or sets the height of separator bar */
  75470. get barHeight(): string;
  75471. set barHeight(value: string);
  75472. private _setBarHeight;
  75473. /** Gets or sets the height of spacers*/
  75474. get spacerHeight(): string;
  75475. set spacerHeight(value: string);
  75476. private _setSpacerHeight;
  75477. /** Adds a bar between groups */
  75478. private _addSpacer;
  75479. /** Add a group to the selection panel
  75480. * @param group is the selector group to add
  75481. */
  75482. addGroup(group: SelectorGroup): void;
  75483. /** Remove the group from the given position
  75484. * @param groupNb is the position of the group in the list
  75485. */
  75486. removeGroup(groupNb: number): void;
  75487. /** Change a group header label
  75488. * @param label is the new group header label
  75489. * @param groupNb is the number of the group to relabel
  75490. * */
  75491. setHeaderName(label: string, groupNb: number): void;
  75492. /** Change selector label to the one given
  75493. * @param label is the new selector label
  75494. * @param groupNb is the number of the groupcontaining the selector
  75495. * @param selectorNb is the number of the selector within a group to relabel
  75496. * */
  75497. relabel(label: string, groupNb: number, selectorNb: number): void;
  75498. /** For a given group position remove the selector at the given position
  75499. * @param groupNb is the number of the group to remove the selector from
  75500. * @param selectorNb is the number of the selector within the group
  75501. */
  75502. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  75503. /** For a given group position of correct type add a checkbox button
  75504. * @param groupNb is the number of the group to remove the selector from
  75505. * @param label is the label for the selector
  75506. * @param func is the function called when the Selector is checked
  75507. * @param checked is true when Selector is checked
  75508. */
  75509. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75510. /** For a given group position of correct type add a radio button
  75511. * @param groupNb is the number of the group to remove the selector from
  75512. * @param label is the label for the selector
  75513. * @param func is the function called when the Selector is checked
  75514. * @param checked is true when Selector is checked
  75515. */
  75516. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  75517. /**
  75518. * For a given slider group add a slider
  75519. * @param groupNb is the number of the group to add the slider to
  75520. * @param label is the label for the Slider
  75521. * @param func is the function called when the Slider moves
  75522. * @param unit is a string describing the units used, eg degrees or metres
  75523. * @param min is the minimum value for the Slider
  75524. * @param max is the maximum value for the Slider
  75525. * @param value is the start value for the Slider between min and max
  75526. * @param onVal is the function used to format the value displayed, eg radians to degrees
  75527. */
  75528. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  75529. }
  75530. }
  75531. declare module BABYLON.GUI {
  75532. /**
  75533. * Class used to hold a the container for ScrollViewer
  75534. * @hidden
  75535. */
  75536. export class _ScrollViewerWindow extends Container {
  75537. parentClientWidth: number;
  75538. parentClientHeight: number;
  75539. private _freezeControls;
  75540. private _parentMeasure;
  75541. private _oldLeft;
  75542. private _oldTop;
  75543. get freezeControls(): boolean;
  75544. set freezeControls(value: boolean);
  75545. private _bucketWidth;
  75546. private _bucketHeight;
  75547. private _buckets;
  75548. private _bucketLen;
  75549. get bucketWidth(): number;
  75550. get bucketHeight(): number;
  75551. setBucketSizes(width: number, height: number): void;
  75552. private _useBuckets;
  75553. private _makeBuckets;
  75554. private _dispatchInBuckets;
  75555. private _updateMeasures;
  75556. private _updateChildrenMeasures;
  75557. private _restoreMeasures;
  75558. /**
  75559. * Creates a new ScrollViewerWindow
  75560. * @param name of ScrollViewerWindow
  75561. */
  75562. constructor(name?: string);
  75563. protected _getTypeName(): string;
  75564. /** @hidden */
  75565. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75566. /** @hidden */
  75567. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  75568. private _scrollChildren;
  75569. private _scrollChildrenWithBuckets;
  75570. /** @hidden */
  75571. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  75572. protected _postMeasure(): void;
  75573. }
  75574. }
  75575. declare module BABYLON.GUI {
  75576. /**
  75577. * Class used to create slider controls
  75578. */
  75579. export class ScrollBar extends BaseSlider {
  75580. name?: string | undefined;
  75581. private _background;
  75582. private _borderColor;
  75583. private _tempMeasure;
  75584. /** Gets or sets border color */
  75585. get borderColor(): string;
  75586. set borderColor(value: string);
  75587. /** Gets or sets background color */
  75588. get background(): string;
  75589. set background(value: string);
  75590. /**
  75591. * Creates a new Slider
  75592. * @param name defines the control name
  75593. */
  75594. constructor(name?: string | undefined);
  75595. protected _getTypeName(): string;
  75596. protected _getThumbThickness(): number;
  75597. _draw(context: CanvasRenderingContext2D): void;
  75598. private _first;
  75599. private _originX;
  75600. private _originY;
  75601. /** @hidden */
  75602. protected _updateValueFromPointer(x: number, y: number): void;
  75603. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75604. }
  75605. }
  75606. declare module BABYLON.GUI {
  75607. /**
  75608. * Class used to create slider controls
  75609. */
  75610. export class ImageScrollBar extends BaseSlider {
  75611. name?: string | undefined;
  75612. private _backgroundBaseImage;
  75613. private _backgroundImage;
  75614. private _thumbImage;
  75615. private _thumbBaseImage;
  75616. private _thumbLength;
  75617. private _thumbHeight;
  75618. private _barImageHeight;
  75619. private _tempMeasure;
  75620. /** Number of 90° rotation to apply on the images when in vertical mode */
  75621. num90RotationInVerticalMode: number;
  75622. /**
  75623. * Gets or sets the image used to render the background for horizontal bar
  75624. */
  75625. get backgroundImage(): Image;
  75626. set backgroundImage(value: Image);
  75627. /**
  75628. * Gets or sets the image used to render the thumb
  75629. */
  75630. get thumbImage(): Image;
  75631. set thumbImage(value: Image);
  75632. /**
  75633. * Gets or sets the length of the thumb
  75634. */
  75635. get thumbLength(): number;
  75636. set thumbLength(value: number);
  75637. /**
  75638. * Gets or sets the height of the thumb
  75639. */
  75640. get thumbHeight(): number;
  75641. set thumbHeight(value: number);
  75642. /**
  75643. * Gets or sets the height of the bar image
  75644. */
  75645. get barImageHeight(): number;
  75646. set barImageHeight(value: number);
  75647. /**
  75648. * Creates a new ImageScrollBar
  75649. * @param name defines the control name
  75650. */
  75651. constructor(name?: string | undefined);
  75652. protected _getTypeName(): string;
  75653. protected _getThumbThickness(): number;
  75654. _draw(context: CanvasRenderingContext2D): void;
  75655. private _first;
  75656. private _originX;
  75657. private _originY;
  75658. /** @hidden */
  75659. protected _updateValueFromPointer(x: number, y: number): void;
  75660. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  75661. }
  75662. }
  75663. declare module BABYLON.GUI {
  75664. /**
  75665. * Class used to hold a viewer window and sliders in a grid
  75666. */
  75667. export class ScrollViewer extends Rectangle {
  75668. private _grid;
  75669. private _horizontalBarSpace;
  75670. private _verticalBarSpace;
  75671. private _dragSpace;
  75672. private _horizontalBar;
  75673. private _verticalBar;
  75674. private _barColor;
  75675. private _barBackground;
  75676. private _barImage;
  75677. private _horizontalBarImage;
  75678. private _verticalBarImage;
  75679. private _barBackgroundImage;
  75680. private _horizontalBarBackgroundImage;
  75681. private _verticalBarBackgroundImage;
  75682. private _barSize;
  75683. private _window;
  75684. private _pointerIsOver;
  75685. private _wheelPrecision;
  75686. private _onWheelObserver;
  75687. private _clientWidth;
  75688. private _clientHeight;
  75689. private _useImageBar;
  75690. private _thumbLength;
  75691. private _thumbHeight;
  75692. private _barImageHeight;
  75693. private _horizontalBarImageHeight;
  75694. private _verticalBarImageHeight;
  75695. private _oldWindowContentsWidth;
  75696. private _oldWindowContentsHeight;
  75697. /**
  75698. * Gets the horizontal scrollbar
  75699. */
  75700. get horizontalBar(): ScrollBar | ImageScrollBar;
  75701. /**
  75702. * Gets the vertical scrollbar
  75703. */
  75704. get verticalBar(): ScrollBar | ImageScrollBar;
  75705. /**
  75706. * Adds a new control to the current container
  75707. * @param control defines the control to add
  75708. * @returns the current container
  75709. */
  75710. addControl(control: BABYLON.Nullable<Control>): Container;
  75711. /**
  75712. * Removes a control from the current container
  75713. * @param control defines the control to remove
  75714. * @returns the current container
  75715. */
  75716. removeControl(control: Control): Container;
  75717. /** Gets the list of children */
  75718. get children(): Control[];
  75719. _flagDescendantsAsMatrixDirty(): void;
  75720. /**
  75721. * Freezes or unfreezes the controls in the window.
  75722. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  75723. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  75724. */
  75725. get freezeControls(): boolean;
  75726. set freezeControls(value: boolean);
  75727. /** Gets the bucket width */
  75728. get bucketWidth(): number;
  75729. /** Gets the bucket height */
  75730. get bucketHeight(): number;
  75731. /**
  75732. * Sets the bucket sizes.
  75733. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  75734. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  75735. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  75736. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  75737. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  75738. * used), that's why it is not enabled by default.
  75739. * @param width width of the bucket
  75740. * @param height height of the bucket
  75741. */
  75742. setBucketSizes(width: number, height: number): void;
  75743. private _forceHorizontalBar;
  75744. private _forceVerticalBar;
  75745. /**
  75746. * Forces the horizontal scroll bar to be displayed
  75747. */
  75748. get forceHorizontalBar(): boolean;
  75749. set forceHorizontalBar(value: boolean);
  75750. /**
  75751. * Forces the vertical scroll bar to be displayed
  75752. */
  75753. get forceVerticalBar(): boolean;
  75754. set forceVerticalBar(value: boolean);
  75755. /**
  75756. * Creates a new ScrollViewer
  75757. * @param name of ScrollViewer
  75758. */
  75759. constructor(name?: string, isImageBased?: boolean);
  75760. /** Reset the scroll viewer window to initial size */
  75761. resetWindow(): void;
  75762. protected _getTypeName(): string;
  75763. private _buildClientSizes;
  75764. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  75765. protected _postMeasure(): void;
  75766. /**
  75767. * Gets or sets the mouse wheel precision
  75768. * from 0 to 1 with a default value of 0.05
  75769. * */
  75770. get wheelPrecision(): number;
  75771. set wheelPrecision(value: number);
  75772. /** Gets or sets the scroll bar container background color */
  75773. get scrollBackground(): string;
  75774. set scrollBackground(color: string);
  75775. /** Gets or sets the bar color */
  75776. get barColor(): string;
  75777. set barColor(color: string);
  75778. /** Gets or sets the bar image */
  75779. get thumbImage(): Image;
  75780. set thumbImage(value: Image);
  75781. /** Gets or sets the horizontal bar image */
  75782. get horizontalThumbImage(): Image;
  75783. set horizontalThumbImage(value: Image);
  75784. /** Gets or sets the vertical bar image */
  75785. get verticalThumbImage(): Image;
  75786. set verticalThumbImage(value: Image);
  75787. /** Gets or sets the size of the bar */
  75788. get barSize(): number;
  75789. set barSize(value: number);
  75790. /** Gets or sets the length of the thumb */
  75791. get thumbLength(): number;
  75792. set thumbLength(value: number);
  75793. /** Gets or sets the height of the thumb */
  75794. get thumbHeight(): number;
  75795. set thumbHeight(value: number);
  75796. /** Gets or sets the height of the bar image */
  75797. get barImageHeight(): number;
  75798. set barImageHeight(value: number);
  75799. /** Gets or sets the height of the horizontal bar image */
  75800. get horizontalBarImageHeight(): number;
  75801. set horizontalBarImageHeight(value: number);
  75802. /** Gets or sets the height of the vertical bar image */
  75803. get verticalBarImageHeight(): number;
  75804. set verticalBarImageHeight(value: number);
  75805. /** Gets or sets the bar background */
  75806. get barBackground(): string;
  75807. set barBackground(color: string);
  75808. /** Gets or sets the bar background image */
  75809. get barImage(): Image;
  75810. set barImage(value: Image);
  75811. /** Gets or sets the horizontal bar background image */
  75812. get horizontalBarImage(): Image;
  75813. set horizontalBarImage(value: Image);
  75814. /** Gets or sets the vertical bar background image */
  75815. get verticalBarImage(): Image;
  75816. set verticalBarImage(value: Image);
  75817. private _setWindowPosition;
  75818. /** @hidden */
  75819. private _updateScroller;
  75820. _link(host: AdvancedDynamicTexture): void;
  75821. /** @hidden */
  75822. private _addBar;
  75823. /** @hidden */
  75824. private _attachWheel;
  75825. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  75826. /** Releases associated resources */
  75827. dispose(): void;
  75828. }
  75829. }
  75830. declare module BABYLON.GUI {
  75831. /** Class used to render a grid */
  75832. export class DisplayGrid extends Control {
  75833. name?: string | undefined;
  75834. private _cellWidth;
  75835. private _cellHeight;
  75836. private _minorLineTickness;
  75837. private _minorLineColor;
  75838. private _majorLineTickness;
  75839. private _majorLineColor;
  75840. private _majorLineFrequency;
  75841. private _background;
  75842. private _displayMajorLines;
  75843. private _displayMinorLines;
  75844. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  75845. get displayMinorLines(): boolean;
  75846. set displayMinorLines(value: boolean);
  75847. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  75848. get displayMajorLines(): boolean;
  75849. set displayMajorLines(value: boolean);
  75850. /** Gets or sets background color (Black by default) */
  75851. get background(): string;
  75852. set background(value: string);
  75853. /** Gets or sets the width of each cell (20 by default) */
  75854. get cellWidth(): number;
  75855. set cellWidth(value: number);
  75856. /** Gets or sets the height of each cell (20 by default) */
  75857. get cellHeight(): number;
  75858. set cellHeight(value: number);
  75859. /** Gets or sets the tickness of minor lines (1 by default) */
  75860. get minorLineTickness(): number;
  75861. set minorLineTickness(value: number);
  75862. /** Gets or sets the color of minor lines (DarkGray by default) */
  75863. get minorLineColor(): string;
  75864. set minorLineColor(value: string);
  75865. /** Gets or sets the tickness of major lines (2 by default) */
  75866. get majorLineTickness(): number;
  75867. set majorLineTickness(value: number);
  75868. /** Gets or sets the color of major lines (White by default) */
  75869. get majorLineColor(): string;
  75870. set majorLineColor(value: string);
  75871. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  75872. get majorLineFrequency(): number;
  75873. set majorLineFrequency(value: number);
  75874. /**
  75875. * Creates a new GridDisplayRectangle
  75876. * @param name defines the control name
  75877. */
  75878. constructor(name?: string | undefined);
  75879. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75880. protected _getTypeName(): string;
  75881. }
  75882. }
  75883. declare module BABYLON.GUI {
  75884. /**
  75885. * Class used to create slider controls based on images
  75886. */
  75887. export class ImageBasedSlider extends BaseSlider {
  75888. name?: string | undefined;
  75889. private _backgroundImage;
  75890. private _thumbImage;
  75891. private _valueBarImage;
  75892. private _tempMeasure;
  75893. get displayThumb(): boolean;
  75894. set displayThumb(value: boolean);
  75895. /**
  75896. * Gets or sets the image used to render the background
  75897. */
  75898. get backgroundImage(): Image;
  75899. set backgroundImage(value: Image);
  75900. /**
  75901. * Gets or sets the image used to render the value bar
  75902. */
  75903. get valueBarImage(): Image;
  75904. set valueBarImage(value: Image);
  75905. /**
  75906. * Gets or sets the image used to render the thumb
  75907. */
  75908. get thumbImage(): Image;
  75909. set thumbImage(value: Image);
  75910. /**
  75911. * Creates a new ImageBasedSlider
  75912. * @param name defines the control name
  75913. */
  75914. constructor(name?: string | undefined);
  75915. protected _getTypeName(): string;
  75916. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  75917. }
  75918. }
  75919. declare module BABYLON.GUI {
  75920. /**
  75921. * Forcing an export so that this code will execute
  75922. * @hidden
  75923. */
  75924. const name = "Statics";
  75925. }
  75926. declare module BABYLON.GUI {
  75927. /**
  75928. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  75929. */
  75930. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  75931. /**
  75932. * Define the instrumented AdvancedDynamicTexture.
  75933. */
  75934. texture: AdvancedDynamicTexture;
  75935. private _captureRenderTime;
  75936. private _renderTime;
  75937. private _captureLayoutTime;
  75938. private _layoutTime;
  75939. private _onBeginRenderObserver;
  75940. private _onEndRenderObserver;
  75941. private _onBeginLayoutObserver;
  75942. private _onEndLayoutObserver;
  75943. /**
  75944. * Gets the perf counter used to capture render time
  75945. */
  75946. get renderTimeCounter(): BABYLON.PerfCounter;
  75947. /**
  75948. * Gets the perf counter used to capture layout time
  75949. */
  75950. get layoutTimeCounter(): BABYLON.PerfCounter;
  75951. /**
  75952. * Enable or disable the render time capture
  75953. */
  75954. get captureRenderTime(): boolean;
  75955. set captureRenderTime(value: boolean);
  75956. /**
  75957. * Enable or disable the layout time capture
  75958. */
  75959. get captureLayoutTime(): boolean;
  75960. set captureLayoutTime(value: boolean);
  75961. /**
  75962. * Instantiates a new advanced dynamic texture instrumentation.
  75963. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  75964. * @param texture Defines the AdvancedDynamicTexture to instrument
  75965. */
  75966. constructor(
  75967. /**
  75968. * Define the instrumented AdvancedDynamicTexture.
  75969. */
  75970. texture: AdvancedDynamicTexture);
  75971. /**
  75972. * Dispose and release associated resources.
  75973. */
  75974. dispose(): void;
  75975. }
  75976. }
  75977. declare module BABYLON.GUI {
  75978. /**
  75979. * Class used to load GUI via XML.
  75980. */
  75981. export class XmlLoader {
  75982. private _nodes;
  75983. private _nodeTypes;
  75984. private _isLoaded;
  75985. private _objectAttributes;
  75986. private _parentClass;
  75987. /**
  75988. * Create a new xml loader
  75989. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  75990. */
  75991. constructor(parentClass?: null);
  75992. private _getChainElement;
  75993. private _getClassAttribute;
  75994. private _createGuiElement;
  75995. private _parseGrid;
  75996. private _parseElement;
  75997. private _prepareSourceElement;
  75998. private _parseElementsFromSource;
  75999. private _parseXml;
  76000. /**
  76001. * Gets if the loading has finished.
  76002. * @returns whether the loading has finished or not
  76003. */
  76004. isLoaded(): boolean;
  76005. /**
  76006. * Gets a loaded node / control by id.
  76007. * @param id the Controls id set in the xml
  76008. * @returns element of type Control
  76009. */
  76010. getNodeById(id: string): any;
  76011. /**
  76012. * Gets all loaded nodes / controls
  76013. * @returns Array of controls
  76014. */
  76015. getNodes(): any;
  76016. /**
  76017. * Initiates the xml layout loading
  76018. * @param xmlFile defines the xml layout to load
  76019. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  76020. * @param callback defines the callback called on layout load.
  76021. */
  76022. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  76023. }
  76024. }
  76025. declare module BABYLON.GUI {
  76026. /**
  76027. * Class used to create containers for controls
  76028. */
  76029. export class Container3D extends Control3D {
  76030. private _blockLayout;
  76031. /**
  76032. * Gets the list of child controls
  76033. */
  76034. protected _children: Control3D[];
  76035. /**
  76036. * Gets the list of child controls
  76037. */
  76038. get children(): Array<Control3D>;
  76039. /**
  76040. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  76041. * This is helpful to optimize layout operation when adding multiple children in a row
  76042. */
  76043. get blockLayout(): boolean;
  76044. set blockLayout(value: boolean);
  76045. /**
  76046. * Creates a new container
  76047. * @param name defines the container name
  76048. */
  76049. constructor(name?: string);
  76050. /**
  76051. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  76052. * @returns the current container
  76053. */
  76054. updateLayout(): Container3D;
  76055. /**
  76056. * Gets a boolean indicating if the given control is in the children of this control
  76057. * @param control defines the control to check
  76058. * @returns true if the control is in the child list
  76059. */
  76060. containsControl(control: Control3D): boolean;
  76061. /**
  76062. * Adds a control to the children of this control
  76063. * @param control defines the control to add
  76064. * @returns the current container
  76065. */
  76066. addControl(control: Control3D): Container3D;
  76067. /**
  76068. * This function will be called everytime a new control is added
  76069. */
  76070. protected _arrangeChildren(): void;
  76071. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76072. /**
  76073. * Removes a control from the children of this control
  76074. * @param control defines the control to remove
  76075. * @returns the current container
  76076. */
  76077. removeControl(control: Control3D): Container3D;
  76078. protected _getTypeName(): string;
  76079. /**
  76080. * Releases all associated resources
  76081. */
  76082. dispose(): void;
  76083. /** Control rotation will remain unchanged */
  76084. static readonly UNSET_ORIENTATION: number;
  76085. /** Control will rotate to make it look at sphere central axis */
  76086. static readonly FACEORIGIN_ORIENTATION: number;
  76087. /** Control will rotate to make it look back at sphere central axis */
  76088. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  76089. /** Control will rotate to look at z axis (0, 0, 1) */
  76090. static readonly FACEFORWARD_ORIENTATION: number;
  76091. /** Control will rotate to look at negative z axis (0, 0, -1) */
  76092. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  76093. }
  76094. }
  76095. declare module BABYLON.GUI {
  76096. /**
  76097. * Class used to manage 3D user interface
  76098. * @see http://doc.babylonjs.com/how_to/gui3d
  76099. */
  76100. export class GUI3DManager implements BABYLON.IDisposable {
  76101. private _scene;
  76102. private _sceneDisposeObserver;
  76103. private _utilityLayer;
  76104. private _rootContainer;
  76105. private _pointerObserver;
  76106. private _pointerOutObserver;
  76107. /** @hidden */
  76108. _lastPickedControl: Control3D;
  76109. /** @hidden */
  76110. _lastControlOver: {
  76111. [pointerId: number]: Control3D;
  76112. };
  76113. /** @hidden */
  76114. _lastControlDown: {
  76115. [pointerId: number]: Control3D;
  76116. };
  76117. /**
  76118. * BABYLON.Observable raised when the point picked by the pointer events changed
  76119. */
  76120. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  76121. /** @hidden */
  76122. _sharedMaterials: {
  76123. [key: string]: BABYLON.Material;
  76124. };
  76125. /** Gets the hosting scene */
  76126. get scene(): BABYLON.Scene;
  76127. /** Gets associated utility layer */
  76128. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  76129. /**
  76130. * Creates a new GUI3DManager
  76131. * @param scene
  76132. */
  76133. constructor(scene?: BABYLON.Scene);
  76134. private _handlePointerOut;
  76135. private _doPicking;
  76136. /**
  76137. * Gets the root container
  76138. */
  76139. get rootContainer(): Container3D;
  76140. /**
  76141. * Gets a boolean indicating if the given control is in the root child list
  76142. * @param control defines the control to check
  76143. * @returns true if the control is in the root child list
  76144. */
  76145. containsControl(control: Control3D): boolean;
  76146. /**
  76147. * Adds a control to the root child list
  76148. * @param control defines the control to add
  76149. * @returns the current manager
  76150. */
  76151. addControl(control: Control3D): GUI3DManager;
  76152. /**
  76153. * Removes a control from the root child list
  76154. * @param control defines the control to remove
  76155. * @returns the current container
  76156. */
  76157. removeControl(control: Control3D): GUI3DManager;
  76158. /**
  76159. * Releases all associated resources
  76160. */
  76161. dispose(): void;
  76162. }
  76163. }
  76164. declare module BABYLON.GUI {
  76165. /**
  76166. * Class used to transport BABYLON.Vector3 information for pointer events
  76167. */
  76168. export class Vector3WithInfo extends BABYLON.Vector3 {
  76169. /** defines the current mouse button index */
  76170. buttonIndex: number;
  76171. /**
  76172. * Creates a new Vector3WithInfo
  76173. * @param source defines the vector3 data to transport
  76174. * @param buttonIndex defines the current mouse button index
  76175. */
  76176. constructor(source: BABYLON.Vector3,
  76177. /** defines the current mouse button index */
  76178. buttonIndex?: number);
  76179. }
  76180. }
  76181. declare module BABYLON.GUI {
  76182. /**
  76183. * Class used as base class for controls
  76184. */
  76185. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  76186. /** Defines the control name */
  76187. name?: string | undefined;
  76188. /** @hidden */
  76189. _host: GUI3DManager;
  76190. private _node;
  76191. private _downCount;
  76192. private _enterCount;
  76193. private _downPointerIds;
  76194. private _isVisible;
  76195. /** Gets or sets the control position in world space */
  76196. get position(): BABYLON.Vector3;
  76197. set position(value: BABYLON.Vector3);
  76198. /** Gets or sets the control scaling in world space */
  76199. get scaling(): BABYLON.Vector3;
  76200. set scaling(value: BABYLON.Vector3);
  76201. /** Callback used to start pointer enter animation */
  76202. pointerEnterAnimation: () => void;
  76203. /** Callback used to start pointer out animation */
  76204. pointerOutAnimation: () => void;
  76205. /** Callback used to start pointer down animation */
  76206. pointerDownAnimation: () => void;
  76207. /** Callback used to start pointer up animation */
  76208. pointerUpAnimation: () => void;
  76209. /**
  76210. * An event triggered when the pointer move over the control
  76211. */
  76212. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  76213. /**
  76214. * An event triggered when the pointer move out of the control
  76215. */
  76216. onPointerOutObservable: BABYLON.Observable<Control3D>;
  76217. /**
  76218. * An event triggered when the pointer taps the control
  76219. */
  76220. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  76221. /**
  76222. * An event triggered when pointer is up
  76223. */
  76224. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  76225. /**
  76226. * An event triggered when a control is clicked on (with a mouse)
  76227. */
  76228. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  76229. /**
  76230. * An event triggered when pointer enters the control
  76231. */
  76232. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  76233. /**
  76234. * Gets or sets the parent container
  76235. */
  76236. parent: BABYLON.Nullable<Container3D>;
  76237. private _behaviors;
  76238. /**
  76239. * Gets the list of attached behaviors
  76240. * @see http://doc.babylonjs.com/features/behaviour
  76241. */
  76242. get behaviors(): BABYLON.Behavior<Control3D>[];
  76243. /**
  76244. * Attach a behavior to the control
  76245. * @see http://doc.babylonjs.com/features/behaviour
  76246. * @param behavior defines the behavior to attach
  76247. * @returns the current control
  76248. */
  76249. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76250. /**
  76251. * Remove an attached behavior
  76252. * @see http://doc.babylonjs.com/features/behaviour
  76253. * @param behavior defines the behavior to attach
  76254. * @returns the current control
  76255. */
  76256. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  76257. /**
  76258. * Gets an attached behavior by name
  76259. * @param name defines the name of the behavior to look for
  76260. * @see http://doc.babylonjs.com/features/behaviour
  76261. * @returns null if behavior was not found else the requested behavior
  76262. */
  76263. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  76264. /** Gets or sets a boolean indicating if the control is visible */
  76265. get isVisible(): boolean;
  76266. set isVisible(value: boolean);
  76267. /**
  76268. * Creates a new control
  76269. * @param name defines the control name
  76270. */
  76271. constructor(
  76272. /** Defines the control name */
  76273. name?: string | undefined);
  76274. /**
  76275. * Gets a string representing the class name
  76276. */
  76277. get typeName(): string;
  76278. /**
  76279. * Get the current class name of the control.
  76280. * @returns current class name
  76281. */
  76282. getClassName(): string;
  76283. protected _getTypeName(): string;
  76284. /**
  76285. * Gets the transform node used by this control
  76286. */
  76287. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  76288. /**
  76289. * Gets the mesh used to render this control
  76290. */
  76291. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76292. /**
  76293. * Link the control as child of the given node
  76294. * @param node defines the node to link to. Use null to unlink the control
  76295. * @returns the current control
  76296. */
  76297. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  76298. /** @hidden **/
  76299. _prepareNode(scene: BABYLON.Scene): void;
  76300. /**
  76301. * Node creation.
  76302. * Can be overriden by children
  76303. * @param scene defines the scene where the node must be attached
  76304. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  76305. */
  76306. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  76307. /**
  76308. * Affect a material to the given mesh
  76309. * @param mesh defines the mesh which will represent the control
  76310. */
  76311. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76312. /** @hidden */
  76313. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  76314. /** @hidden */
  76315. _onPointerEnter(target: Control3D): boolean;
  76316. /** @hidden */
  76317. _onPointerOut(target: Control3D): void;
  76318. /** @hidden */
  76319. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76320. /** @hidden */
  76321. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76322. /** @hidden */
  76323. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76324. /** @hidden */
  76325. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  76326. /** @hidden */
  76327. _disposeNode(): void;
  76328. /**
  76329. * Releases all associated resources
  76330. */
  76331. dispose(): void;
  76332. }
  76333. }
  76334. declare module BABYLON.GUI {
  76335. /**
  76336. * Class used as a root to all buttons
  76337. */
  76338. export class AbstractButton3D extends Control3D {
  76339. /**
  76340. * Creates a new button
  76341. * @param name defines the control name
  76342. */
  76343. constructor(name?: string);
  76344. protected _getTypeName(): string;
  76345. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76346. }
  76347. }
  76348. declare module BABYLON.GUI {
  76349. /**
  76350. * Class used to create a button in 3D
  76351. */
  76352. export class Button3D extends AbstractButton3D {
  76353. /** @hidden */
  76354. protected _currentMaterial: BABYLON.Material;
  76355. private _facadeTexture;
  76356. private _content;
  76357. private _contentResolution;
  76358. private _contentScaleRatio;
  76359. /**
  76360. * Gets or sets the texture resolution used to render content (512 by default)
  76361. */
  76362. get contentResolution(): BABYLON.int;
  76363. set contentResolution(value: BABYLON.int);
  76364. /**
  76365. * Gets or sets the texture scale ratio used to render content (2 by default)
  76366. */
  76367. get contentScaleRatio(): number;
  76368. set contentScaleRatio(value: number);
  76369. protected _disposeFacadeTexture(): void;
  76370. protected _resetContent(): void;
  76371. /**
  76372. * Creates a new button
  76373. * @param name defines the control name
  76374. */
  76375. constructor(name?: string);
  76376. /**
  76377. * Gets or sets the GUI 2D content used to display the button's facade
  76378. */
  76379. get content(): Control;
  76380. set content(value: Control);
  76381. /**
  76382. * Apply the facade texture (created from the content property).
  76383. * This function can be overloaded by child classes
  76384. * @param facadeTexture defines the AdvancedDynamicTexture to use
  76385. */
  76386. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76387. protected _getTypeName(): string;
  76388. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76389. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76390. /**
  76391. * Releases all associated resources
  76392. */
  76393. dispose(): void;
  76394. }
  76395. }
  76396. declare module BABYLON.GUI {
  76397. /**
  76398. * Abstract class used to create a container panel deployed on the surface of a volume
  76399. */
  76400. export abstract class VolumeBasedPanel extends Container3D {
  76401. private _columns;
  76402. private _rows;
  76403. private _rowThenColum;
  76404. private _orientation;
  76405. protected _cellWidth: number;
  76406. protected _cellHeight: number;
  76407. /**
  76408. * Gets or sets the distance between elements
  76409. */
  76410. margin: number;
  76411. /**
  76412. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  76413. * | Value | Type | Description |
  76414. * | ----- | ----------------------------------- | ----------- |
  76415. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  76416. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  76417. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  76418. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  76419. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  76420. */
  76421. get orientation(): number;
  76422. set orientation(value: number);
  76423. /**
  76424. * Gets or sets the number of columns requested (10 by default).
  76425. * The panel will automatically compute the number of rows based on number of child controls.
  76426. */
  76427. get columns(): BABYLON.int;
  76428. set columns(value: BABYLON.int);
  76429. /**
  76430. * Gets or sets a the number of rows requested.
  76431. * The panel will automatically compute the number of columns based on number of child controls.
  76432. */
  76433. get rows(): BABYLON.int;
  76434. set rows(value: BABYLON.int);
  76435. /**
  76436. * Creates new VolumeBasedPanel
  76437. */
  76438. constructor();
  76439. protected _arrangeChildren(): void;
  76440. /** Child classes must implement this function to provide correct control positioning */
  76441. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76442. /** Child classes can implement this function to provide additional processing */
  76443. protected _finalProcessing(): void;
  76444. }
  76445. }
  76446. declare module BABYLON.GUI {
  76447. /**
  76448. * Class used to create a container panel deployed on the surface of a cylinder
  76449. */
  76450. export class CylinderPanel extends VolumeBasedPanel {
  76451. private _radius;
  76452. /**
  76453. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  76454. */
  76455. get radius(): BABYLON.float;
  76456. set radius(value: BABYLON.float);
  76457. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76458. private _cylindricalMapping;
  76459. }
  76460. }
  76461. declare module BABYLON.GUI {
  76462. /** @hidden */
  76463. export var fluentVertexShader: {
  76464. name: string;
  76465. shader: string;
  76466. };
  76467. }
  76468. declare module BABYLON.GUI {
  76469. /** @hidden */
  76470. export var fluentPixelShader: {
  76471. name: string;
  76472. shader: string;
  76473. };
  76474. }
  76475. declare module BABYLON.GUI {
  76476. /** @hidden */
  76477. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  76478. INNERGLOW: boolean;
  76479. BORDER: boolean;
  76480. HOVERLIGHT: boolean;
  76481. TEXTURE: boolean;
  76482. constructor();
  76483. }
  76484. /**
  76485. * Class used to render controls with fluent desgin
  76486. */
  76487. export class FluentMaterial extends BABYLON.PushMaterial {
  76488. /**
  76489. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  76490. */
  76491. innerGlowColorIntensity: number;
  76492. /**
  76493. * Gets or sets the inner glow color (white by default)
  76494. */
  76495. innerGlowColor: BABYLON.Color3;
  76496. /**
  76497. * Gets or sets alpha value (default is 1.0)
  76498. */
  76499. alpha: number;
  76500. /**
  76501. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  76502. */
  76503. albedoColor: BABYLON.Color3;
  76504. /**
  76505. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  76506. */
  76507. renderBorders: boolean;
  76508. /**
  76509. * Gets or sets border width (default is 0.5)
  76510. */
  76511. borderWidth: number;
  76512. /**
  76513. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  76514. */
  76515. edgeSmoothingValue: number;
  76516. /**
  76517. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  76518. */
  76519. borderMinValue: number;
  76520. /**
  76521. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  76522. */
  76523. renderHoverLight: boolean;
  76524. /**
  76525. * Gets or sets the radius used to render the hover light (default is 1.0)
  76526. */
  76527. hoverRadius: number;
  76528. /**
  76529. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  76530. */
  76531. hoverColor: BABYLON.Color4;
  76532. /**
  76533. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  76534. */
  76535. hoverPosition: BABYLON.Vector3;
  76536. private _albedoTexture;
  76537. /** Gets or sets the texture to use for albedo color */
  76538. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  76539. /**
  76540. * Creates a new Fluent material
  76541. * @param name defines the name of the material
  76542. * @param scene defines the hosting scene
  76543. */
  76544. constructor(name: string, scene: BABYLON.Scene);
  76545. needAlphaBlending(): boolean;
  76546. needAlphaTesting(): boolean;
  76547. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  76548. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  76549. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  76550. getActiveTextures(): BABYLON.BaseTexture[];
  76551. hasTexture(texture: BABYLON.BaseTexture): boolean;
  76552. dispose(forceDisposeEffect?: boolean): void;
  76553. clone(name: string): FluentMaterial;
  76554. serialize(): any;
  76555. getClassName(): string;
  76556. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  76557. }
  76558. }
  76559. declare module BABYLON.GUI {
  76560. /**
  76561. * Class used to create a holographic button in 3D
  76562. */
  76563. export class HolographicButton extends Button3D {
  76564. private _backPlate;
  76565. private _textPlate;
  76566. private _frontPlate;
  76567. private _text;
  76568. private _imageUrl;
  76569. private _shareMaterials;
  76570. private _frontMaterial;
  76571. private _backMaterial;
  76572. private _plateMaterial;
  76573. private _pickedPointObserver;
  76574. private _tooltipFade;
  76575. private _tooltipTextBlock;
  76576. private _tooltipTexture;
  76577. private _tooltipMesh;
  76578. private _tooltipHoverObserver;
  76579. private _tooltipOutObserver;
  76580. private _disposeTooltip;
  76581. /**
  76582. * Rendering ground id of all the mesh in the button
  76583. */
  76584. set renderingGroupId(id: number);
  76585. get renderingGroupId(): number;
  76586. /**
  76587. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  76588. */
  76589. set tooltipText(text: BABYLON.Nullable<string>);
  76590. get tooltipText(): BABYLON.Nullable<string>;
  76591. /**
  76592. * Gets or sets text for the button
  76593. */
  76594. get text(): string;
  76595. set text(value: string);
  76596. /**
  76597. * Gets or sets the image url for the button
  76598. */
  76599. get imageUrl(): string;
  76600. set imageUrl(value: string);
  76601. /**
  76602. * Gets the back material used by this button
  76603. */
  76604. get backMaterial(): FluentMaterial;
  76605. /**
  76606. * Gets the front material used by this button
  76607. */
  76608. get frontMaterial(): FluentMaterial;
  76609. /**
  76610. * Gets the plate material used by this button
  76611. */
  76612. get plateMaterial(): BABYLON.StandardMaterial;
  76613. /**
  76614. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  76615. */
  76616. get shareMaterials(): boolean;
  76617. /**
  76618. * Creates a new button
  76619. * @param name defines the control name
  76620. */
  76621. constructor(name?: string, shareMaterials?: boolean);
  76622. protected _getTypeName(): string;
  76623. private _rebuildContent;
  76624. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76625. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  76626. private _createBackMaterial;
  76627. private _createFrontMaterial;
  76628. private _createPlateMaterial;
  76629. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  76630. /**
  76631. * Releases all associated resources
  76632. */
  76633. dispose(): void;
  76634. }
  76635. }
  76636. declare module BABYLON.GUI {
  76637. /**
  76638. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  76639. */
  76640. export class MeshButton3D extends Button3D {
  76641. /** @hidden */
  76642. protected _currentMesh: BABYLON.Mesh;
  76643. /**
  76644. * Creates a new 3D button based on a mesh
  76645. * @param mesh mesh to become a 3D button
  76646. * @param name defines the control name
  76647. */
  76648. constructor(mesh: BABYLON.Mesh, name?: string);
  76649. protected _getTypeName(): string;
  76650. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  76651. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  76652. }
  76653. }
  76654. declare module BABYLON.GUI {
  76655. /**
  76656. * Class used to create a container panel deployed on the surface of a plane
  76657. */
  76658. export class PlanePanel extends VolumeBasedPanel {
  76659. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76660. }
  76661. }
  76662. declare module BABYLON.GUI {
  76663. /**
  76664. * Class used to create a container panel where items get randomized planar mapping
  76665. */
  76666. export class ScatterPanel extends VolumeBasedPanel {
  76667. private _iteration;
  76668. /**
  76669. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  76670. */
  76671. get iteration(): BABYLON.float;
  76672. set iteration(value: BABYLON.float);
  76673. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76674. private _scatterMapping;
  76675. protected _finalProcessing(): void;
  76676. }
  76677. }
  76678. declare module BABYLON.GUI {
  76679. /**
  76680. * Class used to create a container panel deployed on the surface of a sphere
  76681. */
  76682. export class SpherePanel extends VolumeBasedPanel {
  76683. private _radius;
  76684. /**
  76685. * Gets or sets the radius of the sphere where to project controls (5 by default)
  76686. */
  76687. get radius(): BABYLON.float;
  76688. set radius(value: BABYLON.float);
  76689. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  76690. private _sphericalMapping;
  76691. }
  76692. }
  76693. declare module BABYLON.GUI {
  76694. /**
  76695. * Class used to create a stack panel in 3D on XY plane
  76696. */
  76697. export class StackPanel3D extends Container3D {
  76698. private _isVertical;
  76699. /**
  76700. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  76701. */
  76702. get isVertical(): boolean;
  76703. set isVertical(value: boolean);
  76704. /**
  76705. * Gets or sets the distance between elements
  76706. */
  76707. margin: number;
  76708. /**
  76709. * Creates new StackPanel
  76710. * @param isVertical
  76711. */
  76712. constructor(isVertical?: boolean);
  76713. protected _arrangeChildren(): void;
  76714. }
  76715. }
  76716. declare module BABYLON {
  76717. /**
  76718. * Configuration for glTF validation
  76719. */
  76720. export interface IGLTFValidationConfiguration {
  76721. /**
  76722. * The url of the glTF validator.
  76723. */
  76724. url: string;
  76725. }
  76726. /**
  76727. * glTF validation
  76728. */
  76729. export class GLTFValidation {
  76730. /**
  76731. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  76732. */
  76733. static Configuration: IGLTFValidationConfiguration;
  76734. private static _LoadScriptPromise;
  76735. /**
  76736. * Validate a glTF asset using the glTF-Validator.
  76737. * @param data The JSON of a glTF or the array buffer of a binary glTF
  76738. * @param rootUrl The root url for the glTF
  76739. * @param fileName The file name for the glTF
  76740. * @param getExternalResource The callback to get external resources for the glTF validator
  76741. * @returns A promise that resolves with the glTF validation results once complete
  76742. */
  76743. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  76744. }
  76745. }
  76746. declare module BABYLON {
  76747. /**
  76748. * Mode that determines the coordinate system to use.
  76749. */
  76750. export enum GLTFLoaderCoordinateSystemMode {
  76751. /**
  76752. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  76753. */
  76754. AUTO = 0,
  76755. /**
  76756. * Sets the useRightHandedSystem flag on the scene.
  76757. */
  76758. FORCE_RIGHT_HANDED = 1
  76759. }
  76760. /**
  76761. * Mode that determines what animations will start.
  76762. */
  76763. export enum GLTFLoaderAnimationStartMode {
  76764. /**
  76765. * No animation will start.
  76766. */
  76767. NONE = 0,
  76768. /**
  76769. * The first animation will start.
  76770. */
  76771. FIRST = 1,
  76772. /**
  76773. * All animations will start.
  76774. */
  76775. ALL = 2
  76776. }
  76777. /**
  76778. * Interface that contains the data for the glTF asset.
  76779. */
  76780. export interface IGLTFLoaderData {
  76781. /**
  76782. * The object that represents the glTF JSON.
  76783. */
  76784. json: Object;
  76785. /**
  76786. * The BIN chunk of a binary glTF.
  76787. */
  76788. bin: Nullable<IDataBuffer>;
  76789. }
  76790. /**
  76791. * Interface for extending the loader.
  76792. */
  76793. export interface IGLTFLoaderExtension {
  76794. /**
  76795. * The name of this extension.
  76796. */
  76797. readonly name: string;
  76798. /**
  76799. * Defines whether this extension is enabled.
  76800. */
  76801. enabled: boolean;
  76802. /**
  76803. * Defines the order of this extension.
  76804. * The loader sorts the extensions using these values when loading.
  76805. */
  76806. order?: number;
  76807. }
  76808. /**
  76809. * Loader state.
  76810. */
  76811. export enum GLTFLoaderState {
  76812. /**
  76813. * The asset is loading.
  76814. */
  76815. LOADING = 0,
  76816. /**
  76817. * The asset is ready for rendering.
  76818. */
  76819. READY = 1,
  76820. /**
  76821. * The asset is completely loaded.
  76822. */
  76823. COMPLETE = 2
  76824. }
  76825. /** @hidden */
  76826. export interface IImportMeshAsyncOutput {
  76827. meshes: AbstractMesh[];
  76828. particleSystems: IParticleSystem[];
  76829. skeletons: Skeleton[];
  76830. animationGroups: AnimationGroup[];
  76831. lights: Light[];
  76832. transformNodes: TransformNode[];
  76833. }
  76834. /** @hidden */
  76835. export interface IGLTFLoader extends IDisposable {
  76836. readonly state: Nullable<GLTFLoaderState>;
  76837. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  76838. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  76839. }
  76840. /**
  76841. * File loader for loading glTF files into a scene.
  76842. */
  76843. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76844. /** @hidden */
  76845. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76846. /** @hidden */
  76847. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  76848. /**
  76849. * Raised when the asset has been parsed
  76850. */
  76851. onParsedObservable: Observable<IGLTFLoaderData>;
  76852. private _onParsedObserver;
  76853. /**
  76854. * Raised when the asset has been parsed
  76855. */
  76856. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  76857. /**
  76858. * 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.
  76859. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  76860. * Defaults to true.
  76861. * @hidden
  76862. */
  76863. static IncrementalLoading: boolean;
  76864. /**
  76865. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  76866. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  76867. * @hidden
  76868. */
  76869. static HomogeneousCoordinates: boolean;
  76870. /**
  76871. * The coordinate system mode. Defaults to AUTO.
  76872. */
  76873. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  76874. /**
  76875. * The animation start mode. Defaults to FIRST.
  76876. */
  76877. animationStartMode: GLTFLoaderAnimationStartMode;
  76878. /**
  76879. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  76880. */
  76881. compileMaterials: boolean;
  76882. /**
  76883. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  76884. */
  76885. useClipPlane: boolean;
  76886. /**
  76887. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  76888. */
  76889. compileShadowGenerators: boolean;
  76890. /**
  76891. * Defines if the Alpha blended materials are only applied as coverage.
  76892. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  76893. * If true, no extra effects are applied to transparent pixels.
  76894. */
  76895. transparencyAsCoverage: boolean;
  76896. /**
  76897. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  76898. * Enabling will disable offline support and glTF validator.
  76899. * Defaults to false.
  76900. */
  76901. useRangeRequests: boolean;
  76902. /**
  76903. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  76904. */
  76905. createInstances: boolean;
  76906. /**
  76907. * Function called before loading a url referenced by the asset.
  76908. */
  76909. preprocessUrlAsync: (url: string) => Promise<string>;
  76910. /**
  76911. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76912. */
  76913. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  76914. private _onMeshLoadedObserver;
  76915. /**
  76916. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  76917. */
  76918. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  76919. /**
  76920. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  76921. */
  76922. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  76923. private _onTextureLoadedObserver;
  76924. /**
  76925. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  76926. */
  76927. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  76928. /**
  76929. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  76930. */
  76931. readonly onMaterialLoadedObservable: Observable<Material>;
  76932. private _onMaterialLoadedObserver;
  76933. /**
  76934. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  76935. */
  76936. set onMaterialLoaded(callback: (material: Material) => void);
  76937. /**
  76938. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  76939. */
  76940. readonly onCameraLoadedObservable: Observable<Camera>;
  76941. private _onCameraLoadedObserver;
  76942. /**
  76943. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  76944. */
  76945. set onCameraLoaded(callback: (camera: Camera) => void);
  76946. /**
  76947. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  76948. * For assets with LODs, raised when all of the LODs are complete.
  76949. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76950. */
  76951. readonly onCompleteObservable: Observable<void>;
  76952. private _onCompleteObserver;
  76953. /**
  76954. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  76955. * For assets with LODs, raised when all of the LODs are complete.
  76956. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  76957. */
  76958. set onComplete(callback: () => void);
  76959. /**
  76960. * Observable raised when an error occurs.
  76961. */
  76962. readonly onErrorObservable: Observable<any>;
  76963. private _onErrorObserver;
  76964. /**
  76965. * Callback raised when an error occurs.
  76966. */
  76967. set onError(callback: (reason: any) => void);
  76968. /**
  76969. * Observable raised after the loader is disposed.
  76970. */
  76971. readonly onDisposeObservable: Observable<void>;
  76972. private _onDisposeObserver;
  76973. /**
  76974. * Callback raised after the loader is disposed.
  76975. */
  76976. set onDispose(callback: () => void);
  76977. /**
  76978. * Observable raised after a loader extension is created.
  76979. * Set additional options for a loader extension in this event.
  76980. */
  76981. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  76982. private _onExtensionLoadedObserver;
  76983. /**
  76984. * Callback raised after a loader extension is created.
  76985. */
  76986. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  76987. /**
  76988. * Defines if the loader logging is enabled.
  76989. */
  76990. get loggingEnabled(): boolean;
  76991. set loggingEnabled(value: boolean);
  76992. /**
  76993. * Defines if the loader should capture performance counters.
  76994. */
  76995. get capturePerformanceCounters(): boolean;
  76996. set capturePerformanceCounters(value: boolean);
  76997. /**
  76998. * Defines if the loader should validate the asset.
  76999. */
  77000. validate: boolean;
  77001. /**
  77002. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  77003. */
  77004. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  77005. private _onValidatedObserver;
  77006. /**
  77007. * Callback raised after a loader extension is created.
  77008. */
  77009. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  77010. private _loader;
  77011. /**
  77012. * Name of the loader ("gltf")
  77013. */
  77014. name: string;
  77015. /** @hidden */
  77016. extensions: ISceneLoaderPluginExtensions;
  77017. /**
  77018. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  77019. */
  77020. dispose(): void;
  77021. /** @hidden */
  77022. _clear(): void;
  77023. /** @hidden */
  77024. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77025. /** @hidden */
  77026. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  77027. /** @hidden */
  77028. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77029. meshes: AbstractMesh[];
  77030. particleSystems: IParticleSystem[];
  77031. skeletons: Skeleton[];
  77032. animationGroups: AnimationGroup[];
  77033. }>;
  77034. /** @hidden */
  77035. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77036. /** @hidden */
  77037. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77038. /** @hidden */
  77039. canDirectLoad(data: string): boolean;
  77040. /** @hidden */
  77041. directLoad(scene: Scene, data: string): any;
  77042. /**
  77043. * The callback that allows custom handling of the root url based on the response url.
  77044. * @param rootUrl the original root url
  77045. * @param responseURL the response url if available
  77046. * @returns the new root url
  77047. */
  77048. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  77049. /** @hidden */
  77050. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  77051. /**
  77052. * The loader state or null if the loader is not active.
  77053. */
  77054. get loaderState(): Nullable<GLTFLoaderState>;
  77055. /**
  77056. * Returns a promise that resolves when the asset is completely loaded.
  77057. * @returns a promise that resolves when the asset is completely loaded.
  77058. */
  77059. whenCompleteAsync(): Promise<void>;
  77060. private _validate;
  77061. private _getLoader;
  77062. private _parseJson;
  77063. private _unpackBinaryAsync;
  77064. private _unpackBinaryV1Async;
  77065. private _unpackBinaryV2Async;
  77066. private static _parseVersion;
  77067. private static _compareVersion;
  77068. private static readonly _logSpaces;
  77069. private _logIndentLevel;
  77070. private _loggingEnabled;
  77071. /** @hidden */
  77072. _log: (message: string) => void;
  77073. /** @hidden */
  77074. _logOpen(message: string): void;
  77075. /** @hidden */
  77076. _logClose(): void;
  77077. private _logEnabled;
  77078. private _logDisabled;
  77079. private _capturePerformanceCounters;
  77080. /** @hidden */
  77081. _startPerformanceCounter: (counterName: string) => void;
  77082. /** @hidden */
  77083. _endPerformanceCounter: (counterName: string) => void;
  77084. private _startPerformanceCounterEnabled;
  77085. private _startPerformanceCounterDisabled;
  77086. private _endPerformanceCounterEnabled;
  77087. private _endPerformanceCounterDisabled;
  77088. }
  77089. }
  77090. declare module BABYLON.GLTF1 {
  77091. /**
  77092. * Enums
  77093. * @hidden
  77094. */
  77095. export enum EComponentType {
  77096. BYTE = 5120,
  77097. UNSIGNED_BYTE = 5121,
  77098. SHORT = 5122,
  77099. UNSIGNED_SHORT = 5123,
  77100. FLOAT = 5126
  77101. }
  77102. /** @hidden */
  77103. export enum EShaderType {
  77104. FRAGMENT = 35632,
  77105. VERTEX = 35633
  77106. }
  77107. /** @hidden */
  77108. export enum EParameterType {
  77109. BYTE = 5120,
  77110. UNSIGNED_BYTE = 5121,
  77111. SHORT = 5122,
  77112. UNSIGNED_SHORT = 5123,
  77113. INT = 5124,
  77114. UNSIGNED_INT = 5125,
  77115. FLOAT = 5126,
  77116. FLOAT_VEC2 = 35664,
  77117. FLOAT_VEC3 = 35665,
  77118. FLOAT_VEC4 = 35666,
  77119. INT_VEC2 = 35667,
  77120. INT_VEC3 = 35668,
  77121. INT_VEC4 = 35669,
  77122. BOOL = 35670,
  77123. BOOL_VEC2 = 35671,
  77124. BOOL_VEC3 = 35672,
  77125. BOOL_VEC4 = 35673,
  77126. FLOAT_MAT2 = 35674,
  77127. FLOAT_MAT3 = 35675,
  77128. FLOAT_MAT4 = 35676,
  77129. SAMPLER_2D = 35678
  77130. }
  77131. /** @hidden */
  77132. export enum ETextureWrapMode {
  77133. CLAMP_TO_EDGE = 33071,
  77134. MIRRORED_REPEAT = 33648,
  77135. REPEAT = 10497
  77136. }
  77137. /** @hidden */
  77138. export enum ETextureFilterType {
  77139. NEAREST = 9728,
  77140. LINEAR = 9728,
  77141. NEAREST_MIPMAP_NEAREST = 9984,
  77142. LINEAR_MIPMAP_NEAREST = 9985,
  77143. NEAREST_MIPMAP_LINEAR = 9986,
  77144. LINEAR_MIPMAP_LINEAR = 9987
  77145. }
  77146. /** @hidden */
  77147. export enum ETextureFormat {
  77148. ALPHA = 6406,
  77149. RGB = 6407,
  77150. RGBA = 6408,
  77151. LUMINANCE = 6409,
  77152. LUMINANCE_ALPHA = 6410
  77153. }
  77154. /** @hidden */
  77155. export enum ECullingType {
  77156. FRONT = 1028,
  77157. BACK = 1029,
  77158. FRONT_AND_BACK = 1032
  77159. }
  77160. /** @hidden */
  77161. export enum EBlendingFunction {
  77162. ZERO = 0,
  77163. ONE = 1,
  77164. SRC_COLOR = 768,
  77165. ONE_MINUS_SRC_COLOR = 769,
  77166. DST_COLOR = 774,
  77167. ONE_MINUS_DST_COLOR = 775,
  77168. SRC_ALPHA = 770,
  77169. ONE_MINUS_SRC_ALPHA = 771,
  77170. DST_ALPHA = 772,
  77171. ONE_MINUS_DST_ALPHA = 773,
  77172. CONSTANT_COLOR = 32769,
  77173. ONE_MINUS_CONSTANT_COLOR = 32770,
  77174. CONSTANT_ALPHA = 32771,
  77175. ONE_MINUS_CONSTANT_ALPHA = 32772,
  77176. SRC_ALPHA_SATURATE = 776
  77177. }
  77178. /** @hidden */
  77179. export interface IGLTFProperty {
  77180. extensions?: {
  77181. [key: string]: any;
  77182. };
  77183. extras?: Object;
  77184. }
  77185. /** @hidden */
  77186. export interface IGLTFChildRootProperty extends IGLTFProperty {
  77187. name?: string;
  77188. }
  77189. /** @hidden */
  77190. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  77191. bufferView: string;
  77192. byteOffset: number;
  77193. byteStride: number;
  77194. count: number;
  77195. type: string;
  77196. componentType: EComponentType;
  77197. max?: number[];
  77198. min?: number[];
  77199. name?: string;
  77200. }
  77201. /** @hidden */
  77202. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  77203. buffer: string;
  77204. byteOffset: number;
  77205. byteLength: number;
  77206. byteStride: number;
  77207. target?: number;
  77208. }
  77209. /** @hidden */
  77210. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  77211. uri: string;
  77212. byteLength?: number;
  77213. type?: string;
  77214. }
  77215. /** @hidden */
  77216. export interface IGLTFShader extends IGLTFChildRootProperty {
  77217. uri: string;
  77218. type: EShaderType;
  77219. }
  77220. /** @hidden */
  77221. export interface IGLTFProgram extends IGLTFChildRootProperty {
  77222. attributes: string[];
  77223. fragmentShader: string;
  77224. vertexShader: string;
  77225. }
  77226. /** @hidden */
  77227. export interface IGLTFTechniqueParameter {
  77228. type: number;
  77229. count?: number;
  77230. semantic?: string;
  77231. node?: string;
  77232. value?: number | boolean | string | Array<any>;
  77233. source?: string;
  77234. babylonValue?: any;
  77235. }
  77236. /** @hidden */
  77237. export interface IGLTFTechniqueCommonProfile {
  77238. lightingModel: string;
  77239. texcoordBindings: Object;
  77240. parameters?: Array<any>;
  77241. }
  77242. /** @hidden */
  77243. export interface IGLTFTechniqueStatesFunctions {
  77244. blendColor?: number[];
  77245. blendEquationSeparate?: number[];
  77246. blendFuncSeparate?: number[];
  77247. colorMask: boolean[];
  77248. cullFace: number[];
  77249. }
  77250. /** @hidden */
  77251. export interface IGLTFTechniqueStates {
  77252. enable: number[];
  77253. functions: IGLTFTechniqueStatesFunctions;
  77254. }
  77255. /** @hidden */
  77256. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  77257. parameters: {
  77258. [key: string]: IGLTFTechniqueParameter;
  77259. };
  77260. program: string;
  77261. attributes: {
  77262. [key: string]: string;
  77263. };
  77264. uniforms: {
  77265. [key: string]: string;
  77266. };
  77267. states: IGLTFTechniqueStates;
  77268. }
  77269. /** @hidden */
  77270. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  77271. technique?: string;
  77272. values: string[];
  77273. }
  77274. /** @hidden */
  77275. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  77276. attributes: {
  77277. [key: string]: string;
  77278. };
  77279. indices: string;
  77280. material: string;
  77281. mode?: number;
  77282. }
  77283. /** @hidden */
  77284. export interface IGLTFMesh extends IGLTFChildRootProperty {
  77285. primitives: IGLTFMeshPrimitive[];
  77286. }
  77287. /** @hidden */
  77288. export interface IGLTFImage extends IGLTFChildRootProperty {
  77289. uri: string;
  77290. }
  77291. /** @hidden */
  77292. export interface IGLTFSampler extends IGLTFChildRootProperty {
  77293. magFilter?: number;
  77294. minFilter?: number;
  77295. wrapS?: number;
  77296. wrapT?: number;
  77297. }
  77298. /** @hidden */
  77299. export interface IGLTFTexture extends IGLTFChildRootProperty {
  77300. sampler: string;
  77301. source: string;
  77302. format?: ETextureFormat;
  77303. internalFormat?: ETextureFormat;
  77304. target?: number;
  77305. type?: number;
  77306. babylonTexture?: Texture;
  77307. }
  77308. /** @hidden */
  77309. export interface IGLTFAmbienLight {
  77310. color?: number[];
  77311. }
  77312. /** @hidden */
  77313. export interface IGLTFDirectionalLight {
  77314. color?: number[];
  77315. }
  77316. /** @hidden */
  77317. export interface IGLTFPointLight {
  77318. color?: number[];
  77319. constantAttenuation?: number;
  77320. linearAttenuation?: number;
  77321. quadraticAttenuation?: number;
  77322. }
  77323. /** @hidden */
  77324. export interface IGLTFSpotLight {
  77325. color?: number[];
  77326. constantAttenuation?: number;
  77327. fallOfAngle?: number;
  77328. fallOffExponent?: number;
  77329. linearAttenuation?: number;
  77330. quadraticAttenuation?: number;
  77331. }
  77332. /** @hidden */
  77333. export interface IGLTFLight extends IGLTFChildRootProperty {
  77334. type: string;
  77335. }
  77336. /** @hidden */
  77337. export interface IGLTFCameraOrthographic {
  77338. xmag: number;
  77339. ymag: number;
  77340. zfar: number;
  77341. znear: number;
  77342. }
  77343. /** @hidden */
  77344. export interface IGLTFCameraPerspective {
  77345. aspectRatio: number;
  77346. yfov: number;
  77347. zfar: number;
  77348. znear: number;
  77349. }
  77350. /** @hidden */
  77351. export interface IGLTFCamera extends IGLTFChildRootProperty {
  77352. type: string;
  77353. }
  77354. /** @hidden */
  77355. export interface IGLTFAnimationChannelTarget {
  77356. id: string;
  77357. path: string;
  77358. }
  77359. /** @hidden */
  77360. export interface IGLTFAnimationChannel {
  77361. sampler: string;
  77362. target: IGLTFAnimationChannelTarget;
  77363. }
  77364. /** @hidden */
  77365. export interface IGLTFAnimationSampler {
  77366. input: string;
  77367. output: string;
  77368. interpolation?: string;
  77369. }
  77370. /** @hidden */
  77371. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  77372. channels?: IGLTFAnimationChannel[];
  77373. parameters?: {
  77374. [key: string]: string;
  77375. };
  77376. samplers?: {
  77377. [key: string]: IGLTFAnimationSampler;
  77378. };
  77379. }
  77380. /** @hidden */
  77381. export interface IGLTFNodeInstanceSkin {
  77382. skeletons: string[];
  77383. skin: string;
  77384. meshes: string[];
  77385. }
  77386. /** @hidden */
  77387. export interface IGLTFSkins extends IGLTFChildRootProperty {
  77388. bindShapeMatrix: number[];
  77389. inverseBindMatrices: string;
  77390. jointNames: string[];
  77391. babylonSkeleton?: Skeleton;
  77392. }
  77393. /** @hidden */
  77394. export interface IGLTFNode extends IGLTFChildRootProperty {
  77395. camera?: string;
  77396. children: string[];
  77397. skin?: string;
  77398. jointName?: string;
  77399. light?: string;
  77400. matrix: number[];
  77401. mesh?: string;
  77402. meshes?: string[];
  77403. rotation?: number[];
  77404. scale?: number[];
  77405. translation?: number[];
  77406. babylonNode?: Node;
  77407. }
  77408. /** @hidden */
  77409. export interface IGLTFScene extends IGLTFChildRootProperty {
  77410. nodes: string[];
  77411. }
  77412. /** @hidden */
  77413. export interface IGLTFRuntime {
  77414. extensions: {
  77415. [key: string]: any;
  77416. };
  77417. accessors: {
  77418. [key: string]: IGLTFAccessor;
  77419. };
  77420. buffers: {
  77421. [key: string]: IGLTFBuffer;
  77422. };
  77423. bufferViews: {
  77424. [key: string]: IGLTFBufferView;
  77425. };
  77426. meshes: {
  77427. [key: string]: IGLTFMesh;
  77428. };
  77429. lights: {
  77430. [key: string]: IGLTFLight;
  77431. };
  77432. cameras: {
  77433. [key: string]: IGLTFCamera;
  77434. };
  77435. nodes: {
  77436. [key: string]: IGLTFNode;
  77437. };
  77438. images: {
  77439. [key: string]: IGLTFImage;
  77440. };
  77441. textures: {
  77442. [key: string]: IGLTFTexture;
  77443. };
  77444. shaders: {
  77445. [key: string]: IGLTFShader;
  77446. };
  77447. programs: {
  77448. [key: string]: IGLTFProgram;
  77449. };
  77450. samplers: {
  77451. [key: string]: IGLTFSampler;
  77452. };
  77453. techniques: {
  77454. [key: string]: IGLTFTechnique;
  77455. };
  77456. materials: {
  77457. [key: string]: IGLTFMaterial;
  77458. };
  77459. animations: {
  77460. [key: string]: IGLTFAnimation;
  77461. };
  77462. skins: {
  77463. [key: string]: IGLTFSkins;
  77464. };
  77465. currentScene?: Object;
  77466. scenes: {
  77467. [key: string]: IGLTFScene;
  77468. };
  77469. extensionsUsed: string[];
  77470. extensionsRequired?: string[];
  77471. buffersCount: number;
  77472. shaderscount: number;
  77473. scene: Scene;
  77474. rootUrl: string;
  77475. loadedBufferCount: number;
  77476. loadedBufferViews: {
  77477. [name: string]: ArrayBufferView;
  77478. };
  77479. loadedShaderCount: number;
  77480. importOnlyMeshes: boolean;
  77481. importMeshesNames?: string[];
  77482. dummyNodes: Node[];
  77483. forAssetContainer: boolean;
  77484. }
  77485. /** @hidden */
  77486. export interface INodeToRoot {
  77487. bone: Bone;
  77488. node: IGLTFNode;
  77489. id: string;
  77490. }
  77491. /** @hidden */
  77492. export interface IJointNode {
  77493. node: IGLTFNode;
  77494. id: string;
  77495. }
  77496. }
  77497. declare module BABYLON.GLTF1 {
  77498. /**
  77499. * Utils functions for GLTF
  77500. * @hidden
  77501. */
  77502. export class GLTFUtils {
  77503. /**
  77504. * Sets the given "parameter" matrix
  77505. * @param scene: the Scene object
  77506. * @param source: the source node where to pick the matrix
  77507. * @param parameter: the GLTF technique parameter
  77508. * @param uniformName: the name of the shader's uniform
  77509. * @param shaderMaterial: the shader material
  77510. */
  77511. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  77512. /**
  77513. * Sets the given "parameter" matrix
  77514. * @param shaderMaterial: the shader material
  77515. * @param uniform: the name of the shader's uniform
  77516. * @param value: the value of the uniform
  77517. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  77518. */
  77519. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  77520. /**
  77521. * Returns the wrap mode of the texture
  77522. * @param mode: the mode value
  77523. */
  77524. static GetWrapMode(mode: number): number;
  77525. /**
  77526. * Returns the byte stride giving an accessor
  77527. * @param accessor: the GLTF accessor objet
  77528. */
  77529. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  77530. /**
  77531. * Returns the texture filter mode giving a mode value
  77532. * @param mode: the filter mode value
  77533. */
  77534. static GetTextureFilterMode(mode: number): ETextureFilterType;
  77535. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  77536. /**
  77537. * Returns a buffer from its accessor
  77538. * @param gltfRuntime: the GLTF runtime
  77539. * @param accessor: the GLTF accessor
  77540. */
  77541. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  77542. /**
  77543. * Decodes a buffer view into a string
  77544. * @param view: the buffer view
  77545. */
  77546. static DecodeBufferToText(view: ArrayBufferView): string;
  77547. /**
  77548. * Returns the default material of gltf. Related to
  77549. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  77550. * @param scene: the Babylon.js scene
  77551. */
  77552. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  77553. private static _DefaultMaterial;
  77554. }
  77555. }
  77556. declare module BABYLON.GLTF1 {
  77557. /**
  77558. * Implementation of the base glTF spec
  77559. * @hidden
  77560. */
  77561. export class GLTFLoaderBase {
  77562. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  77563. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77564. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  77565. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77566. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  77567. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77568. }
  77569. /**
  77570. * glTF V1 Loader
  77571. * @hidden
  77572. */
  77573. export class GLTFLoader implements IGLTFLoader {
  77574. static Extensions: {
  77575. [name: string]: GLTFLoaderExtension;
  77576. };
  77577. static RegisterExtension(extension: GLTFLoaderExtension): void;
  77578. state: Nullable<GLTFLoaderState>;
  77579. dispose(): void;
  77580. private _importMeshAsync;
  77581. /**
  77582. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  77583. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77584. * @param scene the scene the meshes should be added to
  77585. * @param forAssetContainer defines if the entities must be stored in the scene
  77586. * @param data gltf data containing information of the meshes in a loaded file
  77587. * @param rootUrl root url to load from
  77588. * @param onProgress event that fires when loading progress has occured
  77589. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77590. */
  77591. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  77592. private _loadAsync;
  77593. /**
  77594. * Imports all objects from a loaded gltf file and adds them to the scene
  77595. * @param scene the scene the objects should be added to
  77596. * @param data gltf data containing information of the meshes in a loaded file
  77597. * @param rootUrl root url to load from
  77598. * @param onProgress event that fires when loading progress has occured
  77599. * @returns a promise which completes when objects have been loaded to the scene
  77600. */
  77601. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  77602. private _loadShadersAsync;
  77603. private _loadBuffersAsync;
  77604. private _createNodes;
  77605. }
  77606. /** @hidden */
  77607. export abstract class GLTFLoaderExtension {
  77608. private _name;
  77609. constructor(name: string);
  77610. get name(): string;
  77611. /**
  77612. * Defines an override for loading the runtime
  77613. * Return true to stop further extensions from loading the runtime
  77614. */
  77615. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  77616. /**
  77617. * Defines an onverride for creating gltf runtime
  77618. * Return true to stop further extensions from creating the runtime
  77619. */
  77620. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  77621. /**
  77622. * Defines an override for loading buffers
  77623. * Return true to stop further extensions from loading this buffer
  77624. */
  77625. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  77626. /**
  77627. * Defines an override for loading texture buffers
  77628. * Return true to stop further extensions from loading this texture data
  77629. */
  77630. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77631. /**
  77632. * Defines an override for creating textures
  77633. * Return true to stop further extensions from loading this texture
  77634. */
  77635. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  77636. /**
  77637. * Defines an override for loading shader strings
  77638. * Return true to stop further extensions from loading this shader data
  77639. */
  77640. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77641. /**
  77642. * Defines an override for loading materials
  77643. * Return true to stop further extensions from loading this material
  77644. */
  77645. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77646. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  77647. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  77648. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  77649. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  77650. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  77651. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  77652. private static LoadTextureBufferAsync;
  77653. private static CreateTextureAsync;
  77654. private static ApplyExtensions;
  77655. }
  77656. }
  77657. declare module BABYLON.GLTF1 {
  77658. /** @hidden */
  77659. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  77660. private _bin;
  77661. constructor();
  77662. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  77663. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77664. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  77665. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  77666. }
  77667. }
  77668. declare module BABYLON.GLTF1 {
  77669. /** @hidden */
  77670. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  77671. constructor();
  77672. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  77673. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  77674. private _loadTexture;
  77675. }
  77676. }
  77677. declare module BABYLON.GLTF2.Loader {
  77678. /**
  77679. * Loader interface with an index field.
  77680. */
  77681. export interface IArrayItem {
  77682. /**
  77683. * The index of this item in the array.
  77684. */
  77685. index: number;
  77686. }
  77687. /**
  77688. * Loader interface with additional members.
  77689. */
  77690. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  77691. /** @hidden */
  77692. _data?: Promise<ArrayBufferView>;
  77693. /** @hidden */
  77694. _babylonVertexBuffer?: Promise<VertexBuffer>;
  77695. }
  77696. /**
  77697. * Loader interface with additional members.
  77698. */
  77699. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  77700. }
  77701. /** @hidden */
  77702. export interface _IAnimationSamplerData {
  77703. input: Float32Array;
  77704. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  77705. output: Float32Array;
  77706. }
  77707. /**
  77708. * Loader interface with additional members.
  77709. */
  77710. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  77711. /** @hidden */
  77712. _data?: Promise<_IAnimationSamplerData>;
  77713. }
  77714. /**
  77715. * Loader interface with additional members.
  77716. */
  77717. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  77718. channels: IAnimationChannel[];
  77719. samplers: IAnimationSampler[];
  77720. /** @hidden */
  77721. _babylonAnimationGroup?: AnimationGroup;
  77722. }
  77723. /**
  77724. * Loader interface with additional members.
  77725. */
  77726. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  77727. /** @hidden */
  77728. _data?: Promise<ArrayBufferView>;
  77729. }
  77730. /**
  77731. * Loader interface with additional members.
  77732. */
  77733. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  77734. /** @hidden */
  77735. _data?: Promise<ArrayBufferView>;
  77736. /** @hidden */
  77737. _babylonBuffer?: Promise<Buffer>;
  77738. }
  77739. /**
  77740. * Loader interface with additional members.
  77741. */
  77742. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  77743. }
  77744. /**
  77745. * Loader interface with additional members.
  77746. */
  77747. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  77748. /** @hidden */
  77749. _data?: Promise<ArrayBufferView>;
  77750. }
  77751. /**
  77752. * Loader interface with additional members.
  77753. */
  77754. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  77755. }
  77756. /**
  77757. * Loader interface with additional members.
  77758. */
  77759. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  77760. }
  77761. /**
  77762. * Loader interface with additional members.
  77763. */
  77764. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  77765. baseColorTexture?: ITextureInfo;
  77766. metallicRoughnessTexture?: ITextureInfo;
  77767. }
  77768. /**
  77769. * Loader interface with additional members.
  77770. */
  77771. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  77772. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77773. normalTexture?: IMaterialNormalTextureInfo;
  77774. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77775. emissiveTexture?: ITextureInfo;
  77776. /** @hidden */
  77777. _data?: {
  77778. [babylonDrawMode: number]: {
  77779. babylonMaterial: Material;
  77780. babylonMeshes: AbstractMesh[];
  77781. promise: Promise<void>;
  77782. };
  77783. };
  77784. }
  77785. /**
  77786. * Loader interface with additional members.
  77787. */
  77788. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  77789. primitives: IMeshPrimitive[];
  77790. }
  77791. /**
  77792. * Loader interface with additional members.
  77793. */
  77794. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  77795. /** @hidden */
  77796. _instanceData?: {
  77797. babylonSourceMesh: Mesh;
  77798. promise: Promise<any>;
  77799. };
  77800. }
  77801. /**
  77802. * Loader interface with additional members.
  77803. */
  77804. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  77805. /**
  77806. * The parent glTF node.
  77807. */
  77808. parent?: INode;
  77809. /** @hidden */
  77810. _babylonTransformNode?: TransformNode;
  77811. /** @hidden */
  77812. _primitiveBabylonMeshes?: AbstractMesh[];
  77813. /** @hidden */
  77814. _babylonBones?: Bone[];
  77815. /** @hidden */
  77816. _numMorphTargets?: number;
  77817. }
  77818. /** @hidden */
  77819. export interface _ISamplerData {
  77820. noMipMaps: boolean;
  77821. samplingMode: number;
  77822. wrapU: number;
  77823. wrapV: number;
  77824. }
  77825. /**
  77826. * Loader interface with additional members.
  77827. */
  77828. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  77829. /** @hidden */
  77830. _data?: _ISamplerData;
  77831. }
  77832. /**
  77833. * Loader interface with additional members.
  77834. */
  77835. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  77836. }
  77837. /**
  77838. * Loader interface with additional members.
  77839. */
  77840. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  77841. /** @hidden */
  77842. _data?: {
  77843. babylonSkeleton: Skeleton;
  77844. promise: Promise<void>;
  77845. };
  77846. }
  77847. /**
  77848. * Loader interface with additional members.
  77849. */
  77850. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  77851. }
  77852. /**
  77853. * Loader interface with additional members.
  77854. */
  77855. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  77856. }
  77857. /**
  77858. * Loader interface with additional members.
  77859. */
  77860. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  77861. accessors?: IAccessor[];
  77862. animations?: IAnimation[];
  77863. buffers?: IBuffer[];
  77864. bufferViews?: IBufferView[];
  77865. cameras?: ICamera[];
  77866. images?: IImage[];
  77867. materials?: IMaterial[];
  77868. meshes?: IMesh[];
  77869. nodes?: INode[];
  77870. samplers?: ISampler[];
  77871. scenes?: IScene[];
  77872. skins?: ISkin[];
  77873. textures?: ITexture[];
  77874. }
  77875. }
  77876. declare module BABYLON.GLTF2 {
  77877. /**
  77878. * Interface for a glTF loader extension.
  77879. */
  77880. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  77881. /**
  77882. * Called after the loader state changes to LOADING.
  77883. */
  77884. onLoading?(): void;
  77885. /**
  77886. * Called after the loader state changes to READY.
  77887. */
  77888. onReady?(): void;
  77889. /**
  77890. * Define this method to modify the default behavior when loading scenes.
  77891. * @param context The context when loading the asset
  77892. * @param scene The glTF scene property
  77893. * @returns A promise that resolves when the load is complete or null if not handled
  77894. */
  77895. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  77896. /**
  77897. * Define this method to modify the default behavior when loading nodes.
  77898. * @param context The context when loading the asset
  77899. * @param node The glTF node property
  77900. * @param assign A function called synchronously after parsing the glTF properties
  77901. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  77902. */
  77903. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77904. /**
  77905. * Define this method to modify the default behavior when loading cameras.
  77906. * @param context The context when loading the asset
  77907. * @param camera The glTF camera property
  77908. * @param assign A function called synchronously after parsing the glTF properties
  77909. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  77910. */
  77911. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77912. /**
  77913. * @hidden
  77914. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  77915. * @param context The context when loading the asset
  77916. * @param primitive The glTF mesh primitive property
  77917. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  77918. */
  77919. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  77920. /**
  77921. * @hidden
  77922. * Define this method to modify the default behavior when loading data for mesh primitives.
  77923. * @param context The context when loading the asset
  77924. * @param name The mesh name when loading the asset
  77925. * @param node The glTF node when loading the asset
  77926. * @param mesh The glTF mesh when loading the asset
  77927. * @param primitive The glTF mesh primitive property
  77928. * @param assign A function called synchronously after parsing the glTF properties
  77929. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  77930. */
  77931. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  77932. /**
  77933. * @hidden
  77934. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  77935. * @param context The context when loading the asset
  77936. * @param material The glTF material property
  77937. * @param assign A function called synchronously after parsing the glTF properties
  77938. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  77939. */
  77940. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77941. /**
  77942. * Define this method to modify the default behavior when creating materials.
  77943. * @param context The context when loading the asset
  77944. * @param material The glTF material property
  77945. * @param babylonDrawMode The draw mode for the Babylon material
  77946. * @returns The Babylon material or null if not handled
  77947. */
  77948. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77949. /**
  77950. * Define this method to modify the default behavior when loading material properties.
  77951. * @param context The context when loading the asset
  77952. * @param material The glTF material property
  77953. * @param babylonMaterial The Babylon material
  77954. * @returns A promise that resolves when the load is complete or null if not handled
  77955. */
  77956. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77957. /**
  77958. * Define this method to modify the default behavior when loading texture infos.
  77959. * @param context The context when loading the asset
  77960. * @param textureInfo The glTF texture info property
  77961. * @param assign A function called synchronously after parsing the glTF properties
  77962. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77963. */
  77964. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77965. /**
  77966. * @hidden
  77967. * Define this method to modify the default behavior when loading textures.
  77968. * @param context The context when loading the asset
  77969. * @param texture The glTF texture property
  77970. * @param assign A function called synchronously after parsing the glTF properties
  77971. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  77972. */
  77973. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77974. /**
  77975. * Define this method to modify the default behavior when loading animations.
  77976. * @param context The context when loading the asset
  77977. * @param animation The glTF animation property
  77978. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  77979. */
  77980. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77981. /**
  77982. * @hidden
  77983. * Define this method to modify the default behavior when loading skins.
  77984. * @param context The context when loading the asset
  77985. * @param node The glTF node property
  77986. * @param skin The glTF skin property
  77987. * @returns A promise that resolves when the load is complete or null if not handled
  77988. */
  77989. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  77990. /**
  77991. * @hidden
  77992. * Define this method to modify the default behavior when loading uris.
  77993. * @param context The context when loading the asset
  77994. * @param property The glTF property associated with the uri
  77995. * @param uri The uri to load
  77996. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  77997. */
  77998. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77999. /**
  78000. * Define this method to modify the default behavior when loading buffer views.
  78001. * @param context The context when loading the asset
  78002. * @param bufferView The glTF buffer view property
  78003. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78004. */
  78005. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  78006. /**
  78007. * Define this method to modify the default behavior when loading buffers.
  78008. * @param context The context when loading the asset
  78009. * @param buffer The glTF buffer property
  78010. * @param byteOffset The byte offset to load
  78011. * @param byteLength The byte length to load
  78012. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  78013. */
  78014. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78015. }
  78016. }
  78017. declare module BABYLON.GLTF2 {
  78018. /**
  78019. * Helper class for working with arrays when loading the glTF asset
  78020. */
  78021. export class ArrayItem {
  78022. /**
  78023. * Gets an item from the given array.
  78024. * @param context The context when loading the asset
  78025. * @param array The array to get the item from
  78026. * @param index The index to the array
  78027. * @returns The array item
  78028. */
  78029. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  78030. /**
  78031. * Assign an `index` field to each item of the given array.
  78032. * @param array The array of items
  78033. */
  78034. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  78035. }
  78036. /**
  78037. * The glTF 2.0 loader
  78038. */
  78039. export class GLTFLoader implements IGLTFLoader {
  78040. /** @hidden */
  78041. _completePromises: Promise<any>[];
  78042. /** @hidden */
  78043. _forAssetContainer: boolean;
  78044. /** Storage */
  78045. _babylonLights: Light[];
  78046. private _disposed;
  78047. private _parent;
  78048. private _state;
  78049. private _extensions;
  78050. private _rootUrl;
  78051. private _fileName;
  78052. private _uniqueRootUrl;
  78053. private _gltf;
  78054. private _bin;
  78055. private _babylonScene;
  78056. private _rootBabylonMesh;
  78057. private _defaultBabylonMaterialData;
  78058. private _progressCallback?;
  78059. private _requests;
  78060. private static _RegisteredExtensions;
  78061. /**
  78062. * The default glTF sampler.
  78063. */
  78064. static readonly DefaultSampler: ISampler;
  78065. /**
  78066. * Registers a loader extension.
  78067. * @param name The name of the loader extension.
  78068. * @param factory The factory function that creates the loader extension.
  78069. */
  78070. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  78071. /**
  78072. * Unregisters a loader extension.
  78073. * @param name The name of the loader extension.
  78074. * @returns A boolean indicating whether the extension has been unregistered
  78075. */
  78076. static UnregisterExtension(name: string): boolean;
  78077. /**
  78078. * The loader state.
  78079. */
  78080. get state(): Nullable<GLTFLoaderState>;
  78081. /**
  78082. * The object that represents the glTF JSON.
  78083. */
  78084. get gltf(): IGLTF;
  78085. /**
  78086. * The BIN chunk of a binary glTF.
  78087. */
  78088. get bin(): Nullable<IDataBuffer>;
  78089. /**
  78090. * The parent file loader.
  78091. */
  78092. get parent(): GLTFFileLoader;
  78093. /**
  78094. * The Babylon scene when loading the asset.
  78095. */
  78096. get babylonScene(): Scene;
  78097. /**
  78098. * The root Babylon mesh when loading the asset.
  78099. */
  78100. get rootBabylonMesh(): Mesh;
  78101. /** @hidden */
  78102. constructor(parent: GLTFFileLoader);
  78103. /** @hidden */
  78104. dispose(): void;
  78105. /** @hidden */
  78106. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  78107. /** @hidden */
  78108. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  78109. private _loadAsync;
  78110. private _loadData;
  78111. private _setupData;
  78112. private _loadExtensions;
  78113. private _checkExtensions;
  78114. private _setState;
  78115. private _createRootNode;
  78116. /**
  78117. * Loads a glTF scene.
  78118. * @param context The context when loading the asset
  78119. * @param scene The glTF scene property
  78120. * @returns A promise that resolves when the load is complete
  78121. */
  78122. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  78123. private _forEachPrimitive;
  78124. private _getMeshes;
  78125. private _getTransformNodes;
  78126. private _getSkeletons;
  78127. private _getAnimationGroups;
  78128. private _startAnimations;
  78129. /**
  78130. * Loads a glTF node.
  78131. * @param context The context when loading the asset
  78132. * @param node The glTF node property
  78133. * @param assign A function called synchronously after parsing the glTF properties
  78134. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  78135. */
  78136. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  78137. private _loadMeshAsync;
  78138. /**
  78139. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  78140. * @param context The context when loading the asset
  78141. * @param name The mesh name when loading the asset
  78142. * @param node The glTF node when loading the asset
  78143. * @param mesh The glTF mesh when loading the asset
  78144. * @param primitive The glTF mesh primitive property
  78145. * @param assign A function called synchronously after parsing the glTF properties
  78146. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  78147. */
  78148. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  78149. private _loadVertexDataAsync;
  78150. private _createMorphTargets;
  78151. private _loadMorphTargetsAsync;
  78152. private _loadMorphTargetVertexDataAsync;
  78153. private static _LoadTransform;
  78154. private _loadSkinAsync;
  78155. private _loadBones;
  78156. private _loadBone;
  78157. private _loadSkinInverseBindMatricesDataAsync;
  78158. private _updateBoneMatrices;
  78159. private _getNodeMatrix;
  78160. /**
  78161. * Loads a glTF camera.
  78162. * @param context The context when loading the asset
  78163. * @param camera The glTF camera property
  78164. * @param assign A function called synchronously after parsing the glTF properties
  78165. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  78166. */
  78167. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  78168. private _loadAnimationsAsync;
  78169. /**
  78170. * Loads a glTF animation.
  78171. * @param context The context when loading the asset
  78172. * @param animation The glTF animation property
  78173. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  78174. */
  78175. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  78176. /**
  78177. * @hidden Loads a glTF animation channel.
  78178. * @param context The context when loading the asset
  78179. * @param animationContext The context of the animation when loading the asset
  78180. * @param animation The glTF animation property
  78181. * @param channel The glTF animation channel property
  78182. * @param babylonAnimationGroup The babylon animation group property
  78183. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  78184. * @returns A void promise when the channel load is complete
  78185. */
  78186. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  78187. private _loadAnimationSamplerAsync;
  78188. private _loadBufferAsync;
  78189. /**
  78190. * Loads a glTF buffer view.
  78191. * @param context The context when loading the asset
  78192. * @param bufferView The glTF buffer view property
  78193. * @returns A promise that resolves with the loaded data when the load is complete
  78194. */
  78195. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  78196. private _loadAccessorAsync;
  78197. /** @hidden */
  78198. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  78199. private _loadIndicesAccessorAsync;
  78200. private _loadVertexBufferViewAsync;
  78201. private _loadVertexAccessorAsync;
  78202. private _loadMaterialMetallicRoughnessPropertiesAsync;
  78203. /** @hidden */
  78204. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  78205. private _createDefaultMaterial;
  78206. /**
  78207. * Creates a Babylon material from a glTF material.
  78208. * @param context The context when loading the asset
  78209. * @param material The glTF material property
  78210. * @param babylonDrawMode The draw mode for the Babylon material
  78211. * @returns The Babylon material
  78212. */
  78213. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  78214. /**
  78215. * Loads properties from a glTF material into a Babylon material.
  78216. * @param context The context when loading the asset
  78217. * @param material The glTF material property
  78218. * @param babylonMaterial The Babylon material
  78219. * @returns A promise that resolves when the load is complete
  78220. */
  78221. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78222. /**
  78223. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  78224. * @param context The context when loading the asset
  78225. * @param material The glTF material property
  78226. * @param babylonMaterial The Babylon material
  78227. * @returns A promise that resolves when the load is complete
  78228. */
  78229. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  78230. /**
  78231. * Loads the alpha properties from a glTF material into a Babylon material.
  78232. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  78233. * @param context The context when loading the asset
  78234. * @param material The glTF material property
  78235. * @param babylonMaterial The Babylon material
  78236. */
  78237. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  78238. /**
  78239. * Loads a glTF texture info.
  78240. * @param context The context when loading the asset
  78241. * @param textureInfo The glTF texture info property
  78242. * @param assign A function called synchronously after parsing the glTF properties
  78243. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  78244. */
  78245. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78246. /** @hidden */
  78247. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78248. /** @hidden */
  78249. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  78250. private _loadSampler;
  78251. /**
  78252. * Loads a glTF image.
  78253. * @param context The context when loading the asset
  78254. * @param image The glTF image property
  78255. * @returns A promise that resolves with the loaded data when the load is complete
  78256. */
  78257. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  78258. /**
  78259. * Loads a glTF uri.
  78260. * @param context The context when loading the asset
  78261. * @param property The glTF property associated with the uri
  78262. * @param uri The base64 or relative uri
  78263. * @returns A promise that resolves with the loaded data when the load is complete
  78264. */
  78265. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  78266. private _onProgress;
  78267. /**
  78268. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  78269. * @param babylonObject the Babylon object with metadata
  78270. * @param pointer the JSON pointer
  78271. */
  78272. static AddPointerMetadata(babylonObject: {
  78273. metadata: any;
  78274. }, pointer: string): void;
  78275. private static _GetTextureWrapMode;
  78276. private static _GetTextureSamplingMode;
  78277. private static _GetTypedArrayConstructor;
  78278. private static _GetTypedArray;
  78279. private static _GetNumComponents;
  78280. private static _ValidateUri;
  78281. private static _GetDrawMode;
  78282. private _compileMaterialsAsync;
  78283. private _compileShadowGeneratorsAsync;
  78284. private _forEachExtensions;
  78285. private _applyExtensions;
  78286. private _extensionsOnLoading;
  78287. private _extensionsOnReady;
  78288. private _extensionsLoadSceneAsync;
  78289. private _extensionsLoadNodeAsync;
  78290. private _extensionsLoadCameraAsync;
  78291. private _extensionsLoadVertexDataAsync;
  78292. private _extensionsLoadMeshPrimitiveAsync;
  78293. private _extensionsLoadMaterialAsync;
  78294. private _extensionsCreateMaterial;
  78295. private _extensionsLoadMaterialPropertiesAsync;
  78296. private _extensionsLoadTextureInfoAsync;
  78297. private _extensionsLoadTextureAsync;
  78298. private _extensionsLoadAnimationAsync;
  78299. private _extensionsLoadSkinAsync;
  78300. private _extensionsLoadUriAsync;
  78301. private _extensionsLoadBufferViewAsync;
  78302. private _extensionsLoadBufferAsync;
  78303. /**
  78304. * Helper method called by a loader extension to load an glTF extension.
  78305. * @param context The context when loading the asset
  78306. * @param property The glTF property to load the extension from
  78307. * @param extensionName The name of the extension to load
  78308. * @param actionAsync The action to run
  78309. * @returns The promise returned by actionAsync or null if the extension does not exist
  78310. */
  78311. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78312. /**
  78313. * Helper method called by a loader extension to load a glTF extra.
  78314. * @param context The context when loading the asset
  78315. * @param property The glTF property to load the extra from
  78316. * @param extensionName The name of the extension to load
  78317. * @param actionAsync The action to run
  78318. * @returns The promise returned by actionAsync or null if the extra does not exist
  78319. */
  78320. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  78321. /**
  78322. * Checks for presence of an extension.
  78323. * @param name The name of the extension to check
  78324. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  78325. */
  78326. isExtensionUsed(name: string): boolean;
  78327. /**
  78328. * Increments the indentation level and logs a message.
  78329. * @param message The message to log
  78330. */
  78331. logOpen(message: string): void;
  78332. /**
  78333. * Decrements the indentation level.
  78334. */
  78335. logClose(): void;
  78336. /**
  78337. * Logs a message
  78338. * @param message The message to log
  78339. */
  78340. log(message: string): void;
  78341. /**
  78342. * Starts a performance counter.
  78343. * @param counterName The name of the performance counter
  78344. */
  78345. startPerformanceCounter(counterName: string): void;
  78346. /**
  78347. * Ends a performance counter.
  78348. * @param counterName The name of the performance counter
  78349. */
  78350. endPerformanceCounter(counterName: string): void;
  78351. }
  78352. }
  78353. declare module BABYLON.GLTF2.Loader.Extensions {
  78354. /**
  78355. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  78356. */
  78357. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  78358. /**
  78359. * The name of this extension.
  78360. */
  78361. readonly name: string;
  78362. /**
  78363. * Defines whether this extension is enabled.
  78364. */
  78365. enabled: boolean;
  78366. private _loader;
  78367. private _lights?;
  78368. /** @hidden */
  78369. constructor(loader: GLTFLoader);
  78370. /** @hidden */
  78371. dispose(): void;
  78372. /** @hidden */
  78373. onLoading(): void;
  78374. /** @hidden */
  78375. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78376. private _loadLightAsync;
  78377. }
  78378. }
  78379. declare module BABYLON.GLTF2.Loader.Extensions {
  78380. /**
  78381. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  78382. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  78383. * !!! Experimental Extension Subject to Changes !!!
  78384. */
  78385. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  78386. /**
  78387. * The name of this extension.
  78388. */
  78389. readonly name: string;
  78390. /**
  78391. * Defines whether this extension is enabled.
  78392. */
  78393. enabled: boolean;
  78394. private _loader;
  78395. /** @hidden */
  78396. constructor(loader: GLTFLoader);
  78397. /** @hidden */
  78398. dispose(): void;
  78399. /** @hidden */
  78400. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78401. }
  78402. }
  78403. declare module BABYLON.GLTF2.Loader.Extensions {
  78404. /**
  78405. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  78406. */
  78407. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  78408. /**
  78409. * The name of this extension.
  78410. */
  78411. readonly name: string;
  78412. /**
  78413. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  78414. */
  78415. dracoCompression?: DracoCompression;
  78416. /**
  78417. * Defines whether this extension is enabled.
  78418. */
  78419. enabled: boolean;
  78420. private _loader;
  78421. /** @hidden */
  78422. constructor(loader: GLTFLoader);
  78423. /** @hidden */
  78424. dispose(): void;
  78425. /** @hidden */
  78426. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  78427. }
  78428. }
  78429. declare module BABYLON.GLTF2.Loader.Extensions {
  78430. /**
  78431. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  78432. */
  78433. export class KHR_lights implements IGLTFLoaderExtension {
  78434. /**
  78435. * The name of this extension.
  78436. */
  78437. readonly name: string;
  78438. /**
  78439. * Defines whether this extension is enabled.
  78440. */
  78441. enabled: boolean;
  78442. private _loader;
  78443. private _lights?;
  78444. /** @hidden */
  78445. constructor(loader: GLTFLoader);
  78446. /** @hidden */
  78447. dispose(): void;
  78448. /** @hidden */
  78449. onLoading(): void;
  78450. /** @hidden */
  78451. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78452. }
  78453. }
  78454. declare module BABYLON.GLTF2.Loader.Extensions {
  78455. /**
  78456. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  78457. */
  78458. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  78459. /**
  78460. * The name of this extension.
  78461. */
  78462. readonly name: string;
  78463. /**
  78464. * Defines whether this extension is enabled.
  78465. */
  78466. enabled: boolean;
  78467. /**
  78468. * Defines a number that determines the order the extensions are applied.
  78469. */
  78470. order: number;
  78471. private _loader;
  78472. /** @hidden */
  78473. constructor(loader: GLTFLoader);
  78474. /** @hidden */
  78475. dispose(): void;
  78476. /** @hidden */
  78477. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78478. private _loadSpecularGlossinessPropertiesAsync;
  78479. }
  78480. }
  78481. declare module BABYLON.GLTF2.Loader.Extensions {
  78482. /**
  78483. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  78484. */
  78485. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  78486. /**
  78487. * The name of this extension.
  78488. */
  78489. readonly name: string;
  78490. /**
  78491. * Defines whether this extension is enabled.
  78492. */
  78493. enabled: boolean;
  78494. /**
  78495. * Defines a number that determines the order the extensions are applied.
  78496. */
  78497. order: number;
  78498. private _loader;
  78499. /** @hidden */
  78500. constructor(loader: GLTFLoader);
  78501. /** @hidden */
  78502. dispose(): void;
  78503. /** @hidden */
  78504. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78505. private _loadUnlitPropertiesAsync;
  78506. }
  78507. }
  78508. declare module BABYLON.GLTF2.Loader.Extensions {
  78509. /**
  78510. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78511. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  78512. * !!! Experimental Extension Subject to Changes !!!
  78513. */
  78514. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  78515. /**
  78516. * The name of this extension.
  78517. */
  78518. readonly name: string;
  78519. /**
  78520. * Defines whether this extension is enabled.
  78521. */
  78522. enabled: boolean;
  78523. /**
  78524. * Defines a number that determines the order the extensions are applied.
  78525. */
  78526. order: number;
  78527. private _loader;
  78528. /** @hidden */
  78529. constructor(loader: GLTFLoader);
  78530. /** @hidden */
  78531. dispose(): void;
  78532. /** @hidden */
  78533. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78534. private _loadClearCoatPropertiesAsync;
  78535. }
  78536. }
  78537. declare module BABYLON.GLTF2.Loader.Extensions {
  78538. /**
  78539. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  78540. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78541. * !!! Experimental Extension Subject to Changes !!!
  78542. */
  78543. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  78544. /**
  78545. * The name of this extension.
  78546. */
  78547. readonly name: string;
  78548. /**
  78549. * Defines whether this extension is enabled.
  78550. */
  78551. enabled: boolean;
  78552. /**
  78553. * Defines a number that determines the order the extensions are applied.
  78554. */
  78555. order: number;
  78556. private _loader;
  78557. /** @hidden */
  78558. constructor(loader: GLTFLoader);
  78559. /** @hidden */
  78560. dispose(): void;
  78561. /** @hidden */
  78562. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78563. private _loadSheenPropertiesAsync;
  78564. }
  78565. }
  78566. declare module BABYLON.GLTF2.Loader.Extensions {
  78567. /**
  78568. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  78569. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  78570. * !!! Experimental Extension Subject to Changes !!!
  78571. */
  78572. export class KHR_materials_specular implements IGLTFLoaderExtension {
  78573. /**
  78574. * The name of this extension.
  78575. */
  78576. readonly name: string;
  78577. /**
  78578. * Defines whether this extension is enabled.
  78579. */
  78580. enabled: boolean;
  78581. /**
  78582. * Defines a number that determines the order the extensions are applied.
  78583. */
  78584. order: number;
  78585. private _loader;
  78586. /** @hidden */
  78587. constructor(loader: GLTFLoader);
  78588. /** @hidden */
  78589. dispose(): void;
  78590. /** @hidden */
  78591. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78592. private _loadSpecularPropertiesAsync;
  78593. }
  78594. }
  78595. declare module BABYLON.GLTF2.Loader.Extensions {
  78596. /**
  78597. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  78598. */
  78599. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  78600. /**
  78601. * The name of this extension.
  78602. */
  78603. readonly name: string;
  78604. /**
  78605. * Defines whether this extension is enabled.
  78606. */
  78607. enabled: boolean;
  78608. /** @hidden */
  78609. constructor(loader: GLTFLoader);
  78610. /** @hidden */
  78611. dispose(): void;
  78612. }
  78613. }
  78614. declare module BABYLON.GLTF2.Loader.Extensions {
  78615. /**
  78616. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  78617. * !!! Experimental Extension Subject to Changes !!!
  78618. */
  78619. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  78620. /** The name of this extension. */
  78621. readonly name: string;
  78622. /** Defines whether this extension is enabled. */
  78623. enabled: boolean;
  78624. private _loader;
  78625. /** @hidden */
  78626. constructor(loader: GLTFLoader);
  78627. /** @hidden */
  78628. dispose(): void;
  78629. /** @hidden */
  78630. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78631. }
  78632. }
  78633. declare module BABYLON.GLTF2.Loader.Extensions {
  78634. /**
  78635. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  78636. */
  78637. export class KHR_texture_transform implements IGLTFLoaderExtension {
  78638. /**
  78639. * The name of this extension.
  78640. */
  78641. readonly name: string;
  78642. /**
  78643. * Defines whether this extension is enabled.
  78644. */
  78645. enabled: boolean;
  78646. private _loader;
  78647. /** @hidden */
  78648. constructor(loader: GLTFLoader);
  78649. /** @hidden */
  78650. dispose(): void;
  78651. /** @hidden */
  78652. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  78653. }
  78654. }
  78655. declare module BABYLON.GLTF2.Loader.Extensions {
  78656. /**
  78657. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  78658. */
  78659. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  78660. /**
  78661. * The name of this extension.
  78662. */
  78663. readonly name: string;
  78664. /**
  78665. * Defines whether this extension is enabled.
  78666. */
  78667. enabled: boolean;
  78668. private _loader;
  78669. private _clips;
  78670. private _emitters;
  78671. /** @hidden */
  78672. constructor(loader: GLTFLoader);
  78673. /** @hidden */
  78674. dispose(): void;
  78675. /** @hidden */
  78676. onLoading(): void;
  78677. /** @hidden */
  78678. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78679. /** @hidden */
  78680. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78681. /** @hidden */
  78682. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  78683. private _loadClipAsync;
  78684. private _loadEmitterAsync;
  78685. private _getEventAction;
  78686. private _loadAnimationEventAsync;
  78687. }
  78688. }
  78689. declare module BABYLON.GLTF2.Loader.Extensions {
  78690. /**
  78691. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  78692. */
  78693. export class MSFT_lod implements IGLTFLoaderExtension {
  78694. /**
  78695. * The name of this extension.
  78696. */
  78697. readonly name: string;
  78698. /**
  78699. * Defines whether this extension is enabled.
  78700. */
  78701. enabled: boolean;
  78702. /**
  78703. * Defines a number that determines the order the extensions are applied.
  78704. */
  78705. order: number;
  78706. /**
  78707. * Maximum number of LODs to load, starting from the lowest LOD.
  78708. */
  78709. maxLODsToLoad: number;
  78710. /**
  78711. * Observable raised when all node LODs of one level are loaded.
  78712. * The event data is the index of the loaded LOD starting from zero.
  78713. * Dispose the loader to cancel the loading of the next level of LODs.
  78714. */
  78715. onNodeLODsLoadedObservable: Observable<number>;
  78716. /**
  78717. * Observable raised when all material LODs of one level are loaded.
  78718. * The event data is the index of the loaded LOD starting from zero.
  78719. * Dispose the loader to cancel the loading of the next level of LODs.
  78720. */
  78721. onMaterialLODsLoadedObservable: Observable<number>;
  78722. private _loader;
  78723. private _nodeIndexLOD;
  78724. private _nodeSignalLODs;
  78725. private _nodePromiseLODs;
  78726. private _materialIndexLOD;
  78727. private _materialSignalLODs;
  78728. private _materialPromiseLODs;
  78729. private _indexLOD;
  78730. private _bufferLODs;
  78731. /** @hidden */
  78732. constructor(loader: GLTFLoader);
  78733. /** @hidden */
  78734. dispose(): void;
  78735. /** @hidden */
  78736. onReady(): void;
  78737. /** @hidden */
  78738. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  78739. /** @hidden */
  78740. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78741. /** @hidden */
  78742. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  78743. /** @hidden */
  78744. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  78745. /** @hidden */
  78746. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  78747. private _loadBufferLOD;
  78748. /**
  78749. * Gets an array of LOD properties from lowest to highest.
  78750. */
  78751. private _getLODs;
  78752. private _disposeTransformNode;
  78753. private _disposeMaterials;
  78754. }
  78755. }
  78756. declare module BABYLON.GLTF2.Loader.Extensions {
  78757. /** @hidden */
  78758. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  78759. readonly name: string;
  78760. enabled: boolean;
  78761. private _loader;
  78762. constructor(loader: GLTFLoader);
  78763. dispose(): void;
  78764. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78765. }
  78766. }
  78767. declare module BABYLON.GLTF2.Loader.Extensions {
  78768. /** @hidden */
  78769. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  78770. readonly name: string;
  78771. enabled: boolean;
  78772. private _loader;
  78773. constructor(loader: GLTFLoader);
  78774. dispose(): void;
  78775. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  78776. }
  78777. }
  78778. declare module BABYLON.GLTF2.Loader.Extensions {
  78779. /**
  78780. * Store glTF extras (if present) in BJS objects' metadata
  78781. */
  78782. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  78783. /**
  78784. * The name of this extension.
  78785. */
  78786. readonly name: string;
  78787. /**
  78788. * Defines whether this extension is enabled.
  78789. */
  78790. enabled: boolean;
  78791. private _loader;
  78792. private _assignExtras;
  78793. /** @hidden */
  78794. constructor(loader: GLTFLoader);
  78795. /** @hidden */
  78796. dispose(): void;
  78797. /** @hidden */
  78798. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  78799. /** @hidden */
  78800. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  78801. /** @hidden */
  78802. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  78803. }
  78804. }
  78805. declare module BABYLON {
  78806. /**
  78807. * Class reading and parsing the MTL file bundled with the obj file.
  78808. */
  78809. export class MTLFileLoader {
  78810. /**
  78811. * Invert Y-Axis of referenced textures on load
  78812. */
  78813. static INVERT_TEXTURE_Y: boolean;
  78814. /**
  78815. * All material loaded from the mtl will be set here
  78816. */
  78817. materials: StandardMaterial[];
  78818. /**
  78819. * This function will read the mtl file and create each material described inside
  78820. * This function could be improve by adding :
  78821. * -some component missing (Ni, Tf...)
  78822. * -including the specific options available
  78823. *
  78824. * @param scene defines the scene the material will be created in
  78825. * @param data defines the mtl data to parse
  78826. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  78827. * @param forAssetContainer defines if the material should be registered in the scene
  78828. */
  78829. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  78830. /**
  78831. * Gets the texture for the material.
  78832. *
  78833. * If the material is imported from input file,
  78834. * We sanitize the url to ensure it takes the textre from aside the material.
  78835. *
  78836. * @param rootUrl The root url to load from
  78837. * @param value The value stored in the mtl
  78838. * @return The Texture
  78839. */
  78840. private static _getTexture;
  78841. }
  78842. }
  78843. declare module BABYLON {
  78844. /**
  78845. * Options for loading OBJ/MTL files
  78846. */
  78847. type MeshLoadOptions = {
  78848. /**
  78849. * Defines if UVs are optimized by default during load.
  78850. */
  78851. OptimizeWithUV: boolean;
  78852. /**
  78853. * Defines custom scaling of UV coordinates of loaded meshes.
  78854. */
  78855. UVScaling: Vector2;
  78856. /**
  78857. * Invert model on y-axis (does a model scaling inversion)
  78858. */
  78859. InvertY: boolean;
  78860. /**
  78861. * Invert Y-Axis of referenced textures on load
  78862. */
  78863. InvertTextureY: boolean;
  78864. /**
  78865. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78866. */
  78867. ImportVertexColors: boolean;
  78868. /**
  78869. * Compute the normals for the model, even if normals are present in the file.
  78870. */
  78871. ComputeNormals: boolean;
  78872. /**
  78873. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78874. */
  78875. SkipMaterials: boolean;
  78876. /**
  78877. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78878. */
  78879. MaterialLoadingFailsSilently: boolean;
  78880. };
  78881. /**
  78882. * OBJ file type loader.
  78883. * This is a babylon scene loader plugin.
  78884. */
  78885. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  78886. /**
  78887. * Defines if UVs are optimized by default during load.
  78888. */
  78889. static OPTIMIZE_WITH_UV: boolean;
  78890. /**
  78891. * Invert model on y-axis (does a model scaling inversion)
  78892. */
  78893. static INVERT_Y: boolean;
  78894. /**
  78895. * Invert Y-Axis of referenced textures on load
  78896. */
  78897. static get INVERT_TEXTURE_Y(): boolean;
  78898. static set INVERT_TEXTURE_Y(value: boolean);
  78899. /**
  78900. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  78901. */
  78902. static IMPORT_VERTEX_COLORS: boolean;
  78903. /**
  78904. * Compute the normals for the model, even if normals are present in the file.
  78905. */
  78906. static COMPUTE_NORMALS: boolean;
  78907. /**
  78908. * Defines custom scaling of UV coordinates of loaded meshes.
  78909. */
  78910. static UV_SCALING: Vector2;
  78911. /**
  78912. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  78913. */
  78914. static SKIP_MATERIALS: boolean;
  78915. /**
  78916. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  78917. *
  78918. * Defaults to true for backwards compatibility.
  78919. */
  78920. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  78921. /**
  78922. * Defines the name of the plugin.
  78923. */
  78924. name: string;
  78925. /**
  78926. * Defines the extension the plugin is able to load.
  78927. */
  78928. extensions: string;
  78929. /** @hidden */
  78930. obj: RegExp;
  78931. /** @hidden */
  78932. group: RegExp;
  78933. /** @hidden */
  78934. mtllib: RegExp;
  78935. /** @hidden */
  78936. usemtl: RegExp;
  78937. /** @hidden */
  78938. smooth: RegExp;
  78939. /** @hidden */
  78940. vertexPattern: RegExp;
  78941. /** @hidden */
  78942. normalPattern: RegExp;
  78943. /** @hidden */
  78944. uvPattern: RegExp;
  78945. /** @hidden */
  78946. facePattern1: RegExp;
  78947. /** @hidden */
  78948. facePattern2: RegExp;
  78949. /** @hidden */
  78950. facePattern3: RegExp;
  78951. /** @hidden */
  78952. facePattern4: RegExp;
  78953. /** @hidden */
  78954. facePattern5: RegExp;
  78955. private _forAssetContainer;
  78956. private _meshLoadOptions;
  78957. /**
  78958. * Creates loader for .OBJ files
  78959. *
  78960. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  78961. */
  78962. constructor(meshLoadOptions?: MeshLoadOptions);
  78963. private static get currentMeshLoadOptions();
  78964. /**
  78965. * Calls synchronously the MTL file attached to this obj.
  78966. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  78967. * Without this function materials are not displayed in the first frame (but displayed after).
  78968. * In consequence it is impossible to get material information in your HTML file
  78969. *
  78970. * @param url The URL of the MTL file
  78971. * @param rootUrl
  78972. * @param onSuccess Callback function to be called when the MTL file is loaded
  78973. * @private
  78974. */
  78975. private _loadMTL;
  78976. /**
  78977. * Instantiates a OBJ file loader plugin.
  78978. * @returns the created plugin
  78979. */
  78980. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  78981. /**
  78982. * If the data string can be loaded directly.
  78983. *
  78984. * @param data string containing the file data
  78985. * @returns if the data can be loaded directly
  78986. */
  78987. canDirectLoad(data: string): boolean;
  78988. /**
  78989. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  78990. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  78991. * @param scene the scene the meshes should be added to
  78992. * @param data the OBJ data to load
  78993. * @param rootUrl root url to load from
  78994. * @param onProgress event that fires when loading progress has occured
  78995. * @param fileName Defines the name of the file to load
  78996. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  78997. */
  78998. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  78999. meshes: AbstractMesh[];
  79000. particleSystems: IParticleSystem[];
  79001. skeletons: Skeleton[];
  79002. animationGroups: AnimationGroup[];
  79003. }>;
  79004. /**
  79005. * Imports all objects from the loaded OBJ data and adds them to the scene
  79006. * @param scene the scene the objects should be added to
  79007. * @param data the OBJ data to load
  79008. * @param rootUrl root url to load from
  79009. * @param onProgress event that fires when loading progress has occured
  79010. * @param fileName Defines the name of the file to load
  79011. * @returns a promise which completes when objects have been loaded to the scene
  79012. */
  79013. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79014. /**
  79015. * Load into an asset container.
  79016. * @param scene The scene to load into
  79017. * @param data The data to import
  79018. * @param rootUrl The root url for scene and resources
  79019. * @param onProgress The callback when the load progresses
  79020. * @param fileName Defines the name of the file to load
  79021. * @returns The loaded asset container
  79022. */
  79023. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79024. /**
  79025. * Read the OBJ file and create an Array of meshes.
  79026. * Each mesh contains all information given by the OBJ and the MTL file.
  79027. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  79028. *
  79029. * @param meshesNames
  79030. * @param scene Scene The scene where are displayed the data
  79031. * @param data String The content of the obj file
  79032. * @param rootUrl String The path to the folder
  79033. * @returns Array<AbstractMesh>
  79034. * @private
  79035. */
  79036. private _parseSolid;
  79037. }
  79038. }
  79039. declare module BABYLON {
  79040. /**
  79041. * STL file type loader.
  79042. * This is a babylon scene loader plugin.
  79043. */
  79044. export class STLFileLoader implements ISceneLoaderPlugin {
  79045. /** @hidden */
  79046. solidPattern: RegExp;
  79047. /** @hidden */
  79048. facetsPattern: RegExp;
  79049. /** @hidden */
  79050. normalPattern: RegExp;
  79051. /** @hidden */
  79052. vertexPattern: RegExp;
  79053. /**
  79054. * Defines the name of the plugin.
  79055. */
  79056. name: string;
  79057. /**
  79058. * Defines the extensions the stl loader is able to load.
  79059. * force data to come in as an ArrayBuffer
  79060. * we'll convert to string if it looks like it's an ASCII .stl
  79061. */
  79062. extensions: ISceneLoaderPluginExtensions;
  79063. /**
  79064. * Import meshes into a scene.
  79065. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  79066. * @param scene The scene to import into
  79067. * @param data The data to import
  79068. * @param rootUrl The root url for scene and resources
  79069. * @param meshes The meshes array to import into
  79070. * @param particleSystems The particle systems array to import into
  79071. * @param skeletons The skeletons array to import into
  79072. * @param onError The callback when import fails
  79073. * @returns True if successful or false otherwise
  79074. */
  79075. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  79076. /**
  79077. * Load into a scene.
  79078. * @param scene The scene to load into
  79079. * @param data The data to import
  79080. * @param rootUrl The root url for scene and resources
  79081. * @param onError The callback when import fails
  79082. * @returns true if successful or false otherwise
  79083. */
  79084. load(scene: Scene, data: any, rootUrl: string): boolean;
  79085. /**
  79086. * Load into an asset container.
  79087. * @param scene The scene to load into
  79088. * @param data The data to import
  79089. * @param rootUrl The root url for scene and resources
  79090. * @param onError The callback when import fails
  79091. * @returns The loaded asset container
  79092. */
  79093. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  79094. private _isBinary;
  79095. private _parseBinary;
  79096. private _parseASCII;
  79097. }
  79098. }
  79099. declare module BABYLON {
  79100. /**
  79101. * Class for generating OBJ data from a Babylon scene.
  79102. */
  79103. export class OBJExport {
  79104. /**
  79105. * Exports the geometry of a Mesh array in .OBJ file format (text)
  79106. * @param mesh defines the list of meshes to serialize
  79107. * @param materials defines if materials should be exported
  79108. * @param matlibname defines the name of the associated mtl file
  79109. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  79110. * @returns the OBJ content
  79111. */
  79112. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  79113. /**
  79114. * Exports the material(s) of a mesh in .MTL file format (text)
  79115. * @param mesh defines the mesh to extract the material from
  79116. * @returns the mtl content
  79117. */
  79118. static MTL(mesh: Mesh): string;
  79119. }
  79120. }
  79121. declare module BABYLON {
  79122. /** @hidden */
  79123. export var __IGLTFExporterExtension: number;
  79124. /**
  79125. * Interface for extending the exporter
  79126. * @hidden
  79127. */
  79128. export interface IGLTFExporterExtension {
  79129. /**
  79130. * The name of this extension
  79131. */
  79132. readonly name: string;
  79133. /**
  79134. * Defines whether this extension is enabled
  79135. */
  79136. enabled: boolean;
  79137. /**
  79138. * Defines whether this extension is required
  79139. */
  79140. required: boolean;
  79141. }
  79142. }
  79143. declare module BABYLON.GLTF2.Exporter {
  79144. /** @hidden */
  79145. export var __IGLTFExporterExtensionV2: number;
  79146. /**
  79147. * Interface for a glTF exporter extension
  79148. * @hidden
  79149. */
  79150. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  79151. /**
  79152. * Define this method to modify the default behavior before exporting a texture
  79153. * @param context The context when loading the asset
  79154. * @param babylonTexture The Babylon.js texture
  79155. * @param mimeType The mime-type of the generated image
  79156. * @returns A promise that resolves with the exported texture
  79157. */
  79158. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  79159. /**
  79160. * Define this method to get notified when a texture info is created
  79161. * @param context The context when loading the asset
  79162. * @param textureInfo The glTF texture info
  79163. * @param babylonTexture The Babylon.js texture
  79164. */
  79165. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79166. /**
  79167. * Define this method to modify the default behavior when exporting texture info
  79168. * @param context The context when loading the asset
  79169. * @param meshPrimitive glTF mesh primitive
  79170. * @param babylonSubMesh Babylon submesh
  79171. * @param binaryWriter glTF serializer binary writer instance
  79172. * @returns nullable IMeshPrimitive promise
  79173. */
  79174. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  79175. /**
  79176. * Define this method to modify the default behavior when exporting a node
  79177. * @param context The context when exporting the node
  79178. * @param node glTF node
  79179. * @param babylonNode BabylonJS node
  79180. * @returns nullable INode promise
  79181. */
  79182. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79183. [key: number]: number;
  79184. }): Promise<Nullable<INode>>;
  79185. /**
  79186. * Define this method to modify the default behavior when exporting a material
  79187. * @param material glTF material
  79188. * @param babylonMaterial BabylonJS material
  79189. * @returns nullable IMaterial promise
  79190. */
  79191. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  79192. /**
  79193. * Define this method to return additional textures to export from a material
  79194. * @param material glTF material
  79195. * @param babylonMaterial BabylonJS material
  79196. * @returns List of textures
  79197. */
  79198. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  79199. /** Gets a boolean indicating that this extension was used */
  79200. wasUsed: boolean;
  79201. /** Gets a boolean indicating that this extension is required for the file to work */
  79202. required: boolean;
  79203. /**
  79204. * Called after the exporter state changes to EXPORTING
  79205. */
  79206. onExporting?(): void;
  79207. }
  79208. }
  79209. declare module BABYLON.GLTF2.Exporter {
  79210. /**
  79211. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  79212. * @hidden
  79213. */
  79214. export class _GLTFMaterialExporter {
  79215. /**
  79216. * Represents the dielectric specular values for R, G and B
  79217. */
  79218. private static readonly _DielectricSpecular;
  79219. /**
  79220. * Allows the maximum specular power to be defined for material calculations
  79221. */
  79222. private static readonly _MaxSpecularPower;
  79223. /**
  79224. * Mapping to store textures
  79225. */
  79226. private _textureMap;
  79227. /**
  79228. * Numeric tolerance value
  79229. */
  79230. private static readonly _Epsilon;
  79231. /**
  79232. * Reference to the glTF Exporter
  79233. */
  79234. private _exporter;
  79235. constructor(exporter: _Exporter);
  79236. /**
  79237. * Specifies if two colors are approximately equal in value
  79238. * @param color1 first color to compare to
  79239. * @param color2 second color to compare to
  79240. * @param epsilon threshold value
  79241. */
  79242. private static FuzzyEquals;
  79243. /**
  79244. * Gets the materials from a Babylon scene and converts them to glTF materials
  79245. * @param scene babylonjs scene
  79246. * @param mimeType texture mime type
  79247. * @param images array of images
  79248. * @param textures array of textures
  79249. * @param materials array of materials
  79250. * @param imageData mapping of texture names to base64 textures
  79251. * @param hasTextureCoords specifies if texture coordinates are present on the material
  79252. */
  79253. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  79254. /**
  79255. * Makes a copy of the glTF material without the texture parameters
  79256. * @param originalMaterial original glTF material
  79257. * @returns glTF material without texture parameters
  79258. */
  79259. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  79260. /**
  79261. * Specifies if the material has any texture parameters present
  79262. * @param material glTF Material
  79263. * @returns boolean specifying if texture parameters are present
  79264. */
  79265. _hasTexturesPresent(material: IMaterial): boolean;
  79266. /**
  79267. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  79268. * @param babylonStandardMaterial
  79269. * @returns glTF Metallic Roughness Material representation
  79270. */
  79271. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  79272. /**
  79273. * Computes the metallic factor
  79274. * @param diffuse diffused value
  79275. * @param specular specular value
  79276. * @param oneMinusSpecularStrength one minus the specular strength
  79277. * @returns metallic value
  79278. */
  79279. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  79280. /**
  79281. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  79282. * @param glTFMaterial glTF material
  79283. * @param babylonMaterial Babylon material
  79284. */
  79285. private static _SetAlphaMode;
  79286. /**
  79287. * Converts a Babylon Standard Material to a glTF Material
  79288. * @param babylonStandardMaterial BJS Standard Material
  79289. * @param mimeType mime type to use for the textures
  79290. * @param images array of glTF image interfaces
  79291. * @param textures array of glTF texture interfaces
  79292. * @param materials array of glTF material interfaces
  79293. * @param imageData map of image file name to data
  79294. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79295. */
  79296. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79297. private _finishMaterial;
  79298. /**
  79299. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79300. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  79301. * @param mimeType mime type to use for the textures
  79302. * @param images array of glTF image interfaces
  79303. * @param textures array of glTF texture interfaces
  79304. * @param materials array of glTF material interfaces
  79305. * @param imageData map of image file name to data
  79306. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79307. */
  79308. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79309. /**
  79310. * Converts an image typed array buffer to a base64 image
  79311. * @param buffer typed array buffer
  79312. * @param width width of the image
  79313. * @param height height of the image
  79314. * @param mimeType mimetype of the image
  79315. * @returns base64 image string
  79316. */
  79317. private _createBase64FromCanvasAsync;
  79318. /**
  79319. * Generates a white texture based on the specified width and height
  79320. * @param width width of the texture in pixels
  79321. * @param height height of the texture in pixels
  79322. * @param scene babylonjs scene
  79323. * @returns white texture
  79324. */
  79325. private _createWhiteTexture;
  79326. /**
  79327. * 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
  79328. * @param texture1 first texture to resize
  79329. * @param texture2 second texture to resize
  79330. * @param scene babylonjs scene
  79331. * @returns resized textures or null
  79332. */
  79333. private _resizeTexturesToSameDimensions;
  79334. /**
  79335. * Converts an array of pixels to a Float32Array
  79336. * Throws an error if the pixel format is not supported
  79337. * @param pixels - array buffer containing pixel values
  79338. * @returns Float32 of pixels
  79339. */
  79340. private _convertPixelArrayToFloat32;
  79341. /**
  79342. * Convert Specular Glossiness Textures to Metallic Roughness
  79343. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  79344. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  79345. * @param diffuseTexture texture used to store diffuse information
  79346. * @param specularGlossinessTexture texture used to store specular and glossiness information
  79347. * @param factors specular glossiness material factors
  79348. * @param mimeType the mime type to use for the texture
  79349. * @returns pbr metallic roughness interface or null
  79350. */
  79351. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  79352. /**
  79353. * Converts specular glossiness material properties to metallic roughness
  79354. * @param specularGlossiness interface with specular glossiness material properties
  79355. * @returns interface with metallic roughness material properties
  79356. */
  79357. private _convertSpecularGlossinessToMetallicRoughness;
  79358. /**
  79359. * Calculates the surface reflectance, independent of lighting conditions
  79360. * @param color Color source to calculate brightness from
  79361. * @returns number representing the perceived brightness, or zero if color is undefined
  79362. */
  79363. private _getPerceivedBrightness;
  79364. /**
  79365. * Returns the maximum color component value
  79366. * @param color
  79367. * @returns maximum color component value, or zero if color is null or undefined
  79368. */
  79369. private _getMaxComponent;
  79370. /**
  79371. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  79372. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79373. * @param mimeType mime type to use for the textures
  79374. * @param images array of glTF image interfaces
  79375. * @param textures array of glTF texture interfaces
  79376. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79377. * @param imageData map of image file name to data
  79378. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79379. * @returns glTF PBR Metallic Roughness factors
  79380. */
  79381. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  79382. private _getGLTFTextureSampler;
  79383. private _getGLTFTextureWrapMode;
  79384. private _getGLTFTextureWrapModesSampler;
  79385. /**
  79386. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  79387. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79388. * @param mimeType mime type to use for the textures
  79389. * @param images array of glTF image interfaces
  79390. * @param textures array of glTF texture interfaces
  79391. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  79392. * @param imageData map of image file name to data
  79393. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79394. * @returns glTF PBR Metallic Roughness factors
  79395. */
  79396. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  79397. /**
  79398. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  79399. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  79400. * @param mimeType mime type to use for the textures
  79401. * @param images array of glTF image interfaces
  79402. * @param textures array of glTF texture interfaces
  79403. * @param materials array of glTF material interfaces
  79404. * @param imageData map of image file name to data
  79405. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  79406. */
  79407. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  79408. private setMetallicRoughnessPbrMaterial;
  79409. private getPixelsFromTexture;
  79410. /**
  79411. * Extracts a texture from a Babylon texture into file data and glTF data
  79412. * @param babylonTexture Babylon texture to extract
  79413. * @param mimeType Mime Type of the babylonTexture
  79414. * @return glTF texture info, or null if the texture format is not supported
  79415. */
  79416. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79417. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  79418. /**
  79419. * Builds a texture from base64 string
  79420. * @param base64Texture base64 texture string
  79421. * @param baseTextureName Name to use for the texture
  79422. * @param mimeType image mime type for the texture
  79423. * @param images array of images
  79424. * @param textures array of textures
  79425. * @param imageData map of image data
  79426. * @returns glTF texture info, or null if the texture format is not supported
  79427. */
  79428. private _getTextureInfoFromBase64;
  79429. }
  79430. }
  79431. declare module BABYLON {
  79432. /**
  79433. * Class for holding and downloading glTF file data
  79434. */
  79435. export class GLTFData {
  79436. /**
  79437. * Object which contains the file name as the key and its data as the value
  79438. */
  79439. glTFFiles: {
  79440. [fileName: string]: string | Blob;
  79441. };
  79442. /**
  79443. * Initializes the glTF file object
  79444. */
  79445. constructor();
  79446. /**
  79447. * Downloads the glTF data as files based on their names and data
  79448. */
  79449. downloadFiles(): void;
  79450. }
  79451. }
  79452. declare module BABYLON {
  79453. /**
  79454. * Holds a collection of exporter options and parameters
  79455. */
  79456. export interface IExportOptions {
  79457. /**
  79458. * Function which indicates whether a babylon node should be exported or not
  79459. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  79460. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  79461. */
  79462. shouldExportNode?(node: Node): boolean;
  79463. /**
  79464. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  79465. * @param metadata source metadata to read from
  79466. * @returns the data to store to glTF node extras
  79467. */
  79468. metadataSelector?(metadata: any): any;
  79469. /**
  79470. * The sample rate to bake animation curves
  79471. */
  79472. animationSampleRate?: number;
  79473. /**
  79474. * Begin serialization without waiting for the scene to be ready
  79475. */
  79476. exportWithoutWaitingForScene?: boolean;
  79477. /**
  79478. * Indicates if coordinate system swapping root nodes should be included in export
  79479. */
  79480. includeCoordinateSystemConversionNodes?: boolean;
  79481. }
  79482. /**
  79483. * Class for generating glTF data from a Babylon scene.
  79484. */
  79485. export class GLTF2Export {
  79486. /**
  79487. * Exports the geometry of the scene to .gltf file format asynchronously
  79488. * @param scene Babylon scene with scene hierarchy information
  79489. * @param filePrefix File prefix to use when generating the glTF file
  79490. * @param options Exporter options
  79491. * @returns Returns an object with a .gltf file and associates texture names
  79492. * as keys and their data and paths as values
  79493. */
  79494. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79495. private static _PreExportAsync;
  79496. private static _PostExportAsync;
  79497. /**
  79498. * Exports the geometry of the scene to .glb file format asychronously
  79499. * @param scene Babylon scene with scene hierarchy information
  79500. * @param filePrefix File prefix to use when generating glb file
  79501. * @param options Exporter options
  79502. * @returns Returns an object with a .glb filename as key and data as value
  79503. */
  79504. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  79505. }
  79506. }
  79507. declare module BABYLON.GLTF2.Exporter {
  79508. /**
  79509. * @hidden
  79510. */
  79511. export class _GLTFUtilities {
  79512. /**
  79513. * Creates a buffer view based on the supplied arguments
  79514. * @param bufferIndex index value of the specified buffer
  79515. * @param byteOffset byte offset value
  79516. * @param byteLength byte length of the bufferView
  79517. * @param byteStride byte distance between conequential elements
  79518. * @param name name of the buffer view
  79519. * @returns bufferView for glTF
  79520. */
  79521. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  79522. /**
  79523. * Creates an accessor based on the supplied arguments
  79524. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  79525. * @param name The name of the accessor
  79526. * @param type The type of the accessor
  79527. * @param componentType The datatype of components in the attribute
  79528. * @param count The number of attributes referenced by this accessor
  79529. * @param byteOffset The offset relative to the start of the bufferView in bytes
  79530. * @param min Minimum value of each component in this attribute
  79531. * @param max Maximum value of each component in this attribute
  79532. * @returns accessor for glTF
  79533. */
  79534. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  79535. /**
  79536. * Calculates the minimum and maximum values of an array of position floats
  79537. * @param positions Positions array of a mesh
  79538. * @param vertexStart Starting vertex offset to calculate min and max values
  79539. * @param vertexCount Number of vertices to check for min and max values
  79540. * @returns min number array and max number array
  79541. */
  79542. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  79543. min: number[];
  79544. max: number[];
  79545. };
  79546. /**
  79547. * Converts a new right-handed Vector3
  79548. * @param vector vector3 array
  79549. * @returns right-handed Vector3
  79550. */
  79551. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  79552. /**
  79553. * Converts a Vector3 to right-handed
  79554. * @param vector Vector3 to convert to right-handed
  79555. */
  79556. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  79557. /**
  79558. * Converts a three element number array to right-handed
  79559. * @param vector number array to convert to right-handed
  79560. */
  79561. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  79562. /**
  79563. * Converts a new right-handed Vector3
  79564. * @param vector vector3 array
  79565. * @returns right-handed Vector3
  79566. */
  79567. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  79568. /**
  79569. * Converts a Vector3 to right-handed
  79570. * @param vector Vector3 to convert to right-handed
  79571. */
  79572. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  79573. /**
  79574. * Converts a three element number array to right-handed
  79575. * @param vector number array to convert to right-handed
  79576. */
  79577. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  79578. /**
  79579. * Converts a Vector4 to right-handed
  79580. * @param vector Vector4 to convert to right-handed
  79581. */
  79582. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  79583. /**
  79584. * Converts a Vector4 to right-handed
  79585. * @param vector Vector4 to convert to right-handed
  79586. */
  79587. static _GetRightHandedArray4FromRef(vector: number[]): void;
  79588. /**
  79589. * Converts a Quaternion to right-handed
  79590. * @param quaternion Source quaternion to convert to right-handed
  79591. */
  79592. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  79593. /**
  79594. * Converts a Quaternion to right-handed
  79595. * @param quaternion Source quaternion to convert to right-handed
  79596. */
  79597. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  79598. static _NormalizeTangentFromRef(tangent: Vector4): void;
  79599. }
  79600. }
  79601. declare module BABYLON.GLTF2.Exporter {
  79602. /**
  79603. * Converts Babylon Scene into glTF 2.0.
  79604. * @hidden
  79605. */
  79606. export class _Exporter {
  79607. /**
  79608. * Stores the glTF to export
  79609. */
  79610. _glTF: IGLTF;
  79611. /**
  79612. * Stores all generated buffer views, which represents views into the main glTF buffer data
  79613. */
  79614. _bufferViews: IBufferView[];
  79615. /**
  79616. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  79617. */
  79618. _accessors: IAccessor[];
  79619. /**
  79620. * Stores all the generated nodes, which contains transform and/or mesh information per node
  79621. */
  79622. _nodes: INode[];
  79623. /**
  79624. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  79625. */
  79626. private _scenes;
  79627. /**
  79628. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  79629. */
  79630. private _meshes;
  79631. /**
  79632. * Stores all the generated material information, which represents the appearance of each primitive
  79633. */
  79634. _materials: IMaterial[];
  79635. _materialMap: {
  79636. [materialID: number]: number;
  79637. };
  79638. /**
  79639. * Stores all the generated texture information, which is referenced by glTF materials
  79640. */
  79641. _textures: ITexture[];
  79642. /**
  79643. * Stores all the generated image information, which is referenced by glTF textures
  79644. */
  79645. _images: IImage[];
  79646. /**
  79647. * Stores all the texture samplers
  79648. */
  79649. _samplers: ISampler[];
  79650. /**
  79651. * Stores all the generated animation samplers, which is referenced by glTF animations
  79652. */
  79653. /**
  79654. * Stores the animations for glTF models
  79655. */
  79656. private _animations;
  79657. /**
  79658. * Stores the total amount of bytes stored in the glTF buffer
  79659. */
  79660. private _totalByteLength;
  79661. /**
  79662. * Stores a reference to the Babylon scene containing the source geometry and material information
  79663. */
  79664. _babylonScene: Scene;
  79665. /**
  79666. * Stores a map of the image data, where the key is the file name and the value
  79667. * is the image data
  79668. */
  79669. _imageData: {
  79670. [fileName: string]: {
  79671. data: Uint8Array;
  79672. mimeType: ImageMimeType;
  79673. };
  79674. };
  79675. /**
  79676. * Stores a map of the unique id of a node to its index in the node array
  79677. */
  79678. _nodeMap: {
  79679. [key: number]: number;
  79680. };
  79681. /**
  79682. * Specifies if the source Babylon scene was left handed, and needed conversion.
  79683. */
  79684. _convertToRightHandedSystem: boolean;
  79685. /**
  79686. * Specifies if a Babylon node should be converted to right-handed on export
  79687. */
  79688. _convertToRightHandedSystemMap: {
  79689. [nodeId: number]: boolean;
  79690. };
  79691. _includeCoordinateSystemConversionNodes: boolean;
  79692. /**
  79693. * Baked animation sample rate
  79694. */
  79695. private _animationSampleRate;
  79696. private _options;
  79697. private _localEngine;
  79698. _glTFMaterialExporter: _GLTFMaterialExporter;
  79699. private _extensions;
  79700. private static _ExtensionNames;
  79701. private static _ExtensionFactories;
  79702. private _applyExtension;
  79703. private _applyExtensions;
  79704. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  79705. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  79706. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  79707. [key: number]: number;
  79708. }): Promise<Nullable<INode>>;
  79709. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  79710. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  79711. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  79712. private _forEachExtensions;
  79713. private _extensionsOnExporting;
  79714. /**
  79715. * Load glTF serializer extensions
  79716. */
  79717. private _loadExtensions;
  79718. /**
  79719. * Creates a glTF Exporter instance, which can accept optional exporter options
  79720. * @param babylonScene Babylon scene object
  79721. * @param options Options to modify the behavior of the exporter
  79722. */
  79723. constructor(babylonScene: Scene, options?: IExportOptions);
  79724. dispose(): void;
  79725. /**
  79726. * Registers a glTF exporter extension
  79727. * @param name Name of the extension to export
  79728. * @param factory The factory function that creates the exporter extension
  79729. */
  79730. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  79731. /**
  79732. * Un-registers an exporter extension
  79733. * @param name The name fo the exporter extension
  79734. * @returns A boolean indicating whether the extension has been un-registered
  79735. */
  79736. static UnregisterExtension(name: string): boolean;
  79737. /**
  79738. * Lazy load a local engine
  79739. */
  79740. _getLocalEngine(): Engine;
  79741. private reorderIndicesBasedOnPrimitiveMode;
  79742. /**
  79743. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  79744. * clock-wise during export to glTF
  79745. * @param submesh BabylonJS submesh
  79746. * @param primitiveMode Primitive mode of the mesh
  79747. * @param sideOrientation the winding order of the submesh
  79748. * @param vertexBufferKind The type of vertex attribute
  79749. * @param meshAttributeArray The vertex attribute data
  79750. * @param byteOffset The offset to the binary data
  79751. * @param binaryWriter The binary data for the glTF file
  79752. * @param convertToRightHandedSystem Converts the values to right-handed
  79753. */
  79754. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  79755. /**
  79756. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  79757. * clock-wise during export to glTF
  79758. * @param submesh BabylonJS submesh
  79759. * @param primitiveMode Primitive mode of the mesh
  79760. * @param sideOrientation the winding order of the submesh
  79761. * @param vertexBufferKind The type of vertex attribute
  79762. * @param meshAttributeArray The vertex attribute data
  79763. * @param byteOffset The offset to the binary data
  79764. * @param binaryWriter The binary data for the glTF file
  79765. * @param convertToRightHandedSystem Converts the values to right-handed
  79766. */
  79767. private reorderTriangleFillMode;
  79768. /**
  79769. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  79770. * clock-wise during export to glTF
  79771. * @param submesh BabylonJS submesh
  79772. * @param primitiveMode Primitive mode of the mesh
  79773. * @param sideOrientation the winding order of the submesh
  79774. * @param vertexBufferKind The type of vertex attribute
  79775. * @param meshAttributeArray The vertex attribute data
  79776. * @param byteOffset The offset to the binary data
  79777. * @param binaryWriter The binary data for the glTF file
  79778. * @param convertToRightHandedSystem Converts the values to right-handed
  79779. */
  79780. private reorderTriangleStripDrawMode;
  79781. /**
  79782. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  79783. * clock-wise during export to glTF
  79784. * @param submesh BabylonJS submesh
  79785. * @param primitiveMode Primitive mode of the mesh
  79786. * @param sideOrientation the winding order of the submesh
  79787. * @param vertexBufferKind The type of vertex attribute
  79788. * @param meshAttributeArray The vertex attribute data
  79789. * @param byteOffset The offset to the binary data
  79790. * @param binaryWriter The binary data for the glTF file
  79791. * @param convertToRightHandedSystem Converts the values to right-handed
  79792. */
  79793. private reorderTriangleFanMode;
  79794. /**
  79795. * Writes the vertex attribute data to binary
  79796. * @param vertices The vertices to write to the binary writer
  79797. * @param byteOffset The offset into the binary writer to overwrite binary data
  79798. * @param vertexAttributeKind The vertex attribute type
  79799. * @param meshAttributeArray The vertex attribute data
  79800. * @param binaryWriter The writer containing the binary data
  79801. * @param convertToRightHandedSystem Converts the values to right-handed
  79802. */
  79803. private writeVertexAttributeData;
  79804. /**
  79805. * Writes mesh attribute data to a data buffer
  79806. * Returns the bytelength of the data
  79807. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  79808. * @param meshAttributeArray Array containing the attribute data
  79809. * @param binaryWriter The buffer to write the binary data to
  79810. * @param indices Used to specify the order of the vertex data
  79811. * @param convertToRightHandedSystem Converts the values to right-handed
  79812. */
  79813. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  79814. /**
  79815. * Generates glTF json data
  79816. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  79817. * @param glTFPrefix Text to use when prefixing a glTF file
  79818. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  79819. * @returns json data as string
  79820. */
  79821. private generateJSON;
  79822. /**
  79823. * Generates data for .gltf and .bin files based on the glTF prefix string
  79824. * @param glTFPrefix Text to use when prefixing a glTF file
  79825. * @param dispose Dispose the exporter
  79826. * @returns GLTFData with glTF file data
  79827. */
  79828. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79829. /**
  79830. * Creates a binary buffer for glTF
  79831. * @returns array buffer for binary data
  79832. */
  79833. private _generateBinaryAsync;
  79834. /**
  79835. * Pads the number to a multiple of 4
  79836. * @param num number to pad
  79837. * @returns padded number
  79838. */
  79839. private _getPadding;
  79840. /**
  79841. * @hidden
  79842. */
  79843. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  79844. /**
  79845. * Sets the TRS for each node
  79846. * @param node glTF Node for storing the transformation data
  79847. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  79848. * @param convertToRightHandedSystem Converts the values to right-handed
  79849. */
  79850. private setNodeTransformation;
  79851. private getVertexBufferFromMesh;
  79852. /**
  79853. * Creates a bufferview based on the vertices type for the Babylon mesh
  79854. * @param kind Indicates the type of vertices data
  79855. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  79856. * @param binaryWriter The buffer to write the bufferview data to
  79857. * @param convertToRightHandedSystem Converts the values to right-handed
  79858. */
  79859. private createBufferViewKind;
  79860. /**
  79861. * The primitive mode of the Babylon mesh
  79862. * @param babylonMesh The BabylonJS mesh
  79863. */
  79864. private getMeshPrimitiveMode;
  79865. /**
  79866. * Sets the primitive mode of the glTF mesh primitive
  79867. * @param meshPrimitive glTF mesh primitive
  79868. * @param primitiveMode The primitive mode
  79869. */
  79870. private setPrimitiveMode;
  79871. /**
  79872. * Sets the vertex attribute accessor based of the glTF mesh primitive
  79873. * @param meshPrimitive glTF mesh primitive
  79874. * @param attributeKind vertex attribute
  79875. * @returns boolean specifying if uv coordinates are present
  79876. */
  79877. private setAttributeKind;
  79878. /**
  79879. * Sets data for the primitive attributes of each submesh
  79880. * @param mesh glTF Mesh object to store the primitive attribute information
  79881. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  79882. * @param binaryWriter Buffer to write the attribute data to
  79883. * @param convertToRightHandedSystem Converts the values to right-handed
  79884. */
  79885. private setPrimitiveAttributesAsync;
  79886. /**
  79887. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  79888. * @param node The node to check
  79889. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  79890. */
  79891. private isBabylonCoordinateSystemConvertingNode;
  79892. /**
  79893. * Creates a glTF scene based on the array of meshes
  79894. * Returns the the total byte offset
  79895. * @param babylonScene Babylon scene to get the mesh data from
  79896. * @param binaryWriter Buffer to write binary data to
  79897. */
  79898. private createSceneAsync;
  79899. /**
  79900. * Creates a mapping of Node unique id to node index and handles animations
  79901. * @param babylonScene Babylon Scene
  79902. * @param nodes Babylon transform nodes
  79903. * @param binaryWriter Buffer to write binary data to
  79904. * @returns Node mapping of unique id to index
  79905. */
  79906. private createNodeMapAndAnimationsAsync;
  79907. /**
  79908. * Creates a glTF node from a Babylon mesh
  79909. * @param babylonMesh Source Babylon mesh
  79910. * @param binaryWriter Buffer for storing geometry data
  79911. * @param convertToRightHandedSystem Converts the values to right-handed
  79912. * @param nodeMap Node mapping of unique id to glTF node index
  79913. * @returns glTF node
  79914. */
  79915. private createNodeAsync;
  79916. }
  79917. /**
  79918. * @hidden
  79919. *
  79920. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  79921. */
  79922. export class _BinaryWriter {
  79923. /**
  79924. * Array buffer which stores all binary data
  79925. */
  79926. private _arrayBuffer;
  79927. /**
  79928. * View of the array buffer
  79929. */
  79930. private _dataView;
  79931. /**
  79932. * byte offset of data in array buffer
  79933. */
  79934. private _byteOffset;
  79935. /**
  79936. * Initialize binary writer with an initial byte length
  79937. * @param byteLength Initial byte length of the array buffer
  79938. */
  79939. constructor(byteLength: number);
  79940. /**
  79941. * Resize the array buffer to the specified byte length
  79942. * @param byteLength
  79943. */
  79944. private resizeBuffer;
  79945. /**
  79946. * Get an array buffer with the length of the byte offset
  79947. * @returns ArrayBuffer resized to the byte offset
  79948. */
  79949. getArrayBuffer(): ArrayBuffer;
  79950. /**
  79951. * Get the byte offset of the array buffer
  79952. * @returns byte offset
  79953. */
  79954. getByteOffset(): number;
  79955. /**
  79956. * Stores an UInt8 in the array buffer
  79957. * @param entry
  79958. * @param byteOffset If defined, specifies where to set the value as an offset.
  79959. */
  79960. setUInt8(entry: number, byteOffset?: number): void;
  79961. /**
  79962. * Gets an UInt32 in the array buffer
  79963. * @param entry
  79964. * @param byteOffset If defined, specifies where to set the value as an offset.
  79965. */
  79966. getUInt32(byteOffset: number): number;
  79967. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79968. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  79969. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79970. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  79971. /**
  79972. * Stores a Float32 in the array buffer
  79973. * @param entry
  79974. */
  79975. setFloat32(entry: number, byteOffset?: number): void;
  79976. /**
  79977. * Stores an UInt32 in the array buffer
  79978. * @param entry
  79979. * @param byteOffset If defined, specifies where to set the value as an offset.
  79980. */
  79981. setUInt32(entry: number, byteOffset?: number): void;
  79982. }
  79983. }
  79984. declare module BABYLON.GLTF2.Exporter {
  79985. /**
  79986. * @hidden
  79987. * Interface to store animation data.
  79988. */
  79989. export interface _IAnimationData {
  79990. /**
  79991. * Keyframe data.
  79992. */
  79993. inputs: number[];
  79994. /**
  79995. * Value data.
  79996. */
  79997. outputs: number[][];
  79998. /**
  79999. * Animation interpolation data.
  80000. */
  80001. samplerInterpolation: AnimationSamplerInterpolation;
  80002. /**
  80003. * Minimum keyframe value.
  80004. */
  80005. inputsMin: number;
  80006. /**
  80007. * Maximum keyframe value.
  80008. */
  80009. inputsMax: number;
  80010. }
  80011. /**
  80012. * @hidden
  80013. */
  80014. export interface _IAnimationInfo {
  80015. /**
  80016. * The target channel for the animation
  80017. */
  80018. animationChannelTargetPath: AnimationChannelTargetPath;
  80019. /**
  80020. * The glTF accessor type for the data.
  80021. */
  80022. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  80023. /**
  80024. * Specifies if quaternions should be used.
  80025. */
  80026. useQuaternion: boolean;
  80027. }
  80028. /**
  80029. * @hidden
  80030. * Utility class for generating glTF animation data from BabylonJS.
  80031. */
  80032. export class _GLTFAnimation {
  80033. /**
  80034. * @ignore
  80035. *
  80036. * Creates glTF channel animation from BabylonJS animation.
  80037. * @param babylonTransformNode - BabylonJS mesh.
  80038. * @param animation - animation.
  80039. * @param animationChannelTargetPath - The target animation channel.
  80040. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  80041. * @param useQuaternion - Specifies if quaternions are used.
  80042. * @returns nullable IAnimationData
  80043. */
  80044. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  80045. private static _DeduceAnimationInfo;
  80046. /**
  80047. * @ignore
  80048. * Create node animations from the transform node animations
  80049. * @param babylonNode
  80050. * @param runtimeGLTFAnimation
  80051. * @param idleGLTFAnimations
  80052. * @param nodeMap
  80053. * @param nodes
  80054. * @param binaryWriter
  80055. * @param bufferViews
  80056. * @param accessors
  80057. * @param convertToRightHandedSystem
  80058. * @param animationSampleRate
  80059. */
  80060. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  80061. [key: number]: number;
  80062. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  80063. /**
  80064. * @ignore
  80065. * Create node animations from the animation groups
  80066. * @param babylonScene
  80067. * @param glTFAnimations
  80068. * @param nodeMap
  80069. * @param nodes
  80070. * @param binaryWriter
  80071. * @param bufferViews
  80072. * @param accessors
  80073. * @param convertToRightHandedSystemMap
  80074. * @param animationSampleRate
  80075. */
  80076. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  80077. [key: number]: number;
  80078. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  80079. [nodeId: number]: boolean;
  80080. }, animationSampleRate: number): void;
  80081. private static AddAnimation;
  80082. /**
  80083. * Create a baked animation
  80084. * @param babylonTransformNode BabylonJS mesh
  80085. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  80086. * @param animationChannelTargetPath animation target channel
  80087. * @param minFrame minimum animation frame
  80088. * @param maxFrame maximum animation frame
  80089. * @param fps frames per second of the animation
  80090. * @param inputs input key frames of the animation
  80091. * @param outputs output key frame data of the animation
  80092. * @param convertToRightHandedSystem converts the values to right-handed
  80093. * @param useQuaternion specifies if quaternions should be used
  80094. */
  80095. private static _CreateBakedAnimation;
  80096. private static _ConvertFactorToVector3OrQuaternion;
  80097. private static _SetInterpolatedValue;
  80098. /**
  80099. * Creates linear animation from the animation key frames
  80100. * @param babylonTransformNode BabylonJS mesh
  80101. * @param animation BabylonJS animation
  80102. * @param animationChannelTargetPath The target animation channel
  80103. * @param frameDelta The difference between the last and first frame of the animation
  80104. * @param inputs Array to store the key frame times
  80105. * @param outputs Array to store the key frame data
  80106. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80107. * @param useQuaternion Specifies if quaternions are used in the animation
  80108. */
  80109. private static _CreateLinearOrStepAnimation;
  80110. /**
  80111. * Creates cubic spline animation from the animation key frames
  80112. * @param babylonTransformNode BabylonJS mesh
  80113. * @param animation BabylonJS animation
  80114. * @param animationChannelTargetPath The target animation channel
  80115. * @param frameDelta The difference between the last and first frame of the animation
  80116. * @param inputs Array to store the key frame times
  80117. * @param outputs Array to store the key frame data
  80118. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  80119. * @param useQuaternion Specifies if quaternions are used in the animation
  80120. */
  80121. private static _CreateCubicSplineAnimation;
  80122. private static _GetBasePositionRotationOrScale;
  80123. /**
  80124. * Adds a key frame value
  80125. * @param keyFrame
  80126. * @param animation
  80127. * @param outputs
  80128. * @param animationChannelTargetPath
  80129. * @param basePositionRotationOrScale
  80130. * @param convertToRightHandedSystem
  80131. * @param useQuaternion
  80132. */
  80133. private static _AddKeyframeValue;
  80134. /**
  80135. * Determine the interpolation based on the key frames
  80136. * @param keyFrames
  80137. * @param animationChannelTargetPath
  80138. * @param useQuaternion
  80139. */
  80140. private static _DeduceInterpolation;
  80141. /**
  80142. * Adds an input tangent or output tangent to the output data
  80143. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  80144. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  80145. * @param outputs The animation data by keyframe
  80146. * @param animationChannelTargetPath The target animation channel
  80147. * @param interpolation The interpolation type
  80148. * @param keyFrame The key frame with the animation data
  80149. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  80150. * @param useQuaternion Specifies if quaternions are used
  80151. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  80152. */
  80153. private static AddSplineTangent;
  80154. /**
  80155. * Get the minimum and maximum key frames' frame values
  80156. * @param keyFrames animation key frames
  80157. * @returns the minimum and maximum key frame value
  80158. */
  80159. private static calculateMinMaxKeyFrames;
  80160. }
  80161. }
  80162. declare module BABYLON.GLTF2.Exporter {
  80163. /** @hidden */
  80164. export var textureTransformPixelShader: {
  80165. name: string;
  80166. shader: string;
  80167. };
  80168. }
  80169. declare module BABYLON.GLTF2.Exporter.Extensions {
  80170. /**
  80171. * @hidden
  80172. */
  80173. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  80174. private _recordedTextures;
  80175. /** Name of this extension */
  80176. readonly name: string;
  80177. /** Defines whether this extension is enabled */
  80178. enabled: boolean;
  80179. /** Defines whether this extension is required */
  80180. required: boolean;
  80181. /** Reference to the glTF exporter */
  80182. private _wasUsed;
  80183. constructor(exporter: _Exporter);
  80184. dispose(): void;
  80185. /** @hidden */
  80186. get wasUsed(): boolean;
  80187. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80188. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  80189. /**
  80190. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  80191. * @param babylonTexture
  80192. * @param offset
  80193. * @param rotation
  80194. * @param scale
  80195. * @param scene
  80196. */
  80197. private _textureTransformTextureAsync;
  80198. }
  80199. }
  80200. declare module BABYLON.GLTF2.Exporter.Extensions {
  80201. /**
  80202. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  80203. */
  80204. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  80205. /** The name of this extension. */
  80206. readonly name: string;
  80207. /** Defines whether this extension is enabled. */
  80208. enabled: boolean;
  80209. /** Defines whether this extension is required */
  80210. required: boolean;
  80211. /** Reference to the glTF exporter */
  80212. private _exporter;
  80213. private _lights;
  80214. /** @hidden */
  80215. constructor(exporter: _Exporter);
  80216. /** @hidden */
  80217. dispose(): void;
  80218. /** @hidden */
  80219. get wasUsed(): boolean;
  80220. /** @hidden */
  80221. onExporting(): void;
  80222. /**
  80223. * Define this method to modify the default behavior when exporting a node
  80224. * @param context The context when exporting the node
  80225. * @param node glTF node
  80226. * @param babylonNode BabylonJS node
  80227. * @param nodeMap Node mapping of unique id to glTF node index
  80228. * @returns nullable INode promise
  80229. */
  80230. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  80231. [key: number]: number;
  80232. }): Promise<Nullable<INode>>;
  80233. }
  80234. }
  80235. declare module BABYLON.GLTF2.Exporter.Extensions {
  80236. /**
  80237. * @hidden
  80238. */
  80239. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  80240. /** Name of this extension */
  80241. readonly name: string;
  80242. /** Defines whether this extension is enabled */
  80243. enabled: boolean;
  80244. /** Defines whether this extension is required */
  80245. required: boolean;
  80246. /** Reference to the glTF exporter */
  80247. private _textureInfos;
  80248. private _exportedTextures;
  80249. private _wasUsed;
  80250. constructor(exporter: _Exporter);
  80251. dispose(): void;
  80252. /** @hidden */
  80253. get wasUsed(): boolean;
  80254. private _getTextureIndex;
  80255. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  80256. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  80257. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  80258. }
  80259. }
  80260. declare module BABYLON {
  80261. /**
  80262. * Class for generating STL data from a Babylon scene.
  80263. */
  80264. export class STLExport {
  80265. /**
  80266. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  80267. * @param meshes list defines the mesh to serialize
  80268. * @param download triggers the automatic download of the file.
  80269. * @param fileName changes the downloads fileName.
  80270. * @param binary changes the STL to a binary type.
  80271. * @param isLittleEndian toggle for binary type exporter.
  80272. * @returns the STL as UTF8 string
  80273. */
  80274. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  80275. }
  80276. }
  80277. declare module "babylonjs-gltf2interface" {
  80278. export = BABYLON.GLTF2;
  80279. }
  80280. /**
  80281. * Module for glTF 2.0 Interface
  80282. */
  80283. declare module BABYLON.GLTF2 {
  80284. /**
  80285. * The datatype of the components in the attribute
  80286. */
  80287. const enum AccessorComponentType {
  80288. /**
  80289. * Byte
  80290. */
  80291. BYTE = 5120,
  80292. /**
  80293. * Unsigned Byte
  80294. */
  80295. UNSIGNED_BYTE = 5121,
  80296. /**
  80297. * Short
  80298. */
  80299. SHORT = 5122,
  80300. /**
  80301. * Unsigned Short
  80302. */
  80303. UNSIGNED_SHORT = 5123,
  80304. /**
  80305. * Unsigned Int
  80306. */
  80307. UNSIGNED_INT = 5125,
  80308. /**
  80309. * Float
  80310. */
  80311. FLOAT = 5126,
  80312. }
  80313. /**
  80314. * Specifies if the attirbute is a scalar, vector, or matrix
  80315. */
  80316. const enum AccessorType {
  80317. /**
  80318. * Scalar
  80319. */
  80320. SCALAR = "SCALAR",
  80321. /**
  80322. * Vector2
  80323. */
  80324. VEC2 = "VEC2",
  80325. /**
  80326. * Vector3
  80327. */
  80328. VEC3 = "VEC3",
  80329. /**
  80330. * Vector4
  80331. */
  80332. VEC4 = "VEC4",
  80333. /**
  80334. * Matrix2x2
  80335. */
  80336. MAT2 = "MAT2",
  80337. /**
  80338. * Matrix3x3
  80339. */
  80340. MAT3 = "MAT3",
  80341. /**
  80342. * Matrix4x4
  80343. */
  80344. MAT4 = "MAT4",
  80345. }
  80346. /**
  80347. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80348. */
  80349. const enum AnimationChannelTargetPath {
  80350. /**
  80351. * Translation
  80352. */
  80353. TRANSLATION = "translation",
  80354. /**
  80355. * Rotation
  80356. */
  80357. ROTATION = "rotation",
  80358. /**
  80359. * Scale
  80360. */
  80361. SCALE = "scale",
  80362. /**
  80363. * Weights
  80364. */
  80365. WEIGHTS = "weights",
  80366. }
  80367. /**
  80368. * Interpolation algorithm
  80369. */
  80370. const enum AnimationSamplerInterpolation {
  80371. /**
  80372. * The animated values are linearly interpolated between keyframes
  80373. */
  80374. LINEAR = "LINEAR",
  80375. /**
  80376. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  80377. */
  80378. STEP = "STEP",
  80379. /**
  80380. * The animation's interpolation is computed using a cubic spline with specified tangents
  80381. */
  80382. CUBICSPLINE = "CUBICSPLINE",
  80383. }
  80384. /**
  80385. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80386. */
  80387. const enum CameraType {
  80388. /**
  80389. * A perspective camera containing properties to create a perspective projection matrix
  80390. */
  80391. PERSPECTIVE = "perspective",
  80392. /**
  80393. * An orthographic camera containing properties to create an orthographic projection matrix
  80394. */
  80395. ORTHOGRAPHIC = "orthographic",
  80396. }
  80397. /**
  80398. * The mime-type of the image
  80399. */
  80400. const enum ImageMimeType {
  80401. /**
  80402. * JPEG Mime-type
  80403. */
  80404. JPEG = "image/jpeg",
  80405. /**
  80406. * PNG Mime-type
  80407. */
  80408. PNG = "image/png",
  80409. }
  80410. /**
  80411. * The alpha rendering mode of the material
  80412. */
  80413. const enum MaterialAlphaMode {
  80414. /**
  80415. * The alpha value is ignored and the rendered output is fully opaque
  80416. */
  80417. OPAQUE = "OPAQUE",
  80418. /**
  80419. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  80420. */
  80421. MASK = "MASK",
  80422. /**
  80423. * 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)
  80424. */
  80425. BLEND = "BLEND",
  80426. }
  80427. /**
  80428. * The type of the primitives to render
  80429. */
  80430. const enum MeshPrimitiveMode {
  80431. /**
  80432. * Points
  80433. */
  80434. POINTS = 0,
  80435. /**
  80436. * Lines
  80437. */
  80438. LINES = 1,
  80439. /**
  80440. * Line Loop
  80441. */
  80442. LINE_LOOP = 2,
  80443. /**
  80444. * Line Strip
  80445. */
  80446. LINE_STRIP = 3,
  80447. /**
  80448. * Triangles
  80449. */
  80450. TRIANGLES = 4,
  80451. /**
  80452. * Triangle Strip
  80453. */
  80454. TRIANGLE_STRIP = 5,
  80455. /**
  80456. * Triangle Fan
  80457. */
  80458. TRIANGLE_FAN = 6,
  80459. }
  80460. /**
  80461. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80462. */
  80463. const enum TextureMagFilter {
  80464. /**
  80465. * Nearest
  80466. */
  80467. NEAREST = 9728,
  80468. /**
  80469. * Linear
  80470. */
  80471. LINEAR = 9729,
  80472. }
  80473. /**
  80474. * Minification filter. All valid values correspond to WebGL enums
  80475. */
  80476. const enum TextureMinFilter {
  80477. /**
  80478. * Nearest
  80479. */
  80480. NEAREST = 9728,
  80481. /**
  80482. * Linear
  80483. */
  80484. LINEAR = 9729,
  80485. /**
  80486. * Nearest Mip-Map Nearest
  80487. */
  80488. NEAREST_MIPMAP_NEAREST = 9984,
  80489. /**
  80490. * Linear Mipmap Nearest
  80491. */
  80492. LINEAR_MIPMAP_NEAREST = 9985,
  80493. /**
  80494. * Nearest Mipmap Linear
  80495. */
  80496. NEAREST_MIPMAP_LINEAR = 9986,
  80497. /**
  80498. * Linear Mipmap Linear
  80499. */
  80500. LINEAR_MIPMAP_LINEAR = 9987,
  80501. }
  80502. /**
  80503. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80504. */
  80505. const enum TextureWrapMode {
  80506. /**
  80507. * Clamp to Edge
  80508. */
  80509. CLAMP_TO_EDGE = 33071,
  80510. /**
  80511. * Mirrored Repeat
  80512. */
  80513. MIRRORED_REPEAT = 33648,
  80514. /**
  80515. * Repeat
  80516. */
  80517. REPEAT = 10497,
  80518. }
  80519. /**
  80520. * glTF Property
  80521. */
  80522. interface IProperty {
  80523. /**
  80524. * Dictionary object with extension-specific objects
  80525. */
  80526. extensions?: {
  80527. [key: string]: any;
  80528. };
  80529. /**
  80530. * Application-Specific data
  80531. */
  80532. extras?: any;
  80533. }
  80534. /**
  80535. * glTF Child of Root Property
  80536. */
  80537. interface IChildRootProperty extends IProperty {
  80538. /**
  80539. * The user-defined name of this object
  80540. */
  80541. name?: string;
  80542. }
  80543. /**
  80544. * Indices of those attributes that deviate from their initialization value
  80545. */
  80546. interface IAccessorSparseIndices extends IProperty {
  80547. /**
  80548. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80549. */
  80550. bufferView: number;
  80551. /**
  80552. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80553. */
  80554. byteOffset?: number;
  80555. /**
  80556. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  80557. */
  80558. componentType: AccessorComponentType;
  80559. }
  80560. /**
  80561. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  80562. */
  80563. interface IAccessorSparseValues extends IProperty {
  80564. /**
  80565. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  80566. */
  80567. bufferView: number;
  80568. /**
  80569. * The offset relative to the start of the bufferView in bytes. Must be aligned
  80570. */
  80571. byteOffset?: number;
  80572. }
  80573. /**
  80574. * Sparse storage of attributes that deviate from their initialization value
  80575. */
  80576. interface IAccessorSparse extends IProperty {
  80577. /**
  80578. * The number of attributes encoded in this sparse accessor
  80579. */
  80580. count: number;
  80581. /**
  80582. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  80583. */
  80584. indices: IAccessorSparseIndices;
  80585. /**
  80586. * 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
  80587. */
  80588. values: IAccessorSparseValues;
  80589. }
  80590. /**
  80591. * 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
  80592. */
  80593. interface IAccessor extends IChildRootProperty {
  80594. /**
  80595. * The index of the bufferview
  80596. */
  80597. bufferView?: number;
  80598. /**
  80599. * The offset relative to the start of the bufferView in bytes
  80600. */
  80601. byteOffset?: number;
  80602. /**
  80603. * The datatype of components in the attribute
  80604. */
  80605. componentType: AccessorComponentType;
  80606. /**
  80607. * Specifies whether integer data values should be normalized
  80608. */
  80609. normalized?: boolean;
  80610. /**
  80611. * The number of attributes referenced by this accessor
  80612. */
  80613. count: number;
  80614. /**
  80615. * Specifies if the attribute is a scalar, vector, or matrix
  80616. */
  80617. type: AccessorType;
  80618. /**
  80619. * Maximum value of each component in this attribute
  80620. */
  80621. max?: number[];
  80622. /**
  80623. * Minimum value of each component in this attribute
  80624. */
  80625. min?: number[];
  80626. /**
  80627. * Sparse storage of attributes that deviate from their initialization value
  80628. */
  80629. sparse?: IAccessorSparse;
  80630. }
  80631. /**
  80632. * Targets an animation's sampler at a node's property
  80633. */
  80634. interface IAnimationChannel extends IProperty {
  80635. /**
  80636. * The index of a sampler in this animation used to compute the value for the target
  80637. */
  80638. sampler: number;
  80639. /**
  80640. * The index of the node and TRS property to target
  80641. */
  80642. target: IAnimationChannelTarget;
  80643. }
  80644. /**
  80645. * The index of the node and TRS property that an animation channel targets
  80646. */
  80647. interface IAnimationChannelTarget extends IProperty {
  80648. /**
  80649. * The index of the node to target
  80650. */
  80651. node: number;
  80652. /**
  80653. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  80654. */
  80655. path: AnimationChannelTargetPath;
  80656. }
  80657. /**
  80658. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80659. */
  80660. interface IAnimationSampler extends IProperty {
  80661. /**
  80662. * The index of an accessor containing keyframe input values, e.g., time
  80663. */
  80664. input: number;
  80665. /**
  80666. * Interpolation algorithm
  80667. */
  80668. interpolation?: AnimationSamplerInterpolation;
  80669. /**
  80670. * The index of an accessor, containing keyframe output values
  80671. */
  80672. output: number;
  80673. }
  80674. /**
  80675. * A keyframe animation
  80676. */
  80677. interface IAnimation extends IChildRootProperty {
  80678. /**
  80679. * An array of channels, each of which targets an animation's sampler at a node's property
  80680. */
  80681. channels: IAnimationChannel[];
  80682. /**
  80683. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  80684. */
  80685. samplers: IAnimationSampler[];
  80686. }
  80687. /**
  80688. * Metadata about the glTF asset
  80689. */
  80690. interface IAsset extends IChildRootProperty {
  80691. /**
  80692. * A copyright message suitable for display to credit the content creator
  80693. */
  80694. copyright?: string;
  80695. /**
  80696. * Tool that generated this glTF model. Useful for debugging
  80697. */
  80698. generator?: string;
  80699. /**
  80700. * The glTF version that this asset targets
  80701. */
  80702. version: string;
  80703. /**
  80704. * The minimum glTF version that this asset targets
  80705. */
  80706. minVersion?: string;
  80707. }
  80708. /**
  80709. * A buffer points to binary geometry, animation, or skins
  80710. */
  80711. interface IBuffer extends IChildRootProperty {
  80712. /**
  80713. * 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
  80714. */
  80715. uri?: string;
  80716. /**
  80717. * The length of the buffer in bytes
  80718. */
  80719. byteLength: number;
  80720. }
  80721. /**
  80722. * A view into a buffer generally representing a subset of the buffer
  80723. */
  80724. interface IBufferView extends IChildRootProperty {
  80725. /**
  80726. * The index of the buffer
  80727. */
  80728. buffer: number;
  80729. /**
  80730. * The offset into the buffer in bytes
  80731. */
  80732. byteOffset?: number;
  80733. /**
  80734. * The lenth of the bufferView in bytes
  80735. */
  80736. byteLength: number;
  80737. /**
  80738. * The stride, in bytes
  80739. */
  80740. byteStride?: number;
  80741. }
  80742. /**
  80743. * An orthographic camera containing properties to create an orthographic projection matrix
  80744. */
  80745. interface ICameraOrthographic extends IProperty {
  80746. /**
  80747. * The floating-point horizontal magnification of the view. Must not be zero
  80748. */
  80749. xmag: number;
  80750. /**
  80751. * The floating-point vertical magnification of the view. Must not be zero
  80752. */
  80753. ymag: number;
  80754. /**
  80755. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  80756. */
  80757. zfar: number;
  80758. /**
  80759. * The floating-point distance to the near clipping plane
  80760. */
  80761. znear: number;
  80762. }
  80763. /**
  80764. * A perspective camera containing properties to create a perspective projection matrix
  80765. */
  80766. interface ICameraPerspective extends IProperty {
  80767. /**
  80768. * The floating-point aspect ratio of the field of view
  80769. */
  80770. aspectRatio?: number;
  80771. /**
  80772. * The floating-point vertical field of view in radians
  80773. */
  80774. yfov: number;
  80775. /**
  80776. * The floating-point distance to the far clipping plane
  80777. */
  80778. zfar?: number;
  80779. /**
  80780. * The floating-point distance to the near clipping plane
  80781. */
  80782. znear: number;
  80783. }
  80784. /**
  80785. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  80786. */
  80787. interface ICamera extends IChildRootProperty {
  80788. /**
  80789. * An orthographic camera containing properties to create an orthographic projection matrix
  80790. */
  80791. orthographic?: ICameraOrthographic;
  80792. /**
  80793. * A perspective camera containing properties to create a perspective projection matrix
  80794. */
  80795. perspective?: ICameraPerspective;
  80796. /**
  80797. * Specifies if the camera uses a perspective or orthographic projection
  80798. */
  80799. type: CameraType;
  80800. }
  80801. /**
  80802. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  80803. */
  80804. interface IImage extends IChildRootProperty {
  80805. /**
  80806. * 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
  80807. */
  80808. uri?: string;
  80809. /**
  80810. * The image's MIME type
  80811. */
  80812. mimeType?: ImageMimeType;
  80813. /**
  80814. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  80815. */
  80816. bufferView?: number;
  80817. }
  80818. /**
  80819. * Material Normal Texture Info
  80820. */
  80821. interface IMaterialNormalTextureInfo extends ITextureInfo {
  80822. /**
  80823. * The scalar multiplier applied to each normal vector of the normal texture
  80824. */
  80825. scale?: number;
  80826. }
  80827. /**
  80828. * Material Occlusion Texture Info
  80829. */
  80830. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  80831. /**
  80832. * A scalar multiplier controlling the amount of occlusion applied
  80833. */
  80834. strength?: number;
  80835. }
  80836. /**
  80837. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  80838. */
  80839. interface IMaterialPbrMetallicRoughness {
  80840. /**
  80841. * The material's base color factor
  80842. */
  80843. baseColorFactor?: number[];
  80844. /**
  80845. * The base color texture
  80846. */
  80847. baseColorTexture?: ITextureInfo;
  80848. /**
  80849. * The metalness of the material
  80850. */
  80851. metallicFactor?: number;
  80852. /**
  80853. * The roughness of the material
  80854. */
  80855. roughnessFactor?: number;
  80856. /**
  80857. * The metallic-roughness texture
  80858. */
  80859. metallicRoughnessTexture?: ITextureInfo;
  80860. }
  80861. /**
  80862. * The material appearance of a primitive
  80863. */
  80864. interface IMaterial extends IChildRootProperty {
  80865. /**
  80866. * 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
  80867. */
  80868. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80869. /**
  80870. * The normal map texture
  80871. */
  80872. normalTexture?: IMaterialNormalTextureInfo;
  80873. /**
  80874. * The occlusion map texture
  80875. */
  80876. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80877. /**
  80878. * The emissive map texture
  80879. */
  80880. emissiveTexture?: ITextureInfo;
  80881. /**
  80882. * 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
  80883. */
  80884. emissiveFactor?: number[];
  80885. /**
  80886. * The alpha rendering mode of the material
  80887. */
  80888. alphaMode?: MaterialAlphaMode;
  80889. /**
  80890. * The alpha cutoff value of the material
  80891. */
  80892. alphaCutoff?: number;
  80893. /**
  80894. * Specifies whether the material is double sided
  80895. */
  80896. doubleSided?: boolean;
  80897. }
  80898. /**
  80899. * Geometry to be rendered with the given material
  80900. */
  80901. interface IMeshPrimitive extends IProperty {
  80902. /**
  80903. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  80904. */
  80905. attributes: {
  80906. [name: string]: number;
  80907. };
  80908. /**
  80909. * The index of the accessor that contains the indices
  80910. */
  80911. indices?: number;
  80912. /**
  80913. * The index of the material to apply to this primitive when rendering
  80914. */
  80915. material?: number;
  80916. /**
  80917. * The type of primitives to render. All valid values correspond to WebGL enums
  80918. */
  80919. mode?: MeshPrimitiveMode;
  80920. /**
  80921. * 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
  80922. */
  80923. targets?: {
  80924. [name: string]: number;
  80925. }[];
  80926. }
  80927. /**
  80928. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  80929. */
  80930. interface IMesh extends IChildRootProperty {
  80931. /**
  80932. * An array of primitives, each defining geometry to be rendered with a material
  80933. */
  80934. primitives: IMeshPrimitive[];
  80935. /**
  80936. * Array of weights to be applied to the Morph Targets
  80937. */
  80938. weights?: number[];
  80939. }
  80940. /**
  80941. * A node in the node hierarchy
  80942. */
  80943. interface INode extends IChildRootProperty {
  80944. /**
  80945. * The index of the camera referenced by this node
  80946. */
  80947. camera?: number;
  80948. /**
  80949. * The indices of this node's children
  80950. */
  80951. children?: number[];
  80952. /**
  80953. * The index of the skin referenced by this node
  80954. */
  80955. skin?: number;
  80956. /**
  80957. * A floating-point 4x4 transformation matrix stored in column-major order
  80958. */
  80959. matrix?: number[];
  80960. /**
  80961. * The index of the mesh in this node
  80962. */
  80963. mesh?: number;
  80964. /**
  80965. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  80966. */
  80967. rotation?: number[];
  80968. /**
  80969. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  80970. */
  80971. scale?: number[];
  80972. /**
  80973. * The node's translation along the x, y, and z axes
  80974. */
  80975. translation?: number[];
  80976. /**
  80977. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  80978. */
  80979. weights?: number[];
  80980. }
  80981. /**
  80982. * Texture sampler properties for filtering and wrapping modes
  80983. */
  80984. interface ISampler extends IChildRootProperty {
  80985. /**
  80986. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  80987. */
  80988. magFilter?: TextureMagFilter;
  80989. /**
  80990. * Minification filter. All valid values correspond to WebGL enums
  80991. */
  80992. minFilter?: TextureMinFilter;
  80993. /**
  80994. * S (U) wrapping mode. All valid values correspond to WebGL enums
  80995. */
  80996. wrapS?: TextureWrapMode;
  80997. /**
  80998. * T (V) wrapping mode. All valid values correspond to WebGL enums
  80999. */
  81000. wrapT?: TextureWrapMode;
  81001. }
  81002. /**
  81003. * The root nodes of a scene
  81004. */
  81005. interface IScene extends IChildRootProperty {
  81006. /**
  81007. * The indices of each root node
  81008. */
  81009. nodes: number[];
  81010. }
  81011. /**
  81012. * Joints and matrices defining a skin
  81013. */
  81014. interface ISkin extends IChildRootProperty {
  81015. /**
  81016. * 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
  81017. */
  81018. inverseBindMatrices?: number;
  81019. /**
  81020. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  81021. */
  81022. skeleton?: number;
  81023. /**
  81024. * 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)
  81025. */
  81026. joints: number[];
  81027. }
  81028. /**
  81029. * A texture and its sampler
  81030. */
  81031. interface ITexture extends IChildRootProperty {
  81032. /**
  81033. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  81034. */
  81035. sampler?: number;
  81036. /**
  81037. * The index of the image used by this texture
  81038. */
  81039. source: number;
  81040. }
  81041. /**
  81042. * Reference to a texture
  81043. */
  81044. interface ITextureInfo extends IProperty {
  81045. /**
  81046. * The index of the texture
  81047. */
  81048. index: number;
  81049. /**
  81050. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  81051. */
  81052. texCoord?: number;
  81053. }
  81054. /**
  81055. * The root object for a glTF asset
  81056. */
  81057. interface IGLTF extends IProperty {
  81058. /**
  81059. * An array of accessors. An accessor is a typed view into a bufferView
  81060. */
  81061. accessors?: IAccessor[];
  81062. /**
  81063. * An array of keyframe animations
  81064. */
  81065. animations?: IAnimation[];
  81066. /**
  81067. * Metadata about the glTF asset
  81068. */
  81069. asset: IAsset;
  81070. /**
  81071. * An array of buffers. A buffer points to binary geometry, animation, or skins
  81072. */
  81073. buffers?: IBuffer[];
  81074. /**
  81075. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  81076. */
  81077. bufferViews?: IBufferView[];
  81078. /**
  81079. * An array of cameras
  81080. */
  81081. cameras?: ICamera[];
  81082. /**
  81083. * Names of glTF extensions used somewhere in this asset
  81084. */
  81085. extensionsUsed?: string[];
  81086. /**
  81087. * Names of glTF extensions required to properly load this asset
  81088. */
  81089. extensionsRequired?: string[];
  81090. /**
  81091. * An array of images. An image defines data used to create a texture
  81092. */
  81093. images?: IImage[];
  81094. /**
  81095. * An array of materials. A material defines the appearance of a primitive
  81096. */
  81097. materials?: IMaterial[];
  81098. /**
  81099. * An array of meshes. A mesh is a set of primitives to be rendered
  81100. */
  81101. meshes?: IMesh[];
  81102. /**
  81103. * An array of nodes
  81104. */
  81105. nodes?: INode[];
  81106. /**
  81107. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  81108. */
  81109. samplers?: ISampler[];
  81110. /**
  81111. * The index of the default scene
  81112. */
  81113. scene?: number;
  81114. /**
  81115. * An array of scenes
  81116. */
  81117. scenes?: IScene[];
  81118. /**
  81119. * An array of skins. A skin is defined by joints and matrices
  81120. */
  81121. skins?: ISkin[];
  81122. /**
  81123. * An array of textures
  81124. */
  81125. textures?: ITexture[];
  81126. }
  81127. /**
  81128. * The glTF validation results
  81129. * @ignore
  81130. */
  81131. interface IGLTFValidationResults {
  81132. info: {
  81133. generator: string;
  81134. hasAnimations: boolean;
  81135. hasDefaultScene: boolean;
  81136. hasMaterials: boolean;
  81137. hasMorphTargets: boolean;
  81138. hasSkins: boolean;
  81139. hasTextures: boolean;
  81140. maxAttributesUsed: number;
  81141. primitivesCount: number
  81142. };
  81143. issues: {
  81144. messages: Array<string>;
  81145. numErrors: number;
  81146. numHints: number;
  81147. numInfos: number;
  81148. numWarnings: number;
  81149. truncated: boolean
  81150. };
  81151. mimeType: string;
  81152. uri: string;
  81153. validatedAt: string;
  81154. validatorVersion: string;
  81155. }
  81156. /**
  81157. * The glTF validation options
  81158. */
  81159. interface IGLTFValidationOptions {
  81160. /** Uri to use */
  81161. uri?: string;
  81162. /** Function used to load external resources */
  81163. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  81164. /** Boolean indicating that we need to validate accessor data */
  81165. validateAccessorData?: boolean;
  81166. /** max number of issues allowed */
  81167. maxIssues?: number;
  81168. /** Ignored issues */
  81169. ignoredIssues?: Array<string>;
  81170. /** Value to override severy settings */
  81171. severityOverrides?: Object;
  81172. }
  81173. /**
  81174. * The glTF validator object
  81175. * @ignore
  81176. */
  81177. interface IGLTFValidator {
  81178. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81179. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  81180. }
  81181. }
  81182. declare module BABYLON {
  81183. /** @hidden */
  81184. export var cellPixelShader: {
  81185. name: string;
  81186. shader: string;
  81187. };
  81188. }
  81189. declare module BABYLON {
  81190. /** @hidden */
  81191. export var cellVertexShader: {
  81192. name: string;
  81193. shader: string;
  81194. };
  81195. }
  81196. declare module BABYLON {
  81197. export class CellMaterial extends BABYLON.PushMaterial {
  81198. private _diffuseTexture;
  81199. diffuseTexture: BABYLON.BaseTexture;
  81200. diffuseColor: BABYLON.Color3;
  81201. _computeHighLevel: boolean;
  81202. computeHighLevel: boolean;
  81203. private _disableLighting;
  81204. disableLighting: boolean;
  81205. private _maxSimultaneousLights;
  81206. maxSimultaneousLights: number;
  81207. constructor(name: string, scene: BABYLON.Scene);
  81208. needAlphaBlending(): boolean;
  81209. needAlphaTesting(): boolean;
  81210. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81211. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81212. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81213. getAnimatables(): BABYLON.IAnimatable[];
  81214. getActiveTextures(): BABYLON.BaseTexture[];
  81215. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81216. dispose(forceDisposeEffect?: boolean): void;
  81217. getClassName(): string;
  81218. clone(name: string): CellMaterial;
  81219. serialize(): any;
  81220. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  81221. }
  81222. }
  81223. declare module BABYLON {
  81224. export class CustomShaderStructure {
  81225. FragmentStore: string;
  81226. VertexStore: string;
  81227. constructor();
  81228. }
  81229. export class ShaderSpecialParts {
  81230. constructor();
  81231. Fragment_Begin: string;
  81232. Fragment_Definitions: string;
  81233. Fragment_MainBegin: string;
  81234. Fragment_Custom_Diffuse: string;
  81235. Fragment_Before_Lights: string;
  81236. Fragment_Before_Fog: string;
  81237. Fragment_Custom_Alpha: string;
  81238. Fragment_Before_FragColor: string;
  81239. Vertex_Begin: string;
  81240. Vertex_Definitions: string;
  81241. Vertex_MainBegin: string;
  81242. Vertex_Before_PositionUpdated: string;
  81243. Vertex_Before_NormalUpdated: string;
  81244. Vertex_After_WorldPosComputed: string;
  81245. Vertex_MainEnd: string;
  81246. }
  81247. export class CustomMaterial extends BABYLON.StandardMaterial {
  81248. static ShaderIndexer: number;
  81249. CustomParts: ShaderSpecialParts;
  81250. _isCreatedShader: boolean;
  81251. _createdShaderName: string;
  81252. _customUniform: string[];
  81253. _newUniforms: string[];
  81254. _newUniformInstances: {
  81255. [name: string]: any;
  81256. };
  81257. _newSamplerInstances: {
  81258. [name: string]: BABYLON.Texture;
  81259. };
  81260. _customAttributes: string[];
  81261. FragmentShader: string;
  81262. VertexShader: string;
  81263. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81264. ReviewUniform(name: string, arr: string[]): string[];
  81265. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81266. constructor(name: string, scene: BABYLON.Scene);
  81267. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  81268. AddAttribute(name: string): CustomMaterial;
  81269. Fragment_Begin(shaderPart: string): CustomMaterial;
  81270. Fragment_Definitions(shaderPart: string): CustomMaterial;
  81271. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  81272. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  81273. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  81274. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  81275. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  81276. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  81277. Vertex_Begin(shaderPart: string): CustomMaterial;
  81278. Vertex_Definitions(shaderPart: string): CustomMaterial;
  81279. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  81280. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  81281. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  81282. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  81283. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  81284. }
  81285. }
  81286. declare module BABYLON {
  81287. export class ShaderAlebdoParts {
  81288. constructor();
  81289. Fragment_Begin: string;
  81290. Fragment_Definitions: string;
  81291. Fragment_MainBegin: string;
  81292. Fragment_Custom_Albedo: string;
  81293. Fragment_Before_Lights: string;
  81294. Fragment_Custom_MetallicRoughness: string;
  81295. Fragment_Custom_MicroSurface: string;
  81296. Fragment_Before_Fog: string;
  81297. Fragment_Custom_Alpha: string;
  81298. Fragment_Before_FragColor: string;
  81299. Vertex_Begin: string;
  81300. Vertex_Definitions: string;
  81301. Vertex_MainBegin: string;
  81302. Vertex_Before_PositionUpdated: string;
  81303. Vertex_Before_NormalUpdated: string;
  81304. Vertex_After_WorldPosComputed: string;
  81305. Vertex_MainEnd: string;
  81306. }
  81307. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  81308. static ShaderIndexer: number;
  81309. CustomParts: ShaderAlebdoParts;
  81310. _isCreatedShader: boolean;
  81311. _createdShaderName: string;
  81312. _customUniform: string[];
  81313. _newUniforms: string[];
  81314. _newUniformInstances: {
  81315. [name: string]: any;
  81316. };
  81317. _newSamplerInstances: {
  81318. [name: string]: BABYLON.Texture;
  81319. };
  81320. _customAttributes: string[];
  81321. FragmentShader: string;
  81322. VertexShader: string;
  81323. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  81324. ReviewUniform(name: string, arr: string[]): string[];
  81325. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  81326. constructor(name: string, scene: BABYLON.Scene);
  81327. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  81328. AddAttribute(name: string): PBRCustomMaterial;
  81329. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  81330. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  81331. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  81332. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  81333. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  81334. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  81335. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  81336. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  81337. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  81338. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  81339. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  81340. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  81341. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  81342. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  81343. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  81344. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  81345. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  81346. }
  81347. }
  81348. declare module BABYLON {
  81349. /** @hidden */
  81350. export var firePixelShader: {
  81351. name: string;
  81352. shader: string;
  81353. };
  81354. }
  81355. declare module BABYLON {
  81356. /** @hidden */
  81357. export var fireVertexShader: {
  81358. name: string;
  81359. shader: string;
  81360. };
  81361. }
  81362. declare module BABYLON {
  81363. export class FireMaterial extends BABYLON.PushMaterial {
  81364. private _diffuseTexture;
  81365. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81366. private _distortionTexture;
  81367. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81368. private _opacityTexture;
  81369. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  81370. diffuseColor: BABYLON.Color3;
  81371. speed: number;
  81372. private _scaledDiffuse;
  81373. private _lastTime;
  81374. constructor(name: string, scene: BABYLON.Scene);
  81375. needAlphaBlending(): boolean;
  81376. needAlphaTesting(): boolean;
  81377. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81378. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81379. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81380. getAnimatables(): BABYLON.IAnimatable[];
  81381. getActiveTextures(): BABYLON.BaseTexture[];
  81382. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81383. getClassName(): string;
  81384. dispose(forceDisposeEffect?: boolean): void;
  81385. clone(name: string): FireMaterial;
  81386. serialize(): any;
  81387. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  81388. }
  81389. }
  81390. declare module BABYLON {
  81391. /** @hidden */
  81392. export var furPixelShader: {
  81393. name: string;
  81394. shader: string;
  81395. };
  81396. }
  81397. declare module BABYLON {
  81398. /** @hidden */
  81399. export var furVertexShader: {
  81400. name: string;
  81401. shader: string;
  81402. };
  81403. }
  81404. declare module BABYLON {
  81405. export class FurMaterial extends BABYLON.PushMaterial {
  81406. private _diffuseTexture;
  81407. diffuseTexture: BABYLON.BaseTexture;
  81408. private _heightTexture;
  81409. heightTexture: BABYLON.BaseTexture;
  81410. diffuseColor: BABYLON.Color3;
  81411. furLength: number;
  81412. furAngle: number;
  81413. furColor: BABYLON.Color3;
  81414. furOffset: number;
  81415. furSpacing: number;
  81416. furGravity: BABYLON.Vector3;
  81417. furSpeed: number;
  81418. furDensity: number;
  81419. furOcclusion: number;
  81420. furTexture: BABYLON.DynamicTexture;
  81421. private _disableLighting;
  81422. disableLighting: boolean;
  81423. private _maxSimultaneousLights;
  81424. maxSimultaneousLights: number;
  81425. highLevelFur: boolean;
  81426. _meshes: BABYLON.AbstractMesh[];
  81427. private _furTime;
  81428. constructor(name: string, scene: BABYLON.Scene);
  81429. get furTime(): number;
  81430. set furTime(furTime: number);
  81431. needAlphaBlending(): boolean;
  81432. needAlphaTesting(): boolean;
  81433. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81434. updateFur(): void;
  81435. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81436. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81437. getAnimatables(): BABYLON.IAnimatable[];
  81438. getActiveTextures(): BABYLON.BaseTexture[];
  81439. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81440. dispose(forceDisposeEffect?: boolean): void;
  81441. clone(name: string): FurMaterial;
  81442. serialize(): any;
  81443. getClassName(): string;
  81444. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  81445. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  81446. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  81447. }
  81448. }
  81449. declare module BABYLON {
  81450. /** @hidden */
  81451. export var gradientPixelShader: {
  81452. name: string;
  81453. shader: string;
  81454. };
  81455. }
  81456. declare module BABYLON {
  81457. /** @hidden */
  81458. export var gradientVertexShader: {
  81459. name: string;
  81460. shader: string;
  81461. };
  81462. }
  81463. declare module BABYLON {
  81464. export class GradientMaterial extends BABYLON.PushMaterial {
  81465. private _maxSimultaneousLights;
  81466. maxSimultaneousLights: number;
  81467. topColor: BABYLON.Color3;
  81468. topColorAlpha: number;
  81469. bottomColor: BABYLON.Color3;
  81470. bottomColorAlpha: number;
  81471. offset: number;
  81472. scale: number;
  81473. smoothness: number;
  81474. private _disableLighting;
  81475. disableLighting: boolean;
  81476. constructor(name: string, scene: BABYLON.Scene);
  81477. needAlphaBlending(): boolean;
  81478. needAlphaTesting(): boolean;
  81479. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81480. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81481. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81482. getAnimatables(): BABYLON.IAnimatable[];
  81483. dispose(forceDisposeEffect?: boolean): void;
  81484. clone(name: string): GradientMaterial;
  81485. serialize(): any;
  81486. getClassName(): string;
  81487. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  81488. }
  81489. }
  81490. declare module BABYLON {
  81491. /** @hidden */
  81492. export var gridPixelShader: {
  81493. name: string;
  81494. shader: string;
  81495. };
  81496. }
  81497. declare module BABYLON {
  81498. /** @hidden */
  81499. export var gridVertexShader: {
  81500. name: string;
  81501. shader: string;
  81502. };
  81503. }
  81504. declare module BABYLON {
  81505. /**
  81506. * The grid materials allows you to wrap any shape with a grid.
  81507. * Colors are customizable.
  81508. */
  81509. export class GridMaterial extends BABYLON.PushMaterial {
  81510. /**
  81511. * Main color of the grid (e.g. between lines)
  81512. */
  81513. mainColor: BABYLON.Color3;
  81514. /**
  81515. * Color of the grid lines.
  81516. */
  81517. lineColor: BABYLON.Color3;
  81518. /**
  81519. * The scale of the grid compared to unit.
  81520. */
  81521. gridRatio: number;
  81522. /**
  81523. * Allows setting an offset for the grid lines.
  81524. */
  81525. gridOffset: BABYLON.Vector3;
  81526. /**
  81527. * The frequency of thicker lines.
  81528. */
  81529. majorUnitFrequency: number;
  81530. /**
  81531. * The visibility of minor units in the grid.
  81532. */
  81533. minorUnitVisibility: number;
  81534. /**
  81535. * The grid opacity outside of the lines.
  81536. */
  81537. opacity: number;
  81538. /**
  81539. * Determine RBG output is premultiplied by alpha value.
  81540. */
  81541. preMultiplyAlpha: boolean;
  81542. private _opacityTexture;
  81543. opacityTexture: BABYLON.BaseTexture;
  81544. private _gridControl;
  81545. /**
  81546. * constructor
  81547. * @param name The name given to the material in order to identify it afterwards.
  81548. * @param scene The scene the material is used in.
  81549. */
  81550. constructor(name: string, scene: BABYLON.Scene);
  81551. /**
  81552. * Returns wehter or not the grid requires alpha blending.
  81553. */
  81554. needAlphaBlending(): boolean;
  81555. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81556. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81557. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81558. /**
  81559. * Dispose the material and its associated resources.
  81560. * @param forceDisposeEffect will also dispose the used effect when true
  81561. */
  81562. dispose(forceDisposeEffect?: boolean): void;
  81563. clone(name: string): GridMaterial;
  81564. serialize(): any;
  81565. getClassName(): string;
  81566. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  81567. }
  81568. }
  81569. declare module BABYLON {
  81570. /** @hidden */
  81571. export var lavaPixelShader: {
  81572. name: string;
  81573. shader: string;
  81574. };
  81575. }
  81576. declare module BABYLON {
  81577. /** @hidden */
  81578. export var lavaVertexShader: {
  81579. name: string;
  81580. shader: string;
  81581. };
  81582. }
  81583. declare module BABYLON {
  81584. export class LavaMaterial extends BABYLON.PushMaterial {
  81585. private _diffuseTexture;
  81586. diffuseTexture: BABYLON.BaseTexture;
  81587. noiseTexture: BABYLON.BaseTexture;
  81588. fogColor: BABYLON.Color3;
  81589. speed: number;
  81590. movingSpeed: number;
  81591. lowFrequencySpeed: number;
  81592. fogDensity: number;
  81593. private _lastTime;
  81594. diffuseColor: BABYLON.Color3;
  81595. private _disableLighting;
  81596. disableLighting: boolean;
  81597. private _unlit;
  81598. unlit: boolean;
  81599. private _maxSimultaneousLights;
  81600. maxSimultaneousLights: number;
  81601. private _scaledDiffuse;
  81602. constructor(name: string, scene: BABYLON.Scene);
  81603. needAlphaBlending(): boolean;
  81604. needAlphaTesting(): boolean;
  81605. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81606. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81607. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81608. getAnimatables(): BABYLON.IAnimatable[];
  81609. getActiveTextures(): BABYLON.BaseTexture[];
  81610. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81611. dispose(forceDisposeEffect?: boolean): void;
  81612. clone(name: string): LavaMaterial;
  81613. serialize(): any;
  81614. getClassName(): string;
  81615. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  81616. }
  81617. }
  81618. declare module BABYLON {
  81619. /** @hidden */
  81620. export var mixPixelShader: {
  81621. name: string;
  81622. shader: string;
  81623. };
  81624. }
  81625. declare module BABYLON {
  81626. /** @hidden */
  81627. export var mixVertexShader: {
  81628. name: string;
  81629. shader: string;
  81630. };
  81631. }
  81632. declare module BABYLON {
  81633. export class MixMaterial extends BABYLON.PushMaterial {
  81634. /**
  81635. * Mix textures
  81636. */
  81637. private _mixTexture1;
  81638. mixTexture1: BABYLON.BaseTexture;
  81639. private _mixTexture2;
  81640. mixTexture2: BABYLON.BaseTexture;
  81641. /**
  81642. * Diffuse textures
  81643. */
  81644. private _diffuseTexture1;
  81645. diffuseTexture1: BABYLON.Texture;
  81646. private _diffuseTexture2;
  81647. diffuseTexture2: BABYLON.Texture;
  81648. private _diffuseTexture3;
  81649. diffuseTexture3: BABYLON.Texture;
  81650. private _diffuseTexture4;
  81651. diffuseTexture4: BABYLON.Texture;
  81652. private _diffuseTexture5;
  81653. diffuseTexture5: BABYLON.Texture;
  81654. private _diffuseTexture6;
  81655. diffuseTexture6: BABYLON.Texture;
  81656. private _diffuseTexture7;
  81657. diffuseTexture7: BABYLON.Texture;
  81658. private _diffuseTexture8;
  81659. diffuseTexture8: BABYLON.Texture;
  81660. /**
  81661. * Uniforms
  81662. */
  81663. diffuseColor: BABYLON.Color3;
  81664. specularColor: BABYLON.Color3;
  81665. specularPower: number;
  81666. private _disableLighting;
  81667. disableLighting: boolean;
  81668. private _maxSimultaneousLights;
  81669. maxSimultaneousLights: number;
  81670. constructor(name: string, scene: BABYLON.Scene);
  81671. needAlphaBlending(): boolean;
  81672. needAlphaTesting(): boolean;
  81673. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81674. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81675. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81676. getAnimatables(): BABYLON.IAnimatable[];
  81677. getActiveTextures(): BABYLON.BaseTexture[];
  81678. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81679. dispose(forceDisposeEffect?: boolean): void;
  81680. clone(name: string): MixMaterial;
  81681. serialize(): any;
  81682. getClassName(): string;
  81683. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  81684. }
  81685. }
  81686. declare module BABYLON {
  81687. /** @hidden */
  81688. export var normalPixelShader: {
  81689. name: string;
  81690. shader: string;
  81691. };
  81692. }
  81693. declare module BABYLON {
  81694. /** @hidden */
  81695. export var normalVertexShader: {
  81696. name: string;
  81697. shader: string;
  81698. };
  81699. }
  81700. declare module BABYLON {
  81701. export class NormalMaterial extends BABYLON.PushMaterial {
  81702. private _diffuseTexture;
  81703. diffuseTexture: BABYLON.BaseTexture;
  81704. diffuseColor: BABYLON.Color3;
  81705. private _disableLighting;
  81706. disableLighting: boolean;
  81707. private _maxSimultaneousLights;
  81708. maxSimultaneousLights: number;
  81709. constructor(name: string, scene: BABYLON.Scene);
  81710. needAlphaBlending(): boolean;
  81711. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  81712. needAlphaTesting(): boolean;
  81713. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81714. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81715. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81716. getAnimatables(): BABYLON.IAnimatable[];
  81717. getActiveTextures(): BABYLON.BaseTexture[];
  81718. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81719. dispose(forceDisposeEffect?: boolean): void;
  81720. clone(name: string): NormalMaterial;
  81721. serialize(): any;
  81722. getClassName(): string;
  81723. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  81724. }
  81725. }
  81726. declare module BABYLON {
  81727. /** @hidden */
  81728. export var shadowOnlyPixelShader: {
  81729. name: string;
  81730. shader: string;
  81731. };
  81732. }
  81733. declare module BABYLON {
  81734. /** @hidden */
  81735. export var shadowOnlyVertexShader: {
  81736. name: string;
  81737. shader: string;
  81738. };
  81739. }
  81740. declare module BABYLON {
  81741. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  81742. private _activeLight;
  81743. constructor(name: string, scene: BABYLON.Scene);
  81744. shadowColor: BABYLON.Color3;
  81745. needAlphaBlending(): boolean;
  81746. needAlphaTesting(): boolean;
  81747. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81748. get activeLight(): BABYLON.IShadowLight;
  81749. set activeLight(light: BABYLON.IShadowLight);
  81750. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81751. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81752. clone(name: string): ShadowOnlyMaterial;
  81753. serialize(): any;
  81754. getClassName(): string;
  81755. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  81756. }
  81757. }
  81758. declare module BABYLON {
  81759. /** @hidden */
  81760. export var simplePixelShader: {
  81761. name: string;
  81762. shader: string;
  81763. };
  81764. }
  81765. declare module BABYLON {
  81766. /** @hidden */
  81767. export var simpleVertexShader: {
  81768. name: string;
  81769. shader: string;
  81770. };
  81771. }
  81772. declare module BABYLON {
  81773. export class SimpleMaterial extends BABYLON.PushMaterial {
  81774. private _diffuseTexture;
  81775. diffuseTexture: BABYLON.BaseTexture;
  81776. diffuseColor: BABYLON.Color3;
  81777. private _disableLighting;
  81778. disableLighting: boolean;
  81779. private _maxSimultaneousLights;
  81780. maxSimultaneousLights: number;
  81781. constructor(name: string, scene: BABYLON.Scene);
  81782. needAlphaBlending(): boolean;
  81783. needAlphaTesting(): boolean;
  81784. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81785. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81786. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81787. getAnimatables(): BABYLON.IAnimatable[];
  81788. getActiveTextures(): BABYLON.BaseTexture[];
  81789. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81790. dispose(forceDisposeEffect?: boolean): void;
  81791. clone(name: string): SimpleMaterial;
  81792. serialize(): any;
  81793. getClassName(): string;
  81794. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  81795. }
  81796. }
  81797. declare module BABYLON {
  81798. /** @hidden */
  81799. export var skyPixelShader: {
  81800. name: string;
  81801. shader: string;
  81802. };
  81803. }
  81804. declare module BABYLON {
  81805. /** @hidden */
  81806. export var skyVertexShader: {
  81807. name: string;
  81808. shader: string;
  81809. };
  81810. }
  81811. declare module BABYLON {
  81812. /**
  81813. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  81814. * @see https://doc.babylonjs.com/extensions/sky
  81815. */
  81816. export class SkyMaterial extends BABYLON.PushMaterial {
  81817. /**
  81818. * Defines the overall luminance of sky in interval ]0, 1[.
  81819. */
  81820. luminance: number;
  81821. /**
  81822. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  81823. */
  81824. turbidity: number;
  81825. /**
  81826. * Defines the sky appearance (light intensity).
  81827. */
  81828. rayleigh: number;
  81829. /**
  81830. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  81831. */
  81832. mieCoefficient: number;
  81833. /**
  81834. * Defines the amount of haze particles following the Mie scattering theory.
  81835. */
  81836. mieDirectionalG: number;
  81837. /**
  81838. * Defines the distance of the sun according to the active scene camera.
  81839. */
  81840. distance: number;
  81841. /**
  81842. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  81843. * "inclined".
  81844. */
  81845. inclination: number;
  81846. /**
  81847. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  81848. * an object direction and a reference direction.
  81849. */
  81850. azimuth: number;
  81851. /**
  81852. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  81853. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  81854. */
  81855. sunPosition: BABYLON.Vector3;
  81856. /**
  81857. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  81858. * .sunPosition property.
  81859. */
  81860. useSunPosition: boolean;
  81861. /**
  81862. * Defines an offset vector used to get a horizon offset.
  81863. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  81864. */
  81865. cameraOffset: BABYLON.Vector3;
  81866. private _cameraPosition;
  81867. /**
  81868. * Instantiates a new sky material.
  81869. * This material allows to create dynamic and texture free
  81870. * effects for skyboxes by taking care of the atmosphere state.
  81871. * @see https://doc.babylonjs.com/extensions/sky
  81872. * @param name Define the name of the material in the scene
  81873. * @param scene Define the scene the material belong to
  81874. */
  81875. constructor(name: string, scene: BABYLON.Scene);
  81876. /**
  81877. * Specifies if the material will require alpha blending
  81878. * @returns a boolean specifying if alpha blending is needed
  81879. */
  81880. needAlphaBlending(): boolean;
  81881. /**
  81882. * Specifies if this material should be rendered in alpha test mode
  81883. * @returns false as the sky material doesn't need alpha testing.
  81884. */
  81885. needAlphaTesting(): boolean;
  81886. /**
  81887. * Get the texture used for alpha test purpose.
  81888. * @returns null as the sky material has no texture.
  81889. */
  81890. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81891. /**
  81892. * Get if the submesh is ready to be used and all its information available.
  81893. * Child classes can use it to update shaders
  81894. * @param mesh defines the mesh to check
  81895. * @param subMesh defines which submesh to check
  81896. * @param useInstances specifies that instances should be used
  81897. * @returns a boolean indicating that the submesh is ready or not
  81898. */
  81899. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81900. /**
  81901. * Binds the submesh to this material by preparing the effect and shader to draw
  81902. * @param world defines the world transformation matrix
  81903. * @param mesh defines the mesh containing the submesh
  81904. * @param subMesh defines the submesh to bind the material to
  81905. */
  81906. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81907. /**
  81908. * Get the list of animatables in the material.
  81909. * @returns the list of animatables object used in the material
  81910. */
  81911. getAnimatables(): BABYLON.IAnimatable[];
  81912. /**
  81913. * Disposes the material
  81914. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81915. */
  81916. dispose(forceDisposeEffect?: boolean): void;
  81917. /**
  81918. * Makes a duplicate of the material, and gives it a new name
  81919. * @param name defines the new name for the duplicated material
  81920. * @returns the cloned material
  81921. */
  81922. clone(name: string): SkyMaterial;
  81923. /**
  81924. * Serializes this material in a JSON representation
  81925. * @returns the serialized material object
  81926. */
  81927. serialize(): any;
  81928. /**
  81929. * Gets the current class name of the material e.g. "SkyMaterial"
  81930. * Mainly use in serialization.
  81931. * @returns the class name
  81932. */
  81933. getClassName(): string;
  81934. /**
  81935. * Creates a sky material from parsed material data
  81936. * @param source defines the JSON representation of the material
  81937. * @param scene defines the hosting scene
  81938. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  81939. * @returns a new sky material
  81940. */
  81941. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  81942. }
  81943. }
  81944. declare module BABYLON {
  81945. /** @hidden */
  81946. export var terrainPixelShader: {
  81947. name: string;
  81948. shader: string;
  81949. };
  81950. }
  81951. declare module BABYLON {
  81952. /** @hidden */
  81953. export var terrainVertexShader: {
  81954. name: string;
  81955. shader: string;
  81956. };
  81957. }
  81958. declare module BABYLON {
  81959. export class TerrainMaterial extends BABYLON.PushMaterial {
  81960. private _mixTexture;
  81961. mixTexture: BABYLON.BaseTexture;
  81962. private _diffuseTexture1;
  81963. diffuseTexture1: BABYLON.Texture;
  81964. private _diffuseTexture2;
  81965. diffuseTexture2: BABYLON.Texture;
  81966. private _diffuseTexture3;
  81967. diffuseTexture3: BABYLON.Texture;
  81968. private _bumpTexture1;
  81969. bumpTexture1: BABYLON.Texture;
  81970. private _bumpTexture2;
  81971. bumpTexture2: BABYLON.Texture;
  81972. private _bumpTexture3;
  81973. bumpTexture3: BABYLON.Texture;
  81974. diffuseColor: BABYLON.Color3;
  81975. specularColor: BABYLON.Color3;
  81976. specularPower: number;
  81977. private _disableLighting;
  81978. disableLighting: boolean;
  81979. private _maxSimultaneousLights;
  81980. maxSimultaneousLights: number;
  81981. constructor(name: string, scene: BABYLON.Scene);
  81982. needAlphaBlending(): boolean;
  81983. needAlphaTesting(): boolean;
  81984. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  81985. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  81986. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  81987. getAnimatables(): BABYLON.IAnimatable[];
  81988. getActiveTextures(): BABYLON.BaseTexture[];
  81989. hasTexture(texture: BABYLON.BaseTexture): boolean;
  81990. dispose(forceDisposeEffect?: boolean): void;
  81991. clone(name: string): TerrainMaterial;
  81992. serialize(): any;
  81993. getClassName(): string;
  81994. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  81995. }
  81996. }
  81997. declare module BABYLON {
  81998. /** @hidden */
  81999. export var triplanarPixelShader: {
  82000. name: string;
  82001. shader: string;
  82002. };
  82003. }
  82004. declare module BABYLON {
  82005. /** @hidden */
  82006. export var triplanarVertexShader: {
  82007. name: string;
  82008. shader: string;
  82009. };
  82010. }
  82011. declare module BABYLON {
  82012. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  82013. mixTexture: BABYLON.BaseTexture;
  82014. private _diffuseTextureX;
  82015. diffuseTextureX: BABYLON.BaseTexture;
  82016. private _diffuseTextureY;
  82017. diffuseTextureY: BABYLON.BaseTexture;
  82018. private _diffuseTextureZ;
  82019. diffuseTextureZ: BABYLON.BaseTexture;
  82020. private _normalTextureX;
  82021. normalTextureX: BABYLON.BaseTexture;
  82022. private _normalTextureY;
  82023. normalTextureY: BABYLON.BaseTexture;
  82024. private _normalTextureZ;
  82025. normalTextureZ: BABYLON.BaseTexture;
  82026. tileSize: number;
  82027. diffuseColor: BABYLON.Color3;
  82028. specularColor: BABYLON.Color3;
  82029. specularPower: number;
  82030. private _disableLighting;
  82031. disableLighting: boolean;
  82032. private _maxSimultaneousLights;
  82033. maxSimultaneousLights: number;
  82034. constructor(name: string, scene: BABYLON.Scene);
  82035. needAlphaBlending(): boolean;
  82036. needAlphaTesting(): boolean;
  82037. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82038. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82039. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82040. getAnimatables(): BABYLON.IAnimatable[];
  82041. getActiveTextures(): BABYLON.BaseTexture[];
  82042. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82043. dispose(forceDisposeEffect?: boolean): void;
  82044. clone(name: string): TriPlanarMaterial;
  82045. serialize(): any;
  82046. getClassName(): string;
  82047. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  82048. }
  82049. }
  82050. declare module BABYLON {
  82051. /** @hidden */
  82052. export var waterPixelShader: {
  82053. name: string;
  82054. shader: string;
  82055. };
  82056. }
  82057. declare module BABYLON {
  82058. /** @hidden */
  82059. export var waterVertexShader: {
  82060. name: string;
  82061. shader: string;
  82062. };
  82063. }
  82064. declare module BABYLON {
  82065. export class WaterMaterial extends BABYLON.PushMaterial {
  82066. renderTargetSize: BABYLON.Vector2;
  82067. private _bumpTexture;
  82068. bumpTexture: BABYLON.BaseTexture;
  82069. diffuseColor: BABYLON.Color3;
  82070. specularColor: BABYLON.Color3;
  82071. specularPower: number;
  82072. private _disableLighting;
  82073. disableLighting: boolean;
  82074. private _maxSimultaneousLights;
  82075. maxSimultaneousLights: number;
  82076. /**
  82077. * @param {number}: Represents the wind force
  82078. */
  82079. windForce: number;
  82080. /**
  82081. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  82082. */
  82083. windDirection: BABYLON.Vector2;
  82084. /**
  82085. * @param {number}: Wave height, represents the height of the waves
  82086. */
  82087. waveHeight: number;
  82088. /**
  82089. * @param {number}: Bump height, represents the bump height related to the bump map
  82090. */
  82091. bumpHeight: number;
  82092. /**
  82093. * @param {boolean}: Add a smaller moving bump to less steady waves.
  82094. */
  82095. private _bumpSuperimpose;
  82096. bumpSuperimpose: boolean;
  82097. /**
  82098. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  82099. */
  82100. private _fresnelSeparate;
  82101. fresnelSeparate: boolean;
  82102. /**
  82103. * @param {boolean}: bump Waves modify the reflection.
  82104. */
  82105. private _bumpAffectsReflection;
  82106. bumpAffectsReflection: boolean;
  82107. /**
  82108. * @param {number}: The water color blended with the refraction (near)
  82109. */
  82110. waterColor: BABYLON.Color3;
  82111. /**
  82112. * @param {number}: The blend factor related to the water color
  82113. */
  82114. colorBlendFactor: number;
  82115. /**
  82116. * @param {number}: The water color blended with the reflection (far)
  82117. */
  82118. waterColor2: BABYLON.Color3;
  82119. /**
  82120. * @param {number}: The blend factor related to the water color (reflection, far)
  82121. */
  82122. colorBlendFactor2: number;
  82123. /**
  82124. * @param {number}: Represents the maximum length of a wave
  82125. */
  82126. waveLength: number;
  82127. /**
  82128. * @param {number}: Defines the waves speed
  82129. */
  82130. waveSpeed: number;
  82131. /**
  82132. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  82133. * will avoid calculating useless pixels in the pixel shader of the water material.
  82134. */
  82135. disableClipPlane: boolean;
  82136. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  82137. private _mesh;
  82138. private _refractionRTT;
  82139. private _reflectionRTT;
  82140. private _reflectionTransform;
  82141. private _lastTime;
  82142. private _lastDeltaTime;
  82143. private _useLogarithmicDepth;
  82144. private _waitingRenderList;
  82145. private _imageProcessingConfiguration;
  82146. private _imageProcessingObserver;
  82147. /**
  82148. * Gets a boolean indicating that current material needs to register RTT
  82149. */
  82150. get hasRenderTargetTextures(): boolean;
  82151. /**
  82152. * Constructor
  82153. */
  82154. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  82155. get useLogarithmicDepth(): boolean;
  82156. set useLogarithmicDepth(value: boolean);
  82157. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82158. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  82159. addToRenderList(node: any): void;
  82160. enableRenderTargets(enable: boolean): void;
  82161. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  82162. get renderTargetsEnabled(): boolean;
  82163. needAlphaBlending(): boolean;
  82164. needAlphaTesting(): boolean;
  82165. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  82166. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  82167. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  82168. private _createRenderTargets;
  82169. getAnimatables(): BABYLON.IAnimatable[];
  82170. getActiveTextures(): BABYLON.BaseTexture[];
  82171. hasTexture(texture: BABYLON.BaseTexture): boolean;
  82172. dispose(forceDisposeEffect?: boolean): void;
  82173. clone(name: string): WaterMaterial;
  82174. serialize(): any;
  82175. getClassName(): string;
  82176. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  82177. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  82178. }
  82179. }
  82180. declare module BABYLON {
  82181. /** @hidden */
  82182. export var asciiartPixelShader: {
  82183. name: string;
  82184. shader: string;
  82185. };
  82186. }
  82187. declare module BABYLON {
  82188. /**
  82189. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  82190. *
  82191. * It basically takes care rendering the font front the given font size to a texture.
  82192. * This is used later on in the postprocess.
  82193. */
  82194. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  82195. private _font;
  82196. private _text;
  82197. private _charSize;
  82198. /**
  82199. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82200. */
  82201. get charSize(): number;
  82202. /**
  82203. * Create a new instance of the Ascii Art FontTexture class
  82204. * @param name the name of the texture
  82205. * @param font the font to use, use the W3C CSS notation
  82206. * @param text the caracter set to use in the rendering.
  82207. * @param scene the scene that owns the texture
  82208. */
  82209. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82210. /**
  82211. * Gets the max char width of a font.
  82212. * @param font the font to use, use the W3C CSS notation
  82213. * @return the max char width
  82214. */
  82215. private getFontWidth;
  82216. /**
  82217. * Gets the max char height of a font.
  82218. * @param font the font to use, use the W3C CSS notation
  82219. * @return the max char height
  82220. */
  82221. private getFontHeight;
  82222. /**
  82223. * Clones the current AsciiArtTexture.
  82224. * @return the clone of the texture.
  82225. */
  82226. clone(): AsciiArtFontTexture;
  82227. /**
  82228. * Parses a json object representing the texture and returns an instance of it.
  82229. * @param source the source JSON representation
  82230. * @param scene the scene to create the texture for
  82231. * @return the parsed texture
  82232. */
  82233. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  82234. }
  82235. /**
  82236. * Option available in the Ascii Art Post Process.
  82237. */
  82238. export interface IAsciiArtPostProcessOptions {
  82239. /**
  82240. * The font to use following the w3c font definition.
  82241. */
  82242. font?: string;
  82243. /**
  82244. * The character set to use in the postprocess.
  82245. */
  82246. characterSet?: string;
  82247. /**
  82248. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82249. * This number is defined between 0 and 1;
  82250. */
  82251. mixToTile?: number;
  82252. /**
  82253. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82254. * This number is defined between 0 and 1;
  82255. */
  82256. mixToNormal?: number;
  82257. }
  82258. /**
  82259. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  82260. *
  82261. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82262. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  82263. */
  82264. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  82265. /**
  82266. * The font texture used to render the char in the post process.
  82267. */
  82268. private _asciiArtFontTexture;
  82269. /**
  82270. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  82271. * This number is defined between 0 and 1;
  82272. */
  82273. mixToTile: number;
  82274. /**
  82275. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  82276. * This number is defined between 0 and 1;
  82277. */
  82278. mixToNormal: number;
  82279. /**
  82280. * Instantiates a new Ascii Art Post Process.
  82281. * @param name the name to give to the postprocess
  82282. * @camera the camera to apply the post process to.
  82283. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  82284. */
  82285. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  82286. }
  82287. }
  82288. declare module BABYLON {
  82289. /** @hidden */
  82290. export var digitalrainPixelShader: {
  82291. name: string;
  82292. shader: string;
  82293. };
  82294. }
  82295. declare module BABYLON {
  82296. /**
  82297. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  82298. *
  82299. * It basically takes care rendering the font front the given font size to a texture.
  82300. * This is used later on in the postprocess.
  82301. */
  82302. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  82303. private _font;
  82304. private _text;
  82305. private _charSize;
  82306. /**
  82307. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  82308. */
  82309. get charSize(): number;
  82310. /**
  82311. * Create a new instance of the Digital Rain FontTexture class
  82312. * @param name the name of the texture
  82313. * @param font the font to use, use the W3C CSS notation
  82314. * @param text the caracter set to use in the rendering.
  82315. * @param scene the scene that owns the texture
  82316. */
  82317. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  82318. /**
  82319. * Gets the max char width of a font.
  82320. * @param font the font to use, use the W3C CSS notation
  82321. * @return the max char width
  82322. */
  82323. private getFontWidth;
  82324. /**
  82325. * Gets the max char height of a font.
  82326. * @param font the font to use, use the W3C CSS notation
  82327. * @return the max char height
  82328. */
  82329. private getFontHeight;
  82330. /**
  82331. * Clones the current DigitalRainFontTexture.
  82332. * @return the clone of the texture.
  82333. */
  82334. clone(): DigitalRainFontTexture;
  82335. /**
  82336. * Parses a json object representing the texture and returns an instance of it.
  82337. * @param source the source JSON representation
  82338. * @param scene the scene to create the texture for
  82339. * @return the parsed texture
  82340. */
  82341. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  82342. }
  82343. /**
  82344. * Option available in the Digital Rain Post Process.
  82345. */
  82346. export interface IDigitalRainPostProcessOptions {
  82347. /**
  82348. * The font to use following the w3c font definition.
  82349. */
  82350. font?: string;
  82351. /**
  82352. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82353. * This number is defined between 0 and 1;
  82354. */
  82355. mixToTile?: number;
  82356. /**
  82357. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82358. * This number is defined between 0 and 1;
  82359. */
  82360. mixToNormal?: number;
  82361. }
  82362. /**
  82363. * DigitalRainPostProcess helps rendering everithing in digital rain.
  82364. *
  82365. * Simmply add it to your scene and let the nerd that lives in you have fun.
  82366. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  82367. */
  82368. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  82369. /**
  82370. * The font texture used to render the char in the post process.
  82371. */
  82372. private _digitalRainFontTexture;
  82373. /**
  82374. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  82375. * This number is defined between 0 and 1;
  82376. */
  82377. mixToTile: number;
  82378. /**
  82379. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  82380. * This number is defined between 0 and 1;
  82381. */
  82382. mixToNormal: number;
  82383. /**
  82384. * Instantiates a new Digital Rain Post Process.
  82385. * @param name the name to give to the postprocess
  82386. * @camera the camera to apply the post process to.
  82387. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  82388. */
  82389. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  82390. }
  82391. }
  82392. declare module BABYLON {
  82393. /** @hidden */
  82394. export var brickProceduralTexturePixelShader: {
  82395. name: string;
  82396. shader: string;
  82397. };
  82398. }
  82399. declare module BABYLON {
  82400. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  82401. private _numberOfBricksHeight;
  82402. private _numberOfBricksWidth;
  82403. private _jointColor;
  82404. private _brickColor;
  82405. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82406. updateShaderUniforms(): void;
  82407. get numberOfBricksHeight(): number;
  82408. set numberOfBricksHeight(value: number);
  82409. get numberOfBricksWidth(): number;
  82410. set numberOfBricksWidth(value: number);
  82411. get jointColor(): BABYLON.Color3;
  82412. set jointColor(value: BABYLON.Color3);
  82413. get brickColor(): BABYLON.Color3;
  82414. set brickColor(value: BABYLON.Color3);
  82415. /**
  82416. * Serializes this brick procedural texture
  82417. * @returns a serialized brick procedural texture object
  82418. */
  82419. serialize(): any;
  82420. /**
  82421. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  82422. * @param parsedTexture defines parsed texture data
  82423. * @param scene defines the current scene
  82424. * @param rootUrl defines the root URL containing brick procedural texture information
  82425. * @returns a parsed Brick Procedural BABYLON.Texture
  82426. */
  82427. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  82428. }
  82429. }
  82430. declare module BABYLON {
  82431. /** @hidden */
  82432. export var cloudProceduralTexturePixelShader: {
  82433. name: string;
  82434. shader: string;
  82435. };
  82436. }
  82437. declare module BABYLON {
  82438. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  82439. private _skyColor;
  82440. private _cloudColor;
  82441. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82442. updateShaderUniforms(): void;
  82443. get skyColor(): BABYLON.Color4;
  82444. set skyColor(value: BABYLON.Color4);
  82445. get cloudColor(): BABYLON.Color4;
  82446. set cloudColor(value: BABYLON.Color4);
  82447. /**
  82448. * Serializes this cloud procedural texture
  82449. * @returns a serialized cloud procedural texture object
  82450. */
  82451. serialize(): any;
  82452. /**
  82453. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  82454. * @param parsedTexture defines parsed texture data
  82455. * @param scene defines the current scene
  82456. * @param rootUrl defines the root URL containing cloud procedural texture information
  82457. * @returns a parsed Cloud Procedural BABYLON.Texture
  82458. */
  82459. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  82460. }
  82461. }
  82462. declare module BABYLON {
  82463. /** @hidden */
  82464. export var fireProceduralTexturePixelShader: {
  82465. name: string;
  82466. shader: string;
  82467. };
  82468. }
  82469. declare module BABYLON {
  82470. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  82471. private _time;
  82472. private _speed;
  82473. private _autoGenerateTime;
  82474. private _fireColors;
  82475. private _alphaThreshold;
  82476. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82477. updateShaderUniforms(): void;
  82478. render(useCameraPostProcess?: boolean): void;
  82479. static get PurpleFireColors(): BABYLON.Color3[];
  82480. static get GreenFireColors(): BABYLON.Color3[];
  82481. static get RedFireColors(): BABYLON.Color3[];
  82482. static get BlueFireColors(): BABYLON.Color3[];
  82483. get autoGenerateTime(): boolean;
  82484. set autoGenerateTime(value: boolean);
  82485. get fireColors(): BABYLON.Color3[];
  82486. set fireColors(value: BABYLON.Color3[]);
  82487. get time(): number;
  82488. set time(value: number);
  82489. get speed(): BABYLON.Vector2;
  82490. set speed(value: BABYLON.Vector2);
  82491. get alphaThreshold(): number;
  82492. set alphaThreshold(value: number);
  82493. /**
  82494. * Serializes this fire procedural texture
  82495. * @returns a serialized fire procedural texture object
  82496. */
  82497. serialize(): any;
  82498. /**
  82499. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  82500. * @param parsedTexture defines parsed texture data
  82501. * @param scene defines the current scene
  82502. * @param rootUrl defines the root URL containing fire procedural texture information
  82503. * @returns a parsed Fire Procedural BABYLON.Texture
  82504. */
  82505. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  82506. }
  82507. }
  82508. declare module BABYLON {
  82509. /** @hidden */
  82510. export var grassProceduralTexturePixelShader: {
  82511. name: string;
  82512. shader: string;
  82513. };
  82514. }
  82515. declare module BABYLON {
  82516. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  82517. private _grassColors;
  82518. private _groundColor;
  82519. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82520. updateShaderUniforms(): void;
  82521. get grassColors(): BABYLON.Color3[];
  82522. set grassColors(value: BABYLON.Color3[]);
  82523. get groundColor(): BABYLON.Color3;
  82524. set groundColor(value: BABYLON.Color3);
  82525. /**
  82526. * Serializes this grass procedural texture
  82527. * @returns a serialized grass procedural texture object
  82528. */
  82529. serialize(): any;
  82530. /**
  82531. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  82532. * @param parsedTexture defines parsed texture data
  82533. * @param scene defines the current scene
  82534. * @param rootUrl defines the root URL containing grass procedural texture information
  82535. * @returns a parsed Grass Procedural BABYLON.Texture
  82536. */
  82537. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  82538. }
  82539. }
  82540. declare module BABYLON {
  82541. /** @hidden */
  82542. export var marbleProceduralTexturePixelShader: {
  82543. name: string;
  82544. shader: string;
  82545. };
  82546. }
  82547. declare module BABYLON {
  82548. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  82549. private _numberOfTilesHeight;
  82550. private _numberOfTilesWidth;
  82551. private _amplitude;
  82552. private _jointColor;
  82553. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82554. updateShaderUniforms(): void;
  82555. get numberOfTilesHeight(): number;
  82556. set numberOfTilesHeight(value: number);
  82557. get amplitude(): number;
  82558. set amplitude(value: number);
  82559. get numberOfTilesWidth(): number;
  82560. set numberOfTilesWidth(value: number);
  82561. get jointColor(): BABYLON.Color3;
  82562. set jointColor(value: BABYLON.Color3);
  82563. /**
  82564. * Serializes this marble procedural texture
  82565. * @returns a serialized marble procedural texture object
  82566. */
  82567. serialize(): any;
  82568. /**
  82569. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  82570. * @param parsedTexture defines parsed texture data
  82571. * @param scene defines the current scene
  82572. * @param rootUrl defines the root URL containing marble procedural texture information
  82573. * @returns a parsed Marble Procedural BABYLON.Texture
  82574. */
  82575. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  82576. }
  82577. }
  82578. declare module BABYLON {
  82579. /** @hidden */
  82580. export var normalMapProceduralTexturePixelShader: {
  82581. name: string;
  82582. shader: string;
  82583. };
  82584. }
  82585. declare module BABYLON {
  82586. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  82587. private _baseTexture;
  82588. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82589. updateShaderUniforms(): void;
  82590. render(useCameraPostProcess?: boolean): void;
  82591. resize(size: any, generateMipMaps: any): void;
  82592. get baseTexture(): BABYLON.Texture;
  82593. set baseTexture(texture: BABYLON.Texture);
  82594. /**
  82595. * Serializes this normal map procedural texture
  82596. * @returns a serialized normal map procedural texture object
  82597. */
  82598. serialize(): any;
  82599. /**
  82600. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  82601. * @param parsedTexture defines parsed texture data
  82602. * @param scene defines the current scene
  82603. * @param rootUrl defines the root URL containing normal map procedural texture information
  82604. * @returns a parsed Normal Map Procedural BABYLON.Texture
  82605. */
  82606. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  82607. }
  82608. }
  82609. declare module BABYLON {
  82610. /** @hidden */
  82611. export var perlinNoiseProceduralTexturePixelShader: {
  82612. name: string;
  82613. shader: string;
  82614. };
  82615. }
  82616. declare module BABYLON {
  82617. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  82618. time: number;
  82619. timeScale: number;
  82620. translationSpeed: number;
  82621. private _currentTranslation;
  82622. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82623. updateShaderUniforms(): void;
  82624. render(useCameraPostProcess?: boolean): void;
  82625. resize(size: any, generateMipMaps: any): void;
  82626. /**
  82627. * Serializes this perlin noise procedural texture
  82628. * @returns a serialized perlin noise procedural texture object
  82629. */
  82630. serialize(): any;
  82631. /**
  82632. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  82633. * @param parsedTexture defines parsed texture data
  82634. * @param scene defines the current scene
  82635. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  82636. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  82637. */
  82638. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  82639. }
  82640. }
  82641. declare module BABYLON {
  82642. /** @hidden */
  82643. export var roadProceduralTexturePixelShader: {
  82644. name: string;
  82645. shader: string;
  82646. };
  82647. }
  82648. declare module BABYLON {
  82649. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  82650. private _roadColor;
  82651. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82652. updateShaderUniforms(): void;
  82653. get roadColor(): BABYLON.Color3;
  82654. set roadColor(value: BABYLON.Color3);
  82655. /**
  82656. * Serializes this road procedural texture
  82657. * @returns a serialized road procedural texture object
  82658. */
  82659. serialize(): any;
  82660. /**
  82661. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  82662. * @param parsedTexture defines parsed texture data
  82663. * @param scene defines the current scene
  82664. * @param rootUrl defines the root URL containing road procedural texture information
  82665. * @returns a parsed Road Procedural BABYLON.Texture
  82666. */
  82667. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  82668. }
  82669. }
  82670. declare module BABYLON {
  82671. /** @hidden */
  82672. export var starfieldProceduralTexturePixelShader: {
  82673. name: string;
  82674. shader: string;
  82675. };
  82676. }
  82677. declare module BABYLON {
  82678. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  82679. private _time;
  82680. private _alpha;
  82681. private _beta;
  82682. private _zoom;
  82683. private _formuparam;
  82684. private _stepsize;
  82685. private _tile;
  82686. private _brightness;
  82687. private _darkmatter;
  82688. private _distfading;
  82689. private _saturation;
  82690. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82691. updateShaderUniforms(): void;
  82692. get time(): number;
  82693. set time(value: number);
  82694. get alpha(): number;
  82695. set alpha(value: number);
  82696. get beta(): number;
  82697. set beta(value: number);
  82698. get formuparam(): number;
  82699. set formuparam(value: number);
  82700. get stepsize(): number;
  82701. set stepsize(value: number);
  82702. get zoom(): number;
  82703. set zoom(value: number);
  82704. get tile(): number;
  82705. set tile(value: number);
  82706. get brightness(): number;
  82707. set brightness(value: number);
  82708. get darkmatter(): number;
  82709. set darkmatter(value: number);
  82710. get distfading(): number;
  82711. set distfading(value: number);
  82712. get saturation(): number;
  82713. set saturation(value: number);
  82714. /**
  82715. * Serializes this starfield procedural texture
  82716. * @returns a serialized starfield procedural texture object
  82717. */
  82718. serialize(): any;
  82719. /**
  82720. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  82721. * @param parsedTexture defines parsed texture data
  82722. * @param scene defines the current scene
  82723. * @param rootUrl defines the root URL containing startfield procedural texture information
  82724. * @returns a parsed Starfield Procedural BABYLON.Texture
  82725. */
  82726. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  82727. }
  82728. }
  82729. declare module BABYLON {
  82730. /** @hidden */
  82731. export var woodProceduralTexturePixelShader: {
  82732. name: string;
  82733. shader: string;
  82734. };
  82735. }
  82736. declare module BABYLON {
  82737. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  82738. private _ampScale;
  82739. private _woodColor;
  82740. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  82741. updateShaderUniforms(): void;
  82742. get ampScale(): number;
  82743. set ampScale(value: number);
  82744. get woodColor(): BABYLON.Color3;
  82745. set woodColor(value: BABYLON.Color3);
  82746. /**
  82747. * Serializes this wood procedural texture
  82748. * @returns a serialized wood procedural texture object
  82749. */
  82750. serialize(): any;
  82751. /**
  82752. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  82753. * @param parsedTexture defines parsed texture data
  82754. * @param scene defines the current scene
  82755. * @param rootUrl defines the root URL containing wood procedural texture information
  82756. * @returns a parsed Wood Procedural BABYLON.Texture
  82757. */
  82758. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  82759. }
  82760. }