documentation.d.ts 3.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249
  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. * Class representing a vector containing 2 coordinates
  1909. */
  1910. export class Vector2 {
  1911. /** defines the first coordinate */
  1912. x: number;
  1913. /** defines the second coordinate */
  1914. y: number;
  1915. /**
  1916. * Creates a new Vector2 from the given x and y coordinates
  1917. * @param x defines the first coordinate
  1918. * @param y defines the second coordinate
  1919. */
  1920. constructor(
  1921. /** defines the first coordinate */
  1922. x?: number,
  1923. /** defines the second coordinate */
  1924. y?: number);
  1925. /**
  1926. * Gets a string with the Vector2 coordinates
  1927. * @returns a string with the Vector2 coordinates
  1928. */
  1929. toString(): string;
  1930. /**
  1931. * Gets class name
  1932. * @returns the string "Vector2"
  1933. */
  1934. getClassName(): string;
  1935. /**
  1936. * Gets current vector hash code
  1937. * @returns the Vector2 hash code as a number
  1938. */
  1939. getHashCode(): number;
  1940. /**
  1941. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1942. * @param array defines the source array
  1943. * @param index defines the offset in source array
  1944. * @returns the current Vector2
  1945. */
  1946. toArray(array: FloatArray, index?: number): Vector2;
  1947. /**
  1948. * Copy the current vector to an array
  1949. * @returns a new array with 2 elements: the Vector2 coordinates.
  1950. */
  1951. asArray(): number[];
  1952. /**
  1953. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1954. * @param source defines the source Vector2
  1955. * @returns the current updated Vector2
  1956. */
  1957. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1958. /**
  1959. * Sets the Vector2 coordinates with the given floats
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. * @returns the current updated Vector2
  1963. */
  1964. copyFromFloats(x: number, y: number): Vector2;
  1965. /**
  1966. * Sets the Vector2 coordinates with the given floats
  1967. * @param x defines the first coordinate
  1968. * @param y defines the second coordinate
  1969. * @returns the current updated Vector2
  1970. */
  1971. set(x: number, y: number): Vector2;
  1972. /**
  1973. * Add another vector with the current one
  1974. * @param otherVector defines the other vector
  1975. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1976. */
  1977. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1978. /**
  1979. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1980. * @param otherVector defines the other vector
  1981. * @param result defines the target vector
  1982. * @returns the unmodified current Vector2
  1983. */
  1984. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1985. /**
  1986. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1987. * @param otherVector defines the other vector
  1988. * @returns the current updated Vector2
  1989. */
  1990. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1993. * @param otherVector defines the other vector
  1994. * @returns a new Vector2
  1995. */
  1996. addVector3(otherVector: Vector3): Vector2;
  1997. /**
  1998. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1999. * @param otherVector defines the other vector
  2000. * @returns a new Vector2
  2001. */
  2002. subtract(otherVector: Vector2): Vector2;
  2003. /**
  2004. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2005. * @param otherVector defines the other vector
  2006. * @param result defines the target vector
  2007. * @returns the unmodified current Vector2
  2008. */
  2009. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2010. /**
  2011. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2012. * @param otherVector defines the other vector
  2013. * @returns the current updated Vector2
  2014. */
  2015. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2016. /**
  2017. * Multiplies in place the current Vector2 coordinates by the given ones
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2028. /**
  2029. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2030. * @param otherVector defines the other vector
  2031. * @param result defines the target vector
  2032. * @returns the unmodified current Vector2
  2033. */
  2034. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2035. /**
  2036. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2037. * @param x defines the first coordinate
  2038. * @param y defines the second coordinate
  2039. * @returns a new Vector2
  2040. */
  2041. multiplyByFloats(x: number, y: number): Vector2;
  2042. /**
  2043. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2044. * @param otherVector defines the other vector
  2045. * @returns a new Vector2
  2046. */
  2047. divide(otherVector: Vector2): Vector2;
  2048. /**
  2049. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2050. * @param otherVector defines the other vector
  2051. * @param result defines the target vector
  2052. * @returns the unmodified current Vector2
  2053. */
  2054. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2055. /**
  2056. * Divides the current Vector2 coordinates by the given ones
  2057. * @param otherVector defines the other vector
  2058. * @returns the current updated Vector2
  2059. */
  2060. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2061. /**
  2062. * Gets a new Vector2 with current Vector2 negated coordinates
  2063. * @returns a new Vector2
  2064. */
  2065. negate(): Vector2;
  2066. /**
  2067. * Negate this vector in place
  2068. * @returns this
  2069. */
  2070. negateInPlace(): Vector2;
  2071. /**
  2072. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2073. * @param result defines the Vector3 object where to store the result
  2074. * @returns the current Vector2
  2075. */
  2076. negateToRef(result: Vector2): Vector2;
  2077. /**
  2078. * Multiply the Vector2 coordinates by scale
  2079. * @param scale defines the scaling factor
  2080. * @returns the current updated Vector2
  2081. */
  2082. scaleInPlace(scale: number): Vector2;
  2083. /**
  2084. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2085. * @param scale defines the scaling factor
  2086. * @returns a new Vector2
  2087. */
  2088. scale(scale: number): Vector2;
  2089. /**
  2090. * Scale the current Vector2 values by a factor to a given Vector2
  2091. * @param scale defines the scale factor
  2092. * @param result defines the Vector2 object where to store the result
  2093. * @returns the unmodified current Vector2
  2094. */
  2095. scaleToRef(scale: number, result: Vector2): Vector2;
  2096. /**
  2097. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2098. * @param scale defines the scale factor
  2099. * @param result defines the Vector2 object where to store the result
  2100. * @returns the unmodified current Vector2
  2101. */
  2102. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2103. /**
  2104. * Gets a boolean if two vectors are equals
  2105. * @param otherVector defines the other vector
  2106. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2107. */
  2108. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2109. /**
  2110. * Gets a boolean if two vectors are equals (using an epsilon value)
  2111. * @param otherVector defines the other vector
  2112. * @param epsilon defines the minimal distance to consider equality
  2113. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2114. */
  2115. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2116. /**
  2117. * Gets a new Vector2 from current Vector2 floored values
  2118. * @returns a new Vector2
  2119. */
  2120. floor(): Vector2;
  2121. /**
  2122. * Gets a new Vector2 from current Vector2 floored values
  2123. * @returns a new Vector2
  2124. */
  2125. fract(): Vector2;
  2126. /**
  2127. * Gets the length of the vector
  2128. * @returns the vector length (float)
  2129. */
  2130. length(): number;
  2131. /**
  2132. * Gets the vector squared length
  2133. * @returns the vector squared length (float)
  2134. */
  2135. lengthSquared(): number;
  2136. /**
  2137. * Normalize the vector
  2138. * @returns the current updated Vector2
  2139. */
  2140. normalize(): Vector2;
  2141. /**
  2142. * Gets a new Vector2 copied from the Vector2
  2143. * @returns a new Vector2
  2144. */
  2145. clone(): Vector2;
  2146. /**
  2147. * Gets a new Vector2(0, 0)
  2148. * @returns a new Vector2
  2149. */
  2150. static Zero(): Vector2;
  2151. /**
  2152. * Gets a new Vector2(1, 1)
  2153. * @returns a new Vector2
  2154. */
  2155. static One(): Vector2;
  2156. /**
  2157. * Gets a new Vector2 set from the given index element of the given array
  2158. * @param array defines the data source
  2159. * @param offset defines the offset in the data source
  2160. * @returns a new Vector2
  2161. */
  2162. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2163. /**
  2164. * Sets "result" from the given index element of the given array
  2165. * @param array defines the data source
  2166. * @param offset defines the offset in the data source
  2167. * @param result defines the target vector
  2168. */
  2169. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2170. /**
  2171. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2172. * @param value1 defines 1st point of control
  2173. * @param value2 defines 2nd point of control
  2174. * @param value3 defines 3rd point of control
  2175. * @param value4 defines 4th point of control
  2176. * @param amount defines the interpolation factor
  2177. * @returns a new Vector2
  2178. */
  2179. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2180. /**
  2181. * 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".
  2182. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2183. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2184. * @param value defines the value to clamp
  2185. * @param min defines the lower limit
  2186. * @param max defines the upper limit
  2187. * @returns a new Vector2
  2188. */
  2189. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2192. * @param value1 defines the 1st control point
  2193. * @param tangent1 defines the outgoing tangent
  2194. * @param value2 defines the 2nd control point
  2195. * @param tangent2 defines the incoming tangent
  2196. * @param amount defines the interpolation factor
  2197. * @returns a new Vector2
  2198. */
  2199. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2200. /**
  2201. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2202. * @param start defines the start vector
  2203. * @param end defines the end vector
  2204. * @param amount defines the interpolation factor
  2205. * @returns a new Vector2
  2206. */
  2207. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2208. /**
  2209. * Gets the dot product of the vector "left" and the vector "right"
  2210. * @param left defines first vector
  2211. * @param right defines second vector
  2212. * @returns the dot product (float)
  2213. */
  2214. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2215. /**
  2216. * Returns a new Vector2 equal to the normalized given vector
  2217. * @param vector defines the vector to normalize
  2218. * @returns a new Vector2
  2219. */
  2220. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2223. * @param left defines 1st vector
  2224. * @param right defines 2nd vector
  2225. * @returns a new Vector2
  2226. */
  2227. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2228. /**
  2229. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2230. * @param left defines 1st vector
  2231. * @param right defines 2nd vector
  2232. * @returns a new Vector2
  2233. */
  2234. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2235. /**
  2236. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2237. * @param vector defines the vector to transform
  2238. * @param transformation defines the matrix to apply
  2239. * @returns a new Vector2
  2240. */
  2241. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2242. /**
  2243. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2244. * @param vector defines the vector to transform
  2245. * @param transformation defines the matrix to apply
  2246. * @param result defines the target vector
  2247. */
  2248. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2249. /**
  2250. * Determines if a given vector is included in a triangle
  2251. * @param p defines the vector to test
  2252. * @param p0 defines 1st triangle point
  2253. * @param p1 defines 2nd triangle point
  2254. * @param p2 defines 3rd triangle point
  2255. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2256. */
  2257. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2258. /**
  2259. * Gets the distance between the vectors "value1" and "value2"
  2260. * @param value1 defines first vector
  2261. * @param value2 defines second vector
  2262. * @returns the distance between vectors
  2263. */
  2264. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2265. /**
  2266. * Returns the squared distance between the vectors "value1" and "value2"
  2267. * @param value1 defines first vector
  2268. * @param value2 defines second vector
  2269. * @returns the squared distance between vectors
  2270. */
  2271. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2272. /**
  2273. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2274. * @param value1 defines first vector
  2275. * @param value2 defines second vector
  2276. * @returns a new Vector2
  2277. */
  2278. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2279. /**
  2280. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2281. * @param p defines the middle point
  2282. * @param segA defines one point of the segment
  2283. * @param segB defines the other point of the segment
  2284. * @returns the shortest distance
  2285. */
  2286. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2287. }
  2288. /**
  2289. * Class used to store (x,y,z) vector representation
  2290. * A Vector3 is the main object used in 3D geometry
  2291. * It can represent etiher the coordinates of a point the space, either a direction
  2292. * Reminder: js uses a left handed forward facing system
  2293. */
  2294. export class Vector3 {
  2295. /**
  2296. * Defines the first coordinates (on X axis)
  2297. */
  2298. x: number;
  2299. /**
  2300. * Defines the second coordinates (on Y axis)
  2301. */
  2302. y: number;
  2303. /**
  2304. * Defines the third coordinates (on Z axis)
  2305. */
  2306. z: number;
  2307. private static _UpReadOnly;
  2308. private static _ZeroReadOnly;
  2309. /**
  2310. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2311. * @param x defines the first coordinates (on X axis)
  2312. * @param y defines the second coordinates (on Y axis)
  2313. * @param z defines the third coordinates (on Z axis)
  2314. */
  2315. constructor(
  2316. /**
  2317. * Defines the first coordinates (on X axis)
  2318. */
  2319. x?: number,
  2320. /**
  2321. * Defines the second coordinates (on Y axis)
  2322. */
  2323. y?: number,
  2324. /**
  2325. * Defines the third coordinates (on Z axis)
  2326. */
  2327. z?: number);
  2328. /**
  2329. * Creates a string representation of the Vector3
  2330. * @returns a string with the Vector3 coordinates.
  2331. */
  2332. toString(): string;
  2333. /**
  2334. * Gets the class name
  2335. * @returns the string "Vector3"
  2336. */
  2337. getClassName(): string;
  2338. /**
  2339. * Creates the Vector3 hash code
  2340. * @returns a number which tends to be unique between Vector3 instances
  2341. */
  2342. getHashCode(): number;
  2343. /**
  2344. * Creates an array containing three elements : the coordinates of the Vector3
  2345. * @returns a new array of numbers
  2346. */
  2347. asArray(): number[];
  2348. /**
  2349. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2350. * @param array defines the destination array
  2351. * @param index defines the offset in the destination array
  2352. * @returns the current Vector3
  2353. */
  2354. toArray(array: FloatArray, index?: number): Vector3;
  2355. /**
  2356. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2357. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2358. */
  2359. toQuaternion(): Quaternion;
  2360. /**
  2361. * Adds the given vector to the current Vector3
  2362. * @param otherVector defines the second operand
  2363. * @returns the current updated Vector3
  2364. */
  2365. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2366. /**
  2367. * Adds the given coordinates to the current Vector3
  2368. * @param x defines the x coordinate of the operand
  2369. * @param y defines the y coordinate of the operand
  2370. * @param z defines the z coordinate of the operand
  2371. * @returns the current updated Vector3
  2372. */
  2373. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2374. /**
  2375. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2376. * @param otherVector defines the second operand
  2377. * @returns the resulting Vector3
  2378. */
  2379. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2380. /**
  2381. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2382. * @param otherVector defines the second operand
  2383. * @param result defines the Vector3 object where to store the result
  2384. * @returns the current Vector3
  2385. */
  2386. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2387. /**
  2388. * Subtract the given vector from the current Vector3
  2389. * @param otherVector defines the second operand
  2390. * @returns the current updated Vector3
  2391. */
  2392. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2395. * @param otherVector defines the second operand
  2396. * @returns the resulting Vector3
  2397. */
  2398. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2399. /**
  2400. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2401. * @param otherVector defines the second operand
  2402. * @param result defines the Vector3 object where to store the result
  2403. * @returns the current Vector3
  2404. */
  2405. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2406. /**
  2407. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2408. * @param x defines the x coordinate of the operand
  2409. * @param y defines the y coordinate of the operand
  2410. * @param z defines the z coordinate of the operand
  2411. * @returns the resulting Vector3
  2412. */
  2413. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2414. /**
  2415. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2416. * @param x defines the x coordinate of the operand
  2417. * @param y defines the y coordinate of the operand
  2418. * @param z defines the z coordinate of the operand
  2419. * @param result defines the Vector3 object where to store the result
  2420. * @returns the current Vector3
  2421. */
  2422. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2423. /**
  2424. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2425. * @returns a new Vector3
  2426. */
  2427. negate(): Vector3;
  2428. /**
  2429. * Negate this vector in place
  2430. * @returns this
  2431. */
  2432. negateInPlace(): Vector3;
  2433. /**
  2434. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2435. * @param result defines the Vector3 object where to store the result
  2436. * @returns the current Vector3
  2437. */
  2438. negateToRef(result: Vector3): Vector3;
  2439. /**
  2440. * Multiplies the Vector3 coordinates by the float "scale"
  2441. * @param scale defines the multiplier factor
  2442. * @returns the current updated Vector3
  2443. */
  2444. scaleInPlace(scale: number): Vector3;
  2445. /**
  2446. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2447. * @param scale defines the multiplier factor
  2448. * @returns a new Vector3
  2449. */
  2450. scale(scale: number): Vector3;
  2451. /**
  2452. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2453. * @param scale defines the multiplier factor
  2454. * @param result defines the Vector3 object where to store the result
  2455. * @returns the current Vector3
  2456. */
  2457. scaleToRef(scale: number, result: Vector3): Vector3;
  2458. /**
  2459. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2460. * @param scale defines the scale factor
  2461. * @param result defines the Vector3 object where to store the result
  2462. * @returns the unmodified current Vector3
  2463. */
  2464. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2465. /**
  2466. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2467. * @param otherVector defines the second operand
  2468. * @returns true if both vectors are equals
  2469. */
  2470. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2471. /**
  2472. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2473. * @param otherVector defines the second operand
  2474. * @param epsilon defines the minimal distance to define values as equals
  2475. * @returns true if both vectors are distant less than epsilon
  2476. */
  2477. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2478. /**
  2479. * Returns true if the current Vector3 coordinates equals the given floats
  2480. * @param x defines the x coordinate of the operand
  2481. * @param y defines the y coordinate of the operand
  2482. * @param z defines the z coordinate of the operand
  2483. * @returns true if both vectors are equals
  2484. */
  2485. equalsToFloats(x: number, y: number, z: number): boolean;
  2486. /**
  2487. * Multiplies the current Vector3 coordinates by the given ones
  2488. * @param otherVector defines the second operand
  2489. * @returns the current updated Vector3
  2490. */
  2491. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2492. /**
  2493. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2494. * @param otherVector defines the second operand
  2495. * @returns the new Vector3
  2496. */
  2497. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2498. /**
  2499. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2500. * @param otherVector defines the second operand
  2501. * @param result defines the Vector3 object where to store the result
  2502. * @returns the current Vector3
  2503. */
  2504. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2505. /**
  2506. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2507. * @param x defines the x coordinate of the operand
  2508. * @param y defines the y coordinate of the operand
  2509. * @param z defines the z coordinate of the operand
  2510. * @returns the new Vector3
  2511. */
  2512. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2513. /**
  2514. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2515. * @param otherVector defines the second operand
  2516. * @returns the new Vector3
  2517. */
  2518. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2519. /**
  2520. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2521. * @param otherVector defines the second operand
  2522. * @param result defines the Vector3 object where to store the result
  2523. * @returns the current Vector3
  2524. */
  2525. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2526. /**
  2527. * Divides the current Vector3 coordinates by the given ones.
  2528. * @param otherVector defines the second operand
  2529. * @returns the current updated Vector3
  2530. */
  2531. divideInPlace(otherVector: Vector3): Vector3;
  2532. /**
  2533. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2534. * @param other defines the second operand
  2535. * @returns the current updated Vector3
  2536. */
  2537. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2538. /**
  2539. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2540. * @param other defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2554. * @param x defines the x coordinate of the operand
  2555. * @param y defines the y coordinate of the operand
  2556. * @param z defines the z coordinate of the operand
  2557. * @returns the current updated Vector3
  2558. */
  2559. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2560. /**
  2561. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2562. * Check if is non uniform within a certain amount of decimal places to account for this
  2563. * @param epsilon the amount the values can differ
  2564. * @returns if the the vector is non uniform to a certain number of decimal places
  2565. */
  2566. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2567. /**
  2568. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2569. */
  2570. get isNonUniform(): boolean;
  2571. /**
  2572. * Gets a new Vector3 from current Vector3 floored values
  2573. * @returns a new Vector3
  2574. */
  2575. floor(): Vector3;
  2576. /**
  2577. * Gets a new Vector3 from current Vector3 floored values
  2578. * @returns a new Vector3
  2579. */
  2580. fract(): Vector3;
  2581. /**
  2582. * Gets the length of the Vector3
  2583. * @returns the length of the Vector3
  2584. */
  2585. length(): number;
  2586. /**
  2587. * Gets the squared length of the Vector3
  2588. * @returns squared length of the Vector3
  2589. */
  2590. lengthSquared(): number;
  2591. /**
  2592. * Normalize the current Vector3.
  2593. * Please note that this is an in place operation.
  2594. * @returns the current updated Vector3
  2595. */
  2596. normalize(): Vector3;
  2597. /**
  2598. * Reorders the x y z properties of the vector in place
  2599. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2600. * @returns the current updated vector
  2601. */
  2602. reorderInPlace(order: string): this;
  2603. /**
  2604. * Rotates the vector around 0,0,0 by a quaternion
  2605. * @param quaternion the rotation quaternion
  2606. * @param result vector to store the result
  2607. * @returns the resulting vector
  2608. */
  2609. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2610. /**
  2611. * Rotates a vector around a given point
  2612. * @param quaternion the rotation quaternion
  2613. * @param point the point to rotate around
  2614. * @param result vector to store the result
  2615. * @returns the resulting vector
  2616. */
  2617. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2618. /**
  2619. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2620. * The cross product is then orthogonal to both current and "other"
  2621. * @param other defines the right operand
  2622. * @returns the cross product
  2623. */
  2624. cross(other: Vector3): Vector3;
  2625. /**
  2626. * Normalize the current Vector3 with the given input length.
  2627. * Please note that this is an in place operation.
  2628. * @param len the length of the vector
  2629. * @returns the current updated Vector3
  2630. */
  2631. normalizeFromLength(len: number): Vector3;
  2632. /**
  2633. * Normalize the current Vector3 to a new vector
  2634. * @returns the new Vector3
  2635. */
  2636. normalizeToNew(): Vector3;
  2637. /**
  2638. * Normalize the current Vector3 to the reference
  2639. * @param reference define the Vector3 to update
  2640. * @returns the updated Vector3
  2641. */
  2642. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2643. /**
  2644. * Creates a new Vector3 copied from the current Vector3
  2645. * @returns the new Vector3
  2646. */
  2647. clone(): Vector3;
  2648. /**
  2649. * Copies the given vector coordinates to the current Vector3 ones
  2650. * @param source defines the source Vector3
  2651. * @returns the current updated Vector3
  2652. */
  2653. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2654. /**
  2655. * Copies the given floats to the current Vector3 coordinates
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns the current updated Vector3
  2660. */
  2661. copyFromFloats(x: number, y: number, z: number): Vector3;
  2662. /**
  2663. * Copies the given floats to the current Vector3 coordinates
  2664. * @param x defines the x coordinate of the operand
  2665. * @param y defines the y coordinate of the operand
  2666. * @param z defines the z coordinate of the operand
  2667. * @returns the current updated Vector3
  2668. */
  2669. set(x: number, y: number, z: number): Vector3;
  2670. /**
  2671. * Copies the given float to the current Vector3 coordinates
  2672. * @param v defines the x, y and z coordinates of the operand
  2673. * @returns the current updated Vector3
  2674. */
  2675. setAll(v: number): Vector3;
  2676. /**
  2677. * Get the clip factor between two vectors
  2678. * @param vector0 defines the first operand
  2679. * @param vector1 defines the second operand
  2680. * @param axis defines the axis to use
  2681. * @param size defines the size along the axis
  2682. * @returns the clip factor
  2683. */
  2684. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2685. /**
  2686. * Get angle between two vectors
  2687. * @param vector0 angle between vector0 and vector1
  2688. * @param vector1 angle between vector0 and vector1
  2689. * @param normal direction of the normal
  2690. * @return the angle between vector0 and vector1
  2691. */
  2692. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2693. /**
  2694. * Returns a new Vector3 set from the index "offset" of the given array
  2695. * @param array defines the source array
  2696. * @param offset defines the offset in the source array
  2697. * @returns the new Vector3
  2698. */
  2699. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2700. /**
  2701. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2702. * @param array defines the source array
  2703. * @param offset defines the offset in the source array
  2704. * @returns the new Vector3
  2705. * @deprecated Please use FromArray instead.
  2706. */
  2707. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2708. /**
  2709. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2710. * @param array defines the source array
  2711. * @param offset defines the offset in the source array
  2712. * @param result defines the Vector3 where to store the result
  2713. */
  2714. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2715. /**
  2716. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2717. * @param array defines the source array
  2718. * @param offset defines the offset in the source array
  2719. * @param result defines the Vector3 where to store the result
  2720. * @deprecated Please use FromArrayToRef instead.
  2721. */
  2722. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2723. /**
  2724. * Sets the given vector "result" with the given floats.
  2725. * @param x defines the x coordinate of the source
  2726. * @param y defines the y coordinate of the source
  2727. * @param z defines the z coordinate of the source
  2728. * @param result defines the Vector3 where to store the result
  2729. */
  2730. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2731. /**
  2732. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2733. * @returns a new empty Vector3
  2734. */
  2735. static Zero(): Vector3;
  2736. /**
  2737. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2738. * @returns a new unit Vector3
  2739. */
  2740. static One(): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2743. * @returns a new up Vector3
  2744. */
  2745. static Up(): Vector3;
  2746. /**
  2747. * Gets a up Vector3 that must not be updated
  2748. */
  2749. static get UpReadOnly(): DeepImmutable<Vector3>;
  2750. /**
  2751. * Gets a zero Vector3 that must not be updated
  2752. */
  2753. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2756. * @returns a new down Vector3
  2757. */
  2758. static Down(): Vector3;
  2759. /**
  2760. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2761. * @returns a new forward Vector3
  2762. */
  2763. static Forward(): Vector3;
  2764. /**
  2765. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2766. * @returns a new forward Vector3
  2767. */
  2768. static Backward(): Vector3;
  2769. /**
  2770. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2771. * @returns a new right Vector3
  2772. */
  2773. static Right(): Vector3;
  2774. /**
  2775. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2776. * @returns a new left Vector3
  2777. */
  2778. static Left(): Vector3;
  2779. /**
  2780. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2781. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2782. * @param vector defines the Vector3 to transform
  2783. * @param transformation defines the transformation matrix
  2784. * @returns the transformed Vector3
  2785. */
  2786. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2787. /**
  2788. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2789. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2790. * @param vector defines the Vector3 to transform
  2791. * @param transformation defines the transformation matrix
  2792. * @param result defines the Vector3 where to store the result
  2793. */
  2794. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2795. /**
  2796. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2797. * This method computes tranformed coordinates only, not transformed direction vectors
  2798. * @param x define the x coordinate of the source vector
  2799. * @param y define the y coordinate of the source vector
  2800. * @param z define the z coordinate of the source vector
  2801. * @param transformation defines the transformation matrix
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2807. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the new Vector3
  2811. */
  2812. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2815. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2823. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2833. * @param value1 defines the first control point
  2834. * @param value2 defines the second control point
  2835. * @param value3 defines the third control point
  2836. * @param value4 defines the fourth control point
  2837. * @param amount defines the amount on the spline to use
  2838. * @returns the new Vector3
  2839. */
  2840. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2841. /**
  2842. * 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"
  2843. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2844. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2845. * @param value defines the current value
  2846. * @param min defines the lower range value
  2847. * @param max defines the upper range value
  2848. * @returns the new Vector3
  2849. */
  2850. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * 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"
  2853. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2854. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2855. * @param value defines the current value
  2856. * @param min defines the lower range value
  2857. * @param max defines the upper range value
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2861. /**
  2862. * Checks if a given vector is inside a specific range
  2863. * @param v defines the vector to test
  2864. * @param min defines the minimum range
  2865. * @param max defines the maximum range
  2866. */
  2867. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2868. /**
  2869. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2870. * @param value1 defines the first control point
  2871. * @param tangent1 defines the first tangent vector
  2872. * @param value2 defines the second control point
  2873. * @param tangent2 defines the second tangent vector
  2874. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2875. * @returns the new Vector3
  2876. */
  2877. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2878. /**
  2879. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2880. * @param start defines the start value
  2881. * @param end defines the end value
  2882. * @param amount max defines amount between both (between 0 and 1)
  2883. * @returns the new Vector3
  2884. */
  2885. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2886. /**
  2887. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2888. * @param start defines the start value
  2889. * @param end defines the end value
  2890. * @param amount max defines amount between both (between 0 and 1)
  2891. * @param result defines the Vector3 where to store the result
  2892. */
  2893. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2894. /**
  2895. * Returns the dot product (float) between the vectors "left" and "right"
  2896. * @param left defines the left operand
  2897. * @param right defines the right operand
  2898. * @returns the dot product
  2899. */
  2900. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2901. /**
  2902. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2903. * The cross product is then orthogonal to both "left" and "right"
  2904. * @param left defines the left operand
  2905. * @param right defines the right operand
  2906. * @returns the cross product
  2907. */
  2908. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2909. /**
  2910. * Sets the given vector "result" with the cross product of "left" and "right"
  2911. * The cross product is then orthogonal to both "left" and "right"
  2912. * @param left defines the left operand
  2913. * @param right defines the right operand
  2914. * @param result defines the Vector3 where to store the result
  2915. */
  2916. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2917. /**
  2918. * Returns a new Vector3 as the normalization of the given vector
  2919. * @param vector defines the Vector3 to normalize
  2920. * @returns the new Vector3
  2921. */
  2922. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2923. /**
  2924. * Sets the given vector "result" with the normalization of the given first vector
  2925. * @param vector defines the Vector3 to normalize
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2929. /**
  2930. * Project a Vector3 onto screen space
  2931. * @param vector defines the Vector3 to project
  2932. * @param world defines the world matrix to use
  2933. * @param transform defines the transform (view x projection) matrix to use
  2934. * @param viewport defines the screen viewport to use
  2935. * @returns the new Vector3
  2936. */
  2937. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2938. /** @hidden */
  2939. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2940. /**
  2941. * Unproject from screen space to object space
  2942. * @param source defines the screen space Vector3 to use
  2943. * @param viewportWidth defines the current width of the viewport
  2944. * @param viewportHeight defines the current height of the viewport
  2945. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @returns the new Vector3
  2948. */
  2949. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2950. /**
  2951. * Unproject from screen space to object space
  2952. * @param source defines the screen space Vector3 to use
  2953. * @param viewportWidth defines the current width of the viewport
  2954. * @param viewportHeight defines the current height of the viewport
  2955. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2956. * @param view defines the view matrix to use
  2957. * @param projection defines the projection matrix to use
  2958. * @returns the new Vector3
  2959. */
  2960. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2961. /**
  2962. * Unproject from screen space to object space
  2963. * @param source defines the screen space Vector3 to use
  2964. * @param viewportWidth defines the current width of the viewport
  2965. * @param viewportHeight defines the current height of the viewport
  2966. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2967. * @param view defines the view matrix to use
  2968. * @param projection defines the projection matrix to use
  2969. * @param result defines the Vector3 where to store the result
  2970. */
  2971. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2972. /**
  2973. * Unproject from screen space to object space
  2974. * @param sourceX defines the screen space x coordinate to use
  2975. * @param sourceY defines the screen space y coordinate to use
  2976. * @param sourceZ defines the screen space z coordinate to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Gets the minimal coordinate values between two Vector3
  2987. * @param left defines the first operand
  2988. * @param right defines the second operand
  2989. * @returns the new Vector3
  2990. */
  2991. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2992. /**
  2993. * Gets the maximal coordinate values between two Vector3
  2994. * @param left defines the first operand
  2995. * @param right defines the second operand
  2996. * @returns the new Vector3
  2997. */
  2998. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2999. /**
  3000. * Returns the distance between the vectors "value1" and "value2"
  3001. * @param value1 defines the first operand
  3002. * @param value2 defines the second operand
  3003. * @returns the distance
  3004. */
  3005. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3006. /**
  3007. * Returns the squared distance between the vectors "value1" and "value2"
  3008. * @param value1 defines the first operand
  3009. * @param value2 defines the second operand
  3010. * @returns the squared distance
  3011. */
  3012. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3013. /**
  3014. * Returns a new Vector3 located at the center between "value1" and "value2"
  3015. * @param value1 defines the first operand
  3016. * @param value2 defines the second operand
  3017. * @returns the new Vector3
  3018. */
  3019. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3020. /**
  3021. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3022. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3023. * to something in order to rotate it from its local system to the given target system
  3024. * Note: axis1, axis2 and axis3 are normalized during this operation
  3025. * @param axis1 defines the first axis
  3026. * @param axis2 defines the second axis
  3027. * @param axis3 defines the third axis
  3028. * @returns a new Vector3
  3029. */
  3030. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3031. /**
  3032. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3033. * @param axis1 defines the first axis
  3034. * @param axis2 defines the second axis
  3035. * @param axis3 defines the third axis
  3036. * @param ref defines the Vector3 where to store the result
  3037. */
  3038. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3039. }
  3040. /**
  3041. * Vector4 class created for EulerAngle class conversion to Quaternion
  3042. */
  3043. export class Vector4 {
  3044. /** x value of the vector */
  3045. x: number;
  3046. /** y value of the vector */
  3047. y: number;
  3048. /** z value of the vector */
  3049. z: number;
  3050. /** w value of the vector */
  3051. w: number;
  3052. /**
  3053. * Creates a Vector4 object from the given floats.
  3054. * @param x x value of the vector
  3055. * @param y y value of the vector
  3056. * @param z z value of the vector
  3057. * @param w w value of the vector
  3058. */
  3059. constructor(
  3060. /** x value of the vector */
  3061. x: number,
  3062. /** y value of the vector */
  3063. y: number,
  3064. /** z value of the vector */
  3065. z: number,
  3066. /** w value of the vector */
  3067. w: number);
  3068. /**
  3069. * Returns the string with the Vector4 coordinates.
  3070. * @returns a string containing all the vector values
  3071. */
  3072. toString(): string;
  3073. /**
  3074. * Returns the string "Vector4".
  3075. * @returns "Vector4"
  3076. */
  3077. getClassName(): string;
  3078. /**
  3079. * Returns the Vector4 hash code.
  3080. * @returns a unique hash code
  3081. */
  3082. getHashCode(): number;
  3083. /**
  3084. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3085. * @returns the resulting array
  3086. */
  3087. asArray(): number[];
  3088. /**
  3089. * Populates the given array from the given index with the Vector4 coordinates.
  3090. * @param array array to populate
  3091. * @param index index of the array to start at (default: 0)
  3092. * @returns the Vector4.
  3093. */
  3094. toArray(array: FloatArray, index?: number): Vector4;
  3095. /**
  3096. * Adds the given vector to the current Vector4.
  3097. * @param otherVector the vector to add
  3098. * @returns the updated Vector4.
  3099. */
  3100. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3101. /**
  3102. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3103. * @param otherVector the vector to add
  3104. * @returns the resulting vector
  3105. */
  3106. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3107. /**
  3108. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3109. * @param otherVector the vector to add
  3110. * @param result the vector to store the result
  3111. * @returns the current Vector4.
  3112. */
  3113. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3114. /**
  3115. * Subtract in place the given vector from the current Vector4.
  3116. * @param otherVector the vector to subtract
  3117. * @returns the updated Vector4.
  3118. */
  3119. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3122. * @param otherVector the vector to add
  3123. * @returns the new vector with the result
  3124. */
  3125. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3126. /**
  3127. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3128. * @param otherVector the vector to subtract
  3129. * @param result the vector to store the result
  3130. * @returns the current Vector4.
  3131. */
  3132. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3133. /**
  3134. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3135. */
  3136. /**
  3137. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3138. * @param x value to subtract
  3139. * @param y value to subtract
  3140. * @param z value to subtract
  3141. * @param w value to subtract
  3142. * @returns new vector containing the result
  3143. */
  3144. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3145. /**
  3146. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3147. * @param x value to subtract
  3148. * @param y value to subtract
  3149. * @param z value to subtract
  3150. * @param w value to subtract
  3151. * @param result the vector to store the result in
  3152. * @returns the current Vector4.
  3153. */
  3154. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3155. /**
  3156. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3157. * @returns a new vector with the negated values
  3158. */
  3159. negate(): Vector4;
  3160. /**
  3161. * Negate this vector in place
  3162. * @returns this
  3163. */
  3164. negateInPlace(): Vector4;
  3165. /**
  3166. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3167. * @param result defines the Vector3 object where to store the result
  3168. * @returns the current Vector4
  3169. */
  3170. negateToRef(result: Vector4): Vector4;
  3171. /**
  3172. * Multiplies the current Vector4 coordinates by scale (float).
  3173. * @param scale the number to scale with
  3174. * @returns the updated Vector4.
  3175. */
  3176. scaleInPlace(scale: number): Vector4;
  3177. /**
  3178. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3179. * @param scale the number to scale with
  3180. * @returns a new vector with the result
  3181. */
  3182. scale(scale: number): Vector4;
  3183. /**
  3184. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3185. * @param scale the number to scale with
  3186. * @param result a vector to store the result in
  3187. * @returns the current Vector4.
  3188. */
  3189. scaleToRef(scale: number, result: Vector4): Vector4;
  3190. /**
  3191. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3192. * @param scale defines the scale factor
  3193. * @param result defines the Vector4 object where to store the result
  3194. * @returns the unmodified current Vector4
  3195. */
  3196. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3197. /**
  3198. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3199. * @param otherVector the vector to compare against
  3200. * @returns true if they are equal
  3201. */
  3202. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3203. /**
  3204. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3205. * @param otherVector vector to compare against
  3206. * @param epsilon (Default: very small number)
  3207. * @returns true if they are equal
  3208. */
  3209. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3210. /**
  3211. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3212. * @param x x value to compare against
  3213. * @param y y value to compare against
  3214. * @param z z value to compare against
  3215. * @param w w value to compare against
  3216. * @returns true if equal
  3217. */
  3218. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3219. /**
  3220. * Multiplies in place the current Vector4 by the given one.
  3221. * @param otherVector vector to multiple with
  3222. * @returns the updated Vector4.
  3223. */
  3224. multiplyInPlace(otherVector: Vector4): Vector4;
  3225. /**
  3226. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3227. * @param otherVector vector to multiple with
  3228. * @returns resulting new vector
  3229. */
  3230. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3231. /**
  3232. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3233. * @param otherVector vector to multiple with
  3234. * @param result vector to store the result
  3235. * @returns the current Vector4.
  3236. */
  3237. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3240. * @param x x value multiply with
  3241. * @param y y value multiply with
  3242. * @param z z value multiply with
  3243. * @param w w value multiply with
  3244. * @returns resulting new vector
  3245. */
  3246. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3247. /**
  3248. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3249. * @param otherVector vector to devide with
  3250. * @returns resulting new vector
  3251. */
  3252. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3253. /**
  3254. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3255. * @param otherVector vector to devide with
  3256. * @param result vector to store the result
  3257. * @returns the current Vector4.
  3258. */
  3259. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3260. /**
  3261. * Divides the current Vector3 coordinates by the given ones.
  3262. * @param otherVector vector to devide with
  3263. * @returns the updated Vector3.
  3264. */
  3265. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3268. * @param other defines the second operand
  3269. * @returns the current updated Vector4
  3270. */
  3271. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3272. /**
  3273. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3274. * @param other defines the second operand
  3275. * @returns the current updated Vector4
  3276. */
  3277. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3278. /**
  3279. * Gets a new Vector4 from current Vector4 floored values
  3280. * @returns a new Vector4
  3281. */
  3282. floor(): Vector4;
  3283. /**
  3284. * Gets a new Vector4 from current Vector3 floored values
  3285. * @returns a new Vector4
  3286. */
  3287. fract(): Vector4;
  3288. /**
  3289. * Returns the Vector4 length (float).
  3290. * @returns the length
  3291. */
  3292. length(): number;
  3293. /**
  3294. * Returns the Vector4 squared length (float).
  3295. * @returns the length squared
  3296. */
  3297. lengthSquared(): number;
  3298. /**
  3299. * Normalizes in place the Vector4.
  3300. * @returns the updated Vector4.
  3301. */
  3302. normalize(): Vector4;
  3303. /**
  3304. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3305. * @returns this converted to a new vector3
  3306. */
  3307. toVector3(): Vector3;
  3308. /**
  3309. * Returns a new Vector4 copied from the current one.
  3310. * @returns the new cloned vector
  3311. */
  3312. clone(): Vector4;
  3313. /**
  3314. * Updates the current Vector4 with the given one coordinates.
  3315. * @param source the source vector to copy from
  3316. * @returns the updated Vector4.
  3317. */
  3318. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3319. /**
  3320. * Updates the current Vector4 coordinates with the given floats.
  3321. * @param x float to copy from
  3322. * @param y float to copy from
  3323. * @param z float to copy from
  3324. * @param w float to copy from
  3325. * @returns the updated Vector4.
  3326. */
  3327. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3328. /**
  3329. * Updates the current Vector4 coordinates with the given floats.
  3330. * @param x float to set from
  3331. * @param y float to set from
  3332. * @param z float to set from
  3333. * @param w float to set from
  3334. * @returns the updated Vector4.
  3335. */
  3336. set(x: number, y: number, z: number, w: number): Vector4;
  3337. /**
  3338. * Copies the given float to the current Vector3 coordinates
  3339. * @param v defines the x, y, z and w coordinates of the operand
  3340. * @returns the current updated Vector3
  3341. */
  3342. setAll(v: number): Vector4;
  3343. /**
  3344. * Returns a new Vector4 set from the starting index of the given array.
  3345. * @param array the array to pull values from
  3346. * @param offset the offset into the array to start at
  3347. * @returns the new vector
  3348. */
  3349. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3350. /**
  3351. * Updates the given vector "result" from the starting index of the given array.
  3352. * @param array the array to pull values from
  3353. * @param offset the offset into the array to start at
  3354. * @param result the vector to store the result in
  3355. */
  3356. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3357. /**
  3358. * Updates the given vector "result" from the starting index of the given Float32Array.
  3359. * @param array the array to pull values from
  3360. * @param offset the offset into the array to start at
  3361. * @param result the vector to store the result in
  3362. */
  3363. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3364. /**
  3365. * Updates the given vector "result" coordinates from the given floats.
  3366. * @param x float to set from
  3367. * @param y float to set from
  3368. * @param z float to set from
  3369. * @param w float to set from
  3370. * @param result the vector to the floats in
  3371. */
  3372. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3373. /**
  3374. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3375. * @returns the new vector
  3376. */
  3377. static Zero(): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3380. * @returns the new vector
  3381. */
  3382. static One(): Vector4;
  3383. /**
  3384. * Returns a new normalized Vector4 from the given one.
  3385. * @param vector the vector to normalize
  3386. * @returns the vector
  3387. */
  3388. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3389. /**
  3390. * Updates the given vector "result" from the normalization of the given one.
  3391. * @param vector the vector to normalize
  3392. * @param result the vector to store the result in
  3393. */
  3394. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3395. /**
  3396. * Returns a vector with the minimum values from the left and right vectors
  3397. * @param left left vector to minimize
  3398. * @param right right vector to minimize
  3399. * @returns a new vector with the minimum of the left and right vector values
  3400. */
  3401. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Returns a vector with the maximum values from the left and right vectors
  3404. * @param left left vector to maximize
  3405. * @param right right vector to maximize
  3406. * @returns a new vector with the maximum of the left and right vector values
  3407. */
  3408. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Returns the distance (float) between the vectors "value1" and "value2".
  3411. * @param value1 value to calulate the distance between
  3412. * @param value2 value to calulate the distance between
  3413. * @return the distance between the two vectors
  3414. */
  3415. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3416. /**
  3417. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3418. * @param value1 value to calulate the distance between
  3419. * @param value2 value to calulate the distance between
  3420. * @return the distance between the two vectors squared
  3421. */
  3422. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3423. /**
  3424. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3425. * @param value1 value to calulate the center between
  3426. * @param value2 value to calulate the center between
  3427. * @return the center between the two vectors
  3428. */
  3429. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3430. /**
  3431. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3432. * This methods computes transformed normalized direction vectors only.
  3433. * @param vector the vector to transform
  3434. * @param transformation the transformation matrix to apply
  3435. * @returns the new vector
  3436. */
  3437. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3438. /**
  3439. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3440. * This methods computes transformed normalized direction vectors only.
  3441. * @param vector the vector to transform
  3442. * @param transformation the transformation matrix to apply
  3443. * @param result the vector to store the result in
  3444. */
  3445. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3446. /**
  3447. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3448. * This methods computes transformed normalized direction vectors only.
  3449. * @param x value to transform
  3450. * @param y value to transform
  3451. * @param z value to transform
  3452. * @param w value to transform
  3453. * @param transformation the transformation matrix to apply
  3454. * @param result the vector to store the results in
  3455. */
  3456. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3457. /**
  3458. * Creates a new Vector4 from a Vector3
  3459. * @param source defines the source data
  3460. * @param w defines the 4th component (default is 0)
  3461. * @returns a new Vector4
  3462. */
  3463. static FromVector3(source: Vector3, w?: number): Vector4;
  3464. }
  3465. /**
  3466. * Class used to store quaternion data
  3467. * @see https://en.wikipedia.org/wiki/Quaternion
  3468. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3469. */
  3470. export class Quaternion {
  3471. /** defines the first component (0 by default) */
  3472. x: number;
  3473. /** defines the second component (0 by default) */
  3474. y: number;
  3475. /** defines the third component (0 by default) */
  3476. z: number;
  3477. /** defines the fourth component (1.0 by default) */
  3478. w: number;
  3479. /**
  3480. * Creates a new Quaternion from the given floats
  3481. * @param x defines the first component (0 by default)
  3482. * @param y defines the second component (0 by default)
  3483. * @param z defines the third component (0 by default)
  3484. * @param w defines the fourth component (1.0 by default)
  3485. */
  3486. constructor(
  3487. /** defines the first component (0 by default) */
  3488. x?: number,
  3489. /** defines the second component (0 by default) */
  3490. y?: number,
  3491. /** defines the third component (0 by default) */
  3492. z?: number,
  3493. /** defines the fourth component (1.0 by default) */
  3494. w?: number);
  3495. /**
  3496. * Gets a string representation for the current quaternion
  3497. * @returns a string with the Quaternion coordinates
  3498. */
  3499. toString(): string;
  3500. /**
  3501. * Gets the class name of the quaternion
  3502. * @returns the string "Quaternion"
  3503. */
  3504. getClassName(): string;
  3505. /**
  3506. * Gets a hash code for this quaternion
  3507. * @returns the quaternion hash code
  3508. */
  3509. getHashCode(): number;
  3510. /**
  3511. * Copy the quaternion to an array
  3512. * @returns a new array populated with 4 elements from the quaternion coordinates
  3513. */
  3514. asArray(): number[];
  3515. /**
  3516. * Check if two quaternions are equals
  3517. * @param otherQuaternion defines the second operand
  3518. * @return true if the current quaternion and the given one coordinates are strictly equals
  3519. */
  3520. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3521. /**
  3522. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3523. * @param otherQuaternion defines the other quaternion
  3524. * @param epsilon defines the minimal distance to consider equality
  3525. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3526. */
  3527. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3528. /**
  3529. * Clone the current quaternion
  3530. * @returns a new quaternion copied from the current one
  3531. */
  3532. clone(): Quaternion;
  3533. /**
  3534. * Copy a quaternion to the current one
  3535. * @param other defines the other quaternion
  3536. * @returns the updated current quaternion
  3537. */
  3538. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3539. /**
  3540. * Updates the current quaternion with the given float coordinates
  3541. * @param x defines the x coordinate
  3542. * @param y defines the y coordinate
  3543. * @param z defines the z coordinate
  3544. * @param w defines the w coordinate
  3545. * @returns the updated current quaternion
  3546. */
  3547. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3548. /**
  3549. * Updates the current quaternion from the given float coordinates
  3550. * @param x defines the x coordinate
  3551. * @param y defines the y coordinate
  3552. * @param z defines the z coordinate
  3553. * @param w defines the w coordinate
  3554. * @returns the updated current quaternion
  3555. */
  3556. set(x: number, y: number, z: number, w: number): Quaternion;
  3557. /**
  3558. * Adds two quaternions
  3559. * @param other defines the second operand
  3560. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3561. */
  3562. add(other: DeepImmutable<Quaternion>): Quaternion;
  3563. /**
  3564. * Add a quaternion to the current one
  3565. * @param other defines the quaternion to add
  3566. * @returns the current quaternion
  3567. */
  3568. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3569. /**
  3570. * Subtract two quaternions
  3571. * @param other defines the second operand
  3572. * @returns a new quaternion as the subtraction result of the given one from the current one
  3573. */
  3574. subtract(other: Quaternion): Quaternion;
  3575. /**
  3576. * Multiplies the current quaternion by a scale factor
  3577. * @param value defines the scale factor
  3578. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3579. */
  3580. scale(value: number): Quaternion;
  3581. /**
  3582. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3583. * @param scale defines the scale factor
  3584. * @param result defines the Quaternion object where to store the result
  3585. * @returns the unmodified current quaternion
  3586. */
  3587. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies in place the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns the current modified quaternion
  3592. */
  3593. scaleInPlace(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies two quaternions
  3603. * @param q1 defines the second operand
  3604. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3605. */
  3606. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3607. /**
  3608. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3609. * @param q1 defines the second operand
  3610. * @param result defines the target quaternion
  3611. * @returns the current quaternion
  3612. */
  3613. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3614. /**
  3615. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3616. * @param q1 defines the second operand
  3617. * @returns the currentupdated quaternion
  3618. */
  3619. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3622. * @param ref defines the target quaternion
  3623. * @returns the current quaternion
  3624. */
  3625. conjugateToRef(ref: Quaternion): Quaternion;
  3626. /**
  3627. * Conjugates in place (1-q) the current quaternion
  3628. * @returns the current updated quaternion
  3629. */
  3630. conjugateInPlace(): Quaternion;
  3631. /**
  3632. * Conjugates in place (1-q) the current quaternion
  3633. * @returns a new quaternion
  3634. */
  3635. conjugate(): Quaternion;
  3636. /**
  3637. * Gets length of current quaternion
  3638. * @returns the quaternion length (float)
  3639. */
  3640. length(): number;
  3641. /**
  3642. * Normalize in place the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. normalize(): Quaternion;
  3646. /**
  3647. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3648. * @param order is a reserved parameter and is ignore for now
  3649. * @returns a new Vector3 containing the Euler angles
  3650. */
  3651. toEulerAngles(order?: string): Vector3;
  3652. /**
  3653. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3654. * @param result defines the vector which will be filled with the Euler angles
  3655. * @param order is a reserved parameter and is ignore for now
  3656. * @returns the current unchanged quaternion
  3657. */
  3658. toEulerAnglesToRef(result: Vector3): Quaternion;
  3659. /**
  3660. * Updates the given rotation matrix with the current quaternion values
  3661. * @param result defines the target matrix
  3662. * @returns the current unchanged quaternion
  3663. */
  3664. toRotationMatrix(result: Matrix): Quaternion;
  3665. /**
  3666. * Updates the current quaternion from the given rotation matrix values
  3667. * @param matrix defines the source matrix
  3668. * @returns the current updated quaternion
  3669. */
  3670. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3671. /**
  3672. * Creates a new quaternion from a rotation matrix
  3673. * @param matrix defines the source matrix
  3674. * @returns a new quaternion created from the given rotation matrix values
  3675. */
  3676. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3677. /**
  3678. * Updates the given quaternion with the given rotation matrix values
  3679. * @param matrix defines the source matrix
  3680. * @param result defines the target quaternion
  3681. */
  3682. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3683. /**
  3684. * Returns the dot product (float) between the quaternions "left" and "right"
  3685. * @param left defines the left operand
  3686. * @param right defines the right operand
  3687. * @returns the dot product
  3688. */
  3689. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3690. /**
  3691. * Checks if the two quaternions are close to each other
  3692. * @param quat0 defines the first quaternion to check
  3693. * @param quat1 defines the second quaternion to check
  3694. * @returns true if the two quaternions are close to each other
  3695. */
  3696. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3697. /**
  3698. * Creates an empty quaternion
  3699. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3700. */
  3701. static Zero(): Quaternion;
  3702. /**
  3703. * Inverse a given quaternion
  3704. * @param q defines the source quaternion
  3705. * @returns a new quaternion as the inverted current quaternion
  3706. */
  3707. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3708. /**
  3709. * Inverse a given quaternion
  3710. * @param q defines the source quaternion
  3711. * @param result the quaternion the result will be stored in
  3712. * @returns the result quaternion
  3713. */
  3714. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3715. /**
  3716. * Creates an identity quaternion
  3717. * @returns the identity quaternion
  3718. */
  3719. static Identity(): Quaternion;
  3720. /**
  3721. * Gets a boolean indicating if the given quaternion is identity
  3722. * @param quaternion defines the quaternion to check
  3723. * @returns true if the quaternion is identity
  3724. */
  3725. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3726. /**
  3727. * Creates a quaternion from a rotation around an axis
  3728. * @param axis defines the axis to use
  3729. * @param angle defines the angle to use
  3730. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3731. */
  3732. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3733. /**
  3734. * Creates a rotation around an axis and stores it into the given quaternion
  3735. * @param axis defines the axis to use
  3736. * @param angle defines the angle to use
  3737. * @param result defines the target quaternion
  3738. * @returns the target quaternion
  3739. */
  3740. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3741. /**
  3742. * Creates a new quaternion from data stored into an array
  3743. * @param array defines the data source
  3744. * @param offset defines the offset in the source array where the data starts
  3745. * @returns a new quaternion
  3746. */
  3747. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3748. /**
  3749. * Updates the given quaternion "result" from the starting index of the given array.
  3750. * @param array the array to pull values from
  3751. * @param offset the offset into the array to start at
  3752. * @param result the quaternion to store the result in
  3753. */
  3754. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3755. /**
  3756. * Create a quaternion from Euler rotation angles
  3757. * @param x Pitch
  3758. * @param y Yaw
  3759. * @param z Roll
  3760. * @returns the new Quaternion
  3761. */
  3762. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3763. /**
  3764. * Updates a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @param result the quaternion to store the result
  3769. * @returns the updated quaternion
  3770. */
  3771. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Create a quaternion from Euler rotation vector
  3774. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3775. * @returns the new Quaternion
  3776. */
  3777. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3778. /**
  3779. * Updates a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @param result the quaternion to store the result
  3782. * @returns the updated quaternion
  3783. */
  3784. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3785. /**
  3786. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3787. * @param yaw defines the rotation around Y axis
  3788. * @param pitch defines the rotation around X axis
  3789. * @param roll defines the rotation around Z axis
  3790. * @returns the new quaternion
  3791. */
  3792. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3793. /**
  3794. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @param result defines the target quaternion
  3799. */
  3800. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3801. /**
  3802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3803. * @param alpha defines the rotation around first axis
  3804. * @param beta defines the rotation around second axis
  3805. * @param gamma defines the rotation around third axis
  3806. * @returns the new quaternion
  3807. */
  3808. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @param result defines the target quaternion
  3815. */
  3816. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3817. /**
  3818. * 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)
  3819. * @param axis1 defines the first axis
  3820. * @param axis2 defines the second axis
  3821. * @param axis3 defines the third axis
  3822. * @returns the new quaternion
  3823. */
  3824. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3825. /**
  3826. * 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
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @param ref defines the target quaternion
  3831. */
  3832. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3833. /**
  3834. * Interpolates between two quaternions
  3835. * @param left defines first quaternion
  3836. * @param right defines second quaternion
  3837. * @param amount defines the gradient to use
  3838. * @returns the new interpolated quaternion
  3839. */
  3840. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3841. /**
  3842. * Interpolates between two quaternions and stores it into a target quaternion
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @param result defines the target quaternion
  3847. */
  3848. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3849. /**
  3850. * Interpolate between two quaternions using Hermite interpolation
  3851. * @param value1 defines first quaternion
  3852. * @param tangent1 defines the incoming tangent
  3853. * @param value2 defines second quaternion
  3854. * @param tangent2 defines the outgoing tangent
  3855. * @param amount defines the target quaternion
  3856. * @returns the new interpolated quaternion
  3857. */
  3858. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3859. }
  3860. /**
  3861. * Class used to store matrix data (4x4)
  3862. */
  3863. export class Matrix {
  3864. private static _updateFlagSeed;
  3865. private static _identityReadOnly;
  3866. private _isIdentity;
  3867. private _isIdentityDirty;
  3868. private _isIdentity3x2;
  3869. private _isIdentity3x2Dirty;
  3870. /**
  3871. * Gets the update flag of the matrix which is an unique number for the matrix.
  3872. * It will be incremented every time the matrix data change.
  3873. * You can use it to speed the comparison between two versions of the same matrix.
  3874. */
  3875. updateFlag: number;
  3876. private readonly _m;
  3877. /**
  3878. * Gets the internal data of the matrix
  3879. */
  3880. get m(): DeepImmutable<Float32Array>;
  3881. /** @hidden */
  3882. _markAsUpdated(): void;
  3883. /** @hidden */
  3884. private _updateIdentityStatus;
  3885. /**
  3886. * Creates an empty matrix (filled with zeros)
  3887. */
  3888. constructor();
  3889. /**
  3890. * Check if the current matrix is identity
  3891. * @returns true is the matrix is the identity matrix
  3892. */
  3893. isIdentity(): boolean;
  3894. /**
  3895. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3896. * @returns true is the matrix is the identity matrix
  3897. */
  3898. isIdentityAs3x2(): boolean;
  3899. /**
  3900. * Gets the determinant of the matrix
  3901. * @returns the matrix determinant
  3902. */
  3903. determinant(): number;
  3904. /**
  3905. * Returns the matrix as a Float32Array
  3906. * @returns the matrix underlying array
  3907. */
  3908. toArray(): DeepImmutable<Float32Array>;
  3909. /**
  3910. * Returns the matrix as a Float32Array
  3911. * @returns the matrix underlying array.
  3912. */
  3913. asArray(): DeepImmutable<Float32Array>;
  3914. /**
  3915. * Inverts the current matrix in place
  3916. * @returns the current inverted matrix
  3917. */
  3918. invert(): Matrix;
  3919. /**
  3920. * Sets all the matrix elements to zero
  3921. * @returns the current matrix
  3922. */
  3923. reset(): Matrix;
  3924. /**
  3925. * Adds the current matrix with a second one
  3926. * @param other defines the matrix to add
  3927. * @returns a new matrix as the addition of the current matrix and the given one
  3928. */
  3929. add(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3932. * @param other defines the matrix to add
  3933. * @param result defines the target matrix
  3934. * @returns the current matrix
  3935. */
  3936. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3937. /**
  3938. * Adds in place the given matrix to the current matrix
  3939. * @param other defines the second operand
  3940. * @returns the current updated matrix
  3941. */
  3942. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3943. /**
  3944. * Sets the given matrix to the current inverted Matrix
  3945. * @param other defines the target matrix
  3946. * @returns the unmodified current matrix
  3947. */
  3948. invertToRef(other: Matrix): Matrix;
  3949. /**
  3950. * add a value at the specified position in the current Matrix
  3951. * @param index the index of the value within the matrix. between 0 and 15.
  3952. * @param value the value to be added
  3953. * @returns the current updated matrix
  3954. */
  3955. addAtIndex(index: number, value: number): Matrix;
  3956. /**
  3957. * mutiply the specified position in the current Matrix by a value
  3958. * @param index the index of the value within the matrix. between 0 and 15.
  3959. * @param value the value to be added
  3960. * @returns the current updated matrix
  3961. */
  3962. multiplyAtIndex(index: number, value: number): Matrix;
  3963. /**
  3964. * Inserts the translation vector (using 3 floats) in the current matrix
  3965. * @param x defines the 1st component of the translation
  3966. * @param y defines the 2nd component of the translation
  3967. * @param z defines the 3rd component of the translation
  3968. * @returns the current updated matrix
  3969. */
  3970. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3971. /**
  3972. * Adds the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Inserts the translation vector in the current matrix
  3981. * @param vector3 defines the translation to insert
  3982. * @returns the current updated matrix
  3983. */
  3984. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3985. /**
  3986. * Gets the translation value of the current matrix
  3987. * @returns a new Vector3 as the extracted translation from the matrix
  3988. */
  3989. getTranslation(): Vector3;
  3990. /**
  3991. * Fill a Vector3 with the extracted translation from the matrix
  3992. * @param result defines the Vector3 where to store the translation
  3993. * @returns the current matrix
  3994. */
  3995. getTranslationToRef(result: Vector3): Matrix;
  3996. /**
  3997. * Remove rotation and scaling part from the matrix
  3998. * @returns the updated matrix
  3999. */
  4000. removeRotationAndScaling(): Matrix;
  4001. /**
  4002. * Multiply two matrices
  4003. * @param other defines the second operand
  4004. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4005. */
  4006. multiply(other: DeepImmutable<Matrix>): Matrix;
  4007. /**
  4008. * Copy the current matrix from the given one
  4009. * @param other defines the source matrix
  4010. * @returns the current updated matrix
  4011. */
  4012. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Populates the given array from the starting index with the current matrix values
  4015. * @param array defines the target array
  4016. * @param offset defines the offset in the target array where to start storing values
  4017. * @returns the current matrix
  4018. */
  4019. copyToArray(array: Float32Array, offset?: number): Matrix;
  4020. /**
  4021. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4022. * @param other defines the second operand
  4023. * @param result defines the matrix where to store the multiplication
  4024. * @returns the current matrix
  4025. */
  4026. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4027. /**
  4028. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4029. * @param other defines the second operand
  4030. * @param result defines the array where to store the multiplication
  4031. * @param offset defines the offset in the target array where to start storing values
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4035. /**
  4036. * Check equality between this matrix and a second one
  4037. * @param value defines the second matrix to compare
  4038. * @returns true is the current matrix and the given one values are strictly equal
  4039. */
  4040. equals(value: DeepImmutable<Matrix>): boolean;
  4041. /**
  4042. * Clone the current matrix
  4043. * @returns a new matrix from the current matrix
  4044. */
  4045. clone(): Matrix;
  4046. /**
  4047. * Returns the name of the current matrix class
  4048. * @returns the string "Matrix"
  4049. */
  4050. getClassName(): string;
  4051. /**
  4052. * Gets the hash code of the current matrix
  4053. * @returns the hash code
  4054. */
  4055. getHashCode(): number;
  4056. /**
  4057. * Decomposes the current Matrix into a translation, rotation and scaling components
  4058. * @param scale defines the scale vector3 given as a reference to update
  4059. * @param rotation defines the rotation quaternion given as a reference to update
  4060. * @param translation defines the translation vector3 given as a reference to update
  4061. * @returns true if operation was successful
  4062. */
  4063. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4064. /**
  4065. * Gets specific row of the matrix
  4066. * @param index defines the number of the row to get
  4067. * @returns the index-th row of the current matrix as a new Vector4
  4068. */
  4069. getRow(index: number): Nullable<Vector4>;
  4070. /**
  4071. * Sets the index-th row of the current matrix to the vector4 values
  4072. * @param index defines the number of the row to set
  4073. * @param row defines the target vector4
  4074. * @returns the updated current matrix
  4075. */
  4076. setRow(index: number, row: Vector4): Matrix;
  4077. /**
  4078. * Compute the transpose of the matrix
  4079. * @returns the new transposed matrix
  4080. */
  4081. transpose(): Matrix;
  4082. /**
  4083. * Compute the transpose of the matrix and store it in a given matrix
  4084. * @param result defines the target matrix
  4085. * @returns the current matrix
  4086. */
  4087. transposeToRef(result: Matrix): Matrix;
  4088. /**
  4089. * Sets the index-th row of the current matrix with the given 4 x float values
  4090. * @param index defines the row index
  4091. * @param x defines the x component to set
  4092. * @param y defines the y component to set
  4093. * @param z defines the z component to set
  4094. * @param w defines the w component to set
  4095. * @returns the updated current matrix
  4096. */
  4097. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4098. /**
  4099. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4100. * @param scale defines the scale factor
  4101. * @returns a new matrix
  4102. */
  4103. scale(scale: number): Matrix;
  4104. /**
  4105. * Scale the current matrix values by a factor to a given result matrix
  4106. * @param scale defines the scale factor
  4107. * @param result defines the matrix to store the result
  4108. * @returns the current matrix
  4109. */
  4110. scaleToRef(scale: number, result: Matrix): Matrix;
  4111. /**
  4112. * Scale the current matrix values by a factor and add the result to a given matrix
  4113. * @param scale defines the scale factor
  4114. * @param result defines the Matrix to store the result
  4115. * @returns the current matrix
  4116. */
  4117. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4118. /**
  4119. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4120. * @param ref matrix to store the result
  4121. */
  4122. toNormalMatrix(ref: Matrix): void;
  4123. /**
  4124. * Gets only rotation part of the current matrix
  4125. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4126. */
  4127. getRotationMatrix(): Matrix;
  4128. /**
  4129. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4130. * @param result defines the target matrix to store data to
  4131. * @returns the current matrix
  4132. */
  4133. getRotationMatrixToRef(result: Matrix): Matrix;
  4134. /**
  4135. * Toggles model matrix from being right handed to left handed in place and vice versa
  4136. */
  4137. toggleModelMatrixHandInPlace(): void;
  4138. /**
  4139. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4140. */
  4141. toggleProjectionMatrixHandInPlace(): void;
  4142. /**
  4143. * Creates a matrix from an array
  4144. * @param array defines the source array
  4145. * @param offset defines an offset in the source array
  4146. * @returns a new Matrix set from the starting index of the given array
  4147. */
  4148. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4149. /**
  4150. * Copy the content of an array into a given matrix
  4151. * @param array defines the source array
  4152. * @param offset defines an offset in the source array
  4153. * @param result defines the target matrix
  4154. */
  4155. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4156. /**
  4157. * Stores an array into a matrix after having multiplied each component by a given factor
  4158. * @param array defines the source array
  4159. * @param offset defines the offset in the source array
  4160. * @param scale defines the scaling factor
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4164. /**
  4165. * Gets an identity matrix that must not be updated
  4166. */
  4167. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4168. /**
  4169. * Stores a list of values (16) inside a given matrix
  4170. * @param initialM11 defines 1st value of 1st row
  4171. * @param initialM12 defines 2nd value of 1st row
  4172. * @param initialM13 defines 3rd value of 1st row
  4173. * @param initialM14 defines 4th value of 1st row
  4174. * @param initialM21 defines 1st value of 2nd row
  4175. * @param initialM22 defines 2nd value of 2nd row
  4176. * @param initialM23 defines 3rd value of 2nd row
  4177. * @param initialM24 defines 4th value of 2nd row
  4178. * @param initialM31 defines 1st value of 3rd row
  4179. * @param initialM32 defines 2nd value of 3rd row
  4180. * @param initialM33 defines 3rd value of 3rd row
  4181. * @param initialM34 defines 4th value of 3rd row
  4182. * @param initialM41 defines 1st value of 4th row
  4183. * @param initialM42 defines 2nd value of 4th row
  4184. * @param initialM43 defines 3rd value of 4th row
  4185. * @param initialM44 defines 4th value of 4th row
  4186. * @param result defines the target matrix
  4187. */
  4188. 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;
  4189. /**
  4190. * Creates new matrix from a list of values (16)
  4191. * @param initialM11 defines 1st value of 1st row
  4192. * @param initialM12 defines 2nd value of 1st row
  4193. * @param initialM13 defines 3rd value of 1st row
  4194. * @param initialM14 defines 4th value of 1st row
  4195. * @param initialM21 defines 1st value of 2nd row
  4196. * @param initialM22 defines 2nd value of 2nd row
  4197. * @param initialM23 defines 3rd value of 2nd row
  4198. * @param initialM24 defines 4th value of 2nd row
  4199. * @param initialM31 defines 1st value of 3rd row
  4200. * @param initialM32 defines 2nd value of 3rd row
  4201. * @param initialM33 defines 3rd value of 3rd row
  4202. * @param initialM34 defines 4th value of 3rd row
  4203. * @param initialM41 defines 1st value of 4th row
  4204. * @param initialM42 defines 2nd value of 4th row
  4205. * @param initialM43 defines 3rd value of 4th row
  4206. * @param initialM44 defines 4th value of 4th row
  4207. * @returns the new matrix
  4208. */
  4209. 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;
  4210. /**
  4211. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4212. * @param scale defines the scale vector3
  4213. * @param rotation defines the rotation quaternion
  4214. * @param translation defines the translation vector3
  4215. * @returns a new matrix
  4216. */
  4217. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4218. /**
  4219. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @param result defines the target matrix
  4224. */
  4225. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4226. /**
  4227. * Creates a new identity matrix
  4228. * @returns a new identity matrix
  4229. */
  4230. static Identity(): Matrix;
  4231. /**
  4232. * Creates a new identity matrix and stores the result in a given matrix
  4233. * @param result defines the target matrix
  4234. */
  4235. static IdentityToRef(result: Matrix): void;
  4236. /**
  4237. * Creates a new zero matrix
  4238. * @returns a new zero matrix
  4239. */
  4240. static Zero(): Matrix;
  4241. /**
  4242. * Creates a new rotation matrix for "angle" radians around the X axis
  4243. * @param angle defines the angle (in radians) to use
  4244. * @return the new matrix
  4245. */
  4246. static RotationX(angle: number): Matrix;
  4247. /**
  4248. * Creates a new matrix as the invert of a given matrix
  4249. * @param source defines the source matrix
  4250. * @returns the new matrix
  4251. */
  4252. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4255. * @param angle defines the angle (in radians) to use
  4256. * @param result defines the target matrix
  4257. */
  4258. static RotationXToRef(angle: number, result: Matrix): void;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the Y axis
  4261. * @param angle defines the angle (in radians) to use
  4262. * @return the new matrix
  4263. */
  4264. static RotationY(angle: number): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4267. * @param angle defines the angle (in radians) to use
  4268. * @param result defines the target matrix
  4269. */
  4270. static RotationYToRef(angle: number, result: Matrix): void;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Z axis
  4273. * @param angle defines the angle (in radians) to use
  4274. * @return the new matrix
  4275. */
  4276. static RotationZ(angle: number): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationZToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the given axis
  4285. * @param axis defines the axis to use
  4286. * @param angle defines the angle (in radians) to use
  4287. * @return the new matrix
  4288. */
  4289. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4290. /**
  4291. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4292. * @param axis defines the axis to use
  4293. * @param angle defines the angle (in radians) to use
  4294. * @param result defines the target matrix
  4295. */
  4296. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4297. /**
  4298. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4299. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4300. * @param from defines the vector to align
  4301. * @param to defines the vector to align to
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4305. /**
  4306. * Creates a rotation matrix
  4307. * @param yaw defines the yaw angle in radians (Y axis)
  4308. * @param pitch defines the pitch angle in radians (X axis)
  4309. * @param roll defines the roll angle in radians (X axis)
  4310. * @returns the new rotation matrix
  4311. */
  4312. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4313. /**
  4314. * Creates a rotation matrix and stores it in a given matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4321. /**
  4322. * Creates a scaling matrix
  4323. * @param x defines the scale factor on X axis
  4324. * @param y defines the scale factor on Y axis
  4325. * @param z defines the scale factor on Z axis
  4326. * @returns the new matrix
  4327. */
  4328. static Scaling(x: number, y: number, z: number): Matrix;
  4329. /**
  4330. * Creates a scaling matrix and stores it in a given matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @param result defines the target matrix
  4335. */
  4336. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4337. /**
  4338. * Creates a translation matrix
  4339. * @param x defines the translation on X axis
  4340. * @param y defines the translation on Y axis
  4341. * @param z defines the translationon Z axis
  4342. * @returns the new matrix
  4343. */
  4344. static Translation(x: number, y: number, z: number): Matrix;
  4345. /**
  4346. * Creates a translation matrix and stores it in a given matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @param result defines the target matrix
  4351. */
  4352. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4353. /**
  4354. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4355. * @param startValue defines the start value
  4356. * @param endValue defines the end value
  4357. * @param gradient defines the gradient factor
  4358. * @returns the new matrix
  4359. */
  4360. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4361. /**
  4362. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @param result defines the Matrix object where to store data
  4367. */
  4368. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4369. /**
  4370. * Builds a new matrix whose values are computed by:
  4371. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4372. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4373. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4374. * @param startValue defines the first matrix
  4375. * @param endValue defines the second matrix
  4376. * @param gradient defines the gradient between the two matrices
  4377. * @returns the new matrix
  4378. */
  4379. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4380. /**
  4381. * Update a matrix to values which are computed by:
  4382. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4383. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4384. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4385. * @param startValue defines the first matrix
  4386. * @param endValue defines the second matrix
  4387. * @param gradient defines the gradient between the two matrices
  4388. * @param result defines the target matrix
  4389. */
  4390. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4391. /**
  4392. * 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"
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @returns the new matrix
  4398. */
  4399. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4400. /**
  4401. * 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".
  4402. * This function works in left handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @param result defines the target matrix
  4407. */
  4408. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4409. /**
  4410. * 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"
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @returns the new matrix
  4416. */
  4417. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4418. /**
  4419. * 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".
  4420. * This function works in right handed mode
  4421. * @param eye defines the final position of the entity
  4422. * @param target defines where the entity should look at
  4423. * @param up defines the up vector for the entity
  4424. * @param result defines the target matrix
  4425. */
  4426. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4427. /**
  4428. * Create a left-handed orthographic projection matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @returns a new matrix as a left-handed orthographic projection matrix
  4434. */
  4435. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4436. /**
  4437. * Store a left-handed orthographic projection to a given matrix
  4438. * @param width defines the viewport width
  4439. * @param height defines the viewport height
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @param result defines the target matrix
  4443. */
  4444. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4445. /**
  4446. * Create a left-handed orthographic projection matrix
  4447. * @param left defines the viewport left coordinate
  4448. * @param right defines the viewport right coordinate
  4449. * @param bottom defines the viewport bottom coordinate
  4450. * @param top defines the viewport top coordinate
  4451. * @param znear defines the near clip plane
  4452. * @param zfar defines the far clip plane
  4453. * @returns a new matrix as a left-handed orthographic projection matrix
  4454. */
  4455. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4456. /**
  4457. * Stores a left-handed orthographic projection into a given matrix
  4458. * @param left defines the viewport left coordinate
  4459. * @param right defines the viewport right coordinate
  4460. * @param bottom defines the viewport bottom coordinate
  4461. * @param top defines the viewport top coordinate
  4462. * @param znear defines the near clip plane
  4463. * @param zfar defines the far clip plane
  4464. * @param result defines the target matrix
  4465. */
  4466. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4467. /**
  4468. * Creates a right-handed orthographic projection matrix
  4469. * @param left defines the viewport left coordinate
  4470. * @param right defines the viewport right coordinate
  4471. * @param bottom defines the viewport bottom coordinate
  4472. * @param top defines the viewport top coordinate
  4473. * @param znear defines the near clip plane
  4474. * @param zfar defines the far clip plane
  4475. * @returns a new matrix as a right-handed orthographic projection matrix
  4476. */
  4477. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4478. /**
  4479. * Stores a right-handed orthographic projection into a given matrix
  4480. * @param left defines the viewport left coordinate
  4481. * @param right defines the viewport right coordinate
  4482. * @param bottom defines the viewport bottom coordinate
  4483. * @param top defines the viewport top coordinate
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @param result defines the target matrix
  4487. */
  4488. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param width defines the viewport width
  4492. * @param height defines the viewport height
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Creates a left-handed perspective projection matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @returns a new matrix as a left-handed perspective projection matrix
  4505. */
  4506. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4507. /**
  4508. * Stores a left-handed perspective projection into a given matrix
  4509. * @param fov defines the horizontal field of view
  4510. * @param aspect defines the aspect ratio
  4511. * @param znear defines the near clip plane
  4512. * @param zfar defines the far clip plane
  4513. * @param result defines the target matrix
  4514. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4515. */
  4516. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4517. /**
  4518. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4519. * @param fov defines the horizontal field of view
  4520. * @param aspect defines the aspect ratio
  4521. * @param znear defines the near clip plane
  4522. * @param zfar not used as infinity is used as far clip
  4523. * @param result defines the target matrix
  4524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4525. */
  4526. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4527. /**
  4528. * Creates a right-handed perspective projection matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @returns a new matrix as a right-handed perspective projection matrix
  4534. */
  4535. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4536. /**
  4537. * Stores a right-handed perspective projection into a given matrix
  4538. * @param fov defines the horizontal field of view
  4539. * @param aspect defines the aspect ratio
  4540. * @param znear defines the near clip plane
  4541. * @param zfar defines the far clip plane
  4542. * @param result defines the target matrix
  4543. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4544. */
  4545. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4546. /**
  4547. * Stores a right-handed perspective projection into a given matrix
  4548. * @param fov defines the horizontal field of view
  4549. * @param aspect defines the aspect ratio
  4550. * @param znear defines the near clip plane
  4551. * @param zfar not used as infinity is used as far clip
  4552. * @param result defines the target matrix
  4553. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4554. */
  4555. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4556. /**
  4557. * Stores a perspective projection for WebVR info a given matrix
  4558. * @param fov defines the field of view
  4559. * @param znear defines the near clip plane
  4560. * @param zfar defines the far clip plane
  4561. * @param result defines the target matrix
  4562. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4563. */
  4564. static PerspectiveFovWebVRToRef(fov: {
  4565. upDegrees: number;
  4566. downDegrees: number;
  4567. leftDegrees: number;
  4568. rightDegrees: number;
  4569. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4570. /**
  4571. * Computes a complete transformation matrix
  4572. * @param viewport defines the viewport to use
  4573. * @param world defines the world matrix
  4574. * @param view defines the view matrix
  4575. * @param projection defines the projection matrix
  4576. * @param zmin defines the near clip plane
  4577. * @param zmax defines the far clip plane
  4578. * @returns the transformation matrix
  4579. */
  4580. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4581. /**
  4582. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4583. * @param matrix defines the matrix to use
  4584. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4585. */
  4586. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4587. /**
  4588. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Compute the transpose of a given matrix
  4595. * @param matrix defines the matrix to transpose
  4596. * @returns the new matrix
  4597. */
  4598. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4599. /**
  4600. * Compute the transpose of a matrix and store it in a target matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @param result defines the target matrix
  4603. */
  4604. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4605. /**
  4606. * Computes a reflection matrix from a plane
  4607. * @param plane defines the reflection plane
  4608. * @returns a new matrix
  4609. */
  4610. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @param result defines the target matrix
  4615. */
  4616. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4617. /**
  4618. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4619. * @param xaxis defines the value of the 1st axis
  4620. * @param yaxis defines the value of the 2nd axis
  4621. * @param zaxis defines the value of the 3rd axis
  4622. * @param result defines the target matrix
  4623. */
  4624. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4625. /**
  4626. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4627. * @param quat defines the quaternion to use
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4631. }
  4632. /**
  4633. * @hidden
  4634. */
  4635. export class TmpVectors {
  4636. static Vector2: Vector2[];
  4637. static Vector3: Vector3[];
  4638. static Vector4: Vector4[];
  4639. static Quaternion: Quaternion[];
  4640. static Matrix: Matrix[];
  4641. }
  4642. }
  4643. declare module BABYLON {
  4644. /**
  4645. * Defines potential orientation for back face culling
  4646. */
  4647. export enum Orientation {
  4648. /**
  4649. * Clockwise
  4650. */
  4651. CW = 0,
  4652. /** Counter clockwise */
  4653. CCW = 1
  4654. }
  4655. /** Class used to represent a Bezier curve */
  4656. export class BezierCurve {
  4657. /**
  4658. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4659. * @param t defines the time
  4660. * @param x1 defines the left coordinate on X axis
  4661. * @param y1 defines the left coordinate on Y axis
  4662. * @param x2 defines the right coordinate on X axis
  4663. * @param y2 defines the right coordinate on Y axis
  4664. * @returns the interpolated value
  4665. */
  4666. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4667. }
  4668. /**
  4669. * Defines angle representation
  4670. */
  4671. export class Angle {
  4672. private _radians;
  4673. /**
  4674. * Creates an Angle object of "radians" radians (float).
  4675. * @param radians the angle in radians
  4676. */
  4677. constructor(radians: number);
  4678. /**
  4679. * Get value in degrees
  4680. * @returns the Angle value in degrees (float)
  4681. */
  4682. degrees(): number;
  4683. /**
  4684. * Get value in radians
  4685. * @returns the Angle value in radians (float)
  4686. */
  4687. radians(): number;
  4688. /**
  4689. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4690. * @param a defines first vector
  4691. * @param b defines second vector
  4692. * @returns a new Angle
  4693. */
  4694. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4695. /**
  4696. * Gets a new Angle object from the given float in radians
  4697. * @param radians defines the angle value in radians
  4698. * @returns a new Angle
  4699. */
  4700. static FromRadians(radians: number): Angle;
  4701. /**
  4702. * Gets a new Angle object from the given float in degrees
  4703. * @param degrees defines the angle value in degrees
  4704. * @returns a new Angle
  4705. */
  4706. static FromDegrees(degrees: number): Angle;
  4707. }
  4708. /**
  4709. * This represents an arc in a 2d space.
  4710. */
  4711. export class Arc2 {
  4712. /** Defines the start point of the arc */
  4713. startPoint: Vector2;
  4714. /** Defines the mid point of the arc */
  4715. midPoint: Vector2;
  4716. /** Defines the end point of the arc */
  4717. endPoint: Vector2;
  4718. /**
  4719. * Defines the center point of the arc.
  4720. */
  4721. centerPoint: Vector2;
  4722. /**
  4723. * Defines the radius of the arc.
  4724. */
  4725. radius: number;
  4726. /**
  4727. * Defines the angle of the arc (from mid point to end point).
  4728. */
  4729. angle: Angle;
  4730. /**
  4731. * Defines the start angle of the arc (from start point to middle point).
  4732. */
  4733. startAngle: Angle;
  4734. /**
  4735. * Defines the orientation of the arc (clock wise/counter clock wise).
  4736. */
  4737. orientation: Orientation;
  4738. /**
  4739. * Creates an Arc object from the three given points : start, middle and end.
  4740. * @param startPoint Defines the start point of the arc
  4741. * @param midPoint Defines the midlle point of the arc
  4742. * @param endPoint Defines the end point of the arc
  4743. */
  4744. constructor(
  4745. /** Defines the start point of the arc */
  4746. startPoint: Vector2,
  4747. /** Defines the mid point of the arc */
  4748. midPoint: Vector2,
  4749. /** Defines the end point of the arc */
  4750. endPoint: Vector2);
  4751. }
  4752. /**
  4753. * Represents a 2D path made up of multiple 2D points
  4754. */
  4755. export class Path2 {
  4756. private _points;
  4757. private _length;
  4758. /**
  4759. * If the path start and end point are the same
  4760. */
  4761. closed: boolean;
  4762. /**
  4763. * Creates a Path2 object from the starting 2D coordinates x and y.
  4764. * @param x the starting points x value
  4765. * @param y the starting points y value
  4766. */
  4767. constructor(x: number, y: number);
  4768. /**
  4769. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4770. * @param x the added points x value
  4771. * @param y the added points y value
  4772. * @returns the updated Path2.
  4773. */
  4774. addLineTo(x: number, y: number): Path2;
  4775. /**
  4776. * 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.
  4777. * @param midX middle point x value
  4778. * @param midY middle point y value
  4779. * @param endX end point x value
  4780. * @param endY end point y value
  4781. * @param numberOfSegments (default: 36)
  4782. * @returns the updated Path2.
  4783. */
  4784. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4785. /**
  4786. * Closes the Path2.
  4787. * @returns the Path2.
  4788. */
  4789. close(): Path2;
  4790. /**
  4791. * Gets the sum of the distance between each sequential point in the path
  4792. * @returns the Path2 total length (float).
  4793. */
  4794. length(): number;
  4795. /**
  4796. * Gets the points which construct the path
  4797. * @returns the Path2 internal array of points.
  4798. */
  4799. getPoints(): Vector2[];
  4800. /**
  4801. * Retreives the point at the distance aways from the starting point
  4802. * @param normalizedLengthPosition the length along the path to retreive the point from
  4803. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4804. */
  4805. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4806. /**
  4807. * Creates a new path starting from an x and y position
  4808. * @param x starting x value
  4809. * @param y starting y value
  4810. * @returns a new Path2 starting at the coordinates (x, y).
  4811. */
  4812. static StartingAt(x: number, y: number): Path2;
  4813. }
  4814. /**
  4815. * Represents a 3D path made up of multiple 3D points
  4816. */
  4817. export class Path3D {
  4818. /**
  4819. * an array of Vector3, the curve axis of the Path3D
  4820. */
  4821. path: Vector3[];
  4822. private _curve;
  4823. private _distances;
  4824. private _tangents;
  4825. private _normals;
  4826. private _binormals;
  4827. private _raw;
  4828. private _alignTangentsWithPath;
  4829. private readonly _pointAtData;
  4830. /**
  4831. * new Path3D(path, normal, raw)
  4832. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4833. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4834. * @param path an array of Vector3, the curve axis of the Path3D
  4835. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4836. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4837. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4838. */
  4839. constructor(
  4840. /**
  4841. * an array of Vector3, the curve axis of the Path3D
  4842. */
  4843. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4844. /**
  4845. * Returns the Path3D array of successive Vector3 designing its curve.
  4846. * @returns the Path3D array of successive Vector3 designing its curve.
  4847. */
  4848. getCurve(): Vector3[];
  4849. /**
  4850. * Returns the Path3D array of successive Vector3 designing its curve.
  4851. * @returns the Path3D array of successive Vector3 designing its curve.
  4852. */
  4853. getPoints(): Vector3[];
  4854. /**
  4855. * @returns the computed length (float) of the path.
  4856. */
  4857. length(): number;
  4858. /**
  4859. * Returns an array populated with tangent vectors on each Path3D curve point.
  4860. * @returns an array populated with tangent vectors on each Path3D curve point.
  4861. */
  4862. getTangents(): Vector3[];
  4863. /**
  4864. * Returns an array populated with normal vectors on each Path3D curve point.
  4865. * @returns an array populated with normal vectors on each Path3D curve point.
  4866. */
  4867. getNormals(): Vector3[];
  4868. /**
  4869. * Returns an array populated with binormal vectors on each Path3D curve point.
  4870. * @returns an array populated with binormal vectors on each Path3D curve point.
  4871. */
  4872. getBinormals(): Vector3[];
  4873. /**
  4874. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4875. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4876. */
  4877. getDistances(): number[];
  4878. /**
  4879. * Returns an interpolated point along this path
  4880. * @param position the position of the point along this path, from 0.0 to 1.0
  4881. * @returns a new Vector3 as the point
  4882. */
  4883. getPointAt(position: number): Vector3;
  4884. /**
  4885. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4886. * @param position the position of the point along this path, from 0.0 to 1.0
  4887. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4888. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4889. */
  4890. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4891. /**
  4892. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4893. * @param position the position of the point along this path, from 0.0 to 1.0
  4894. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4895. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4896. */
  4897. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4898. /**
  4899. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4900. * @param position the position of the point along this path, from 0.0 to 1.0
  4901. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4902. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4903. */
  4904. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4905. /**
  4906. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4907. * @param position the position of the point along this path, from 0.0 to 1.0
  4908. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4909. */
  4910. getDistanceAt(position: number): number;
  4911. /**
  4912. * Returns the array index of the previous point of an interpolated point along this path
  4913. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4914. * @returns the array index
  4915. */
  4916. getPreviousPointIndexAt(position: number): number;
  4917. /**
  4918. * 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)
  4919. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4920. * @returns the sub position
  4921. */
  4922. getSubPositionAt(position: number): number;
  4923. /**
  4924. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4925. * @param target the vector of which to get the closest position to
  4926. * @returns the position of the closest virtual point on this path to the target vector
  4927. */
  4928. getClosestPositionTo(target: Vector3): number;
  4929. /**
  4930. * Returns a sub path (slice) of this path
  4931. * @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
  4932. * @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
  4933. * @returns a sub path (slice) of this path
  4934. */
  4935. slice(start?: number, end?: number): Path3D;
  4936. /**
  4937. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4938. * @param path path which all values are copied into the curves points
  4939. * @param firstNormal which should be projected onto the curve
  4940. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4941. * @returns the same object updated.
  4942. */
  4943. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4944. private _compute;
  4945. private _getFirstNonNullVector;
  4946. private _getLastNonNullVector;
  4947. private _normalVector;
  4948. /**
  4949. * Updates the point at data for an interpolated point along this curve
  4950. * @param position the position of the point along this curve, from 0.0 to 1.0
  4951. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4952. * @returns the (updated) point at data
  4953. */
  4954. private _updatePointAtData;
  4955. /**
  4956. * Updates the point at data from the specified parameters
  4957. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4958. * @param point the interpolated point
  4959. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4960. */
  4961. private _setPointAtData;
  4962. /**
  4963. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4964. */
  4965. private _updateInterpolationMatrix;
  4966. }
  4967. /**
  4968. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4969. * A Curve3 is designed from a series of successive Vector3.
  4970. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4971. */
  4972. export class Curve3 {
  4973. private _points;
  4974. private _length;
  4975. /**
  4976. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4978. * @param v1 (Vector3) the control point
  4979. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4980. * @param nbPoints (integer) the wanted number of points in the curve
  4981. * @returns the created Curve3
  4982. */
  4983. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4984. /**
  4985. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4986. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4987. * @param v1 (Vector3) the first control point
  4988. * @param v2 (Vector3) the second control point
  4989. * @param v3 (Vector3) the end point of the Cubic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4996. * @param p1 (Vector3) the origin point of the Hermite Spline
  4997. * @param t1 (Vector3) the tangent vector at the origin point
  4998. * @param p2 (Vector3) the end point of the Hermite Spline
  4999. * @param t2 (Vector3) the tangent vector at the end point
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a CatmullRom Spline curve :
  5006. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5007. * @param nbPoints (integer) the wanted number of points between each curve control points
  5008. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5012. /**
  5013. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5014. * A Curve3 is designed from a series of successive Vector3.
  5015. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5016. * @param points points which make up the curve
  5017. */
  5018. constructor(points: Vector3[]);
  5019. /**
  5020. * @returns the Curve3 stored array of successive Vector3
  5021. */
  5022. getPoints(): Vector3[];
  5023. /**
  5024. * @returns the computed length (float) of the curve.
  5025. */
  5026. length(): number;
  5027. /**
  5028. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5029. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5030. * curveA and curveB keep unchanged.
  5031. * @param curve the curve to continue from this curve
  5032. * @returns the newly constructed curve
  5033. */
  5034. continue(curve: DeepImmutable<Curve3>): Curve3;
  5035. private _computeLength;
  5036. }
  5037. }
  5038. declare module BABYLON {
  5039. /**
  5040. * This represents the main contract an easing function should follow.
  5041. * Easing functions are used throughout the animation system.
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export interface IEasingFunction {
  5045. /**
  5046. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5047. * of the easing function.
  5048. * The link below provides some of the most common examples of easing functions.
  5049. * @see https://easings.net/
  5050. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5051. * @returns the corresponding value on the curve defined by the easing function
  5052. */
  5053. ease(gradient: number): number;
  5054. }
  5055. /**
  5056. * Base class used for every default easing function.
  5057. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5058. */
  5059. export class EasingFunction implements IEasingFunction {
  5060. /**
  5061. * Interpolation follows the mathematical formula associated with the easing function.
  5062. */
  5063. static readonly EASINGMODE_EASEIN: number;
  5064. /**
  5065. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5066. */
  5067. static readonly EASINGMODE_EASEOUT: number;
  5068. /**
  5069. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5070. */
  5071. static readonly EASINGMODE_EASEINOUT: number;
  5072. private _easingMode;
  5073. /**
  5074. * Sets the easing mode of the current function.
  5075. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5076. */
  5077. setEasingMode(easingMode: number): void;
  5078. /**
  5079. * Gets the current easing mode.
  5080. * @returns the easing mode
  5081. */
  5082. getEasingMode(): number;
  5083. /**
  5084. * @hidden
  5085. */
  5086. easeInCore(gradient: number): number;
  5087. /**
  5088. * Given an input gradient between 0 and 1, this returns the corresponding value
  5089. * of the easing function.
  5090. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5091. * @returns the corresponding value on the curve defined by the easing function
  5092. */
  5093. ease(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a circle shape (see link below).
  5097. * @see https://easings.net/#easeInCirc
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class CircleEase extends EasingFunction implements IEasingFunction {
  5101. /** @hidden */
  5102. easeInCore(gradient: number): number;
  5103. }
  5104. /**
  5105. * Easing function with a ease back shape (see link below).
  5106. * @see https://easings.net/#easeInBack
  5107. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5108. */
  5109. export class BackEase extends EasingFunction implements IEasingFunction {
  5110. /** Defines the amplitude of the function */
  5111. amplitude: number;
  5112. /**
  5113. * Instantiates a back ease easing
  5114. * @see https://easings.net/#easeInBack
  5115. * @param amplitude Defines the amplitude of the function
  5116. */
  5117. constructor(
  5118. /** Defines the amplitude of the function */
  5119. amplitude?: number);
  5120. /** @hidden */
  5121. easeInCore(gradient: number): number;
  5122. }
  5123. /**
  5124. * Easing function with a bouncing shape (see link below).
  5125. * @see https://easings.net/#easeInBounce
  5126. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5127. */
  5128. export class BounceEase extends EasingFunction implements IEasingFunction {
  5129. /** Defines the number of bounces */
  5130. bounces: number;
  5131. /** Defines the amplitude of the bounce */
  5132. bounciness: number;
  5133. /**
  5134. * Instantiates a bounce easing
  5135. * @see https://easings.net/#easeInBounce
  5136. * @param bounces Defines the number of bounces
  5137. * @param bounciness Defines the amplitude of the bounce
  5138. */
  5139. constructor(
  5140. /** Defines the number of bounces */
  5141. bounces?: number,
  5142. /** Defines the amplitude of the bounce */
  5143. bounciness?: number);
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with a power of 3 shape (see link below).
  5149. * @see https://easings.net/#easeInCubic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class CubicEase extends EasingFunction implements IEasingFunction {
  5153. /** @hidden */
  5154. easeInCore(gradient: number): number;
  5155. }
  5156. /**
  5157. * Easing function with an elastic shape (see link below).
  5158. * @see https://easings.net/#easeInElastic
  5159. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5160. */
  5161. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5162. /** Defines the number of oscillations*/
  5163. oscillations: number;
  5164. /** Defines the amplitude of the oscillations*/
  5165. springiness: number;
  5166. /**
  5167. * Instantiates an elastic easing function
  5168. * @see https://easings.net/#easeInElastic
  5169. * @param oscillations Defines the number of oscillations
  5170. * @param springiness Defines the amplitude of the oscillations
  5171. */
  5172. constructor(
  5173. /** Defines the number of oscillations*/
  5174. oscillations?: number,
  5175. /** Defines the amplitude of the oscillations*/
  5176. springiness?: number);
  5177. /** @hidden */
  5178. easeInCore(gradient: number): number;
  5179. }
  5180. /**
  5181. * Easing function with an exponential shape (see link below).
  5182. * @see https://easings.net/#easeInExpo
  5183. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5184. */
  5185. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5186. /** Defines the exponent of the function */
  5187. exponent: number;
  5188. /**
  5189. * Instantiates an exponential easing function
  5190. * @see https://easings.net/#easeInExpo
  5191. * @param exponent Defines the exponent of the function
  5192. */
  5193. constructor(
  5194. /** Defines the exponent of the function */
  5195. exponent?: number);
  5196. /** @hidden */
  5197. easeInCore(gradient: number): number;
  5198. }
  5199. /**
  5200. * Easing function with a power shape (see link below).
  5201. * @see https://easings.net/#easeInQuad
  5202. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5203. */
  5204. export class PowerEase extends EasingFunction implements IEasingFunction {
  5205. /** Defines the power of the function */
  5206. power: number;
  5207. /**
  5208. * Instantiates an power base easing function
  5209. * @see https://easings.net/#easeInQuad
  5210. * @param power Defines the power of the function
  5211. */
  5212. constructor(
  5213. /** Defines the power of the function */
  5214. power?: number);
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 2 shape (see link below).
  5220. * @see https://easings.net/#easeInQuad
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 4 shape (see link below).
  5229. * @see https://easings.net/#easeInQuart
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a power of 5 shape (see link below).
  5238. * @see https://easings.net/#easeInQuint
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a sin shape (see link below).
  5247. * @see https://easings.net/#easeInSine
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class SineEase extends EasingFunction implements IEasingFunction {
  5251. /** @hidden */
  5252. easeInCore(gradient: number): number;
  5253. }
  5254. /**
  5255. * Easing function with a bezier shape (see link below).
  5256. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5257. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5258. */
  5259. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5260. /** Defines the x component of the start tangent in the bezier curve */
  5261. x1: number;
  5262. /** Defines the y component of the start tangent in the bezier curve */
  5263. y1: number;
  5264. /** Defines the x component of the end tangent in the bezier curve */
  5265. x2: number;
  5266. /** Defines the y component of the end tangent in the bezier curve */
  5267. y2: number;
  5268. /**
  5269. * Instantiates a bezier function
  5270. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5271. * @param x1 Defines the x component of the start tangent in the bezier curve
  5272. * @param y1 Defines the y component of the start tangent in the bezier curve
  5273. * @param x2 Defines the x component of the end tangent in the bezier curve
  5274. * @param y2 Defines the y component of the end tangent in the bezier curve
  5275. */
  5276. constructor(
  5277. /** Defines the x component of the start tangent in the bezier curve */
  5278. x1?: number,
  5279. /** Defines the y component of the start tangent in the bezier curve */
  5280. y1?: number,
  5281. /** Defines the x component of the end tangent in the bezier curve */
  5282. x2?: number,
  5283. /** Defines the y component of the end tangent in the bezier curve */
  5284. y2?: number);
  5285. /** @hidden */
  5286. easeInCore(gradient: number): number;
  5287. }
  5288. }
  5289. declare module BABYLON {
  5290. /**
  5291. * Class used to hold a RBG color
  5292. */
  5293. export class Color3 {
  5294. /**
  5295. * Defines the red component (between 0 and 1, default is 0)
  5296. */
  5297. r: number;
  5298. /**
  5299. * Defines the green component (between 0 and 1, default is 0)
  5300. */
  5301. g: number;
  5302. /**
  5303. * Defines the blue component (between 0 and 1, default is 0)
  5304. */
  5305. b: number;
  5306. /**
  5307. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5308. * @param r defines the red component (between 0 and 1, default is 0)
  5309. * @param g defines the green component (between 0 and 1, default is 0)
  5310. * @param b defines the blue component (between 0 and 1, default is 0)
  5311. */
  5312. constructor(
  5313. /**
  5314. * Defines the red component (between 0 and 1, default is 0)
  5315. */
  5316. r?: number,
  5317. /**
  5318. * Defines the green component (between 0 and 1, default is 0)
  5319. */
  5320. g?: number,
  5321. /**
  5322. * Defines the blue component (between 0 and 1, default is 0)
  5323. */
  5324. b?: number);
  5325. /**
  5326. * Creates a string with the Color3 current values
  5327. * @returns the string representation of the Color3 object
  5328. */
  5329. toString(): string;
  5330. /**
  5331. * Returns the string "Color3"
  5332. * @returns "Color3"
  5333. */
  5334. getClassName(): string;
  5335. /**
  5336. * Compute the Color3 hash code
  5337. * @returns an unique number that can be used to hash Color3 objects
  5338. */
  5339. getHashCode(): number;
  5340. /**
  5341. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5342. * @param array defines the array where to store the r,g,b components
  5343. * @param index defines an optional index in the target array to define where to start storing values
  5344. * @returns the current Color3 object
  5345. */
  5346. toArray(array: FloatArray, index?: number): Color3;
  5347. /**
  5348. * Returns a new Color4 object from the current Color3 and the given alpha
  5349. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5350. * @returns a new Color4 object
  5351. */
  5352. toColor4(alpha?: number): Color4;
  5353. /**
  5354. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5355. * @returns the new array
  5356. */
  5357. asArray(): number[];
  5358. /**
  5359. * Returns the luminance value
  5360. * @returns a float value
  5361. */
  5362. toLuminance(): number;
  5363. /**
  5364. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5365. * @param otherColor defines the second operand
  5366. * @returns the new Color3 object
  5367. */
  5368. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5369. /**
  5370. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5371. * @param otherColor defines the second operand
  5372. * @param result defines the Color3 object where to store the result
  5373. * @returns the current Color3
  5374. */
  5375. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5376. /**
  5377. * Determines equality between Color3 objects
  5378. * @param otherColor defines the second operand
  5379. * @returns true if the rgb values are equal to the given ones
  5380. */
  5381. equals(otherColor: DeepImmutable<Color3>): boolean;
  5382. /**
  5383. * Determines equality between the current Color3 object and a set of r,b,g values
  5384. * @param r defines the red component to check
  5385. * @param g defines the green component to check
  5386. * @param b defines the blue component to check
  5387. * @returns true if the rgb values are equal to the given ones
  5388. */
  5389. equalsFloats(r: number, g: number, b: number): boolean;
  5390. /**
  5391. * Multiplies in place each rgb value by scale
  5392. * @param scale defines the scaling factor
  5393. * @returns the updated Color3
  5394. */
  5395. scale(scale: number): Color3;
  5396. /**
  5397. * Multiplies the rgb values by scale and stores the result into "result"
  5398. * @param scale defines the scaling factor
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the unmodified current Color3
  5401. */
  5402. scaleToRef(scale: number, result: Color3): Color3;
  5403. /**
  5404. * Scale the current Color3 values by a factor and add the result to a given Color3
  5405. * @param scale defines the scale factor
  5406. * @param result defines color to store the result into
  5407. * @returns the unmodified current Color3
  5408. */
  5409. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5410. /**
  5411. * Clamps the rgb values by the min and max values and stores the result into "result"
  5412. * @param min defines minimum clamping value (default is 0)
  5413. * @param max defines maximum clamping value (default is 1)
  5414. * @param result defines color to store the result into
  5415. * @returns the original Color3
  5416. */
  5417. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5418. /**
  5419. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5420. * @param otherColor defines the second operand
  5421. * @returns the new Color3
  5422. */
  5423. add(otherColor: DeepImmutable<Color3>): Color3;
  5424. /**
  5425. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5426. * @param otherColor defines the second operand
  5427. * @param result defines Color3 object to store the result into
  5428. * @returns the unmodified current Color3
  5429. */
  5430. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5431. /**
  5432. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5433. * @param otherColor defines the second operand
  5434. * @returns the new Color3
  5435. */
  5436. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5437. /**
  5438. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5439. * @param otherColor defines the second operand
  5440. * @param result defines Color3 object to store the result into
  5441. * @returns the unmodified current Color3
  5442. */
  5443. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5444. /**
  5445. * Copy the current object
  5446. * @returns a new Color3 copied the current one
  5447. */
  5448. clone(): Color3;
  5449. /**
  5450. * Copies the rgb values from the source in the current Color3
  5451. * @param source defines the source Color3 object
  5452. * @returns the updated Color3 object
  5453. */
  5454. copyFrom(source: DeepImmutable<Color3>): Color3;
  5455. /**
  5456. * Updates the Color3 rgb values from the given floats
  5457. * @param r defines the red component to read from
  5458. * @param g defines the green component to read from
  5459. * @param b defines the blue component to read from
  5460. * @returns the current Color3 object
  5461. */
  5462. copyFromFloats(r: number, g: number, b: number): Color3;
  5463. /**
  5464. * Updates the Color3 rgb values from the given floats
  5465. * @param r defines the red component to read from
  5466. * @param g defines the green component to read from
  5467. * @param b defines the blue component to read from
  5468. * @returns the current Color3 object
  5469. */
  5470. set(r: number, g: number, b: number): Color3;
  5471. /**
  5472. * Compute the Color3 hexadecimal code as a string
  5473. * @returns a string containing the hexadecimal representation of the Color3 object
  5474. */
  5475. toHexString(): string;
  5476. /**
  5477. * Computes a new Color3 converted from the current one to linear space
  5478. * @returns a new Color3 object
  5479. */
  5480. toLinearSpace(): Color3;
  5481. /**
  5482. * Converts current color in rgb space to HSV values
  5483. * @returns a new color3 representing the HSV values
  5484. */
  5485. toHSV(): Color3;
  5486. /**
  5487. * Converts current color in rgb space to HSV values
  5488. * @param result defines the Color3 where to store the HSV values
  5489. */
  5490. toHSVToRef(result: Color3): void;
  5491. /**
  5492. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5493. * @param convertedColor defines the Color3 object where to store the linear space version
  5494. * @returns the unmodified Color3
  5495. */
  5496. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5497. /**
  5498. * Computes a new Color3 converted from the current one to gamma space
  5499. * @returns a new Color3 object
  5500. */
  5501. toGammaSpace(): Color3;
  5502. /**
  5503. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the gamma space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5508. private static _BlackReadOnly;
  5509. /**
  5510. * Convert Hue, saturation and value to a Color3 (RGB)
  5511. * @param hue defines the hue
  5512. * @param saturation defines the saturation
  5513. * @param value defines the value
  5514. * @param result defines the Color3 where to store the RGB values
  5515. */
  5516. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5517. /**
  5518. * Creates a new Color3 from the string containing valid hexadecimal values
  5519. * @param hex defines a string containing valid hexadecimal values
  5520. * @returns a new Color3 object
  5521. */
  5522. static FromHexString(hex: string): Color3;
  5523. /**
  5524. * Creates a new Color3 from the starting index of the given array
  5525. * @param array defines the source array
  5526. * @param offset defines an offset in the source array
  5527. * @returns a new Color3 object
  5528. */
  5529. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5530. /**
  5531. * Creates a new Color3 from integer values (< 256)
  5532. * @param r defines the red component to read from (value between 0 and 255)
  5533. * @param g defines the green component to read from (value between 0 and 255)
  5534. * @param b defines the blue component to read from (value between 0 and 255)
  5535. * @returns a new Color3 object
  5536. */
  5537. static FromInts(r: number, g: number, b: number): Color3;
  5538. /**
  5539. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5540. * @param start defines the start Color3 value
  5541. * @param end defines the end Color3 value
  5542. * @param amount defines the gradient value between start and end
  5543. * @returns a new Color3 object
  5544. */
  5545. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5546. /**
  5547. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5548. * @param left defines the start value
  5549. * @param right defines the end value
  5550. * @param amount defines the gradient factor
  5551. * @param result defines the Color3 object where to store the result
  5552. */
  5553. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5554. /**
  5555. * Returns a Color3 value containing a red color
  5556. * @returns a new Color3 object
  5557. */
  5558. static Red(): Color3;
  5559. /**
  5560. * Returns a Color3 value containing a green color
  5561. * @returns a new Color3 object
  5562. */
  5563. static Green(): Color3;
  5564. /**
  5565. * Returns a Color3 value containing a blue color
  5566. * @returns a new Color3 object
  5567. */
  5568. static Blue(): Color3;
  5569. /**
  5570. * Returns a Color3 value containing a black color
  5571. * @returns a new Color3 object
  5572. */
  5573. static Black(): Color3;
  5574. /**
  5575. * Gets a Color3 value containing a black color that must not be updated
  5576. */
  5577. static get BlackReadOnly(): DeepImmutable<Color3>;
  5578. /**
  5579. * Returns a Color3 value containing a white color
  5580. * @returns a new Color3 object
  5581. */
  5582. static White(): Color3;
  5583. /**
  5584. * Returns a Color3 value containing a purple color
  5585. * @returns a new Color3 object
  5586. */
  5587. static Purple(): Color3;
  5588. /**
  5589. * Returns a Color3 value containing a magenta color
  5590. * @returns a new Color3 object
  5591. */
  5592. static Magenta(): Color3;
  5593. /**
  5594. * Returns a Color3 value containing a yellow color
  5595. * @returns a new Color3 object
  5596. */
  5597. static Yellow(): Color3;
  5598. /**
  5599. * Returns a Color3 value containing a gray color
  5600. * @returns a new Color3 object
  5601. */
  5602. static Gray(): Color3;
  5603. /**
  5604. * Returns a Color3 value containing a teal color
  5605. * @returns a new Color3 object
  5606. */
  5607. static Teal(): Color3;
  5608. /**
  5609. * Returns a Color3 value containing a random color
  5610. * @returns a new Color3 object
  5611. */
  5612. static Random(): Color3;
  5613. }
  5614. /**
  5615. * Class used to hold a RBGA color
  5616. */
  5617. export class Color4 {
  5618. /**
  5619. * Defines the red component (between 0 and 1, default is 0)
  5620. */
  5621. r: number;
  5622. /**
  5623. * Defines the green component (between 0 and 1, default is 0)
  5624. */
  5625. g: number;
  5626. /**
  5627. * Defines the blue component (between 0 and 1, default is 0)
  5628. */
  5629. b: number;
  5630. /**
  5631. * Defines the alpha component (between 0 and 1, default is 1)
  5632. */
  5633. a: number;
  5634. /**
  5635. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5636. * @param r defines the red component (between 0 and 1, default is 0)
  5637. * @param g defines the green component (between 0 and 1, default is 0)
  5638. * @param b defines the blue component (between 0 and 1, default is 0)
  5639. * @param a defines the alpha component (between 0 and 1, default is 1)
  5640. */
  5641. constructor(
  5642. /**
  5643. * Defines the red component (between 0 and 1, default is 0)
  5644. */
  5645. r?: number,
  5646. /**
  5647. * Defines the green component (between 0 and 1, default is 0)
  5648. */
  5649. g?: number,
  5650. /**
  5651. * Defines the blue component (between 0 and 1, default is 0)
  5652. */
  5653. b?: number,
  5654. /**
  5655. * Defines the alpha component (between 0 and 1, default is 1)
  5656. */
  5657. a?: number);
  5658. /**
  5659. * Adds in place the given Color4 values to the current Color4 object
  5660. * @param right defines the second operand
  5661. * @returns the current updated Color4 object
  5662. */
  5663. addInPlace(right: DeepImmutable<Color4>): Color4;
  5664. /**
  5665. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5666. * @returns the new array
  5667. */
  5668. asArray(): number[];
  5669. /**
  5670. * Stores from the starting index in the given array the Color4 successive values
  5671. * @param array defines the array where to store the r,g,b components
  5672. * @param index defines an optional index in the target array to define where to start storing values
  5673. * @returns the current Color4 object
  5674. */
  5675. toArray(array: number[], index?: number): Color4;
  5676. /**
  5677. * Determines equality between Color4 objects
  5678. * @param otherColor defines the second operand
  5679. * @returns true if the rgba values are equal to the given ones
  5680. */
  5681. equals(otherColor: DeepImmutable<Color4>): boolean;
  5682. /**
  5683. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5684. * @param right defines the second operand
  5685. * @returns a new Color4 object
  5686. */
  5687. add(right: DeepImmutable<Color4>): Color4;
  5688. /**
  5689. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5690. * @param right defines the second operand
  5691. * @returns a new Color4 object
  5692. */
  5693. subtract(right: DeepImmutable<Color4>): Color4;
  5694. /**
  5695. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5696. * @param right defines the second operand
  5697. * @param result defines the Color4 object where to store the result
  5698. * @returns the current Color4 object
  5699. */
  5700. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5701. /**
  5702. * Creates a new Color4 with the current Color4 values multiplied by scale
  5703. * @param scale defines the scaling factor to apply
  5704. * @returns a new Color4 object
  5705. */
  5706. scale(scale: number): Color4;
  5707. /**
  5708. * Multiplies the current Color4 values by scale and stores the result in "result"
  5709. * @param scale defines the scaling factor to apply
  5710. * @param result defines the Color4 object where to store the result
  5711. * @returns the current unmodified Color4
  5712. */
  5713. scaleToRef(scale: number, result: Color4): Color4;
  5714. /**
  5715. * Scale the current Color4 values by a factor and add the result to a given Color4
  5716. * @param scale defines the scale factor
  5717. * @param result defines the Color4 object where to store the result
  5718. * @returns the unmodified current Color4
  5719. */
  5720. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5721. /**
  5722. * Clamps the rgb values by the min and max values and stores the result into "result"
  5723. * @param min defines minimum clamping value (default is 0)
  5724. * @param max defines maximum clamping value (default is 1)
  5725. * @param result defines color to store the result into.
  5726. * @returns the cuurent Color4
  5727. */
  5728. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5729. /**
  5730. * Multipy an Color4 value by another and return a new Color4 object
  5731. * @param color defines the Color4 value to multiply by
  5732. * @returns a new Color4 object
  5733. */
  5734. multiply(color: Color4): Color4;
  5735. /**
  5736. * Multipy a Color4 value by another and push the result in a reference value
  5737. * @param color defines the Color4 value to multiply by
  5738. * @param result defines the Color4 to fill the result in
  5739. * @returns the result Color4
  5740. */
  5741. multiplyToRef(color: Color4, result: Color4): Color4;
  5742. /**
  5743. * Creates a string with the Color4 current values
  5744. * @returns the string representation of the Color4 object
  5745. */
  5746. toString(): string;
  5747. /**
  5748. * Returns the string "Color4"
  5749. * @returns "Color4"
  5750. */
  5751. getClassName(): string;
  5752. /**
  5753. * Compute the Color4 hash code
  5754. * @returns an unique number that can be used to hash Color4 objects
  5755. */
  5756. getHashCode(): number;
  5757. /**
  5758. * Creates a new Color4 copied from the current one
  5759. * @returns a new Color4 object
  5760. */
  5761. clone(): Color4;
  5762. /**
  5763. * Copies the given Color4 values into the current one
  5764. * @param source defines the source Color4 object
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFrom(source: Color4): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. set(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Compute the Color4 hexadecimal code as a string
  5788. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5789. * @returns a string containing the hexadecimal representation of the Color4 object
  5790. */
  5791. toHexString(returnAsColor3?: boolean): string;
  5792. /**
  5793. * Computes a new Color4 converted from the current one to linear space
  5794. * @returns a new Color4 object
  5795. */
  5796. toLinearSpace(): Color4;
  5797. /**
  5798. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5799. * @param convertedColor defines the Color4 object where to store the linear space version
  5800. * @returns the unmodified Color4
  5801. */
  5802. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5803. /**
  5804. * Computes a new Color4 converted from the current one to gamma space
  5805. * @returns a new Color4 object
  5806. */
  5807. toGammaSpace(): Color4;
  5808. /**
  5809. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5810. * @param convertedColor defines the Color4 object where to store the gamma space version
  5811. * @returns the unmodified Color4
  5812. */
  5813. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5814. /**
  5815. * Creates a new Color4 from the string containing valid hexadecimal values
  5816. * @param hex defines a string containing valid hexadecimal values
  5817. * @returns a new Color4 object
  5818. */
  5819. static FromHexString(hex: string): Color4;
  5820. /**
  5821. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5822. * @param left defines the start value
  5823. * @param right defines the end value
  5824. * @param amount defines the gradient factor
  5825. * @returns a new Color4 object
  5826. */
  5827. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5828. /**
  5829. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @param result defines the Color4 object where to store data
  5834. */
  5835. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5836. /**
  5837. * Creates a new Color4 from a Color3 and an alpha value
  5838. * @param color3 defines the source Color3 to read from
  5839. * @param alpha defines the alpha component (1.0 by default)
  5840. * @returns a new Color4 object
  5841. */
  5842. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5843. /**
  5844. * Creates a new Color4 from the starting index element of the given array
  5845. * @param array defines the source array to read from
  5846. * @param offset defines the offset in the source array
  5847. * @returns a new Color4 object
  5848. */
  5849. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5850. /**
  5851. * Creates a new Color3 from integer values (< 256)
  5852. * @param r defines the red component to read from (value between 0 and 255)
  5853. * @param g defines the green component to read from (value between 0 and 255)
  5854. * @param b defines the blue component to read from (value between 0 and 255)
  5855. * @param a defines the alpha component to read from (value between 0 and 255)
  5856. * @returns a new Color3 object
  5857. */
  5858. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5859. /**
  5860. * Check the content of a given array and convert it to an array containing RGBA data
  5861. * If the original array was already containing count * 4 values then it is returned directly
  5862. * @param colors defines the array to check
  5863. * @param count defines the number of RGBA data to expect
  5864. * @returns an array containing count * 4 values (RGBA)
  5865. */
  5866. static CheckColors4(colors: number[], count: number): number[];
  5867. }
  5868. /**
  5869. * @hidden
  5870. */
  5871. export class TmpColors {
  5872. static Color3: Color3[];
  5873. static Color4: Color4[];
  5874. }
  5875. }
  5876. declare module BABYLON {
  5877. /**
  5878. * Defines an interface which represents an animation key frame
  5879. */
  5880. export interface IAnimationKey {
  5881. /**
  5882. * Frame of the key frame
  5883. */
  5884. frame: number;
  5885. /**
  5886. * Value at the specifies key frame
  5887. */
  5888. value: any;
  5889. /**
  5890. * The input tangent for the cubic hermite spline
  5891. */
  5892. inTangent?: any;
  5893. /**
  5894. * The output tangent for the cubic hermite spline
  5895. */
  5896. outTangent?: any;
  5897. /**
  5898. * The animation interpolation type
  5899. */
  5900. interpolation?: AnimationKeyInterpolation;
  5901. }
  5902. /**
  5903. * Enum for the animation key frame interpolation type
  5904. */
  5905. export enum AnimationKeyInterpolation {
  5906. /**
  5907. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5908. */
  5909. STEP = 1
  5910. }
  5911. }
  5912. declare module BABYLON {
  5913. /**
  5914. * Represents the range of an animation
  5915. */
  5916. export class AnimationRange {
  5917. /**The name of the animation range**/
  5918. name: string;
  5919. /**The starting frame of the animation */
  5920. from: number;
  5921. /**The ending frame of the animation*/
  5922. to: number;
  5923. /**
  5924. * Initializes the range of an animation
  5925. * @param name The name of the animation range
  5926. * @param from The starting frame of the animation
  5927. * @param to The ending frame of the animation
  5928. */
  5929. constructor(
  5930. /**The name of the animation range**/
  5931. name: string,
  5932. /**The starting frame of the animation */
  5933. from: number,
  5934. /**The ending frame of the animation*/
  5935. to: number);
  5936. /**
  5937. * Makes a copy of the animation range
  5938. * @returns A copy of the animation range
  5939. */
  5940. clone(): AnimationRange;
  5941. }
  5942. }
  5943. declare module BABYLON {
  5944. /**
  5945. * Composed of a frame, and an action function
  5946. */
  5947. export class AnimationEvent {
  5948. /** The frame for which the event is triggered **/
  5949. frame: number;
  5950. /** The event to perform when triggered **/
  5951. action: (currentFrame: number) => void;
  5952. /** Specifies if the event should be triggered only once**/
  5953. onlyOnce?: boolean | undefined;
  5954. /**
  5955. * Specifies if the animation event is done
  5956. */
  5957. isDone: boolean;
  5958. /**
  5959. * Initializes the animation event
  5960. * @param frame The frame for which the event is triggered
  5961. * @param action The event to perform when triggered
  5962. * @param onlyOnce Specifies if the event should be triggered only once
  5963. */
  5964. constructor(
  5965. /** The frame for which the event is triggered **/
  5966. frame: number,
  5967. /** The event to perform when triggered **/
  5968. action: (currentFrame: number) => void,
  5969. /** Specifies if the event should be triggered only once**/
  5970. onlyOnce?: boolean | undefined);
  5971. /** @hidden */
  5972. _clone(): AnimationEvent;
  5973. }
  5974. }
  5975. declare module BABYLON {
  5976. /**
  5977. * Interface used to define a behavior
  5978. */
  5979. export interface Behavior<T> {
  5980. /** gets or sets behavior's name */
  5981. name: string;
  5982. /**
  5983. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5984. */
  5985. init(): void;
  5986. /**
  5987. * Called when the behavior is attached to a target
  5988. * @param target defines the target where the behavior is attached to
  5989. */
  5990. attach(target: T): void;
  5991. /**
  5992. * Called when the behavior is detached from its target
  5993. */
  5994. detach(): void;
  5995. }
  5996. /**
  5997. * Interface implemented by classes supporting behaviors
  5998. */
  5999. export interface IBehaviorAware<T> {
  6000. /**
  6001. * Attach a behavior
  6002. * @param behavior defines the behavior to attach
  6003. * @returns the current host
  6004. */
  6005. addBehavior(behavior: Behavior<T>): T;
  6006. /**
  6007. * Remove a behavior from the current object
  6008. * @param behavior defines the behavior to detach
  6009. * @returns the current host
  6010. */
  6011. removeBehavior(behavior: Behavior<T>): T;
  6012. /**
  6013. * Gets a behavior using its name to search
  6014. * @param name defines the name to search
  6015. * @returns the behavior or null if not found
  6016. */
  6017. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6018. }
  6019. }
  6020. declare module BABYLON {
  6021. /**
  6022. * Defines an array and its length.
  6023. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6024. */
  6025. export interface ISmartArrayLike<T> {
  6026. /**
  6027. * The data of the array.
  6028. */
  6029. data: Array<T>;
  6030. /**
  6031. * The active length of the array.
  6032. */
  6033. length: number;
  6034. }
  6035. /**
  6036. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6037. */
  6038. export class SmartArray<T> implements ISmartArrayLike<T> {
  6039. /**
  6040. * The full set of data from the array.
  6041. */
  6042. data: Array<T>;
  6043. /**
  6044. * The active length of the array.
  6045. */
  6046. length: number;
  6047. protected _id: number;
  6048. /**
  6049. * Instantiates a Smart Array.
  6050. * @param capacity defines the default capacity of the array.
  6051. */
  6052. constructor(capacity: number);
  6053. /**
  6054. * Pushes a value at the end of the active data.
  6055. * @param value defines the object to push in the array.
  6056. */
  6057. push(value: T): void;
  6058. /**
  6059. * Iterates over the active data and apply the lambda to them.
  6060. * @param func defines the action to apply on each value.
  6061. */
  6062. forEach(func: (content: T) => void): void;
  6063. /**
  6064. * Sorts the full sets of data.
  6065. * @param compareFn defines the comparison function to apply.
  6066. */
  6067. sort(compareFn: (a: T, b: T) => number): void;
  6068. /**
  6069. * Resets the active data to an empty array.
  6070. */
  6071. reset(): void;
  6072. /**
  6073. * Releases all the data from the array as well as the array.
  6074. */
  6075. dispose(): void;
  6076. /**
  6077. * Concats the active data with a given array.
  6078. * @param array defines the data to concatenate with.
  6079. */
  6080. concat(array: any): void;
  6081. /**
  6082. * Returns the position of a value in the active data.
  6083. * @param value defines the value to find the index for
  6084. * @returns the index if found in the active data otherwise -1
  6085. */
  6086. indexOf(value: T): number;
  6087. /**
  6088. * Returns whether an element is part of the active data.
  6089. * @param value defines the value to look for
  6090. * @returns true if found in the active data otherwise false
  6091. */
  6092. contains(value: T): boolean;
  6093. private static _GlobalId;
  6094. }
  6095. /**
  6096. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6097. * The data in this array can only be present once
  6098. */
  6099. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6100. private _duplicateId;
  6101. /**
  6102. * Pushes a value at the end of the active data.
  6103. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6104. * @param value defines the object to push in the array.
  6105. */
  6106. push(value: T): void;
  6107. /**
  6108. * Pushes a value at the end of the active data.
  6109. * If the data is already present, it won t be added again
  6110. * @param value defines the object to push in the array.
  6111. * @returns true if added false if it was already present
  6112. */
  6113. pushNoDuplicate(value: T): boolean;
  6114. /**
  6115. * Resets the active data to an empty array.
  6116. */
  6117. reset(): void;
  6118. /**
  6119. * Concats the active data with a given array.
  6120. * This ensures no dupplicate will be present in the result.
  6121. * @param array defines the data to concatenate with.
  6122. */
  6123. concatWithNoDuplicate(array: any): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @ignore
  6129. * This is a list of all the different input types that are available in the application.
  6130. * Fo instance: ArcRotateCameraGamepadInput...
  6131. */
  6132. export var CameraInputTypes: {};
  6133. /**
  6134. * This is the contract to implement in order to create a new input class.
  6135. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6136. */
  6137. export interface ICameraInput<TCamera extends Camera> {
  6138. /**
  6139. * Defines the camera the input is attached to.
  6140. */
  6141. camera: Nullable<TCamera>;
  6142. /**
  6143. * Gets the class name of the current intput.
  6144. * @returns the class name
  6145. */
  6146. getClassName(): string;
  6147. /**
  6148. * Get the friendly name associated with the input class.
  6149. * @returns the input friendly name
  6150. */
  6151. getSimpleName(): string;
  6152. /**
  6153. * Attach the input controls to a specific dom element to get the input from.
  6154. * @param element Defines the element the controls should be listened from
  6155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6156. */
  6157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6158. /**
  6159. * Detach the current controls from the specified dom element.
  6160. * @param element Defines the element to stop listening the inputs from
  6161. */
  6162. detachControl(element: Nullable<HTMLElement>): void;
  6163. /**
  6164. * Update the current camera state depending on the inputs that have been used this frame.
  6165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6166. */
  6167. checkInputs?: () => void;
  6168. }
  6169. /**
  6170. * Represents a map of input types to input instance or input index to input instance.
  6171. */
  6172. export interface CameraInputsMap<TCamera extends Camera> {
  6173. /**
  6174. * Accessor to the input by input type.
  6175. */
  6176. [name: string]: ICameraInput<TCamera>;
  6177. /**
  6178. * Accessor to the input by input index.
  6179. */
  6180. [idx: number]: ICameraInput<TCamera>;
  6181. }
  6182. /**
  6183. * This represents the input manager used within a camera.
  6184. * It helps dealing with all the different kind of input attached to a camera.
  6185. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6186. */
  6187. export class CameraInputsManager<TCamera extends Camera> {
  6188. /**
  6189. * Defines the list of inputs attahed to the camera.
  6190. */
  6191. attached: CameraInputsMap<TCamera>;
  6192. /**
  6193. * Defines the dom element the camera is collecting inputs from.
  6194. * This is null if the controls have not been attached.
  6195. */
  6196. attachedElement: Nullable<HTMLElement>;
  6197. /**
  6198. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6199. */
  6200. noPreventDefault: boolean;
  6201. /**
  6202. * Defined the camera the input manager belongs to.
  6203. */
  6204. camera: TCamera;
  6205. /**
  6206. * Update the current camera state depending on the inputs that have been used this frame.
  6207. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6208. */
  6209. checkInputs: () => void;
  6210. /**
  6211. * Instantiate a new Camera Input Manager.
  6212. * @param camera Defines the camera the input manager blongs to
  6213. */
  6214. constructor(camera: TCamera);
  6215. /**
  6216. * Add an input method to a camera
  6217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6218. * @param input camera input method
  6219. */
  6220. add(input: ICameraInput<TCamera>): void;
  6221. /**
  6222. * Remove a specific input method from a camera
  6223. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6224. * @param inputToRemove camera input method
  6225. */
  6226. remove(inputToRemove: ICameraInput<TCamera>): void;
  6227. /**
  6228. * Remove a specific input type from a camera
  6229. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6230. * @param inputType the type of the input to remove
  6231. */
  6232. removeByType(inputType: string): void;
  6233. private _addCheckInputs;
  6234. /**
  6235. * Attach the input controls to the currently attached dom element to listen the events from.
  6236. * @param input Defines the input to attach
  6237. */
  6238. attachInput(input: ICameraInput<TCamera>): void;
  6239. /**
  6240. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6241. * @param element Defines the dom element to collect the events from
  6242. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6243. */
  6244. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6245. /**
  6246. * Detach the current manager inputs controls from a specific dom element.
  6247. * @param element Defines the dom element to collect the events from
  6248. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6249. */
  6250. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6251. /**
  6252. * Rebuild the dynamic inputCheck function from the current list of
  6253. * defined inputs in the manager.
  6254. */
  6255. rebuildInputCheck(): void;
  6256. /**
  6257. * Remove all attached input methods from a camera
  6258. */
  6259. clear(): void;
  6260. /**
  6261. * Serialize the current input manager attached to a camera.
  6262. * This ensures than once parsed,
  6263. * the input associated to the camera will be identical to the current ones
  6264. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6265. */
  6266. serialize(serializedCamera: any): void;
  6267. /**
  6268. * Parses an input manager serialized JSON to restore the previous list of inputs
  6269. * and states associated to a camera.
  6270. * @param parsedCamera Defines the JSON to parse
  6271. */
  6272. parse(parsedCamera: any): void;
  6273. }
  6274. }
  6275. declare module BABYLON {
  6276. /**
  6277. * Class used to store data that will be store in GPU memory
  6278. */
  6279. export class Buffer {
  6280. private _engine;
  6281. private _buffer;
  6282. /** @hidden */
  6283. _data: Nullable<DataArray>;
  6284. private _updatable;
  6285. private _instanced;
  6286. private _divisor;
  6287. /**
  6288. * Gets the byte stride.
  6289. */
  6290. readonly byteStride: number;
  6291. /**
  6292. * Constructor
  6293. * @param engine the engine
  6294. * @param data the data to use for this buffer
  6295. * @param updatable whether the data is updatable
  6296. * @param stride the stride (optional)
  6297. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6298. * @param instanced whether the buffer is instanced (optional)
  6299. * @param useBytes set to true if the stride in in bytes (optional)
  6300. * @param divisor sets an optional divisor for instances (1 by default)
  6301. */
  6302. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6303. /**
  6304. * Create a new VertexBuffer based on the current buffer
  6305. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6306. * @param offset defines offset in the buffer (0 by default)
  6307. * @param size defines the size in floats of attributes (position is 3 for instance)
  6308. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6309. * @param instanced defines if the vertex buffer contains indexed data
  6310. * @param useBytes defines if the offset and stride are in bytes *
  6311. * @param divisor sets an optional divisor for instances (1 by default)
  6312. * @returns the new vertex buffer
  6313. */
  6314. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6315. /**
  6316. * Gets a boolean indicating if the Buffer is updatable?
  6317. * @returns true if the buffer is updatable
  6318. */
  6319. isUpdatable(): boolean;
  6320. /**
  6321. * Gets current buffer's data
  6322. * @returns a DataArray or null
  6323. */
  6324. getData(): Nullable<DataArray>;
  6325. /**
  6326. * Gets underlying native buffer
  6327. * @returns underlying native buffer
  6328. */
  6329. getBuffer(): Nullable<DataBuffer>;
  6330. /**
  6331. * Gets the stride in float32 units (i.e. byte stride / 4).
  6332. * May not be an integer if the byte stride is not divisible by 4.
  6333. * @returns the stride in float32 units
  6334. * @deprecated Please use byteStride instead.
  6335. */
  6336. getStrideSize(): number;
  6337. /**
  6338. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6339. * @param data defines the data to store
  6340. */
  6341. create(data?: Nullable<DataArray>): void;
  6342. /** @hidden */
  6343. _rebuild(): void;
  6344. /**
  6345. * Update current buffer data
  6346. * @param data defines the data to store
  6347. */
  6348. update(data: DataArray): void;
  6349. /**
  6350. * Updates the data directly.
  6351. * @param data the new data
  6352. * @param offset the new offset
  6353. * @param vertexCount the vertex count (optional)
  6354. * @param useBytes set to true if the offset is in bytes
  6355. */
  6356. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6357. /**
  6358. * Release all resources
  6359. */
  6360. dispose(): void;
  6361. }
  6362. /**
  6363. * Specialized buffer used to store vertex data
  6364. */
  6365. export class VertexBuffer {
  6366. /** @hidden */
  6367. _buffer: Buffer;
  6368. private _kind;
  6369. private _size;
  6370. private _ownsBuffer;
  6371. private _instanced;
  6372. private _instanceDivisor;
  6373. /**
  6374. * The byte type.
  6375. */
  6376. static readonly BYTE: number;
  6377. /**
  6378. * The unsigned byte type.
  6379. */
  6380. static readonly UNSIGNED_BYTE: number;
  6381. /**
  6382. * The short type.
  6383. */
  6384. static readonly SHORT: number;
  6385. /**
  6386. * The unsigned short type.
  6387. */
  6388. static readonly UNSIGNED_SHORT: number;
  6389. /**
  6390. * The integer type.
  6391. */
  6392. static readonly INT: number;
  6393. /**
  6394. * The unsigned integer type.
  6395. */
  6396. static readonly UNSIGNED_INT: number;
  6397. /**
  6398. * The float type.
  6399. */
  6400. static readonly FLOAT: number;
  6401. /**
  6402. * Gets or sets the instance divisor when in instanced mode
  6403. */
  6404. get instanceDivisor(): number;
  6405. set instanceDivisor(value: number);
  6406. /**
  6407. * Gets the byte stride.
  6408. */
  6409. readonly byteStride: number;
  6410. /**
  6411. * Gets the byte offset.
  6412. */
  6413. readonly byteOffset: number;
  6414. /**
  6415. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6416. */
  6417. readonly normalized: boolean;
  6418. /**
  6419. * Gets the data type of each component in the array.
  6420. */
  6421. readonly type: number;
  6422. /**
  6423. * Constructor
  6424. * @param engine the engine
  6425. * @param data the data to use for this vertex buffer
  6426. * @param kind the vertex buffer kind
  6427. * @param updatable whether the data is updatable
  6428. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6429. * @param stride the stride (optional)
  6430. * @param instanced whether the buffer is instanced (optional)
  6431. * @param offset the offset of the data (optional)
  6432. * @param size the number of components (optional)
  6433. * @param type the type of the component (optional)
  6434. * @param normalized whether the data contains normalized data (optional)
  6435. * @param useBytes set to true if stride and offset are in bytes (optional)
  6436. * @param divisor defines the instance divisor to use (1 by default)
  6437. */
  6438. 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);
  6439. /** @hidden */
  6440. _rebuild(): void;
  6441. /**
  6442. * Returns the kind of the VertexBuffer (string)
  6443. * @returns a string
  6444. */
  6445. getKind(): string;
  6446. /**
  6447. * Gets a boolean indicating if the VertexBuffer is updatable?
  6448. * @returns true if the buffer is updatable
  6449. */
  6450. isUpdatable(): boolean;
  6451. /**
  6452. * Gets current buffer's data
  6453. * @returns a DataArray or null
  6454. */
  6455. getData(): Nullable<DataArray>;
  6456. /**
  6457. * Gets underlying native buffer
  6458. * @returns underlying native buffer
  6459. */
  6460. getBuffer(): Nullable<DataBuffer>;
  6461. /**
  6462. * Gets the stride in float32 units (i.e. byte stride / 4).
  6463. * May not be an integer if the byte stride is not divisible by 4.
  6464. * @returns the stride in float32 units
  6465. * @deprecated Please use byteStride instead.
  6466. */
  6467. getStrideSize(): number;
  6468. /**
  6469. * Returns the offset as a multiple of the type byte length.
  6470. * @returns the offset in bytes
  6471. * @deprecated Please use byteOffset instead.
  6472. */
  6473. getOffset(): number;
  6474. /**
  6475. * Returns the number of components per vertex attribute (integer)
  6476. * @returns the size in float
  6477. */
  6478. getSize(): number;
  6479. /**
  6480. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6481. * @returns true if this buffer is instanced
  6482. */
  6483. getIsInstanced(): boolean;
  6484. /**
  6485. * Returns the instancing divisor, zero for non-instanced (integer).
  6486. * @returns a number
  6487. */
  6488. getInstanceDivisor(): number;
  6489. /**
  6490. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6491. * @param data defines the data to store
  6492. */
  6493. create(data?: DataArray): void;
  6494. /**
  6495. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6496. * This function will create a new buffer if the current one is not updatable
  6497. * @param data defines the data to store
  6498. */
  6499. update(data: DataArray): void;
  6500. /**
  6501. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6502. * Returns the directly updated WebGLBuffer.
  6503. * @param data the new data
  6504. * @param offset the new offset
  6505. * @param useBytes set to true if the offset is in bytes
  6506. */
  6507. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6508. /**
  6509. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6510. */
  6511. dispose(): void;
  6512. /**
  6513. * Enumerates each value of this vertex buffer as numbers.
  6514. * @param count the number of values to enumerate
  6515. * @param callback the callback function called for each value
  6516. */
  6517. forEach(count: number, callback: (value: number, index: number) => void): void;
  6518. /**
  6519. * Positions
  6520. */
  6521. static readonly PositionKind: string;
  6522. /**
  6523. * Normals
  6524. */
  6525. static readonly NormalKind: string;
  6526. /**
  6527. * Tangents
  6528. */
  6529. static readonly TangentKind: string;
  6530. /**
  6531. * Texture coordinates
  6532. */
  6533. static readonly UVKind: string;
  6534. /**
  6535. * Texture coordinates 2
  6536. */
  6537. static readonly UV2Kind: string;
  6538. /**
  6539. * Texture coordinates 3
  6540. */
  6541. static readonly UV3Kind: string;
  6542. /**
  6543. * Texture coordinates 4
  6544. */
  6545. static readonly UV4Kind: string;
  6546. /**
  6547. * Texture coordinates 5
  6548. */
  6549. static readonly UV5Kind: string;
  6550. /**
  6551. * Texture coordinates 6
  6552. */
  6553. static readonly UV6Kind: string;
  6554. /**
  6555. * Colors
  6556. */
  6557. static readonly ColorKind: string;
  6558. /**
  6559. * Matrix indices (for bones)
  6560. */
  6561. static readonly MatricesIndicesKind: string;
  6562. /**
  6563. * Matrix weights (for bones)
  6564. */
  6565. static readonly MatricesWeightsKind: string;
  6566. /**
  6567. * Additional matrix indices (for bones)
  6568. */
  6569. static readonly MatricesIndicesExtraKind: string;
  6570. /**
  6571. * Additional matrix weights (for bones)
  6572. */
  6573. static readonly MatricesWeightsExtraKind: string;
  6574. /**
  6575. * Deduces the stride given a kind.
  6576. * @param kind The kind string to deduce
  6577. * @returns The deduced stride
  6578. */
  6579. static DeduceStride(kind: string): number;
  6580. /**
  6581. * Gets the byte length of the given type.
  6582. * @param type the type
  6583. * @returns the number of bytes
  6584. */
  6585. static GetTypeByteLength(type: number): number;
  6586. /**
  6587. * Enumerates each value of the given parameters as numbers.
  6588. * @param data the data to enumerate
  6589. * @param byteOffset the byte offset of the data
  6590. * @param byteStride the byte stride of the data
  6591. * @param componentCount the number of components per element
  6592. * @param componentType the type of the component
  6593. * @param count the number of values to enumerate
  6594. * @param normalized whether the data is normalized
  6595. * @param callback the callback function called for each value
  6596. */
  6597. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6598. private static _GetFloatValue;
  6599. }
  6600. }
  6601. declare module BABYLON {
  6602. /**
  6603. * @hidden
  6604. */
  6605. export class IntersectionInfo {
  6606. bu: Nullable<number>;
  6607. bv: Nullable<number>;
  6608. distance: number;
  6609. faceId: number;
  6610. subMeshId: number;
  6611. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6612. }
  6613. }
  6614. declare module BABYLON {
  6615. /**
  6616. * Represens a plane by the equation ax + by + cz + d = 0
  6617. */
  6618. export class Plane {
  6619. private static _TmpMatrix;
  6620. /**
  6621. * Normal of the plane (a,b,c)
  6622. */
  6623. normal: Vector3;
  6624. /**
  6625. * d component of the plane
  6626. */
  6627. d: number;
  6628. /**
  6629. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6630. * @param a a component of the plane
  6631. * @param b b component of the plane
  6632. * @param c c component of the plane
  6633. * @param d d component of the plane
  6634. */
  6635. constructor(a: number, b: number, c: number, d: number);
  6636. /**
  6637. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6638. */
  6639. asArray(): number[];
  6640. /**
  6641. * @returns a new plane copied from the current Plane.
  6642. */
  6643. clone(): Plane;
  6644. /**
  6645. * @returns the string "Plane".
  6646. */
  6647. getClassName(): string;
  6648. /**
  6649. * @returns the Plane hash code.
  6650. */
  6651. getHashCode(): number;
  6652. /**
  6653. * Normalize the current Plane in place.
  6654. * @returns the updated Plane.
  6655. */
  6656. normalize(): Plane;
  6657. /**
  6658. * Applies a transformation the plane and returns the result
  6659. * @param transformation the transformation matrix to be applied to the plane
  6660. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6661. */
  6662. transform(transformation: DeepImmutable<Matrix>): Plane;
  6663. /**
  6664. * Calcualtte the dot product between the point and the plane normal
  6665. * @param point point to calculate the dot product with
  6666. * @returns the dot product (float) of the point coordinates and the plane normal.
  6667. */
  6668. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6669. /**
  6670. * Updates the current Plane from the plane defined by the three given points.
  6671. * @param point1 one of the points used to contruct the plane
  6672. * @param point2 one of the points used to contruct the plane
  6673. * @param point3 one of the points used to contruct the plane
  6674. * @returns the updated Plane.
  6675. */
  6676. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6677. /**
  6678. * Checks if the plane is facing a given direction
  6679. * @param direction the direction to check if the plane is facing
  6680. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6681. * @returns True is the vector "direction" is the same side than the plane normal.
  6682. */
  6683. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6684. /**
  6685. * Calculates the distance to a point
  6686. * @param point point to calculate distance to
  6687. * @returns the signed distance (float) from the given point to the Plane.
  6688. */
  6689. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6690. /**
  6691. * Creates a plane from an array
  6692. * @param array the array to create a plane from
  6693. * @returns a new Plane from the given array.
  6694. */
  6695. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6696. /**
  6697. * Creates a plane from three points
  6698. * @param point1 point used to create the plane
  6699. * @param point2 point used to create the plane
  6700. * @param point3 point used to create the plane
  6701. * @returns a new Plane defined by the three given points.
  6702. */
  6703. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6704. /**
  6705. * Creates a plane from an origin point and a normal
  6706. * @param origin origin of the plane to be constructed
  6707. * @param normal normal of the plane to be constructed
  6708. * @returns a new Plane the normal vector to this plane at the given origin point.
  6709. * Note : the vector "normal" is updated because normalized.
  6710. */
  6711. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6712. /**
  6713. * Calculates the distance from a plane and a point
  6714. * @param origin origin of the plane to be constructed
  6715. * @param normal normal of the plane to be constructed
  6716. * @param point point to calculate distance to
  6717. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6718. */
  6719. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6720. }
  6721. }
  6722. declare module BABYLON {
  6723. /**
  6724. * Class used to store bounding sphere information
  6725. */
  6726. export class BoundingSphere {
  6727. /**
  6728. * Gets the center of the bounding sphere in local space
  6729. */
  6730. readonly center: Vector3;
  6731. /**
  6732. * Radius of the bounding sphere in local space
  6733. */
  6734. radius: number;
  6735. /**
  6736. * Gets the center of the bounding sphere in world space
  6737. */
  6738. readonly centerWorld: Vector3;
  6739. /**
  6740. * Radius of the bounding sphere in world space
  6741. */
  6742. radiusWorld: number;
  6743. /**
  6744. * Gets the minimum vector in local space
  6745. */
  6746. readonly minimum: Vector3;
  6747. /**
  6748. * Gets the maximum vector in local space
  6749. */
  6750. readonly maximum: Vector3;
  6751. private _worldMatrix;
  6752. private static readonly TmpVector3;
  6753. /**
  6754. * Creates a new bounding sphere
  6755. * @param min defines the minimum vector (in local space)
  6756. * @param max defines the maximum vector (in local space)
  6757. * @param worldMatrix defines the new world matrix
  6758. */
  6759. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6760. /**
  6761. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6762. * @param min defines the new minimum vector (in local space)
  6763. * @param max defines the new maximum vector (in local space)
  6764. * @param worldMatrix defines the new world matrix
  6765. */
  6766. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6767. /**
  6768. * Scale the current bounding sphere by applying a scale factor
  6769. * @param factor defines the scale factor to apply
  6770. * @returns the current bounding box
  6771. */
  6772. scale(factor: number): BoundingSphere;
  6773. /**
  6774. * Gets the world matrix of the bounding box
  6775. * @returns a matrix
  6776. */
  6777. getWorldMatrix(): DeepImmutable<Matrix>;
  6778. /** @hidden */
  6779. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6780. /**
  6781. * Tests if the bounding sphere is intersecting the frustum planes
  6782. * @param frustumPlanes defines the frustum planes to test
  6783. * @returns true if there is an intersection
  6784. */
  6785. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6786. /**
  6787. * Tests if the bounding sphere center is in between the frustum planes.
  6788. * Used for optimistic fast inclusion.
  6789. * @param frustumPlanes defines the frustum planes to test
  6790. * @returns true if the sphere center is in between the frustum planes
  6791. */
  6792. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6793. /**
  6794. * Tests if a point is inside the bounding sphere
  6795. * @param point defines the point to test
  6796. * @returns true if the point is inside the bounding sphere
  6797. */
  6798. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6799. /**
  6800. * Checks if two sphere intersct
  6801. * @param sphere0 sphere 0
  6802. * @param sphere1 sphere 1
  6803. * @returns true if the speres intersect
  6804. */
  6805. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6806. }
  6807. }
  6808. declare module BABYLON {
  6809. /**
  6810. * Class used to store bounding box information
  6811. */
  6812. export class BoundingBox implements ICullable {
  6813. /**
  6814. * Gets the 8 vectors representing the bounding box in local space
  6815. */
  6816. readonly vectors: Vector3[];
  6817. /**
  6818. * Gets the center of the bounding box in local space
  6819. */
  6820. readonly center: Vector3;
  6821. /**
  6822. * Gets the center of the bounding box in world space
  6823. */
  6824. readonly centerWorld: Vector3;
  6825. /**
  6826. * Gets the extend size in local space
  6827. */
  6828. readonly extendSize: Vector3;
  6829. /**
  6830. * Gets the extend size in world space
  6831. */
  6832. readonly extendSizeWorld: Vector3;
  6833. /**
  6834. * Gets the OBB (object bounding box) directions
  6835. */
  6836. readonly directions: Vector3[];
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in world space
  6839. */
  6840. readonly vectorsWorld: Vector3[];
  6841. /**
  6842. * Gets the minimum vector in world space
  6843. */
  6844. readonly minimumWorld: Vector3;
  6845. /**
  6846. * Gets the maximum vector in world space
  6847. */
  6848. readonly maximumWorld: Vector3;
  6849. /**
  6850. * Gets the minimum vector in local space
  6851. */
  6852. readonly minimum: Vector3;
  6853. /**
  6854. * Gets the maximum vector in local space
  6855. */
  6856. readonly maximum: Vector3;
  6857. private _worldMatrix;
  6858. private static readonly TmpVector3;
  6859. /**
  6860. * @hidden
  6861. */
  6862. _tag: number;
  6863. /**
  6864. * Creates a new bounding box
  6865. * @param min defines the minimum vector (in local space)
  6866. * @param max defines the maximum vector (in local space)
  6867. * @param worldMatrix defines the new world matrix
  6868. */
  6869. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6870. /**
  6871. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6872. * @param min defines the new minimum vector (in local space)
  6873. * @param max defines the new maximum vector (in local space)
  6874. * @param worldMatrix defines the new world matrix
  6875. */
  6876. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6877. /**
  6878. * Scale the current bounding box by applying a scale factor
  6879. * @param factor defines the scale factor to apply
  6880. * @returns the current bounding box
  6881. */
  6882. scale(factor: number): BoundingBox;
  6883. /**
  6884. * Gets the world matrix of the bounding box
  6885. * @returns a matrix
  6886. */
  6887. getWorldMatrix(): DeepImmutable<Matrix>;
  6888. /** @hidden */
  6889. _update(world: DeepImmutable<Matrix>): void;
  6890. /**
  6891. * Tests if the bounding box is intersecting the frustum planes
  6892. * @param frustumPlanes defines the frustum planes to test
  6893. * @returns true if there is an intersection
  6894. */
  6895. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6896. /**
  6897. * Tests if the bounding box is entirely inside the frustum planes
  6898. * @param frustumPlanes defines the frustum planes to test
  6899. * @returns true if there is an inclusion
  6900. */
  6901. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6902. /**
  6903. * Tests if a point is inside the bounding box
  6904. * @param point defines the point to test
  6905. * @returns true if the point is inside the bounding box
  6906. */
  6907. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6908. /**
  6909. * Tests if the bounding box intersects with a bounding sphere
  6910. * @param sphere defines the sphere to test
  6911. * @returns true if there is an intersection
  6912. */
  6913. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6914. /**
  6915. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6916. * @param min defines the min vector to use
  6917. * @param max defines the max vector to use
  6918. * @returns true if there is an intersection
  6919. */
  6920. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6921. /**
  6922. * Tests if two bounding boxes are intersections
  6923. * @param box0 defines the first box to test
  6924. * @param box1 defines the second box to test
  6925. * @returns true if there is an intersection
  6926. */
  6927. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6928. /**
  6929. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6930. * @param minPoint defines the minimum vector of the bounding box
  6931. * @param maxPoint defines the maximum vector of the bounding box
  6932. * @param sphereCenter defines the sphere center
  6933. * @param sphereRadius defines the sphere radius
  6934. * @returns true if there is an intersection
  6935. */
  6936. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6937. /**
  6938. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6939. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @return true if there is an inclusion
  6942. */
  6943. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6946. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6947. * @param frustumPlanes defines the frustum planes to test
  6948. * @return true if there is an intersection
  6949. */
  6950. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6951. }
  6952. }
  6953. declare module BABYLON {
  6954. /** @hidden */
  6955. export class Collider {
  6956. /** Define if a collision was found */
  6957. collisionFound: boolean;
  6958. /**
  6959. * Define last intersection point in local space
  6960. */
  6961. intersectionPoint: Vector3;
  6962. /**
  6963. * Define last collided mesh
  6964. */
  6965. collidedMesh: Nullable<AbstractMesh>;
  6966. private _collisionPoint;
  6967. private _planeIntersectionPoint;
  6968. private _tempVector;
  6969. private _tempVector2;
  6970. private _tempVector3;
  6971. private _tempVector4;
  6972. private _edge;
  6973. private _baseToVertex;
  6974. private _destinationPoint;
  6975. private _slidePlaneNormal;
  6976. private _displacementVector;
  6977. /** @hidden */
  6978. _radius: Vector3;
  6979. /** @hidden */
  6980. _retry: number;
  6981. private _velocity;
  6982. private _basePoint;
  6983. private _epsilon;
  6984. /** @hidden */
  6985. _velocityWorldLength: number;
  6986. /** @hidden */
  6987. _basePointWorld: Vector3;
  6988. private _velocityWorld;
  6989. private _normalizedVelocity;
  6990. /** @hidden */
  6991. _initialVelocity: Vector3;
  6992. /** @hidden */
  6993. _initialPosition: Vector3;
  6994. private _nearestDistance;
  6995. private _collisionMask;
  6996. get collisionMask(): number;
  6997. set collisionMask(mask: number);
  6998. /**
  6999. * Gets the plane normal used to compute the sliding response (in local space)
  7000. */
  7001. get slidePlaneNormal(): Vector3;
  7002. /** @hidden */
  7003. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7004. /** @hidden */
  7005. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7006. /** @hidden */
  7007. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7008. /** @hidden */
  7009. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7010. /** @hidden */
  7011. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7012. /** @hidden */
  7013. _getResponse(pos: Vector3, vel: Vector3): void;
  7014. }
  7015. }
  7016. declare module BABYLON {
  7017. /**
  7018. * Interface for cullable objects
  7019. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7020. */
  7021. export interface ICullable {
  7022. /**
  7023. * Checks if the object or part of the object is in the frustum
  7024. * @param frustumPlanes Camera near/planes
  7025. * @returns true if the object is in frustum otherwise false
  7026. */
  7027. isInFrustum(frustumPlanes: Plane[]): boolean;
  7028. /**
  7029. * Checks if a cullable object (mesh...) is in the camera frustum
  7030. * Unlike isInFrustum this cheks the full bounding box
  7031. * @param frustumPlanes Camera near/planes
  7032. * @returns true if the object is in frustum otherwise false
  7033. */
  7034. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7035. }
  7036. /**
  7037. * Info for a bounding data of a mesh
  7038. */
  7039. export class BoundingInfo implements ICullable {
  7040. /**
  7041. * Bounding box for the mesh
  7042. */
  7043. readonly boundingBox: BoundingBox;
  7044. /**
  7045. * Bounding sphere for the mesh
  7046. */
  7047. readonly boundingSphere: BoundingSphere;
  7048. private _isLocked;
  7049. private static readonly TmpVector3;
  7050. /**
  7051. * Constructs bounding info
  7052. * @param minimum min vector of the bounding box/sphere
  7053. * @param maximum max vector of the bounding box/sphere
  7054. * @param worldMatrix defines the new world matrix
  7055. */
  7056. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7057. /**
  7058. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7059. * @param min defines the new minimum vector (in local space)
  7060. * @param max defines the new maximum vector (in local space)
  7061. * @param worldMatrix defines the new world matrix
  7062. */
  7063. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7064. /**
  7065. * min vector of the bounding box/sphere
  7066. */
  7067. get minimum(): Vector3;
  7068. /**
  7069. * max vector of the bounding box/sphere
  7070. */
  7071. get maximum(): Vector3;
  7072. /**
  7073. * If the info is locked and won't be updated to avoid perf overhead
  7074. */
  7075. get isLocked(): boolean;
  7076. set isLocked(value: boolean);
  7077. /**
  7078. * Updates the bounding sphere and box
  7079. * @param world world matrix to be used to update
  7080. */
  7081. update(world: DeepImmutable<Matrix>): void;
  7082. /**
  7083. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7084. * @param center New center of the bounding info
  7085. * @param extend New extend of the bounding info
  7086. * @returns the current bounding info
  7087. */
  7088. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7089. /**
  7090. * Scale the current bounding info by applying a scale factor
  7091. * @param factor defines the scale factor to apply
  7092. * @returns the current bounding info
  7093. */
  7094. scale(factor: number): BoundingInfo;
  7095. /**
  7096. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7097. * @param frustumPlanes defines the frustum to test
  7098. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7099. * @returns true if the bounding info is in the frustum planes
  7100. */
  7101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7102. /**
  7103. * Gets the world distance between the min and max points of the bounding box
  7104. */
  7105. get diagonalLength(): number;
  7106. /**
  7107. * Checks if a cullable object (mesh...) is in the camera frustum
  7108. * Unlike isInFrustum this cheks the full bounding box
  7109. * @param frustumPlanes Camera near/planes
  7110. * @returns true if the object is in frustum otherwise false
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /** @hidden */
  7114. _checkCollision(collider: Collider): boolean;
  7115. /**
  7116. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7117. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7118. * @param point the point to check intersection with
  7119. * @returns if the point intersects
  7120. */
  7121. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7122. /**
  7123. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param boundingInfo the bounding info to check intersection with
  7126. * @param precise if the intersection should be done using OBB
  7127. * @returns if the bounding info intersects
  7128. */
  7129. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7130. }
  7131. }
  7132. declare module BABYLON {
  7133. /**
  7134. * Extracts minimum and maximum values from a list of indexed positions
  7135. * @param positions defines the positions to use
  7136. * @param indices defines the indices to the positions
  7137. * @param indexStart defines the start index
  7138. * @param indexCount defines the end index
  7139. * @param bias defines bias value to add to the result
  7140. * @return minimum and maximum values
  7141. */
  7142. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7143. minimum: Vector3;
  7144. maximum: Vector3;
  7145. };
  7146. /**
  7147. * Extracts minimum and maximum values from a list of positions
  7148. * @param positions defines the positions to use
  7149. * @param start defines the start index in the positions array
  7150. * @param count defines the number of positions to handle
  7151. * @param bias defines bias value to add to the result
  7152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7153. * @return minimum and maximum values
  7154. */
  7155. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7156. minimum: Vector3;
  7157. maximum: Vector3;
  7158. };
  7159. }
  7160. declare module BABYLON {
  7161. /** @hidden */
  7162. export class WebGLDataBuffer extends DataBuffer {
  7163. private _buffer;
  7164. constructor(resource: WebGLBuffer);
  7165. get underlyingResource(): any;
  7166. }
  7167. }
  7168. declare module BABYLON {
  7169. /** @hidden */
  7170. export class WebGLPipelineContext implements IPipelineContext {
  7171. engine: ThinEngine;
  7172. program: Nullable<WebGLProgram>;
  7173. context?: WebGLRenderingContext;
  7174. vertexShader?: WebGLShader;
  7175. fragmentShader?: WebGLShader;
  7176. isParallelCompiled: boolean;
  7177. onCompiled?: () => void;
  7178. transformFeedback?: WebGLTransformFeedback | null;
  7179. vertexCompilationError: Nullable<string>;
  7180. fragmentCompilationError: Nullable<string>;
  7181. programLinkError: Nullable<string>;
  7182. programValidationError: Nullable<string>;
  7183. get isAsync(): boolean;
  7184. get isReady(): boolean;
  7185. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7186. _getVertexShaderCode(): string | null;
  7187. _getFragmentShaderCode(): string | null;
  7188. }
  7189. }
  7190. declare module BABYLON {
  7191. interface ThinEngine {
  7192. /**
  7193. * Create an uniform buffer
  7194. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7195. * @param elements defines the content of the uniform buffer
  7196. * @returns the webGL uniform buffer
  7197. */
  7198. createUniformBuffer(elements: FloatArray): DataBuffer;
  7199. /**
  7200. * Create a dynamic uniform buffer
  7201. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7202. * @param elements defines the content of the uniform buffer
  7203. * @returns the webGL uniform buffer
  7204. */
  7205. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7206. /**
  7207. * Update an existing uniform buffer
  7208. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7209. * @param uniformBuffer defines the target uniform buffer
  7210. * @param elements defines the content to update
  7211. * @param offset defines the offset in the uniform buffer where update should start
  7212. * @param count defines the size of the data to update
  7213. */
  7214. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7215. /**
  7216. * Bind an uniform buffer to the current webGL context
  7217. * @param buffer defines the buffer to bind
  7218. */
  7219. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7220. /**
  7221. * Bind a buffer to the current webGL context at a given location
  7222. * @param buffer defines the buffer to bind
  7223. * @param location defines the index where to bind the buffer
  7224. */
  7225. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7226. /**
  7227. * Bind a specific block at a given index in a specific shader program
  7228. * @param pipelineContext defines the pipeline context to use
  7229. * @param blockName defines the block name
  7230. * @param index defines the index where to bind the block
  7231. */
  7232. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Uniform buffer objects.
  7238. *
  7239. * Handles blocks of uniform on the GPU.
  7240. *
  7241. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7242. *
  7243. * For more information, please refer to :
  7244. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7245. */
  7246. export class UniformBuffer {
  7247. private _engine;
  7248. private _buffer;
  7249. private _data;
  7250. private _bufferData;
  7251. private _dynamic?;
  7252. private _uniformLocations;
  7253. private _uniformSizes;
  7254. private _uniformLocationPointer;
  7255. private _needSync;
  7256. private _noUBO;
  7257. private _currentEffect;
  7258. /** @hidden */
  7259. _alreadyBound: boolean;
  7260. private static _MAX_UNIFORM_SIZE;
  7261. private static _tempBuffer;
  7262. /**
  7263. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7268. /**
  7269. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7274. /**
  7275. * Lambda to Update a single float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat: (name: string, x: number) => void;
  7280. /**
  7281. * Lambda to Update a vec2 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a vec3 of float in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7292. /**
  7293. * Lambda to Update a vec4 of float in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7298. /**
  7299. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateMatrix: (name: string, mat: Matrix) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateVector3: (name: string, vector: Vector3) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateVector4: (name: string, vector: Vector4) => void;
  7316. /**
  7317. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7318. * This is dynamic to allow compat with webgl 1 and 2.
  7319. * You will need to pass the name of the uniform as well as the value.
  7320. */
  7321. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7322. /**
  7323. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7324. * This is dynamic to allow compat with webgl 1 and 2.
  7325. * You will need to pass the name of the uniform as well as the value.
  7326. */
  7327. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7328. /**
  7329. * Instantiates a new Uniform buffer objects.
  7330. *
  7331. * Handles blocks of uniform on the GPU.
  7332. *
  7333. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7334. *
  7335. * For more information, please refer to :
  7336. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7337. * @param engine Define the engine the buffer is associated with
  7338. * @param data Define the data contained in the buffer
  7339. * @param dynamic Define if the buffer is updatable
  7340. */
  7341. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7342. /**
  7343. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7344. * or just falling back on setUniformXXX calls.
  7345. */
  7346. get useUbo(): boolean;
  7347. /**
  7348. * Indicates if the WebGL underlying uniform buffer is in sync
  7349. * with the javascript cache data.
  7350. */
  7351. get isSync(): boolean;
  7352. /**
  7353. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7354. * Also, a dynamic UniformBuffer will disable cache verification and always
  7355. * update the underlying WebGL uniform buffer to the GPU.
  7356. * @returns if Dynamic, otherwise false
  7357. */
  7358. isDynamic(): boolean;
  7359. /**
  7360. * The data cache on JS side.
  7361. * @returns the underlying data as a float array
  7362. */
  7363. getData(): Float32Array;
  7364. /**
  7365. * The underlying WebGL Uniform buffer.
  7366. * @returns the webgl buffer
  7367. */
  7368. getBuffer(): Nullable<DataBuffer>;
  7369. /**
  7370. * std140 layout specifies how to align data within an UBO structure.
  7371. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7372. * for specs.
  7373. */
  7374. private _fillAlignment;
  7375. /**
  7376. * Adds an uniform in the buffer.
  7377. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7378. * for the layout to be correct !
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param size Data size, or data directly.
  7381. */
  7382. addUniform(name: string, size: number | number[]): void;
  7383. /**
  7384. * Adds a Matrix 4x4 to the uniform buffer.
  7385. * @param name Name of the uniform, as used in the uniform block in the shader.
  7386. * @param mat A 4x4 matrix.
  7387. */
  7388. addMatrix(name: string, mat: Matrix): void;
  7389. /**
  7390. * Adds a vec2 to the uniform buffer.
  7391. * @param name Name of the uniform, as used in the uniform block in the shader.
  7392. * @param x Define the x component value of the vec2
  7393. * @param y Define the y component value of the vec2
  7394. */
  7395. addFloat2(name: string, x: number, y: number): void;
  7396. /**
  7397. * Adds a vec3 to the uniform buffer.
  7398. * @param name Name of the uniform, as used in the uniform block in the shader.
  7399. * @param x Define the x component value of the vec3
  7400. * @param y Define the y component value of the vec3
  7401. * @param z Define the z component value of the vec3
  7402. */
  7403. addFloat3(name: string, x: number, y: number, z: number): void;
  7404. /**
  7405. * Adds a vec3 to the uniform buffer.
  7406. * @param name Name of the uniform, as used in the uniform block in the shader.
  7407. * @param color Define the vec3 from a Color
  7408. */
  7409. addColor3(name: string, color: Color3): void;
  7410. /**
  7411. * Adds a vec4 to the uniform buffer.
  7412. * @param name Name of the uniform, as used in the uniform block in the shader.
  7413. * @param color Define the rgb components from a Color
  7414. * @param alpha Define the a component of the vec4
  7415. */
  7416. addColor4(name: string, color: Color3, alpha: number): void;
  7417. /**
  7418. * Adds a vec3 to the uniform buffer.
  7419. * @param name Name of the uniform, as used in the uniform block in the shader.
  7420. * @param vector Define the vec3 components from a Vector
  7421. */
  7422. addVector3(name: string, vector: Vector3): void;
  7423. /**
  7424. * Adds a Matrix 3x3 to the uniform buffer.
  7425. * @param name Name of the uniform, as used in the uniform block in the shader.
  7426. */
  7427. addMatrix3x3(name: string): void;
  7428. /**
  7429. * Adds a Matrix 2x2 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. */
  7432. addMatrix2x2(name: string): void;
  7433. /**
  7434. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7435. */
  7436. create(): void;
  7437. /** @hidden */
  7438. _rebuild(): void;
  7439. /**
  7440. * Updates the WebGL Uniform Buffer on the GPU.
  7441. * If the `dynamic` flag is set to true, no cache comparison is done.
  7442. * Otherwise, the buffer will be updated only if the cache differs.
  7443. */
  7444. update(): void;
  7445. /**
  7446. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7447. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7448. * @param data Define the flattened data
  7449. * @param size Define the size of the data.
  7450. */
  7451. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7452. private _valueCache;
  7453. private _cacheMatrix;
  7454. private _updateMatrix3x3ForUniform;
  7455. private _updateMatrix3x3ForEffect;
  7456. private _updateMatrix2x2ForEffect;
  7457. private _updateMatrix2x2ForUniform;
  7458. private _updateFloatForEffect;
  7459. private _updateFloatForUniform;
  7460. private _updateFloat2ForEffect;
  7461. private _updateFloat2ForUniform;
  7462. private _updateFloat3ForEffect;
  7463. private _updateFloat3ForUniform;
  7464. private _updateFloat4ForEffect;
  7465. private _updateFloat4ForUniform;
  7466. private _updateMatrixForEffect;
  7467. private _updateMatrixForUniform;
  7468. private _updateVector3ForEffect;
  7469. private _updateVector3ForUniform;
  7470. private _updateVector4ForEffect;
  7471. private _updateVector4ForUniform;
  7472. private _updateColor3ForEffect;
  7473. private _updateColor3ForUniform;
  7474. private _updateColor4ForEffect;
  7475. private _updateColor4ForUniform;
  7476. /**
  7477. * Sets a sampler uniform on the effect.
  7478. * @param name Define the name of the sampler.
  7479. * @param texture Define the texture to set in the sampler
  7480. */
  7481. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7482. /**
  7483. * Directly updates the value of the uniform in the cache AND on the GPU.
  7484. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7485. * @param data Define the flattened data
  7486. */
  7487. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7488. /**
  7489. * Binds this uniform buffer to an effect.
  7490. * @param effect Define the effect to bind the buffer to
  7491. * @param name Name of the uniform block in the shader.
  7492. */
  7493. bindToEffect(effect: Effect, name: string): void;
  7494. /**
  7495. * Disposes the uniform buffer.
  7496. */
  7497. dispose(): void;
  7498. }
  7499. }
  7500. declare module BABYLON {
  7501. /**
  7502. * Enum that determines the text-wrapping mode to use.
  7503. */
  7504. export enum InspectableType {
  7505. /**
  7506. * Checkbox for booleans
  7507. */
  7508. Checkbox = 0,
  7509. /**
  7510. * Sliders for numbers
  7511. */
  7512. Slider = 1,
  7513. /**
  7514. * Vector3
  7515. */
  7516. Vector3 = 2,
  7517. /**
  7518. * Quaternions
  7519. */
  7520. Quaternion = 3,
  7521. /**
  7522. * Color3
  7523. */
  7524. Color3 = 4,
  7525. /**
  7526. * String
  7527. */
  7528. String = 5
  7529. }
  7530. /**
  7531. * Interface used to define custom inspectable properties.
  7532. * This interface is used by the inspector to display custom property grids
  7533. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7534. */
  7535. export interface IInspectable {
  7536. /**
  7537. * Gets the label to display
  7538. */
  7539. label: string;
  7540. /**
  7541. * Gets the name of the property to edit
  7542. */
  7543. propertyName: string;
  7544. /**
  7545. * Gets the type of the editor to use
  7546. */
  7547. type: InspectableType;
  7548. /**
  7549. * Gets the minimum value of the property when using in "slider" mode
  7550. */
  7551. min?: number;
  7552. /**
  7553. * Gets the maximum value of the property when using in "slider" mode
  7554. */
  7555. max?: number;
  7556. /**
  7557. * Gets the setp to use when using in "slider" mode
  7558. */
  7559. step?: number;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to provide helper for timing
  7565. */
  7566. export class TimingTools {
  7567. /**
  7568. * Polyfill for setImmediate
  7569. * @param action defines the action to execute after the current execution block
  7570. */
  7571. static SetImmediate(action: () => void): void;
  7572. }
  7573. }
  7574. declare module BABYLON {
  7575. /**
  7576. * Class used to enable instatition of objects by class name
  7577. */
  7578. export class InstantiationTools {
  7579. /**
  7580. * Use this object to register external classes like custom textures or material
  7581. * to allow the laoders to instantiate them
  7582. */
  7583. static RegisteredExternalClasses: {
  7584. [key: string]: Object;
  7585. };
  7586. /**
  7587. * Tries to instantiate a new object from a given class name
  7588. * @param className defines the class name to instantiate
  7589. * @returns the new object or null if the system was not able to do the instantiation
  7590. */
  7591. static Instantiate(className: string): any;
  7592. }
  7593. }
  7594. declare module BABYLON {
  7595. /**
  7596. * Define options used to create a depth texture
  7597. */
  7598. export class DepthTextureCreationOptions {
  7599. /** Specifies whether or not a stencil should be allocated in the texture */
  7600. generateStencil?: boolean;
  7601. /** Specifies whether or not bilinear filtering is enable on the texture */
  7602. bilinearFiltering?: boolean;
  7603. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7604. comparisonFunction?: number;
  7605. /** Specifies if the created texture is a cube texture */
  7606. isCube?: boolean;
  7607. }
  7608. }
  7609. declare module BABYLON {
  7610. interface ThinEngine {
  7611. /**
  7612. * Creates a depth stencil cube texture.
  7613. * This is only available in WebGL 2.
  7614. * @param size The size of face edge in the cube texture.
  7615. * @param options The options defining the cube texture.
  7616. * @returns The cube texture
  7617. */
  7618. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7619. /**
  7620. * Creates a cube texture
  7621. * @param rootUrl defines the url where the files to load is located
  7622. * @param scene defines the current scene
  7623. * @param files defines the list of files to load (1 per face)
  7624. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7625. * @param onLoad defines an optional callback raised when the texture is loaded
  7626. * @param onError defines an optional callback raised if there is an issue to load the texture
  7627. * @param format defines the format of the data
  7628. * @param forcedExtension defines the extension to use to pick the right loader
  7629. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7630. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7631. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7632. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7633. * @returns the cube texture as an InternalTexture
  7634. */
  7635. 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;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @returns the cube texture as an InternalTexture
  7647. */
  7648. 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;
  7649. /**
  7650. * Creates a cube texture
  7651. * @param rootUrl defines the url where the files to load is located
  7652. * @param scene defines the current scene
  7653. * @param files defines the list of files to load (1 per face)
  7654. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7655. * @param onLoad defines an optional callback raised when the texture is loaded
  7656. * @param onError defines an optional callback raised if there is an issue to load the texture
  7657. * @param format defines the format of the data
  7658. * @param forcedExtension defines the extension to use to pick the right loader
  7659. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7660. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7661. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  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, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7665. /** @hidden */
  7666. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7667. /** @hidden */
  7668. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7669. /** @hidden */
  7670. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7671. /** @hidden */
  7672. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7673. /**
  7674. * @hidden
  7675. */
  7676. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7677. }
  7678. }
  7679. declare module BABYLON {
  7680. /**
  7681. * Class for creating a cube texture
  7682. */
  7683. export class CubeTexture extends BaseTexture {
  7684. private _delayedOnLoad;
  7685. /**
  7686. * Observable triggered once the texture has been loaded.
  7687. */
  7688. onLoadObservable: Observable<CubeTexture>;
  7689. /**
  7690. * The url of the texture
  7691. */
  7692. url: string;
  7693. /**
  7694. * Gets or sets the center of the bounding box associated with the cube texture.
  7695. * It must define where the camera used to render the texture was set
  7696. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7697. */
  7698. boundingBoxPosition: Vector3;
  7699. private _boundingBoxSize;
  7700. /**
  7701. * Gets or sets the size of the bounding box associated with the cube texture
  7702. * When defined, the cubemap will switch to local mode
  7703. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7704. * @example https://www.babylonjs-playground.com/#RNASML
  7705. */
  7706. set boundingBoxSize(value: Vector3);
  7707. /**
  7708. * Returns the bounding box size
  7709. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7710. */
  7711. get boundingBoxSize(): Vector3;
  7712. protected _rotationY: number;
  7713. /**
  7714. * Sets texture matrix rotation angle around Y axis in radians.
  7715. */
  7716. set rotationY(value: number);
  7717. /**
  7718. * Gets texture matrix rotation angle around Y axis radians.
  7719. */
  7720. get rotationY(): number;
  7721. /**
  7722. * Are mip maps generated for this texture or not.
  7723. */
  7724. get noMipmap(): boolean;
  7725. private _noMipmap;
  7726. private _files;
  7727. protected _forcedExtension: Nullable<string>;
  7728. private _extensions;
  7729. private _textureMatrix;
  7730. private _format;
  7731. private _createPolynomials;
  7732. /** @hidden */
  7733. _prefiltered: boolean;
  7734. /**
  7735. * Creates a cube texture from an array of image urls
  7736. * @param files defines an array of image urls
  7737. * @param scene defines the hosting scene
  7738. * @param noMipmap specifies if mip maps are not used
  7739. * @returns a cube texture
  7740. */
  7741. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7742. /**
  7743. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7744. * @param url defines the url of the prefiltered texture
  7745. * @param scene defines the scene the texture is attached to
  7746. * @param forcedExtension defines the extension of the file if different from the url
  7747. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7748. * @return the prefiltered texture
  7749. */
  7750. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7751. /**
  7752. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7753. * as prefiltered data.
  7754. * @param rootUrl defines the url of the texture or the root name of the six images
  7755. * @param scene defines the scene the texture is attached to
  7756. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7757. * @param noMipmap defines if mipmaps should be created or not
  7758. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7759. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7760. * @param onError defines a callback triggered in case of error during load
  7761. * @param format defines the internal format to use for the texture once loaded
  7762. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7763. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7764. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7765. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7766. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7767. * @return the cube texture
  7768. */
  7769. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7770. /**
  7771. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7772. */
  7773. get isPrefiltered(): boolean;
  7774. /**
  7775. * Get the current class name of the texture useful for serialization or dynamic coding.
  7776. * @returns "CubeTexture"
  7777. */
  7778. getClassName(): string;
  7779. /**
  7780. * Update the url (and optional buffer) of this texture if url was null during construction.
  7781. * @param url the url of the texture
  7782. * @param forcedExtension defines the extension to use
  7783. * @param onLoad callback called when the texture is loaded (defaults to null)
  7784. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7785. */
  7786. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7787. /**
  7788. * Delays loading of the cube texture
  7789. * @param forcedExtension defines the extension to use
  7790. */
  7791. delayLoad(forcedExtension?: string): void;
  7792. /**
  7793. * Returns the reflection texture matrix
  7794. * @returns the reflection texture matrix
  7795. */
  7796. getReflectionTextureMatrix(): Matrix;
  7797. /**
  7798. * Sets the reflection texture matrix
  7799. * @param value Reflection texture matrix
  7800. */
  7801. setReflectionTextureMatrix(value: Matrix): void;
  7802. /**
  7803. * Parses text to create a cube texture
  7804. * @param parsedTexture define the serialized text to read from
  7805. * @param scene defines the hosting scene
  7806. * @param rootUrl defines the root url of the cube texture
  7807. * @returns a cube texture
  7808. */
  7809. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7810. /**
  7811. * Makes a clone, or deep copy, of the cube texture
  7812. * @returns a new cube texture
  7813. */
  7814. clone(): CubeTexture;
  7815. }
  7816. }
  7817. declare module BABYLON {
  7818. /**
  7819. * Manages the defines for the Material
  7820. */
  7821. export class MaterialDefines {
  7822. /** @hidden */
  7823. protected _keys: string[];
  7824. private _isDirty;
  7825. /** @hidden */
  7826. _renderId: number;
  7827. /** @hidden */
  7828. _areLightsDirty: boolean;
  7829. /** @hidden */
  7830. _areLightsDisposed: boolean;
  7831. /** @hidden */
  7832. _areAttributesDirty: boolean;
  7833. /** @hidden */
  7834. _areTexturesDirty: boolean;
  7835. /** @hidden */
  7836. _areFresnelDirty: boolean;
  7837. /** @hidden */
  7838. _areMiscDirty: boolean;
  7839. /** @hidden */
  7840. _areImageProcessingDirty: boolean;
  7841. /** @hidden */
  7842. _normals: boolean;
  7843. /** @hidden */
  7844. _uvs: boolean;
  7845. /** @hidden */
  7846. _needNormals: boolean;
  7847. /** @hidden */
  7848. _needUVs: boolean;
  7849. [id: string]: any;
  7850. /**
  7851. * Specifies if the material needs to be re-calculated
  7852. */
  7853. get isDirty(): boolean;
  7854. /**
  7855. * Marks the material to indicate that it has been re-calculated
  7856. */
  7857. markAsProcessed(): void;
  7858. /**
  7859. * Marks the material to indicate that it needs to be re-calculated
  7860. */
  7861. markAsUnprocessed(): void;
  7862. /**
  7863. * Marks the material to indicate all of its defines need to be re-calculated
  7864. */
  7865. markAllAsDirty(): void;
  7866. /**
  7867. * Marks the material to indicate that image processing needs to be re-calculated
  7868. */
  7869. markAsImageProcessingDirty(): void;
  7870. /**
  7871. * Marks the material to indicate the lights need to be re-calculated
  7872. * @param disposed Defines whether the light is dirty due to dispose or not
  7873. */
  7874. markAsLightDirty(disposed?: boolean): void;
  7875. /**
  7876. * Marks the attribute state as changed
  7877. */
  7878. markAsAttributesDirty(): void;
  7879. /**
  7880. * Marks the texture state as changed
  7881. */
  7882. markAsTexturesDirty(): void;
  7883. /**
  7884. * Marks the fresnel state as changed
  7885. */
  7886. markAsFresnelDirty(): void;
  7887. /**
  7888. * Marks the misc state as changed
  7889. */
  7890. markAsMiscDirty(): void;
  7891. /**
  7892. * Rebuilds the material defines
  7893. */
  7894. rebuild(): void;
  7895. /**
  7896. * Specifies if two material defines are equal
  7897. * @param other - A material define instance to compare to
  7898. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7899. */
  7900. isEqual(other: MaterialDefines): boolean;
  7901. /**
  7902. * Clones this instance's defines to another instance
  7903. * @param other - material defines to clone values to
  7904. */
  7905. cloneTo(other: MaterialDefines): void;
  7906. /**
  7907. * Resets the material define values
  7908. */
  7909. reset(): void;
  7910. /**
  7911. * Converts the material define values to a string
  7912. * @returns - String of material define information
  7913. */
  7914. toString(): string;
  7915. }
  7916. }
  7917. declare module BABYLON {
  7918. /**
  7919. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7920. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7921. * 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;
  7922. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7923. */
  7924. export class ColorCurves {
  7925. private _dirty;
  7926. private _tempColor;
  7927. private _globalCurve;
  7928. private _highlightsCurve;
  7929. private _midtonesCurve;
  7930. private _shadowsCurve;
  7931. private _positiveCurve;
  7932. private _negativeCurve;
  7933. private _globalHue;
  7934. private _globalDensity;
  7935. private _globalSaturation;
  7936. private _globalExposure;
  7937. /**
  7938. * Gets the global Hue value.
  7939. * 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).
  7940. */
  7941. get globalHue(): number;
  7942. /**
  7943. * Sets the global Hue value.
  7944. * 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).
  7945. */
  7946. set globalHue(value: number);
  7947. /**
  7948. * Gets the global Density value.
  7949. * 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.
  7950. * Values less than zero provide a filter of opposite hue.
  7951. */
  7952. get globalDensity(): number;
  7953. /**
  7954. * Sets the global Density value.
  7955. * 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.
  7956. * Values less than zero provide a filter of opposite hue.
  7957. */
  7958. set globalDensity(value: number);
  7959. /**
  7960. * Gets the global Saturation value.
  7961. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7962. */
  7963. get globalSaturation(): number;
  7964. /**
  7965. * Sets the global Saturation value.
  7966. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7967. */
  7968. set globalSaturation(value: number);
  7969. /**
  7970. * Gets the global Exposure value.
  7971. * 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.
  7972. */
  7973. get globalExposure(): number;
  7974. /**
  7975. * Sets the global Exposure value.
  7976. * 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.
  7977. */
  7978. set globalExposure(value: number);
  7979. private _highlightsHue;
  7980. private _highlightsDensity;
  7981. private _highlightsSaturation;
  7982. private _highlightsExposure;
  7983. /**
  7984. * Gets the highlights Hue value.
  7985. * 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).
  7986. */
  7987. get highlightsHue(): number;
  7988. /**
  7989. * Sets the highlights Hue value.
  7990. * 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).
  7991. */
  7992. set highlightsHue(value: number);
  7993. /**
  7994. * Gets the highlights Density value.
  7995. * 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.
  7996. * Values less than zero provide a filter of opposite hue.
  7997. */
  7998. get highlightsDensity(): number;
  7999. /**
  8000. * Sets the highlights Density value.
  8001. * 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.
  8002. * Values less than zero provide a filter of opposite hue.
  8003. */
  8004. set highlightsDensity(value: number);
  8005. /**
  8006. * Gets the highlights Saturation value.
  8007. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8008. */
  8009. get highlightsSaturation(): number;
  8010. /**
  8011. * Sets the highlights Saturation value.
  8012. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8013. */
  8014. set highlightsSaturation(value: number);
  8015. /**
  8016. * Gets the highlights Exposure value.
  8017. * 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.
  8018. */
  8019. get highlightsExposure(): number;
  8020. /**
  8021. * Sets the highlights Exposure value.
  8022. * 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.
  8023. */
  8024. set highlightsExposure(value: number);
  8025. private _midtonesHue;
  8026. private _midtonesDensity;
  8027. private _midtonesSaturation;
  8028. private _midtonesExposure;
  8029. /**
  8030. * Gets the midtones Hue value.
  8031. * 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).
  8032. */
  8033. get midtonesHue(): number;
  8034. /**
  8035. * Sets the midtones Hue value.
  8036. * 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).
  8037. */
  8038. set midtonesHue(value: number);
  8039. /**
  8040. * Gets the midtones Density value.
  8041. * 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.
  8042. * Values less than zero provide a filter of opposite hue.
  8043. */
  8044. get midtonesDensity(): number;
  8045. /**
  8046. * Sets the midtones Density value.
  8047. * 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.
  8048. * Values less than zero provide a filter of opposite hue.
  8049. */
  8050. set midtonesDensity(value: number);
  8051. /**
  8052. * Gets the midtones Saturation value.
  8053. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8054. */
  8055. get midtonesSaturation(): number;
  8056. /**
  8057. * Sets the midtones Saturation value.
  8058. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8059. */
  8060. set midtonesSaturation(value: number);
  8061. /**
  8062. * Gets the midtones Exposure value.
  8063. * 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.
  8064. */
  8065. get midtonesExposure(): number;
  8066. /**
  8067. * Sets the midtones Exposure value.
  8068. * 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.
  8069. */
  8070. set midtonesExposure(value: number);
  8071. private _shadowsHue;
  8072. private _shadowsDensity;
  8073. private _shadowsSaturation;
  8074. private _shadowsExposure;
  8075. /**
  8076. * Gets the shadows Hue value.
  8077. * 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).
  8078. */
  8079. get shadowsHue(): number;
  8080. /**
  8081. * Sets the shadows Hue value.
  8082. * 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).
  8083. */
  8084. set shadowsHue(value: number);
  8085. /**
  8086. * Gets the shadows Density value.
  8087. * 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.
  8088. * Values less than zero provide a filter of opposite hue.
  8089. */
  8090. get shadowsDensity(): number;
  8091. /**
  8092. * Sets the shadows Density value.
  8093. * 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.
  8094. * Values less than zero provide a filter of opposite hue.
  8095. */
  8096. set shadowsDensity(value: number);
  8097. /**
  8098. * Gets the shadows Saturation value.
  8099. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8100. */
  8101. get shadowsSaturation(): number;
  8102. /**
  8103. * Sets the shadows Saturation value.
  8104. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8105. */
  8106. set shadowsSaturation(value: number);
  8107. /**
  8108. * Gets the shadows Exposure value.
  8109. * 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.
  8110. */
  8111. get shadowsExposure(): number;
  8112. /**
  8113. * Sets the shadows Exposure value.
  8114. * 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.
  8115. */
  8116. set shadowsExposure(value: number);
  8117. /**
  8118. * Returns the class name
  8119. * @returns The class name
  8120. */
  8121. getClassName(): string;
  8122. /**
  8123. * Binds the color curves to the shader.
  8124. * @param colorCurves The color curve to bind
  8125. * @param effect The effect to bind to
  8126. * @param positiveUniform The positive uniform shader parameter
  8127. * @param neutralUniform The neutral uniform shader parameter
  8128. * @param negativeUniform The negative uniform shader parameter
  8129. */
  8130. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8131. /**
  8132. * Prepare the list of uniforms associated with the ColorCurves effects.
  8133. * @param uniformsList The list of uniforms used in the effect
  8134. */
  8135. static PrepareUniforms(uniformsList: string[]): void;
  8136. /**
  8137. * Returns color grading data based on a hue, density, saturation and exposure value.
  8138. * @param filterHue The hue of the color filter.
  8139. * @param filterDensity The density of the color filter.
  8140. * @param saturation The saturation.
  8141. * @param exposure The exposure.
  8142. * @param result The result data container.
  8143. */
  8144. private getColorGradingDataToRef;
  8145. /**
  8146. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8147. * @param value The input slider value in range [-100,100].
  8148. * @returns Adjusted value.
  8149. */
  8150. private static applyColorGradingSliderNonlinear;
  8151. /**
  8152. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8153. * @param hue The hue (H) input.
  8154. * @param saturation The saturation (S) input.
  8155. * @param brightness The brightness (B) input.
  8156. * @result An RGBA color represented as Vector4.
  8157. */
  8158. private static fromHSBToRef;
  8159. /**
  8160. * Returns a value clamped between min and max
  8161. * @param value The value to clamp
  8162. * @param min The minimum of value
  8163. * @param max The maximum of value
  8164. * @returns The clamped value.
  8165. */
  8166. private static clamp;
  8167. /**
  8168. * Clones the current color curve instance.
  8169. * @return The cloned curves
  8170. */
  8171. clone(): ColorCurves;
  8172. /**
  8173. * Serializes the current color curve instance to a json representation.
  8174. * @return a JSON representation
  8175. */
  8176. serialize(): any;
  8177. /**
  8178. * Parses the color curve from a json representation.
  8179. * @param source the JSON source to parse
  8180. * @return The parsed curves
  8181. */
  8182. static Parse(source: any): ColorCurves;
  8183. }
  8184. }
  8185. declare module BABYLON {
  8186. /**
  8187. * Interface to follow in your material defines to integrate easily the
  8188. * Image proccessing functions.
  8189. * @hidden
  8190. */
  8191. export interface IImageProcessingConfigurationDefines {
  8192. IMAGEPROCESSING: boolean;
  8193. VIGNETTE: boolean;
  8194. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8195. VIGNETTEBLENDMODEOPAQUE: boolean;
  8196. TONEMAPPING: boolean;
  8197. TONEMAPPING_ACES: boolean;
  8198. CONTRAST: boolean;
  8199. EXPOSURE: boolean;
  8200. COLORCURVES: boolean;
  8201. COLORGRADING: boolean;
  8202. COLORGRADING3D: boolean;
  8203. SAMPLER3DGREENDEPTH: boolean;
  8204. SAMPLER3DBGRMAP: boolean;
  8205. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8206. }
  8207. /**
  8208. * @hidden
  8209. */
  8210. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8211. IMAGEPROCESSING: boolean;
  8212. VIGNETTE: boolean;
  8213. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8214. VIGNETTEBLENDMODEOPAQUE: boolean;
  8215. TONEMAPPING: boolean;
  8216. TONEMAPPING_ACES: boolean;
  8217. CONTRAST: boolean;
  8218. COLORCURVES: boolean;
  8219. COLORGRADING: boolean;
  8220. COLORGRADING3D: boolean;
  8221. SAMPLER3DGREENDEPTH: boolean;
  8222. SAMPLER3DBGRMAP: boolean;
  8223. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8224. EXPOSURE: boolean;
  8225. constructor();
  8226. }
  8227. /**
  8228. * This groups together the common properties used for image processing either in direct forward pass
  8229. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8230. * or not.
  8231. */
  8232. export class ImageProcessingConfiguration {
  8233. /**
  8234. * Default tone mapping applied in BabylonJS.
  8235. */
  8236. static readonly TONEMAPPING_STANDARD: number;
  8237. /**
  8238. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8239. * to other engines rendering to increase portability.
  8240. */
  8241. static readonly TONEMAPPING_ACES: number;
  8242. /**
  8243. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8244. */
  8245. colorCurves: Nullable<ColorCurves>;
  8246. private _colorCurvesEnabled;
  8247. /**
  8248. * Gets wether the color curves effect is enabled.
  8249. */
  8250. get colorCurvesEnabled(): boolean;
  8251. /**
  8252. * Sets wether the color curves effect is enabled.
  8253. */
  8254. set colorCurvesEnabled(value: boolean);
  8255. private _colorGradingTexture;
  8256. /**
  8257. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8258. */
  8259. get colorGradingTexture(): Nullable<BaseTexture>;
  8260. /**
  8261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8262. */
  8263. set colorGradingTexture(value: Nullable<BaseTexture>);
  8264. private _colorGradingEnabled;
  8265. /**
  8266. * Gets wether the color grading effect is enabled.
  8267. */
  8268. get colorGradingEnabled(): boolean;
  8269. /**
  8270. * Sets wether the color grading effect is enabled.
  8271. */
  8272. set colorGradingEnabled(value: boolean);
  8273. private _colorGradingWithGreenDepth;
  8274. /**
  8275. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8276. */
  8277. get colorGradingWithGreenDepth(): boolean;
  8278. /**
  8279. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8280. */
  8281. set colorGradingWithGreenDepth(value: boolean);
  8282. private _colorGradingBGR;
  8283. /**
  8284. * Gets wether the color grading texture contains BGR values.
  8285. */
  8286. get colorGradingBGR(): boolean;
  8287. /**
  8288. * Sets wether the color grading texture contains BGR values.
  8289. */
  8290. set colorGradingBGR(value: boolean);
  8291. /** @hidden */
  8292. _exposure: number;
  8293. /**
  8294. * Gets the Exposure used in the effect.
  8295. */
  8296. get exposure(): number;
  8297. /**
  8298. * Sets the Exposure used in the effect.
  8299. */
  8300. set exposure(value: number);
  8301. private _toneMappingEnabled;
  8302. /**
  8303. * Gets wether the tone mapping effect is enabled.
  8304. */
  8305. get toneMappingEnabled(): boolean;
  8306. /**
  8307. * Sets wether the tone mapping effect is enabled.
  8308. */
  8309. set toneMappingEnabled(value: boolean);
  8310. private _toneMappingType;
  8311. /**
  8312. * Gets the type of tone mapping effect.
  8313. */
  8314. get toneMappingType(): number;
  8315. /**
  8316. * Sets the type of tone mapping effect used in BabylonJS.
  8317. */
  8318. set toneMappingType(value: number);
  8319. protected _contrast: number;
  8320. /**
  8321. * Gets the contrast used in the effect.
  8322. */
  8323. get contrast(): number;
  8324. /**
  8325. * Sets the contrast used in the effect.
  8326. */
  8327. set contrast(value: number);
  8328. /**
  8329. * Vignette stretch size.
  8330. */
  8331. vignetteStretch: number;
  8332. /**
  8333. * Vignette centre X Offset.
  8334. */
  8335. vignetteCentreX: number;
  8336. /**
  8337. * Vignette centre Y Offset.
  8338. */
  8339. vignetteCentreY: number;
  8340. /**
  8341. * Vignette weight or intensity of the vignette effect.
  8342. */
  8343. vignetteWeight: number;
  8344. /**
  8345. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8346. * if vignetteEnabled is set to true.
  8347. */
  8348. vignetteColor: Color4;
  8349. /**
  8350. * Camera field of view used by the Vignette effect.
  8351. */
  8352. vignetteCameraFov: number;
  8353. private _vignetteBlendMode;
  8354. /**
  8355. * Gets the vignette blend mode allowing different kind of effect.
  8356. */
  8357. get vignetteBlendMode(): number;
  8358. /**
  8359. * Sets the vignette blend mode allowing different kind of effect.
  8360. */
  8361. set vignetteBlendMode(value: number);
  8362. private _vignetteEnabled;
  8363. /**
  8364. * Gets wether the vignette effect is enabled.
  8365. */
  8366. get vignetteEnabled(): boolean;
  8367. /**
  8368. * Sets wether the vignette effect is enabled.
  8369. */
  8370. set vignetteEnabled(value: boolean);
  8371. private _applyByPostProcess;
  8372. /**
  8373. * Gets wether the image processing is applied through a post process or not.
  8374. */
  8375. get applyByPostProcess(): boolean;
  8376. /**
  8377. * Sets wether the image processing is applied through a post process or not.
  8378. */
  8379. set applyByPostProcess(value: boolean);
  8380. private _isEnabled;
  8381. /**
  8382. * Gets wether the image processing is enabled or not.
  8383. */
  8384. get isEnabled(): boolean;
  8385. /**
  8386. * Sets wether the image processing is enabled or not.
  8387. */
  8388. set isEnabled(value: boolean);
  8389. /**
  8390. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8391. */
  8392. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8393. /**
  8394. * Method called each time the image processing information changes requires to recompile the effect.
  8395. */
  8396. protected _updateParameters(): void;
  8397. /**
  8398. * Gets the current class name.
  8399. * @return "ImageProcessingConfiguration"
  8400. */
  8401. getClassName(): string;
  8402. /**
  8403. * Prepare the list of uniforms associated with the Image Processing effects.
  8404. * @param uniforms The list of uniforms used in the effect
  8405. * @param defines the list of defines currently in use
  8406. */
  8407. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8408. /**
  8409. * Prepare the list of samplers associated with the Image Processing effects.
  8410. * @param samplersList The list of uniforms used in the effect
  8411. * @param defines the list of defines currently in use
  8412. */
  8413. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8414. /**
  8415. * Prepare the list of defines associated to the shader.
  8416. * @param defines the list of defines to complete
  8417. * @param forPostProcess Define if we are currently in post process mode or not
  8418. */
  8419. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8420. /**
  8421. * Returns true if all the image processing information are ready.
  8422. * @returns True if ready, otherwise, false
  8423. */
  8424. isReady(): boolean;
  8425. /**
  8426. * Binds the image processing to the shader.
  8427. * @param effect The effect to bind to
  8428. * @param overrideAspectRatio Override the aspect ratio of the effect
  8429. */
  8430. bind(effect: Effect, overrideAspectRatio?: number): void;
  8431. /**
  8432. * Clones the current image processing instance.
  8433. * @return The cloned image processing
  8434. */
  8435. clone(): ImageProcessingConfiguration;
  8436. /**
  8437. * Serializes the current image processing instance to a json representation.
  8438. * @return a JSON representation
  8439. */
  8440. serialize(): any;
  8441. /**
  8442. * Parses the image processing from a json representation.
  8443. * @param source the JSON source to parse
  8444. * @return The parsed image processing
  8445. */
  8446. static Parse(source: any): ImageProcessingConfiguration;
  8447. private static _VIGNETTEMODE_MULTIPLY;
  8448. private static _VIGNETTEMODE_OPAQUE;
  8449. /**
  8450. * Used to apply the vignette as a mix with the pixel color.
  8451. */
  8452. static get VIGNETTEMODE_MULTIPLY(): number;
  8453. /**
  8454. * Used to apply the vignette as a replacement of the pixel color.
  8455. */
  8456. static get VIGNETTEMODE_OPAQUE(): number;
  8457. }
  8458. }
  8459. declare module BABYLON {
  8460. /** @hidden */
  8461. export var postprocessVertexShader: {
  8462. name: string;
  8463. shader: string;
  8464. };
  8465. }
  8466. declare module BABYLON {
  8467. interface ThinEngine {
  8468. /**
  8469. * Creates a new render target texture
  8470. * @param size defines the size of the texture
  8471. * @param options defines the options used to create the texture
  8472. * @returns a new render target texture stored in an InternalTexture
  8473. */
  8474. createRenderTargetTexture(size: number | {
  8475. width: number;
  8476. height: number;
  8477. layers?: number;
  8478. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8479. /**
  8480. * Creates a depth stencil texture.
  8481. * This is only available in WebGL 2 or with the depth texture extension available.
  8482. * @param size The size of face edge in the texture.
  8483. * @param options The options defining the texture.
  8484. * @returns The texture
  8485. */
  8486. createDepthStencilTexture(size: number | {
  8487. width: number;
  8488. height: number;
  8489. layers?: number;
  8490. }, options: DepthTextureCreationOptions): InternalTexture;
  8491. /** @hidden */
  8492. _createDepthStencilTexture(size: number | {
  8493. width: number;
  8494. height: number;
  8495. layers?: number;
  8496. }, options: DepthTextureCreationOptions): InternalTexture;
  8497. }
  8498. }
  8499. declare module BABYLON {
  8500. /** Defines supported spaces */
  8501. export enum Space {
  8502. /** Local (object) space */
  8503. LOCAL = 0,
  8504. /** World space */
  8505. WORLD = 1,
  8506. /** Bone space */
  8507. BONE = 2
  8508. }
  8509. /** Defines the 3 main axes */
  8510. export class Axis {
  8511. /** X axis */
  8512. static X: Vector3;
  8513. /** Y axis */
  8514. static Y: Vector3;
  8515. /** Z axis */
  8516. static Z: Vector3;
  8517. }
  8518. }
  8519. declare module BABYLON {
  8520. /**
  8521. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8522. * This is the base of the follow, arc rotate cameras and Free camera
  8523. * @see http://doc.babylonjs.com/features/cameras
  8524. */
  8525. export class TargetCamera extends Camera {
  8526. private static _RigCamTransformMatrix;
  8527. private static _TargetTransformMatrix;
  8528. private static _TargetFocalPoint;
  8529. /**
  8530. * Define the current direction the camera is moving to
  8531. */
  8532. cameraDirection: Vector3;
  8533. /**
  8534. * Define the current rotation the camera is rotating to
  8535. */
  8536. cameraRotation: Vector2;
  8537. /**
  8538. * When set, the up vector of the camera will be updated by the rotation of the camera
  8539. */
  8540. updateUpVectorFromRotation: boolean;
  8541. private _tmpQuaternion;
  8542. /**
  8543. * Define the current rotation of the camera
  8544. */
  8545. rotation: Vector3;
  8546. /**
  8547. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8548. */
  8549. rotationQuaternion: Quaternion;
  8550. /**
  8551. * Define the current speed of the camera
  8552. */
  8553. speed: number;
  8554. /**
  8555. * Add constraint to the camera to prevent it to move freely in all directions and
  8556. * around all axis.
  8557. */
  8558. noRotationConstraint: boolean;
  8559. /**
  8560. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  8561. * panning
  8562. */
  8563. invertRotation: boolean;
  8564. /**
  8565. * Speed multiplier for inverse camera panning
  8566. */
  8567. inverseRotationSpeed: number;
  8568. /**
  8569. * Define the current target of the camera as an object or a position.
  8570. */
  8571. lockedTarget: any;
  8572. /** @hidden */
  8573. _currentTarget: Vector3;
  8574. /** @hidden */
  8575. _initialFocalDistance: number;
  8576. /** @hidden */
  8577. _viewMatrix: Matrix;
  8578. /** @hidden */
  8579. _camMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraTransformMatrix: Matrix;
  8582. /** @hidden */
  8583. _cameraRotationMatrix: Matrix;
  8584. /** @hidden */
  8585. _referencePoint: Vector3;
  8586. /** @hidden */
  8587. _transformedReferencePoint: Vector3;
  8588. protected _globalCurrentTarget: Vector3;
  8589. protected _globalCurrentUpVector: Vector3;
  8590. /** @hidden */
  8591. _reset: () => void;
  8592. private _defaultUp;
  8593. /**
  8594. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8595. * This is the base of the follow, arc rotate cameras and Free camera
  8596. * @see http://doc.babylonjs.com/features/cameras
  8597. * @param name Defines the name of the camera in the scene
  8598. * @param position Defines the start position of the camera in the scene
  8599. * @param scene Defines the scene the camera belongs to
  8600. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8601. */
  8602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8603. /**
  8604. * Gets the position in front of the camera at a given distance.
  8605. * @param distance The distance from the camera we want the position to be
  8606. * @returns the position
  8607. */
  8608. getFrontPosition(distance: number): Vector3;
  8609. /** @hidden */
  8610. _getLockedTargetPosition(): Nullable<Vector3>;
  8611. private _storedPosition;
  8612. private _storedRotation;
  8613. private _storedRotationQuaternion;
  8614. /**
  8615. * Store current camera state of the camera (fov, position, rotation, etc..)
  8616. * @returns the camera
  8617. */
  8618. storeState(): Camera;
  8619. /**
  8620. * Restored camera state. You must call storeState() first
  8621. * @returns whether it was successful or not
  8622. * @hidden
  8623. */
  8624. _restoreStateValues(): boolean;
  8625. /** @hidden */
  8626. _initCache(): void;
  8627. /** @hidden */
  8628. _updateCache(ignoreParentClass?: boolean): void;
  8629. /** @hidden */
  8630. _isSynchronizedViewMatrix(): boolean;
  8631. /** @hidden */
  8632. _computeLocalCameraSpeed(): number;
  8633. /**
  8634. * Defines the target the camera should look at.
  8635. * @param target Defines the new target as a Vector or a mesh
  8636. */
  8637. setTarget(target: Vector3): void;
  8638. /**
  8639. * Return the current target position of the camera. This value is expressed in local space.
  8640. * @returns the target position
  8641. */
  8642. getTarget(): Vector3;
  8643. /** @hidden */
  8644. _decideIfNeedsToMove(): boolean;
  8645. /** @hidden */
  8646. _updatePosition(): void;
  8647. /** @hidden */
  8648. _checkInputs(): void;
  8649. protected _updateCameraRotationMatrix(): void;
  8650. /**
  8651. * 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)
  8652. * @returns the current camera
  8653. */
  8654. private _rotateUpVectorWithCameraRotationMatrix;
  8655. private _cachedRotationZ;
  8656. private _cachedQuaternionRotationZ;
  8657. /** @hidden */
  8658. _getViewMatrix(): Matrix;
  8659. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8660. /**
  8661. * @hidden
  8662. */
  8663. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8664. /**
  8665. * @hidden
  8666. */
  8667. _updateRigCameras(): void;
  8668. private _getRigCamPositionAndTarget;
  8669. /**
  8670. * Gets the current object class name.
  8671. * @return the class name
  8672. */
  8673. getClassName(): string;
  8674. }
  8675. }
  8676. declare module BABYLON {
  8677. /**
  8678. * Gather the list of keyboard event types as constants.
  8679. */
  8680. export class KeyboardEventTypes {
  8681. /**
  8682. * The keydown event is fired when a key becomes active (pressed).
  8683. */
  8684. static readonly KEYDOWN: number;
  8685. /**
  8686. * The keyup event is fired when a key has been released.
  8687. */
  8688. static readonly KEYUP: number;
  8689. }
  8690. /**
  8691. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8692. */
  8693. export class KeyboardInfo {
  8694. /**
  8695. * Defines the type of event (KeyboardEventTypes)
  8696. */
  8697. type: number;
  8698. /**
  8699. * Defines the related dom event
  8700. */
  8701. event: KeyboardEvent;
  8702. /**
  8703. * Instantiates a new keyboard info.
  8704. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8705. * @param type Defines the type of event (KeyboardEventTypes)
  8706. * @param event Defines the related dom event
  8707. */
  8708. constructor(
  8709. /**
  8710. * Defines the type of event (KeyboardEventTypes)
  8711. */
  8712. type: number,
  8713. /**
  8714. * Defines the related dom event
  8715. */
  8716. event: KeyboardEvent);
  8717. }
  8718. /**
  8719. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8720. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8721. */
  8722. export class KeyboardInfoPre extends KeyboardInfo {
  8723. /**
  8724. * Defines the type of event (KeyboardEventTypes)
  8725. */
  8726. type: number;
  8727. /**
  8728. * Defines the related dom event
  8729. */
  8730. event: KeyboardEvent;
  8731. /**
  8732. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8733. */
  8734. skipOnPointerObservable: boolean;
  8735. /**
  8736. * Instantiates a new keyboard pre info.
  8737. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8738. * @param type Defines the type of event (KeyboardEventTypes)
  8739. * @param event Defines the related dom event
  8740. */
  8741. constructor(
  8742. /**
  8743. * Defines the type of event (KeyboardEventTypes)
  8744. */
  8745. type: number,
  8746. /**
  8747. * Defines the related dom event
  8748. */
  8749. event: KeyboardEvent);
  8750. }
  8751. }
  8752. declare module BABYLON {
  8753. /**
  8754. * Manage the keyboard inputs to control the movement of a free camera.
  8755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8756. */
  8757. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8758. /**
  8759. * Defines the camera the input is attached to.
  8760. */
  8761. camera: FreeCamera;
  8762. /**
  8763. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8764. */
  8765. keysUp: number[];
  8766. /**
  8767. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  8768. */
  8769. keysUpward: number[];
  8770. /**
  8771. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8772. */
  8773. keysDown: number[];
  8774. /**
  8775. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  8776. */
  8777. keysDownward: number[];
  8778. /**
  8779. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8780. */
  8781. keysLeft: number[];
  8782. /**
  8783. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8784. */
  8785. keysRight: number[];
  8786. private _keys;
  8787. private _onCanvasBlurObserver;
  8788. private _onKeyboardObserver;
  8789. private _engine;
  8790. private _scene;
  8791. /**
  8792. * Attach the input controls to a specific dom element to get the input from.
  8793. * @param element Defines the element the controls should be listened from
  8794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8795. */
  8796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8797. /**
  8798. * Detach the current controls from the specified dom element.
  8799. * @param element Defines the element to stop listening the inputs from
  8800. */
  8801. detachControl(element: Nullable<HTMLElement>): void;
  8802. /**
  8803. * Update the current camera state depending on the inputs that have been used this frame.
  8804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8805. */
  8806. checkInputs(): void;
  8807. /**
  8808. * Gets the class name of the current intput.
  8809. * @returns the class name
  8810. */
  8811. getClassName(): string;
  8812. /** @hidden */
  8813. _onLostFocus(): void;
  8814. /**
  8815. * Get the friendly name associated with the input class.
  8816. * @returns the input friendly name
  8817. */
  8818. getSimpleName(): string;
  8819. }
  8820. }
  8821. declare module BABYLON {
  8822. /**
  8823. * Interface describing all the common properties and methods a shadow light needs to implement.
  8824. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8825. * as well as binding the different shadow properties to the effects.
  8826. */
  8827. export interface IShadowLight extends Light {
  8828. /**
  8829. * The light id in the scene (used in scene.findLighById for instance)
  8830. */
  8831. id: string;
  8832. /**
  8833. * The position the shdow will be casted from.
  8834. */
  8835. position: Vector3;
  8836. /**
  8837. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8838. */
  8839. direction: Vector3;
  8840. /**
  8841. * The transformed position. Position of the light in world space taking parenting in account.
  8842. */
  8843. transformedPosition: Vector3;
  8844. /**
  8845. * The transformed direction. Direction of the light in world space taking parenting in account.
  8846. */
  8847. transformedDirection: Vector3;
  8848. /**
  8849. * The friendly name of the light in the scene.
  8850. */
  8851. name: string;
  8852. /**
  8853. * Defines the shadow projection clipping minimum z value.
  8854. */
  8855. shadowMinZ: number;
  8856. /**
  8857. * Defines the shadow projection clipping maximum z value.
  8858. */
  8859. shadowMaxZ: number;
  8860. /**
  8861. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8862. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8863. */
  8864. computeTransformedInformation(): boolean;
  8865. /**
  8866. * Gets the scene the light belongs to.
  8867. * @returns The scene
  8868. */
  8869. getScene(): Scene;
  8870. /**
  8871. * Callback defining a custom Projection Matrix Builder.
  8872. * This can be used to override the default projection matrix computation.
  8873. */
  8874. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8875. /**
  8876. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8877. * @param matrix The materix to updated with the projection information
  8878. * @param viewMatrix The transform matrix of the light
  8879. * @param renderList The list of mesh to render in the map
  8880. * @returns The current light
  8881. */
  8882. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8883. /**
  8884. * Gets the current depth scale used in ESM.
  8885. * @returns The scale
  8886. */
  8887. getDepthScale(): number;
  8888. /**
  8889. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8890. * @returns true if a cube texture needs to be use
  8891. */
  8892. needCube(): boolean;
  8893. /**
  8894. * Detects if the projection matrix requires to be recomputed this frame.
  8895. * @returns true if it requires to be recomputed otherwise, false.
  8896. */
  8897. needProjectionMatrixCompute(): boolean;
  8898. /**
  8899. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8900. */
  8901. forceProjectionMatrixCompute(): void;
  8902. /**
  8903. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8904. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8905. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8906. */
  8907. getShadowDirection(faceIndex?: number): Vector3;
  8908. /**
  8909. * Gets the minZ used for shadow according to both the scene and the light.
  8910. * @param activeCamera The camera we are returning the min for
  8911. * @returns the depth min z
  8912. */
  8913. getDepthMinZ(activeCamera: Camera): number;
  8914. /**
  8915. * Gets the maxZ used for shadow according to both the scene and the light.
  8916. * @param activeCamera The camera we are returning the max for
  8917. * @returns the depth max z
  8918. */
  8919. getDepthMaxZ(activeCamera: Camera): number;
  8920. }
  8921. /**
  8922. * Base implementation IShadowLight
  8923. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8924. */
  8925. export abstract class ShadowLight extends Light implements IShadowLight {
  8926. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8927. protected _position: Vector3;
  8928. protected _setPosition(value: Vector3): void;
  8929. /**
  8930. * Sets the position the shadow will be casted from. Also use as the light position for both
  8931. * point and spot lights.
  8932. */
  8933. get position(): Vector3;
  8934. /**
  8935. * Sets the position the shadow will be casted from. Also use as the light position for both
  8936. * point and spot lights.
  8937. */
  8938. set position(value: Vector3);
  8939. protected _direction: Vector3;
  8940. protected _setDirection(value: Vector3): void;
  8941. /**
  8942. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8943. * Also use as the light direction on spot and directional lights.
  8944. */
  8945. get direction(): Vector3;
  8946. /**
  8947. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8948. * Also use as the light direction on spot and directional lights.
  8949. */
  8950. set direction(value: Vector3);
  8951. protected _shadowMinZ: number;
  8952. /**
  8953. * Gets the shadow projection clipping minimum z value.
  8954. */
  8955. get shadowMinZ(): number;
  8956. /**
  8957. * Sets the shadow projection clipping minimum z value.
  8958. */
  8959. set shadowMinZ(value: number);
  8960. protected _shadowMaxZ: number;
  8961. /**
  8962. * Sets the shadow projection clipping maximum z value.
  8963. */
  8964. get shadowMaxZ(): number;
  8965. /**
  8966. * Gets the shadow projection clipping maximum z value.
  8967. */
  8968. set shadowMaxZ(value: number);
  8969. /**
  8970. * Callback defining a custom Projection Matrix Builder.
  8971. * This can be used to override the default projection matrix computation.
  8972. */
  8973. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8974. /**
  8975. * The transformed position. Position of the light in world space taking parenting in account.
  8976. */
  8977. transformedPosition: Vector3;
  8978. /**
  8979. * The transformed direction. Direction of the light in world space taking parenting in account.
  8980. */
  8981. transformedDirection: Vector3;
  8982. private _needProjectionMatrixCompute;
  8983. /**
  8984. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8985. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8986. */
  8987. computeTransformedInformation(): boolean;
  8988. /**
  8989. * Return the depth scale used for the shadow map.
  8990. * @returns the depth scale.
  8991. */
  8992. getDepthScale(): number;
  8993. /**
  8994. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8995. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8996. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8997. */
  8998. getShadowDirection(faceIndex?: number): Vector3;
  8999. /**
  9000. * Returns the ShadowLight absolute position in the World.
  9001. * @returns the position vector in world space
  9002. */
  9003. getAbsolutePosition(): Vector3;
  9004. /**
  9005. * Sets the ShadowLight direction toward the passed target.
  9006. * @param target The point to target in local space
  9007. * @returns the updated ShadowLight direction
  9008. */
  9009. setDirectionToTarget(target: Vector3): Vector3;
  9010. /**
  9011. * Returns the light rotation in euler definition.
  9012. * @returns the x y z rotation in local space.
  9013. */
  9014. getRotation(): Vector3;
  9015. /**
  9016. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9017. * @returns true if a cube texture needs to be use
  9018. */
  9019. needCube(): boolean;
  9020. /**
  9021. * Detects if the projection matrix requires to be recomputed this frame.
  9022. * @returns true if it requires to be recomputed otherwise, false.
  9023. */
  9024. needProjectionMatrixCompute(): boolean;
  9025. /**
  9026. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9027. */
  9028. forceProjectionMatrixCompute(): void;
  9029. /** @hidden */
  9030. _initCache(): void;
  9031. /** @hidden */
  9032. _isSynchronized(): boolean;
  9033. /**
  9034. * Computes the world matrix of the node
  9035. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9036. * @returns the world matrix
  9037. */
  9038. computeWorldMatrix(force?: boolean): Matrix;
  9039. /**
  9040. * Gets the minZ used for shadow according to both the scene and the light.
  9041. * @param activeCamera The camera we are returning the min for
  9042. * @returns the depth min z
  9043. */
  9044. getDepthMinZ(activeCamera: Camera): number;
  9045. /**
  9046. * Gets the maxZ used for shadow according to both the scene and the light.
  9047. * @param activeCamera The camera we are returning the max for
  9048. * @returns the depth max z
  9049. */
  9050. getDepthMaxZ(activeCamera: Camera): number;
  9051. /**
  9052. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9053. * @param matrix The materix to updated with the projection information
  9054. * @param viewMatrix The transform matrix of the light
  9055. * @param renderList The list of mesh to render in the map
  9056. * @returns The current light
  9057. */
  9058. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9059. }
  9060. }
  9061. declare module BABYLON {
  9062. /**
  9063. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9064. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9065. */
  9066. export class EffectFallbacks implements IEffectFallbacks {
  9067. private _defines;
  9068. private _currentRank;
  9069. private _maxRank;
  9070. private _mesh;
  9071. /**
  9072. * Removes the fallback from the bound mesh.
  9073. */
  9074. unBindMesh(): void;
  9075. /**
  9076. * Adds a fallback on the specified property.
  9077. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9078. * @param define The name of the define in the shader
  9079. */
  9080. addFallback(rank: number, define: string): void;
  9081. /**
  9082. * Sets the mesh to use CPU skinning when needing to fallback.
  9083. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9084. * @param mesh The mesh to use the fallbacks.
  9085. */
  9086. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9087. /**
  9088. * Checks to see if more fallbacks are still availible.
  9089. */
  9090. get hasMoreFallbacks(): boolean;
  9091. /**
  9092. * Removes the defines that should be removed when falling back.
  9093. * @param currentDefines defines the current define statements for the shader.
  9094. * @param effect defines the current effect we try to compile
  9095. * @returns The resulting defines with defines of the current rank removed.
  9096. */
  9097. reduce(currentDefines: string, effect: Effect): string;
  9098. }
  9099. }
  9100. declare module BABYLON {
  9101. /**
  9102. * "Static Class" containing the most commonly used helper while dealing with material for
  9103. * rendering purpose.
  9104. *
  9105. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9106. *
  9107. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9108. */
  9109. export class MaterialHelper {
  9110. /**
  9111. * Bind the current view position to an effect.
  9112. * @param effect The effect to be bound
  9113. * @param scene The scene the eyes position is used from
  9114. */
  9115. static BindEyePosition(effect: Effect, scene: Scene): void;
  9116. /**
  9117. * Helps preparing the defines values about the UVs in used in the effect.
  9118. * UVs are shared as much as we can accross channels in the shaders.
  9119. * @param texture The texture we are preparing the UVs for
  9120. * @param defines The defines to update
  9121. * @param key The channel key "diffuse", "specular"... used in the shader
  9122. */
  9123. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9124. /**
  9125. * Binds a texture matrix value to its corrsponding uniform
  9126. * @param texture The texture to bind the matrix for
  9127. * @param uniformBuffer The uniform buffer receivin the data
  9128. * @param key The channel key "diffuse", "specular"... used in the shader
  9129. */
  9130. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9131. /**
  9132. * Gets the current status of the fog (should it be enabled?)
  9133. * @param mesh defines the mesh to evaluate for fog support
  9134. * @param scene defines the hosting scene
  9135. * @returns true if fog must be enabled
  9136. */
  9137. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9138. /**
  9139. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9140. * @param mesh defines the current mesh
  9141. * @param scene defines the current scene
  9142. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9143. * @param pointsCloud defines if point cloud rendering has to be turned on
  9144. * @param fogEnabled defines if fog has to be turned on
  9145. * @param alphaTest defines if alpha testing has to be turned on
  9146. * @param defines defines the current list of defines
  9147. */
  9148. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9149. /**
  9150. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9151. * @param scene defines the current scene
  9152. * @param engine defines the current engine
  9153. * @param defines specifies the list of active defines
  9154. * @param useInstances defines if instances have to be turned on
  9155. * @param useClipPlane defines if clip plane have to be turned on
  9156. */
  9157. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9158. /**
  9159. * Prepares the defines for bones
  9160. * @param mesh The mesh containing the geometry data we will draw
  9161. * @param defines The defines to update
  9162. */
  9163. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9164. /**
  9165. * Prepares the defines for morph targets
  9166. * @param mesh The mesh containing the geometry data we will draw
  9167. * @param defines The defines to update
  9168. */
  9169. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9170. /**
  9171. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9172. * @param mesh The mesh containing the geometry data we will draw
  9173. * @param defines The defines to update
  9174. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9175. * @param useBones Precise whether bones should be used or not (override mesh info)
  9176. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9177. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9178. * @returns false if defines are considered not dirty and have not been checked
  9179. */
  9180. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9181. /**
  9182. * Prepares the defines related to multiview
  9183. * @param scene The scene we are intending to draw
  9184. * @param defines The defines to update
  9185. */
  9186. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9187. /**
  9188. * Prepares the defines related to the light information passed in parameter
  9189. * @param scene The scene we are intending to draw
  9190. * @param mesh The mesh the effect is compiling for
  9191. * @param light The light the effect is compiling for
  9192. * @param lightIndex The index of the light
  9193. * @param defines The defines to update
  9194. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9195. * @param state Defines the current state regarding what is needed (normals, etc...)
  9196. */
  9197. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9198. needNormals: boolean;
  9199. needRebuild: boolean;
  9200. shadowEnabled: boolean;
  9201. specularEnabled: boolean;
  9202. lightmapMode: boolean;
  9203. }): 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 defines The defines to update
  9209. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9210. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9211. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9212. * @returns true if normals will be required for the rest of the effect
  9213. */
  9214. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9215. /**
  9216. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9217. * @param lightIndex defines the light index
  9218. * @param uniformsList The uniform list
  9219. * @param samplersList The sampler list
  9220. * @param projectedLightTexture defines if projected texture must be used
  9221. * @param uniformBuffersList defines an optional list of uniform buffers
  9222. */
  9223. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9224. /**
  9225. * Prepares the uniforms and samplers list to be used in the effect
  9226. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9227. * @param samplersList The sampler list
  9228. * @param defines The defines helping in the list generation
  9229. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9230. */
  9231. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9232. /**
  9233. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9234. * @param defines The defines to update while falling back
  9235. * @param fallbacks The authorized effect fallbacks
  9236. * @param maxSimultaneousLights The maximum number of lights allowed
  9237. * @param rank the current rank of the Effect
  9238. * @returns The newly affected rank
  9239. */
  9240. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9241. private static _TmpMorphInfluencers;
  9242. /**
  9243. * Prepares the list of attributes required for morph targets according to the effect defines.
  9244. * @param attribs The current list of supported attribs
  9245. * @param mesh The mesh to prepare the morph targets attributes for
  9246. * @param influencers The number of influencers
  9247. */
  9248. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9249. /**
  9250. * Prepares the list of attributes required for morph targets according to the effect defines.
  9251. * @param attribs The current list of supported attribs
  9252. * @param mesh The mesh to prepare the morph targets attributes for
  9253. * @param defines The current Defines of the effect
  9254. */
  9255. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9256. /**
  9257. * Prepares the list of attributes required for bones according to the effect defines.
  9258. * @param attribs The current list of supported attribs
  9259. * @param mesh The mesh to prepare the bones attributes for
  9260. * @param defines The current Defines of the effect
  9261. * @param fallbacks The current efffect fallback strategy
  9262. */
  9263. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9264. /**
  9265. * Check and prepare the list of attributes required for instances according to the effect defines.
  9266. * @param attribs The current list of supported attribs
  9267. * @param defines The current MaterialDefines of the effect
  9268. */
  9269. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9270. /**
  9271. * Add the list of attributes required for instances to the attribs array.
  9272. * @param attribs The current list of supported attribs
  9273. */
  9274. static PushAttributesForInstances(attribs: string[]): void;
  9275. /**
  9276. * Binds the light information to the effect.
  9277. * @param light The light containing the generator
  9278. * @param effect The effect we are binding the data to
  9279. * @param lightIndex The light index in the effect used to render
  9280. */
  9281. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9282. /**
  9283. * Binds the lights information from the scene to the effect for the given mesh.
  9284. * @param light Light to bind
  9285. * @param lightIndex Light index
  9286. * @param scene The scene where the light belongs to
  9287. * @param effect The effect we are binding the data to
  9288. * @param useSpecular Defines if specular is supported
  9289. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9290. */
  9291. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9292. /**
  9293. * Binds the lights information from the scene to the effect for the given mesh.
  9294. * @param scene The scene the lights belongs to
  9295. * @param mesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. * @param defines The generated defines for the effect
  9298. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9299. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9300. */
  9301. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9302. private static _tempFogColor;
  9303. /**
  9304. * Binds the fog information from the scene to the effect for the given mesh.
  9305. * @param scene The scene the lights belongs to
  9306. * @param mesh The mesh we are binding the information to render
  9307. * @param effect The effect we are binding the data to
  9308. * @param linearSpace Defines if the fog effect is applied in linear space
  9309. */
  9310. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9311. /**
  9312. * Binds the bones information from the mesh to the effect.
  9313. * @param mesh The mesh we are binding the information to render
  9314. * @param effect The effect we are binding the data to
  9315. */
  9316. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9317. /**
  9318. * Binds the morph targets information from the mesh to the effect.
  9319. * @param abstractMesh The mesh we are binding the information to render
  9320. * @param effect The effect we are binding the data to
  9321. */
  9322. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9323. /**
  9324. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9325. * @param defines The generated defines used in the effect
  9326. * @param effect The effect we are binding the data to
  9327. * @param scene The scene we are willing to render with logarithmic scale for
  9328. */
  9329. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9330. /**
  9331. * Binds the clip plane information from the scene to the effect.
  9332. * @param scene The scene the clip plane information are extracted from
  9333. * @param effect The effect we are binding the data to
  9334. */
  9335. static BindClipPlane(effect: Effect, scene: Scene): void;
  9336. }
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var packingFunctions: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var clipPlaneFragmentDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var clipPlaneFragment: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var shadowMapPixelShader: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var bonesDeclaration: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var morphTargetsVertexGlobalDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var morphTargetsVertexDeclaration: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var instancesDeclaration: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var helperFunctions: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var clipPlaneVertexDeclaration: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var morphTargetsVertex: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var instancesVertex: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var bonesVertex: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var clipPlaneVertex: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var shadowMapVertexShader: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var depthBoxBlurPixelShader: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /**
  9452. * Class representing a ray with position and direction
  9453. */
  9454. export class Ray {
  9455. /** origin point */
  9456. origin: Vector3;
  9457. /** direction */
  9458. direction: Vector3;
  9459. /** length of the ray */
  9460. length: number;
  9461. private static readonly TmpVector3;
  9462. private _tmpRay;
  9463. /**
  9464. * Creates a new ray
  9465. * @param origin origin point
  9466. * @param direction direction
  9467. * @param length length of the ray
  9468. */
  9469. constructor(
  9470. /** origin point */
  9471. origin: Vector3,
  9472. /** direction */
  9473. direction: Vector3,
  9474. /** length of the ray */
  9475. length?: number);
  9476. /**
  9477. * Checks if the ray intersects a box
  9478. * @param minimum bound of the box
  9479. * @param maximum bound of the box
  9480. * @param intersectionTreshold extra extend to be added to the box in all direction
  9481. * @returns if the box was hit
  9482. */
  9483. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9484. /**
  9485. * Checks if the ray intersects a box
  9486. * @param box the bounding box to check
  9487. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9488. * @returns if the box was hit
  9489. */
  9490. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9491. /**
  9492. * If the ray hits a sphere
  9493. * @param sphere the bounding sphere to check
  9494. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9495. * @returns true if it hits the sphere
  9496. */
  9497. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9498. /**
  9499. * If the ray hits a triange
  9500. * @param vertex0 triangle vertex
  9501. * @param vertex1 triangle vertex
  9502. * @param vertex2 triangle vertex
  9503. * @returns intersection information if hit
  9504. */
  9505. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9506. /**
  9507. * Checks if ray intersects a plane
  9508. * @param plane the plane to check
  9509. * @returns the distance away it was hit
  9510. */
  9511. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9512. /**
  9513. * Calculate the intercept of a ray on a given axis
  9514. * @param axis to check 'x' | 'y' | 'z'
  9515. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9516. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9517. */
  9518. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9519. /**
  9520. * Checks if ray intersects a mesh
  9521. * @param mesh the mesh to check
  9522. * @param fastCheck if only the bounding box should checked
  9523. * @returns picking info of the intersecton
  9524. */
  9525. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9526. /**
  9527. * Checks if ray intersects a mesh
  9528. * @param meshes the meshes to check
  9529. * @param fastCheck if only the bounding box should checked
  9530. * @param results array to store result in
  9531. * @returns Array of picking infos
  9532. */
  9533. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9534. private _comparePickingInfo;
  9535. private static smallnum;
  9536. private static rayl;
  9537. /**
  9538. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9539. * @param sega the first point of the segment to test the intersection against
  9540. * @param segb the second point of the segment to test the intersection against
  9541. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9542. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9543. */
  9544. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9545. /**
  9546. * Update the ray from viewport position
  9547. * @param x position
  9548. * @param y y position
  9549. * @param viewportWidth viewport width
  9550. * @param viewportHeight viewport height
  9551. * @param world world matrix
  9552. * @param view view matrix
  9553. * @param projection projection matrix
  9554. * @returns this ray updated
  9555. */
  9556. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9557. /**
  9558. * Creates a ray with origin and direction of 0,0,0
  9559. * @returns the new ray
  9560. */
  9561. static Zero(): Ray;
  9562. /**
  9563. * Creates a new ray from screen space and viewport
  9564. * @param x position
  9565. * @param y y position
  9566. * @param viewportWidth viewport width
  9567. * @param viewportHeight viewport height
  9568. * @param world world matrix
  9569. * @param view view matrix
  9570. * @param projection projection matrix
  9571. * @returns new ray
  9572. */
  9573. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9574. /**
  9575. * 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
  9576. * transformed to the given world matrix.
  9577. * @param origin The origin point
  9578. * @param end The end point
  9579. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9580. * @returns the new ray
  9581. */
  9582. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9583. /**
  9584. * Transforms a ray by a matrix
  9585. * @param ray ray to transform
  9586. * @param matrix matrix to apply
  9587. * @returns the resulting new ray
  9588. */
  9589. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9590. /**
  9591. * Transforms a ray by a matrix
  9592. * @param ray ray to transform
  9593. * @param matrix matrix to apply
  9594. * @param result ray to store result in
  9595. */
  9596. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9597. /**
  9598. * Unproject a ray from screen space to object space
  9599. * @param sourceX defines the screen space x coordinate to use
  9600. * @param sourceY defines the screen space y coordinate to use
  9601. * @param viewportWidth defines the current width of the viewport
  9602. * @param viewportHeight defines the current height of the viewport
  9603. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9604. * @param view defines the view matrix to use
  9605. * @param projection defines the projection matrix to use
  9606. */
  9607. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9608. }
  9609. /**
  9610. * Type used to define predicate used to select faces when a mesh intersection is detected
  9611. */
  9612. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9613. interface Scene {
  9614. /** @hidden */
  9615. _tempPickingRay: Nullable<Ray>;
  9616. /** @hidden */
  9617. _cachedRayForTransform: Ray;
  9618. /** @hidden */
  9619. _pickWithRayInverseMatrix: Matrix;
  9620. /** @hidden */
  9621. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9622. /** @hidden */
  9623. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9624. }
  9625. }
  9626. declare module BABYLON {
  9627. /**
  9628. * Groups all the scene component constants in one place to ease maintenance.
  9629. * @hidden
  9630. */
  9631. export class SceneComponentConstants {
  9632. static readonly NAME_EFFECTLAYER: string;
  9633. static readonly NAME_LAYER: string;
  9634. static readonly NAME_LENSFLARESYSTEM: string;
  9635. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9636. static readonly NAME_PARTICLESYSTEM: string;
  9637. static readonly NAME_GAMEPAD: string;
  9638. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9639. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9640. static readonly NAME_DEPTHRENDERER: string;
  9641. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9642. static readonly NAME_SPRITE: string;
  9643. static readonly NAME_OUTLINERENDERER: string;
  9644. static readonly NAME_PROCEDURALTEXTURE: string;
  9645. static readonly NAME_SHADOWGENERATOR: string;
  9646. static readonly NAME_OCTREE: string;
  9647. static readonly NAME_PHYSICSENGINE: string;
  9648. static readonly NAME_AUDIO: string;
  9649. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9650. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9651. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9652. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9653. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9654. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9655. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9656. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9657. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9658. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9659. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9660. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9661. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9662. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9663. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9664. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9665. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9666. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9667. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9668. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9669. static readonly STEP_AFTERRENDER_AUDIO: number;
  9670. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9671. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9672. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9673. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9674. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9675. static readonly STEP_POINTERMOVE_SPRITE: number;
  9676. static readonly STEP_POINTERDOWN_SPRITE: number;
  9677. static readonly STEP_POINTERUP_SPRITE: number;
  9678. }
  9679. /**
  9680. * This represents a scene component.
  9681. *
  9682. * This is used to decouple the dependency the scene is having on the different workloads like
  9683. * layers, post processes...
  9684. */
  9685. export interface ISceneComponent {
  9686. /**
  9687. * The name of the component. Each component must have a unique name.
  9688. */
  9689. name: string;
  9690. /**
  9691. * The scene the component belongs to.
  9692. */
  9693. scene: Scene;
  9694. /**
  9695. * Register the component to one instance of a scene.
  9696. */
  9697. register(): void;
  9698. /**
  9699. * Rebuilds the elements related to this component in case of
  9700. * context lost for instance.
  9701. */
  9702. rebuild(): void;
  9703. /**
  9704. * Disposes the component and the associated ressources.
  9705. */
  9706. dispose(): void;
  9707. }
  9708. /**
  9709. * This represents a SERIALIZABLE scene component.
  9710. *
  9711. * This extends Scene Component to add Serialization methods on top.
  9712. */
  9713. export interface ISceneSerializableComponent extends ISceneComponent {
  9714. /**
  9715. * Adds all the elements from the container to the scene
  9716. * @param container the container holding the elements
  9717. */
  9718. addFromContainer(container: AbstractScene): void;
  9719. /**
  9720. * Removes all the elements in the container from the scene
  9721. * @param container contains the elements to remove
  9722. * @param dispose if the removed element should be disposed (default: false)
  9723. */
  9724. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9725. /**
  9726. * Serializes the component data to the specified json object
  9727. * @param serializationObject The object to serialize to
  9728. */
  9729. serialize(serializationObject: any): void;
  9730. }
  9731. /**
  9732. * Strong typing of a Mesh related stage step action
  9733. */
  9734. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9735. /**
  9736. * Strong typing of a Evaluate Sub Mesh related stage step action
  9737. */
  9738. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9739. /**
  9740. * Strong typing of a Active Mesh related stage step action
  9741. */
  9742. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9743. /**
  9744. * Strong typing of a Camera related stage step action
  9745. */
  9746. export type CameraStageAction = (camera: Camera) => void;
  9747. /**
  9748. * Strong typing of a Camera Frame buffer related stage step action
  9749. */
  9750. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9751. /**
  9752. * Strong typing of a Render Target related stage step action
  9753. */
  9754. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9755. /**
  9756. * Strong typing of a RenderingGroup related stage step action
  9757. */
  9758. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9759. /**
  9760. * Strong typing of a Mesh Render related stage step action
  9761. */
  9762. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9763. /**
  9764. * Strong typing of a simple stage step action
  9765. */
  9766. export type SimpleStageAction = () => void;
  9767. /**
  9768. * Strong typing of a render target action.
  9769. */
  9770. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9771. /**
  9772. * Strong typing of a pointer move action.
  9773. */
  9774. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9775. /**
  9776. * Strong typing of a pointer up/down action.
  9777. */
  9778. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9779. /**
  9780. * Representation of a stage in the scene (Basically a list of ordered steps)
  9781. * @hidden
  9782. */
  9783. export class Stage<T extends Function> extends Array<{
  9784. index: number;
  9785. component: ISceneComponent;
  9786. action: T;
  9787. }> {
  9788. /**
  9789. * Hide ctor from the rest of the world.
  9790. * @param items The items to add.
  9791. */
  9792. private constructor();
  9793. /**
  9794. * Creates a new Stage.
  9795. * @returns A new instance of a Stage
  9796. */
  9797. static Create<T extends Function>(): Stage<T>;
  9798. /**
  9799. * Registers a step in an ordered way in the targeted stage.
  9800. * @param index Defines the position to register the step in
  9801. * @param component Defines the component attached to the step
  9802. * @param action Defines the action to launch during the step
  9803. */
  9804. registerStep(index: number, component: ISceneComponent, action: T): void;
  9805. /**
  9806. * Clears all the steps from the stage.
  9807. */
  9808. clear(): void;
  9809. }
  9810. }
  9811. declare module BABYLON {
  9812. interface Scene {
  9813. /** @hidden */
  9814. _pointerOverSprite: Nullable<Sprite>;
  9815. /** @hidden */
  9816. _pickedDownSprite: Nullable<Sprite>;
  9817. /** @hidden */
  9818. _tempSpritePickingRay: Nullable<Ray>;
  9819. /**
  9820. * All of the sprite managers added to this scene
  9821. * @see http://doc.babylonjs.com/babylon101/sprites
  9822. */
  9823. spriteManagers: Array<ISpriteManager>;
  9824. /**
  9825. * An event triggered when sprites rendering is about to start
  9826. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9827. */
  9828. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9829. /**
  9830. * An event triggered when sprites rendering is done
  9831. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9832. */
  9833. onAfterSpritesRenderingObservable: Observable<Scene>;
  9834. /** @hidden */
  9835. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9836. /** Launch a ray to try to pick a sprite in the scene
  9837. * @param x position on screen
  9838. * @param y position on screen
  9839. * @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
  9840. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9841. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9842. * @returns a PickingInfo
  9843. */
  9844. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9845. /** Use the given ray to pick a sprite in the scene
  9846. * @param ray The ray (in world space) to use to pick meshes
  9847. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9848. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9849. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9850. * @returns a PickingInfo
  9851. */
  9852. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9853. /** @hidden */
  9854. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9855. /** Launch a ray to try to pick sprites in the scene
  9856. * @param x position on screen
  9857. * @param y position on screen
  9858. * @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
  9859. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9860. * @returns a PickingInfo array
  9861. */
  9862. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9863. /** Use the given ray to pick sprites in the scene
  9864. * @param ray The ray (in world space) to use to pick meshes
  9865. * @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
  9866. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9867. * @returns a PickingInfo array
  9868. */
  9869. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9870. /**
  9871. * Force the sprite under the pointer
  9872. * @param sprite defines the sprite to use
  9873. */
  9874. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9875. /**
  9876. * Gets the sprite under the pointer
  9877. * @returns a Sprite or null if no sprite is under the pointer
  9878. */
  9879. getPointerOverSprite(): Nullable<Sprite>;
  9880. }
  9881. /**
  9882. * Defines the sprite scene component responsible to manage sprites
  9883. * in a given scene.
  9884. */
  9885. export class SpriteSceneComponent implements ISceneComponent {
  9886. /**
  9887. * The component name helpfull to identify the component in the list of scene components.
  9888. */
  9889. readonly name: string;
  9890. /**
  9891. * The scene the component belongs to.
  9892. */
  9893. scene: Scene;
  9894. /** @hidden */
  9895. private _spritePredicate;
  9896. /**
  9897. * Creates a new instance of the component for the given scene
  9898. * @param scene Defines the scene to register the component in
  9899. */
  9900. constructor(scene: Scene);
  9901. /**
  9902. * Registers the component in a given scene
  9903. */
  9904. register(): void;
  9905. /**
  9906. * Rebuilds the elements related to this component in case of
  9907. * context lost for instance.
  9908. */
  9909. rebuild(): void;
  9910. /**
  9911. * Disposes the component and the associated ressources.
  9912. */
  9913. dispose(): void;
  9914. private _pickSpriteButKeepRay;
  9915. private _pointerMove;
  9916. private _pointerDown;
  9917. private _pointerUp;
  9918. }
  9919. }
  9920. declare module BABYLON {
  9921. /** @hidden */
  9922. export var fogFragmentDeclaration: {
  9923. name: string;
  9924. shader: string;
  9925. };
  9926. }
  9927. declare module BABYLON {
  9928. /** @hidden */
  9929. export var fogFragment: {
  9930. name: string;
  9931. shader: string;
  9932. };
  9933. }
  9934. declare module BABYLON {
  9935. /** @hidden */
  9936. export var spritesPixelShader: {
  9937. name: string;
  9938. shader: string;
  9939. };
  9940. }
  9941. declare module BABYLON {
  9942. /** @hidden */
  9943. export var fogVertexDeclaration: {
  9944. name: string;
  9945. shader: string;
  9946. };
  9947. }
  9948. declare module BABYLON {
  9949. /** @hidden */
  9950. export var spritesVertexShader: {
  9951. name: string;
  9952. shader: string;
  9953. };
  9954. }
  9955. declare module BABYLON {
  9956. /**
  9957. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9958. */
  9959. export interface ISpriteManager extends IDisposable {
  9960. /**
  9961. * Restricts the camera to viewing objects with the same layerMask.
  9962. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9963. */
  9964. layerMask: number;
  9965. /**
  9966. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9967. */
  9968. isPickable: boolean;
  9969. /**
  9970. * Specifies the rendering group id for this mesh (0 by default)
  9971. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9972. */
  9973. renderingGroupId: number;
  9974. /**
  9975. * Defines the list of sprites managed by the manager.
  9976. */
  9977. sprites: Array<Sprite>;
  9978. /**
  9979. * Tests the intersection of a sprite with a specific ray.
  9980. * @param ray The ray we are sending to test the collision
  9981. * @param camera The camera space we are sending rays in
  9982. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9983. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9984. * @returns picking info or null.
  9985. */
  9986. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9987. /**
  9988. * Intersects the sprites with a ray
  9989. * @param ray defines the ray to intersect with
  9990. * @param camera defines the current active camera
  9991. * @param predicate defines a predicate used to select candidate sprites
  9992. * @returns null if no hit or a PickingInfo array
  9993. */
  9994. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9995. /**
  9996. * Renders the list of sprites on screen.
  9997. */
  9998. render(): void;
  9999. }
  10000. /**
  10001. * Class used to manage multiple sprites on the same spritesheet
  10002. * @see http://doc.babylonjs.com/babylon101/sprites
  10003. */
  10004. export class SpriteManager implements ISpriteManager {
  10005. /** defines the manager's name */
  10006. name: string;
  10007. /** Gets the list of sprites */
  10008. sprites: Sprite[];
  10009. /** Gets or sets the rendering group id (0 by default) */
  10010. renderingGroupId: number;
  10011. /** Gets or sets camera layer mask */
  10012. layerMask: number;
  10013. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10014. fogEnabled: boolean;
  10015. /** Gets or sets a boolean indicating if the sprites are pickable */
  10016. isPickable: boolean;
  10017. /** Defines the default width of a cell in the spritesheet */
  10018. cellWidth: number;
  10019. /** Defines the default height of a cell in the spritesheet */
  10020. cellHeight: number;
  10021. /** Associative array from JSON sprite data file */
  10022. private _cellData;
  10023. /** Array of sprite names from JSON sprite data file */
  10024. private _spriteMap;
  10025. /** True when packed cell data from JSON file is ready*/
  10026. private _packedAndReady;
  10027. /**
  10028. * An event triggered when the manager is disposed.
  10029. */
  10030. onDisposeObservable: Observable<SpriteManager>;
  10031. private _onDisposeObserver;
  10032. /**
  10033. * Callback called when the manager is disposed
  10034. */
  10035. set onDispose(callback: () => void);
  10036. private _capacity;
  10037. private _fromPacked;
  10038. private _spriteTexture;
  10039. private _epsilon;
  10040. private _scene;
  10041. private _vertexData;
  10042. private _buffer;
  10043. private _vertexBuffers;
  10044. private _indexBuffer;
  10045. private _effectBase;
  10046. private _effectFog;
  10047. /**
  10048. * Gets or sets the spritesheet texture
  10049. */
  10050. get texture(): Texture;
  10051. set texture(value: Texture);
  10052. private _blendMode;
  10053. /**
  10054. * Blend mode use to render the particle, it can be any of
  10055. * the static Constants.ALPHA_x properties provided in this class.
  10056. * Default value is Constants.ALPHA_COMBINE
  10057. */
  10058. get blendMode(): number;
  10059. set blendMode(blendMode: number);
  10060. /** Disables writing to the depth buffer when rendering the sprites.
  10061. * It can be handy to disable depth writing when using textures without alpha channel
  10062. * and setting some specific blend modes.
  10063. */
  10064. disableDepthWrite: boolean;
  10065. /**
  10066. * Creates a new sprite manager
  10067. * @param name defines the manager's name
  10068. * @param imgUrl defines the sprite sheet url
  10069. * @param capacity defines the maximum allowed number of sprites
  10070. * @param cellSize defines the size of a sprite cell
  10071. * @param scene defines the hosting scene
  10072. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10073. * @param samplingMode defines the smapling mode to use with spritesheet
  10074. * @param fromPacked set to false; do not alter
  10075. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10076. */
  10077. constructor(
  10078. /** defines the manager's name */
  10079. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10080. private _makePacked;
  10081. private _appendSpriteVertex;
  10082. /**
  10083. * Intersects the sprites with a ray
  10084. * @param ray defines the ray to intersect with
  10085. * @param camera defines the current active camera
  10086. * @param predicate defines a predicate used to select candidate sprites
  10087. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10088. * @returns null if no hit or a PickingInfo
  10089. */
  10090. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10091. /**
  10092. * Intersects the sprites with a ray
  10093. * @param ray defines the ray to intersect with
  10094. * @param camera defines the current active camera
  10095. * @param predicate defines a predicate used to select candidate sprites
  10096. * @returns null if no hit or a PickingInfo array
  10097. */
  10098. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10099. /**
  10100. * Render all child sprites
  10101. */
  10102. render(): void;
  10103. /**
  10104. * Release associated resources
  10105. */
  10106. dispose(): void;
  10107. }
  10108. }
  10109. declare module BABYLON {
  10110. /** Interface used by value gradients (color, factor, ...) */
  10111. export interface IValueGradient {
  10112. /**
  10113. * Gets or sets the gradient value (between 0 and 1)
  10114. */
  10115. gradient: number;
  10116. }
  10117. /** Class used to store color4 gradient */
  10118. export class ColorGradient implements IValueGradient {
  10119. /**
  10120. * Gets or sets the gradient value (between 0 and 1)
  10121. */
  10122. gradient: number;
  10123. /**
  10124. * Gets or sets first associated color
  10125. */
  10126. color1: Color4;
  10127. /**
  10128. * Gets or sets second associated color
  10129. */
  10130. color2?: Color4 | undefined;
  10131. /**
  10132. * Creates a new color4 gradient
  10133. * @param gradient gets or sets the gradient value (between 0 and 1)
  10134. * @param color1 gets or sets first associated color
  10135. * @param color2 gets or sets first second color
  10136. */
  10137. constructor(
  10138. /**
  10139. * Gets or sets the gradient value (between 0 and 1)
  10140. */
  10141. gradient: number,
  10142. /**
  10143. * Gets or sets first associated color
  10144. */
  10145. color1: Color4,
  10146. /**
  10147. * Gets or sets second associated color
  10148. */
  10149. color2?: Color4 | undefined);
  10150. /**
  10151. * Will get a color picked randomly between color1 and color2.
  10152. * If color2 is undefined then color1 will be used
  10153. * @param result defines the target Color4 to store the result in
  10154. */
  10155. getColorToRef(result: Color4): void;
  10156. }
  10157. /** Class used to store color 3 gradient */
  10158. export class Color3Gradient implements IValueGradient {
  10159. /**
  10160. * Gets or sets the gradient value (between 0 and 1)
  10161. */
  10162. gradient: number;
  10163. /**
  10164. * Gets or sets the associated color
  10165. */
  10166. color: Color3;
  10167. /**
  10168. * Creates a new color3 gradient
  10169. * @param gradient gets or sets the gradient value (between 0 and 1)
  10170. * @param color gets or sets associated color
  10171. */
  10172. constructor(
  10173. /**
  10174. * Gets or sets the gradient value (between 0 and 1)
  10175. */
  10176. gradient: number,
  10177. /**
  10178. * Gets or sets the associated color
  10179. */
  10180. color: Color3);
  10181. }
  10182. /** Class used to store factor gradient */
  10183. export class FactorGradient implements IValueGradient {
  10184. /**
  10185. * Gets or sets the gradient value (between 0 and 1)
  10186. */
  10187. gradient: number;
  10188. /**
  10189. * Gets or sets first associated factor
  10190. */
  10191. factor1: number;
  10192. /**
  10193. * Gets or sets second associated factor
  10194. */
  10195. factor2?: number | undefined;
  10196. /**
  10197. * Creates a new factor gradient
  10198. * @param gradient gets or sets the gradient value (between 0 and 1)
  10199. * @param factor1 gets or sets first associated factor
  10200. * @param factor2 gets or sets second associated factor
  10201. */
  10202. constructor(
  10203. /**
  10204. * Gets or sets the gradient value (between 0 and 1)
  10205. */
  10206. gradient: number,
  10207. /**
  10208. * Gets or sets first associated factor
  10209. */
  10210. factor1: number,
  10211. /**
  10212. * Gets or sets second associated factor
  10213. */
  10214. factor2?: number | undefined);
  10215. /**
  10216. * Will get a number picked randomly between factor1 and factor2.
  10217. * If factor2 is undefined then factor1 will be used
  10218. * @returns the picked number
  10219. */
  10220. getFactor(): number;
  10221. }
  10222. /**
  10223. * Helper used to simplify some generic gradient tasks
  10224. */
  10225. export class GradientHelper {
  10226. /**
  10227. * Gets the current gradient from an array of IValueGradient
  10228. * @param ratio defines the current ratio to get
  10229. * @param gradients defines the array of IValueGradient
  10230. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10231. */
  10232. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10233. }
  10234. }
  10235. declare module BABYLON {
  10236. /**
  10237. * Interface for the size containing width and height
  10238. */
  10239. export interface ISize {
  10240. /**
  10241. * Width
  10242. */
  10243. width: number;
  10244. /**
  10245. * Heighht
  10246. */
  10247. height: number;
  10248. }
  10249. /**
  10250. * Size containing widht and height
  10251. */
  10252. export class Size implements ISize {
  10253. /**
  10254. * Width
  10255. */
  10256. width: number;
  10257. /**
  10258. * Height
  10259. */
  10260. height: number;
  10261. /**
  10262. * Creates a Size object from the given width and height (floats).
  10263. * @param width width of the new size
  10264. * @param height height of the new size
  10265. */
  10266. constructor(width: number, height: number);
  10267. /**
  10268. * Returns a string with the Size width and height
  10269. * @returns a string with the Size width and height
  10270. */
  10271. toString(): string;
  10272. /**
  10273. * "Size"
  10274. * @returns the string "Size"
  10275. */
  10276. getClassName(): string;
  10277. /**
  10278. * Returns the Size hash code.
  10279. * @returns a hash code for a unique width and height
  10280. */
  10281. getHashCode(): number;
  10282. /**
  10283. * Updates the current size from the given one.
  10284. * @param src the given size
  10285. */
  10286. copyFrom(src: Size): void;
  10287. /**
  10288. * Updates in place the current Size from the given floats.
  10289. * @param width width of the new size
  10290. * @param height height of the new size
  10291. * @returns the updated Size.
  10292. */
  10293. copyFromFloats(width: number, height: number): Size;
  10294. /**
  10295. * Updates in place the current Size from the given floats.
  10296. * @param width width to set
  10297. * @param height height to set
  10298. * @returns the updated Size.
  10299. */
  10300. set(width: number, height: number): Size;
  10301. /**
  10302. * Multiplies the width and height by numbers
  10303. * @param w factor to multiple the width by
  10304. * @param h factor to multiple the height by
  10305. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10306. */
  10307. multiplyByFloats(w: number, h: number): Size;
  10308. /**
  10309. * Clones the size
  10310. * @returns a new Size copied from the given one.
  10311. */
  10312. clone(): Size;
  10313. /**
  10314. * True if the current Size and the given one width and height are strictly equal.
  10315. * @param other the other size to compare against
  10316. * @returns True if the current Size and the given one width and height are strictly equal.
  10317. */
  10318. equals(other: Size): boolean;
  10319. /**
  10320. * The surface of the Size : width * height (float).
  10321. */
  10322. get surface(): number;
  10323. /**
  10324. * Create a new size of zero
  10325. * @returns a new Size set to (0.0, 0.0)
  10326. */
  10327. static Zero(): Size;
  10328. /**
  10329. * Sums the width and height of two sizes
  10330. * @param otherSize size to add to this size
  10331. * @returns a new Size set as the addition result of the current Size and the given one.
  10332. */
  10333. add(otherSize: Size): Size;
  10334. /**
  10335. * Subtracts the width and height of two
  10336. * @param otherSize size to subtract to this size
  10337. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10338. */
  10339. subtract(otherSize: Size): Size;
  10340. /**
  10341. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10342. * @param start starting size to lerp between
  10343. * @param end end size to lerp between
  10344. * @param amount amount to lerp between the start and end values
  10345. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10346. */
  10347. static Lerp(start: Size, end: Size, amount: number): Size;
  10348. }
  10349. }
  10350. declare module BABYLON {
  10351. interface ThinEngine {
  10352. /**
  10353. * Creates a dynamic texture
  10354. * @param width defines the width of the texture
  10355. * @param height defines the height of the texture
  10356. * @param generateMipMaps defines if the engine should generate the mip levels
  10357. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10358. * @returns the dynamic texture inside an InternalTexture
  10359. */
  10360. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10361. /**
  10362. * Update the content of a dynamic texture
  10363. * @param texture defines the texture to update
  10364. * @param canvas defines the canvas containing the source
  10365. * @param invertY defines if data must be stored with Y axis inverted
  10366. * @param premulAlpha defines if alpha is stored as premultiplied
  10367. * @param format defines the format of the data
  10368. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10369. */
  10370. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10371. }
  10372. }
  10373. declare module BABYLON {
  10374. /**
  10375. * Helper class used to generate a canvas to manipulate images
  10376. */
  10377. export class CanvasGenerator {
  10378. /**
  10379. * Create a new canvas (or offscreen canvas depending on the context)
  10380. * @param width defines the expected width
  10381. * @param height defines the expected height
  10382. * @return a new canvas or offscreen canvas
  10383. */
  10384. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10385. }
  10386. }
  10387. declare module BABYLON {
  10388. /**
  10389. * A class extending Texture allowing drawing on a texture
  10390. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10391. */
  10392. export class DynamicTexture extends Texture {
  10393. private _generateMipMaps;
  10394. private _canvas;
  10395. private _context;
  10396. private _engine;
  10397. /**
  10398. * Creates a DynamicTexture
  10399. * @param name defines the name of the texture
  10400. * @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
  10401. * @param scene defines the scene where you want the texture
  10402. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10403. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10404. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10405. */
  10406. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10407. /**
  10408. * Get the current class name of the texture useful for serialization or dynamic coding.
  10409. * @returns "DynamicTexture"
  10410. */
  10411. getClassName(): string;
  10412. /**
  10413. * Gets the current state of canRescale
  10414. */
  10415. get canRescale(): boolean;
  10416. private _recreate;
  10417. /**
  10418. * Scales the texture
  10419. * @param ratio the scale factor to apply to both width and height
  10420. */
  10421. scale(ratio: number): void;
  10422. /**
  10423. * Resizes the texture
  10424. * @param width the new width
  10425. * @param height the new height
  10426. */
  10427. scaleTo(width: number, height: number): void;
  10428. /**
  10429. * Gets the context of the canvas used by the texture
  10430. * @returns the canvas context of the dynamic texture
  10431. */
  10432. getContext(): CanvasRenderingContext2D;
  10433. /**
  10434. * Clears the texture
  10435. */
  10436. clear(): void;
  10437. /**
  10438. * Updates the texture
  10439. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10440. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10441. */
  10442. update(invertY?: boolean, premulAlpha?: boolean): void;
  10443. /**
  10444. * Draws text onto the texture
  10445. * @param text defines the text to be drawn
  10446. * @param x defines the placement of the text from the left
  10447. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10448. * @param font defines the font to be used with font-style, font-size, font-name
  10449. * @param color defines the color used for the text
  10450. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10451. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10452. * @param update defines whether texture is immediately update (default is true)
  10453. */
  10454. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  10455. /**
  10456. * Clones the texture
  10457. * @returns the clone of the texture.
  10458. */
  10459. clone(): DynamicTexture;
  10460. /**
  10461. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10462. * @returns a serialized dynamic texture object
  10463. */
  10464. serialize(): any;
  10465. /** @hidden */
  10466. _rebuild(): void;
  10467. }
  10468. }
  10469. declare module BABYLON {
  10470. interface Engine {
  10471. /**
  10472. * Creates a raw texture
  10473. * @param data defines the data to store in the texture
  10474. * @param width defines the width of the texture
  10475. * @param height defines the height of the texture
  10476. * @param format defines the format of the data
  10477. * @param generateMipMaps defines if the engine should generate the mip levels
  10478. * @param invertY defines if data must be stored with Y axis inverted
  10479. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10480. * @param compression defines the compression used (null by default)
  10481. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10482. * @returns the raw texture inside an InternalTexture
  10483. */
  10484. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10485. /**
  10486. * Update a raw texture
  10487. * @param texture defines the texture to update
  10488. * @param data defines the data to store in the texture
  10489. * @param format defines the format of the data
  10490. * @param invertY defines if data must be stored with Y axis inverted
  10491. */
  10492. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10493. /**
  10494. * Update a raw texture
  10495. * @param texture defines the texture to update
  10496. * @param data defines the data to store in the texture
  10497. * @param format defines the format of the data
  10498. * @param invertY defines if data must be stored with Y axis inverted
  10499. * @param compression defines the compression used (null by default)
  10500. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10501. */
  10502. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10503. /**
  10504. * Creates a new raw cube texture
  10505. * @param data defines the array of data to use to create each face
  10506. * @param size defines the size of the textures
  10507. * @param format defines the format of the data
  10508. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10509. * @param generateMipMaps defines if the engine should generate the mip levels
  10510. * @param invertY defines if data must be stored with Y axis inverted
  10511. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10512. * @param compression defines the compression used (null by default)
  10513. * @returns the cube texture as an InternalTexture
  10514. */
  10515. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10516. /**
  10517. * Update a raw cube texture
  10518. * @param texture defines the texture to udpdate
  10519. * @param data defines the data to store
  10520. * @param format defines the data format
  10521. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10522. * @param invertY defines if data must be stored with Y axis inverted
  10523. */
  10524. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10525. /**
  10526. * Update a raw cube texture
  10527. * @param texture defines the texture to udpdate
  10528. * @param data defines the data to store
  10529. * @param format defines the data format
  10530. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10531. * @param invertY defines if data must be stored with Y axis inverted
  10532. * @param compression defines the compression used (null by default)
  10533. */
  10534. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10535. /**
  10536. * Update a raw cube texture
  10537. * @param texture defines the texture to udpdate
  10538. * @param data defines the data to store
  10539. * @param format defines the data format
  10540. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10541. * @param invertY defines if data must be stored with Y axis inverted
  10542. * @param compression defines the compression used (null by default)
  10543. * @param level defines which level of the texture to update
  10544. */
  10545. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10546. /**
  10547. * Creates a new raw cube texture from a specified url
  10548. * @param url defines the url where the data is located
  10549. * @param scene defines the current scene
  10550. * @param size defines the size of the textures
  10551. * @param format defines the format of the data
  10552. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10553. * @param noMipmap defines if the engine should avoid generating the mip levels
  10554. * @param callback defines a callback used to extract texture data from loaded data
  10555. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10556. * @param onLoad defines a callback called when texture is loaded
  10557. * @param onError defines a callback called if there is an error
  10558. * @returns the cube texture as an InternalTexture
  10559. */
  10560. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10561. /**
  10562. * Creates a new raw cube texture from a specified url
  10563. * @param url defines the url where the data is located
  10564. * @param scene defines the current scene
  10565. * @param size defines the size of the textures
  10566. * @param format defines the format of the data
  10567. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10568. * @param noMipmap defines if the engine should avoid generating the mip levels
  10569. * @param callback defines a callback used to extract texture data from loaded data
  10570. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10571. * @param onLoad defines a callback called when texture is loaded
  10572. * @param onError defines a callback called if there is an error
  10573. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10574. * @param invertY defines if data must be stored with Y axis inverted
  10575. * @returns the cube texture as an InternalTexture
  10576. */
  10577. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10578. /**
  10579. * Creates a new raw 3D texture
  10580. * @param data defines the data used to create the texture
  10581. * @param width defines the width of the texture
  10582. * @param height defines the height of the texture
  10583. * @param depth defines the depth of the texture
  10584. * @param format defines the format of the texture
  10585. * @param generateMipMaps defines if the engine must generate mip levels
  10586. * @param invertY defines if data must be stored with Y axis inverted
  10587. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10588. * @param compression defines the compressed used (can be null)
  10589. * @param textureType defines the compressed used (can be null)
  10590. * @returns a new raw 3D texture (stored in an InternalTexture)
  10591. */
  10592. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10593. /**
  10594. * Update a raw 3D texture
  10595. * @param texture defines the texture to update
  10596. * @param data defines the data to store
  10597. * @param format defines the data format
  10598. * @param invertY defines if data must be stored with Y axis inverted
  10599. */
  10600. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10601. /**
  10602. * Update a raw 3D texture
  10603. * @param texture defines the texture to update
  10604. * @param data defines the data to store
  10605. * @param format defines the data format
  10606. * @param invertY defines if data must be stored with Y axis inverted
  10607. * @param compression defines the used compression (can be null)
  10608. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10609. */
  10610. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10611. /**
  10612. * Creates a new raw 2D array texture
  10613. * @param data defines the data used to create the texture
  10614. * @param width defines the width of the texture
  10615. * @param height defines the height of the texture
  10616. * @param depth defines the number of layers of the texture
  10617. * @param format defines the format of the texture
  10618. * @param generateMipMaps defines if the engine must generate mip levels
  10619. * @param invertY defines if data must be stored with Y axis inverted
  10620. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10621. * @param compression defines the compressed used (can be null)
  10622. * @param textureType defines the compressed used (can be null)
  10623. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10624. */
  10625. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10626. /**
  10627. * Update a raw 2D array texture
  10628. * @param texture defines the texture to update
  10629. * @param data defines the data to store
  10630. * @param format defines the data format
  10631. * @param invertY defines if data must be stored with Y axis inverted
  10632. */
  10633. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10634. /**
  10635. * Update a raw 2D array texture
  10636. * @param texture defines the texture to update
  10637. * @param data defines the data to store
  10638. * @param format defines the data format
  10639. * @param invertY defines if data must be stored with Y axis inverted
  10640. * @param compression defines the used compression (can be null)
  10641. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10642. */
  10643. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10644. }
  10645. }
  10646. declare module BABYLON {
  10647. /**
  10648. * Raw texture can help creating a texture directly from an array of data.
  10649. * This can be super useful if you either get the data from an uncompressed source or
  10650. * if you wish to create your texture pixel by pixel.
  10651. */
  10652. export class RawTexture extends Texture {
  10653. /**
  10654. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10655. */
  10656. format: number;
  10657. private _engine;
  10658. /**
  10659. * Instantiates a new RawTexture.
  10660. * Raw texture can help creating a texture directly from an array of data.
  10661. * This can be super useful if you either get the data from an uncompressed source or
  10662. * if you wish to create your texture pixel by pixel.
  10663. * @param data define the array of data to use to create the texture
  10664. * @param width define the width of the texture
  10665. * @param height define the height of the texture
  10666. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10667. * @param scene define the scene the texture belongs to
  10668. * @param generateMipMaps define whether mip maps should be generated or not
  10669. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10670. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10671. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10672. */
  10673. constructor(data: ArrayBufferView, width: number, height: number,
  10674. /**
  10675. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10676. */
  10677. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10678. /**
  10679. * Updates the texture underlying data.
  10680. * @param data Define the new data of the texture
  10681. */
  10682. update(data: ArrayBufferView): void;
  10683. /**
  10684. * Creates a luminance texture from some data.
  10685. * @param data Define the texture data
  10686. * @param width Define the width of the texture
  10687. * @param height Define the height of the texture
  10688. * @param scene Define the scene the texture belongs to
  10689. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10690. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10691. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10692. * @returns the luminance texture
  10693. */
  10694. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10695. /**
  10696. * Creates a luminance alpha texture from some data.
  10697. * @param data Define the texture data
  10698. * @param width Define the width of the texture
  10699. * @param height Define the height of the texture
  10700. * @param scene Define the scene the texture belongs to
  10701. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10702. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10703. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10704. * @returns the luminance alpha texture
  10705. */
  10706. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10707. /**
  10708. * Creates an alpha texture from some data.
  10709. * @param data Define the texture data
  10710. * @param width Define the width of the texture
  10711. * @param height Define the height of the texture
  10712. * @param scene Define the scene the texture belongs to
  10713. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10714. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10715. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10716. * @returns the alpha texture
  10717. */
  10718. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10719. /**
  10720. * Creates a RGB texture from some data.
  10721. * @param data Define the texture data
  10722. * @param width Define the width of the texture
  10723. * @param height Define the height of the texture
  10724. * @param scene Define the scene the texture belongs to
  10725. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10726. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10727. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10728. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10729. * @returns the RGB alpha texture
  10730. */
  10731. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10732. /**
  10733. * Creates a RGBA texture from some data.
  10734. * @param data Define the texture data
  10735. * @param width Define the width of the texture
  10736. * @param height Define the height of the texture
  10737. * @param scene Define the scene the texture belongs to
  10738. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10739. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10740. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10741. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10742. * @returns the RGBA texture
  10743. */
  10744. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10745. /**
  10746. * Creates a R texture from some data.
  10747. * @param data Define the texture data
  10748. * @param width Define the width of the texture
  10749. * @param height Define the height of the texture
  10750. * @param scene Define the scene the texture belongs to
  10751. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10752. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10753. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10754. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10755. * @returns the R texture
  10756. */
  10757. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10758. }
  10759. }
  10760. declare module BABYLON {
  10761. interface AbstractScene {
  10762. /**
  10763. * The list of procedural textures added to the scene
  10764. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10765. */
  10766. proceduralTextures: Array<ProceduralTexture>;
  10767. }
  10768. /**
  10769. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10770. * in a given scene.
  10771. */
  10772. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10773. /**
  10774. * The component name helpfull to identify the component in the list of scene components.
  10775. */
  10776. readonly name: string;
  10777. /**
  10778. * The scene the component belongs to.
  10779. */
  10780. scene: Scene;
  10781. /**
  10782. * Creates a new instance of the component for the given scene
  10783. * @param scene Defines the scene to register the component in
  10784. */
  10785. constructor(scene: Scene);
  10786. /**
  10787. * Registers the component in a given scene
  10788. */
  10789. register(): void;
  10790. /**
  10791. * Rebuilds the elements related to this component in case of
  10792. * context lost for instance.
  10793. */
  10794. rebuild(): void;
  10795. /**
  10796. * Disposes the component and the associated ressources.
  10797. */
  10798. dispose(): void;
  10799. private _beforeClear;
  10800. }
  10801. }
  10802. declare module BABYLON {
  10803. interface ThinEngine {
  10804. /**
  10805. * Creates a new render target cube texture
  10806. * @param size defines the size of the texture
  10807. * @param options defines the options used to create the texture
  10808. * @returns a new render target cube texture stored in an InternalTexture
  10809. */
  10810. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /** @hidden */
  10815. export var proceduralVertexShader: {
  10816. name: string;
  10817. shader: string;
  10818. };
  10819. }
  10820. declare module BABYLON {
  10821. /**
  10822. * 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.
  10823. * This is the base class of any Procedural texture and contains most of the shareable code.
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10825. */
  10826. export class ProceduralTexture extends Texture {
  10827. isCube: boolean;
  10828. /**
  10829. * Define if the texture is enabled or not (disabled texture will not render)
  10830. */
  10831. isEnabled: boolean;
  10832. /**
  10833. * Define if the texture must be cleared before rendering (default is true)
  10834. */
  10835. autoClear: boolean;
  10836. /**
  10837. * Callback called when the texture is generated
  10838. */
  10839. onGenerated: () => void;
  10840. /**
  10841. * Event raised when the texture is generated
  10842. */
  10843. onGeneratedObservable: Observable<ProceduralTexture>;
  10844. /** @hidden */
  10845. _generateMipMaps: boolean;
  10846. /** @hidden **/
  10847. _effect: Effect;
  10848. /** @hidden */
  10849. _textures: {
  10850. [key: string]: Texture;
  10851. };
  10852. /** @hidden */
  10853. protected _fallbackTexture: Nullable<Texture>;
  10854. private _size;
  10855. private _currentRefreshId;
  10856. private _frameId;
  10857. private _refreshRate;
  10858. private _vertexBuffers;
  10859. private _indexBuffer;
  10860. private _uniforms;
  10861. private _samplers;
  10862. private _fragment;
  10863. private _floats;
  10864. private _ints;
  10865. private _floatsArrays;
  10866. private _colors3;
  10867. private _colors4;
  10868. private _vectors2;
  10869. private _vectors3;
  10870. private _matrices;
  10871. private _fallbackTextureUsed;
  10872. private _engine;
  10873. private _cachedDefines;
  10874. private _contentUpdateId;
  10875. private _contentData;
  10876. /**
  10877. * Instantiates a new procedural texture.
  10878. * 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.
  10879. * This is the base class of any Procedural texture and contains most of the shareable code.
  10880. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10881. * @param name Define the name of the texture
  10882. * @param size Define the size of the texture to create
  10883. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10884. * @param scene Define the scene the texture belongs to
  10885. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10886. * @param generateMipMaps Define if the texture should creates mip maps or not
  10887. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10888. */
  10889. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10890. /**
  10891. * The effect that is created when initializing the post process.
  10892. * @returns The created effect corresponding the the postprocess.
  10893. */
  10894. getEffect(): Effect;
  10895. /**
  10896. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10897. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10898. */
  10899. getContent(): Nullable<ArrayBufferView>;
  10900. private _createIndexBuffer;
  10901. /** @hidden */
  10902. _rebuild(): void;
  10903. /**
  10904. * Resets the texture in order to recreate its associated resources.
  10905. * This can be called in case of context loss
  10906. */
  10907. reset(): void;
  10908. protected _getDefines(): string;
  10909. /**
  10910. * Is the texture ready to be used ? (rendered at least once)
  10911. * @returns true if ready, otherwise, false.
  10912. */
  10913. isReady(): boolean;
  10914. /**
  10915. * Resets the refresh counter of the texture and start bak from scratch.
  10916. * Could be useful to regenerate the texture if it is setup to render only once.
  10917. */
  10918. resetRefreshCounter(): void;
  10919. /**
  10920. * Set the fragment shader to use in order to render the texture.
  10921. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10922. */
  10923. setFragment(fragment: any): void;
  10924. /**
  10925. * Define the refresh rate of the texture or the rendering frequency.
  10926. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10927. */
  10928. get refreshRate(): number;
  10929. set refreshRate(value: number);
  10930. /** @hidden */
  10931. _shouldRender(): boolean;
  10932. /**
  10933. * Get the size the texture is rendering at.
  10934. * @returns the size (texture is always squared)
  10935. */
  10936. getRenderSize(): number;
  10937. /**
  10938. * Resize the texture to new value.
  10939. * @param size Define the new size the texture should have
  10940. * @param generateMipMaps Define whether the new texture should create mip maps
  10941. */
  10942. resize(size: number, generateMipMaps: boolean): void;
  10943. private _checkUniform;
  10944. /**
  10945. * Set a texture in the shader program used to render.
  10946. * @param name Define the name of the uniform samplers as defined in the shader
  10947. * @param texture Define the texture to bind to this sampler
  10948. * @return the texture itself allowing "fluent" like uniform updates
  10949. */
  10950. setTexture(name: string, texture: Texture): ProceduralTexture;
  10951. /**
  10952. * Set a float in the shader.
  10953. * @param name Define the name of the uniform as defined in the shader
  10954. * @param value Define the value to give to the uniform
  10955. * @return the texture itself allowing "fluent" like uniform updates
  10956. */
  10957. setFloat(name: string, value: number): ProceduralTexture;
  10958. /**
  10959. * Set a int in the shader.
  10960. * @param name Define the name of the uniform as defined in the shader
  10961. * @param value Define the value to give to the uniform
  10962. * @return the texture itself allowing "fluent" like uniform updates
  10963. */
  10964. setInt(name: string, value: number): ProceduralTexture;
  10965. /**
  10966. * Set an array of floats in the shader.
  10967. * @param name Define the name of the uniform as defined in the shader
  10968. * @param value Define the value to give to the uniform
  10969. * @return the texture itself allowing "fluent" like uniform updates
  10970. */
  10971. setFloats(name: string, value: number[]): ProceduralTexture;
  10972. /**
  10973. * Set a vec3 in the shader from a Color3.
  10974. * @param name Define the name of the uniform as defined in the shader
  10975. * @param value Define the value to give to the uniform
  10976. * @return the texture itself allowing "fluent" like uniform updates
  10977. */
  10978. setColor3(name: string, value: Color3): ProceduralTexture;
  10979. /**
  10980. * Set a vec4 in the shader from a Color4.
  10981. * @param name Define the name of the uniform as defined in the shader
  10982. * @param value Define the value to give to the uniform
  10983. * @return the texture itself allowing "fluent" like uniform updates
  10984. */
  10985. setColor4(name: string, value: Color4): ProceduralTexture;
  10986. /**
  10987. * Set a vec2 in the shader from a Vector2.
  10988. * @param name Define the name of the uniform as defined in the shader
  10989. * @param value Define the value to give to the uniform
  10990. * @return the texture itself allowing "fluent" like uniform updates
  10991. */
  10992. setVector2(name: string, value: Vector2): ProceduralTexture;
  10993. /**
  10994. * Set a vec3 in the shader from a Vector3.
  10995. * @param name Define the name of the uniform as defined in the shader
  10996. * @param value Define the value to give to the uniform
  10997. * @return the texture itself allowing "fluent" like uniform updates
  10998. */
  10999. setVector3(name: string, value: Vector3): ProceduralTexture;
  11000. /**
  11001. * Set a mat4 in the shader from a MAtrix.
  11002. * @param name Define the name of the uniform as defined in the shader
  11003. * @param value Define the value to give to the uniform
  11004. * @return the texture itself allowing "fluent" like uniform updates
  11005. */
  11006. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11007. /**
  11008. * Render the texture to its associated render target.
  11009. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11010. */
  11011. render(useCameraPostProcess?: boolean): void;
  11012. /**
  11013. * Clone the texture.
  11014. * @returns the cloned texture
  11015. */
  11016. clone(): ProceduralTexture;
  11017. /**
  11018. * Dispose the texture and release its asoociated resources.
  11019. */
  11020. dispose(): void;
  11021. }
  11022. }
  11023. declare module BABYLON {
  11024. /**
  11025. * This represents the base class for particle system in Babylon.
  11026. * 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.
  11027. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11028. * @example https://doc.babylonjs.com/babylon101/particles
  11029. */
  11030. export class BaseParticleSystem {
  11031. /**
  11032. * Source color is added to the destination color without alpha affecting the result
  11033. */
  11034. static BLENDMODE_ONEONE: number;
  11035. /**
  11036. * Blend current color and particle color using particle’s alpha
  11037. */
  11038. static BLENDMODE_STANDARD: number;
  11039. /**
  11040. * Add current color and particle color multiplied by particle’s alpha
  11041. */
  11042. static BLENDMODE_ADD: number;
  11043. /**
  11044. * Multiply current color with particle color
  11045. */
  11046. static BLENDMODE_MULTIPLY: number;
  11047. /**
  11048. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11049. */
  11050. static BLENDMODE_MULTIPLYADD: number;
  11051. /**
  11052. * List of animations used by the particle system.
  11053. */
  11054. animations: Animation[];
  11055. /**
  11056. * Gets or sets the unique id of the particle system
  11057. */
  11058. uniqueId: number;
  11059. /**
  11060. * The id of the Particle system.
  11061. */
  11062. id: string;
  11063. /**
  11064. * The friendly name of the Particle system.
  11065. */
  11066. name: string;
  11067. /**
  11068. * Snippet ID if the particle system was created from the snippet server
  11069. */
  11070. snippetId: string;
  11071. /**
  11072. * The rendering group used by the Particle system to chose when to render.
  11073. */
  11074. renderingGroupId: number;
  11075. /**
  11076. * The emitter represents the Mesh or position we are attaching the particle system to.
  11077. */
  11078. emitter: Nullable<AbstractMesh | Vector3>;
  11079. /**
  11080. * The maximum number of particles to emit per frame
  11081. */
  11082. emitRate: number;
  11083. /**
  11084. * If you want to launch only a few particles at once, that can be done, as well.
  11085. */
  11086. manualEmitCount: number;
  11087. /**
  11088. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11089. */
  11090. updateSpeed: number;
  11091. /**
  11092. * The amount of time the particle system is running (depends of the overall update speed).
  11093. */
  11094. targetStopDuration: number;
  11095. /**
  11096. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11097. */
  11098. disposeOnStop: boolean;
  11099. /**
  11100. * Minimum power of emitting particles.
  11101. */
  11102. minEmitPower: number;
  11103. /**
  11104. * Maximum power of emitting particles.
  11105. */
  11106. maxEmitPower: number;
  11107. /**
  11108. * Minimum life time of emitting particles.
  11109. */
  11110. minLifeTime: number;
  11111. /**
  11112. * Maximum life time of emitting particles.
  11113. */
  11114. maxLifeTime: number;
  11115. /**
  11116. * Minimum Size of emitting particles.
  11117. */
  11118. minSize: number;
  11119. /**
  11120. * Maximum Size of emitting particles.
  11121. */
  11122. maxSize: number;
  11123. /**
  11124. * Minimum scale of emitting particles on X axis.
  11125. */
  11126. minScaleX: number;
  11127. /**
  11128. * Maximum scale of emitting particles on X axis.
  11129. */
  11130. maxScaleX: number;
  11131. /**
  11132. * Minimum scale of emitting particles on Y axis.
  11133. */
  11134. minScaleY: number;
  11135. /**
  11136. * Maximum scale of emitting particles on Y axis.
  11137. */
  11138. maxScaleY: number;
  11139. /**
  11140. * Gets or sets the minimal initial rotation in radians.
  11141. */
  11142. minInitialRotation: number;
  11143. /**
  11144. * Gets or sets the maximal initial rotation in radians.
  11145. */
  11146. maxInitialRotation: number;
  11147. /**
  11148. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11149. */
  11150. minAngularSpeed: number;
  11151. /**
  11152. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11153. */
  11154. maxAngularSpeed: number;
  11155. /**
  11156. * The texture used to render each particle. (this can be a spritesheet)
  11157. */
  11158. particleTexture: Nullable<Texture>;
  11159. /**
  11160. * The layer mask we are rendering the particles through.
  11161. */
  11162. layerMask: number;
  11163. /**
  11164. * This can help using your own shader to render the particle system.
  11165. * The according effect will be created
  11166. */
  11167. customShader: any;
  11168. /**
  11169. * By default particle system starts as soon as they are created. This prevents the
  11170. * automatic start to happen and let you decide when to start emitting particles.
  11171. */
  11172. preventAutoStart: boolean;
  11173. private _noiseTexture;
  11174. /**
  11175. * Gets or sets a texture used to add random noise to particle positions
  11176. */
  11177. get noiseTexture(): Nullable<ProceduralTexture>;
  11178. set noiseTexture(value: Nullable<ProceduralTexture>);
  11179. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11180. noiseStrength: Vector3;
  11181. /**
  11182. * Callback triggered when the particle animation is ending.
  11183. */
  11184. onAnimationEnd: Nullable<() => void>;
  11185. /**
  11186. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11187. */
  11188. blendMode: number;
  11189. /**
  11190. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11191. * to override the particles.
  11192. */
  11193. forceDepthWrite: boolean;
  11194. /** 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 */
  11195. preWarmCycles: number;
  11196. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11197. preWarmStepOffset: number;
  11198. /**
  11199. * 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)
  11200. */
  11201. spriteCellChangeSpeed: number;
  11202. /**
  11203. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11204. */
  11205. startSpriteCellID: number;
  11206. /**
  11207. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11208. */
  11209. endSpriteCellID: number;
  11210. /**
  11211. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11212. */
  11213. spriteCellWidth: number;
  11214. /**
  11215. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11216. */
  11217. spriteCellHeight: number;
  11218. /**
  11219. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11220. */
  11221. spriteRandomStartCell: boolean;
  11222. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11223. translationPivot: Vector2;
  11224. /** @hidden */
  11225. protected _isAnimationSheetEnabled: boolean;
  11226. /**
  11227. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11228. */
  11229. beginAnimationOnStart: boolean;
  11230. /**
  11231. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11232. */
  11233. beginAnimationFrom: number;
  11234. /**
  11235. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11236. */
  11237. beginAnimationTo: number;
  11238. /**
  11239. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11240. */
  11241. beginAnimationLoop: boolean;
  11242. /**
  11243. * Gets or sets a world offset applied to all particles
  11244. */
  11245. worldOffset: Vector3;
  11246. /**
  11247. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11248. */
  11249. get isAnimationSheetEnabled(): boolean;
  11250. set isAnimationSheetEnabled(value: boolean);
  11251. /**
  11252. * Get hosting scene
  11253. * @returns the scene
  11254. */
  11255. getScene(): Scene;
  11256. /**
  11257. * You can use gravity if you want to give an orientation to your particles.
  11258. */
  11259. gravity: Vector3;
  11260. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11261. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11262. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11263. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11264. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11265. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11266. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11267. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11268. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11269. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11270. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11271. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11272. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11273. /**
  11274. * Defines the delay in milliseconds before starting the system (0 by default)
  11275. */
  11276. startDelay: number;
  11277. /**
  11278. * Gets the current list of drag gradients.
  11279. * You must use addDragGradient and removeDragGradient to udpate this list
  11280. * @returns the list of drag gradients
  11281. */
  11282. getDragGradients(): Nullable<Array<FactorGradient>>;
  11283. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11284. limitVelocityDamping: number;
  11285. /**
  11286. * Gets the current list of limit velocity gradients.
  11287. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11288. * @returns the list of limit velocity gradients
  11289. */
  11290. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11291. /**
  11292. * Gets the current list of color gradients.
  11293. * You must use addColorGradient and removeColorGradient to udpate this list
  11294. * @returns the list of color gradients
  11295. */
  11296. getColorGradients(): Nullable<Array<ColorGradient>>;
  11297. /**
  11298. * Gets the current list of size gradients.
  11299. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11300. * @returns the list of size gradients
  11301. */
  11302. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11303. /**
  11304. * Gets the current list of color remap gradients.
  11305. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11306. * @returns the list of color remap gradients
  11307. */
  11308. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11309. /**
  11310. * Gets the current list of alpha remap gradients.
  11311. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11312. * @returns the list of alpha remap gradients
  11313. */
  11314. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11315. /**
  11316. * Gets the current list of life time gradients.
  11317. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11318. * @returns the list of life time gradients
  11319. */
  11320. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11321. /**
  11322. * Gets the current list of angular speed gradients.
  11323. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11324. * @returns the list of angular speed gradients
  11325. */
  11326. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11327. /**
  11328. * Gets the current list of velocity gradients.
  11329. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11330. * @returns the list of velocity gradients
  11331. */
  11332. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11333. /**
  11334. * Gets the current list of start size gradients.
  11335. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11336. * @returns the list of start size gradients
  11337. */
  11338. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11339. /**
  11340. * Gets the current list of emit rate gradients.
  11341. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11342. * @returns the list of emit rate gradients
  11343. */
  11344. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11345. /**
  11346. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11347. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11348. */
  11349. get direction1(): Vector3;
  11350. set direction1(value: Vector3);
  11351. /**
  11352. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11353. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11354. */
  11355. get direction2(): Vector3;
  11356. set direction2(value: Vector3);
  11357. /**
  11358. * 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.
  11359. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11360. */
  11361. get minEmitBox(): Vector3;
  11362. set minEmitBox(value: Vector3);
  11363. /**
  11364. * 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.
  11365. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11366. */
  11367. get maxEmitBox(): Vector3;
  11368. set maxEmitBox(value: Vector3);
  11369. /**
  11370. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11371. */
  11372. color1: Color4;
  11373. /**
  11374. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11375. */
  11376. color2: Color4;
  11377. /**
  11378. * Color the particle will have at the end of its lifetime
  11379. */
  11380. colorDead: Color4;
  11381. /**
  11382. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11383. */
  11384. textureMask: Color4;
  11385. /**
  11386. * The particle emitter type defines the emitter used by the particle system.
  11387. * It can be for example box, sphere, or cone...
  11388. */
  11389. particleEmitterType: IParticleEmitterType;
  11390. /** @hidden */
  11391. _isSubEmitter: boolean;
  11392. /**
  11393. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11394. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11395. */
  11396. billboardMode: number;
  11397. protected _isBillboardBased: boolean;
  11398. /**
  11399. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11400. */
  11401. get isBillboardBased(): boolean;
  11402. set isBillboardBased(value: boolean);
  11403. /**
  11404. * The scene the particle system belongs to.
  11405. */
  11406. protected _scene: Scene;
  11407. /**
  11408. * Local cache of defines for image processing.
  11409. */
  11410. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11411. /**
  11412. * Default configuration related to image processing available in the standard Material.
  11413. */
  11414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11415. /**
  11416. * Gets the image processing configuration used either in this material.
  11417. */
  11418. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11419. /**
  11420. * Sets the Default image processing configuration used either in the this material.
  11421. *
  11422. * If sets to null, the scene one is in use.
  11423. */
  11424. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11425. /**
  11426. * Attaches a new image processing configuration to the Standard Material.
  11427. * @param configuration
  11428. */
  11429. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11430. /** @hidden */
  11431. protected _reset(): void;
  11432. /** @hidden */
  11433. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11434. /**
  11435. * Instantiates a particle system.
  11436. * 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.
  11437. * @param name The name of the particle system
  11438. */
  11439. constructor(name: string);
  11440. /**
  11441. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11442. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11443. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11444. * @returns the emitter
  11445. */
  11446. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11447. /**
  11448. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11449. * @param radius The radius of the hemisphere to emit from
  11450. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11451. * @returns the emitter
  11452. */
  11453. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11454. /**
  11455. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11456. * @param radius The radius of the sphere to emit from
  11457. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11458. * @returns the emitter
  11459. */
  11460. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11461. /**
  11462. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11463. * @param radius The radius of the sphere to emit from
  11464. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11465. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11466. * @returns the emitter
  11467. */
  11468. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11469. /**
  11470. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11471. * @param radius The radius of the emission cylinder
  11472. * @param height The height of the emission cylinder
  11473. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11474. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11475. * @returns the emitter
  11476. */
  11477. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11478. /**
  11479. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11480. * @param radius The radius of the cylinder to emit from
  11481. * @param height The height of the emission cylinder
  11482. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11485. * @returns the emitter
  11486. */
  11487. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11488. /**
  11489. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11490. * @param radius The radius of the cone to emit from
  11491. * @param angle The base angle of the cone
  11492. * @returns the emitter
  11493. */
  11494. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11495. /**
  11496. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11497. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11498. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11499. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11500. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11501. * @returns the emitter
  11502. */
  11503. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11504. }
  11505. }
  11506. declare module BABYLON {
  11507. /**
  11508. * Type of sub emitter
  11509. */
  11510. export enum SubEmitterType {
  11511. /**
  11512. * Attached to the particle over it's lifetime
  11513. */
  11514. ATTACHED = 0,
  11515. /**
  11516. * Created when the particle dies
  11517. */
  11518. END = 1
  11519. }
  11520. /**
  11521. * Sub emitter class used to emit particles from an existing particle
  11522. */
  11523. export class SubEmitter {
  11524. /**
  11525. * the particle system to be used by the sub emitter
  11526. */
  11527. particleSystem: ParticleSystem;
  11528. /**
  11529. * Type of the submitter (Default: END)
  11530. */
  11531. type: SubEmitterType;
  11532. /**
  11533. * 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)
  11534. * Note: This only is supported when using an emitter of type Mesh
  11535. */
  11536. inheritDirection: boolean;
  11537. /**
  11538. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11539. */
  11540. inheritedVelocityAmount: number;
  11541. /**
  11542. * Creates a sub emitter
  11543. * @param particleSystem the particle system to be used by the sub emitter
  11544. */
  11545. constructor(
  11546. /**
  11547. * the particle system to be used by the sub emitter
  11548. */
  11549. particleSystem: ParticleSystem);
  11550. /**
  11551. * Clones the sub emitter
  11552. * @returns the cloned sub emitter
  11553. */
  11554. clone(): SubEmitter;
  11555. /**
  11556. * Serialize current object to a JSON object
  11557. * @returns the serialized object
  11558. */
  11559. serialize(): any;
  11560. /** @hidden */
  11561. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11562. /**
  11563. * Creates a new SubEmitter from a serialized JSON version
  11564. * @param serializationObject defines the JSON object to read from
  11565. * @param scene defines the hosting scene
  11566. * @param rootUrl defines the rootUrl for data loading
  11567. * @returns a new SubEmitter
  11568. */
  11569. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11570. /** Release associated resources */
  11571. dispose(): void;
  11572. }
  11573. }
  11574. declare module BABYLON {
  11575. /** @hidden */
  11576. export var imageProcessingDeclaration: {
  11577. name: string;
  11578. shader: string;
  11579. };
  11580. }
  11581. declare module BABYLON {
  11582. /** @hidden */
  11583. export var imageProcessingFunctions: {
  11584. name: string;
  11585. shader: string;
  11586. };
  11587. }
  11588. declare module BABYLON {
  11589. /** @hidden */
  11590. export var particlesPixelShader: {
  11591. name: string;
  11592. shader: string;
  11593. };
  11594. }
  11595. declare module BABYLON {
  11596. /** @hidden */
  11597. export var particlesVertexShader: {
  11598. name: string;
  11599. shader: string;
  11600. };
  11601. }
  11602. declare module BABYLON {
  11603. /**
  11604. * This represents a particle system in Babylon.
  11605. * 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.
  11606. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11607. * @example https://doc.babylonjs.com/babylon101/particles
  11608. */
  11609. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11610. /**
  11611. * Billboard mode will only apply to Y axis
  11612. */
  11613. static readonly BILLBOARDMODE_Y: number;
  11614. /**
  11615. * Billboard mode will apply to all axes
  11616. */
  11617. static readonly BILLBOARDMODE_ALL: number;
  11618. /**
  11619. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11620. */
  11621. static readonly BILLBOARDMODE_STRETCHED: number;
  11622. /**
  11623. * This function can be defined to provide custom update for active particles.
  11624. * This function will be called instead of regular update (age, position, color, etc.).
  11625. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11626. */
  11627. updateFunction: (particles: Particle[]) => void;
  11628. private _emitterWorldMatrix;
  11629. /**
  11630. * This function can be defined to specify initial direction for every new particle.
  11631. * It by default use the emitterType defined function
  11632. */
  11633. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11634. /**
  11635. * This function can be defined to specify initial position for every new particle.
  11636. * It by default use the emitterType defined function
  11637. */
  11638. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  11639. /**
  11640. * @hidden
  11641. */
  11642. _inheritedVelocityOffset: Vector3;
  11643. /**
  11644. * An event triggered when the system is disposed
  11645. */
  11646. onDisposeObservable: Observable<ParticleSystem>;
  11647. private _onDisposeObserver;
  11648. /**
  11649. * Sets a callback that will be triggered when the system is disposed
  11650. */
  11651. set onDispose(callback: () => void);
  11652. private _particles;
  11653. private _epsilon;
  11654. private _capacity;
  11655. private _stockParticles;
  11656. private _newPartsExcess;
  11657. private _vertexData;
  11658. private _vertexBuffer;
  11659. private _vertexBuffers;
  11660. private _spriteBuffer;
  11661. private _indexBuffer;
  11662. private _effect;
  11663. private _customEffect;
  11664. private _cachedDefines;
  11665. private _scaledColorStep;
  11666. private _colorDiff;
  11667. private _scaledDirection;
  11668. private _scaledGravity;
  11669. private _currentRenderId;
  11670. private _alive;
  11671. private _useInstancing;
  11672. private _started;
  11673. private _stopped;
  11674. private _actualFrame;
  11675. private _scaledUpdateSpeed;
  11676. private _vertexBufferSize;
  11677. /** @hidden */
  11678. _currentEmitRateGradient: Nullable<FactorGradient>;
  11679. /** @hidden */
  11680. _currentEmitRate1: number;
  11681. /** @hidden */
  11682. _currentEmitRate2: number;
  11683. /** @hidden */
  11684. _currentStartSizeGradient: Nullable<FactorGradient>;
  11685. /** @hidden */
  11686. _currentStartSize1: number;
  11687. /** @hidden */
  11688. _currentStartSize2: number;
  11689. private readonly _rawTextureWidth;
  11690. private _rampGradientsTexture;
  11691. private _useRampGradients;
  11692. /** Gets or sets a boolean indicating that ramp gradients must be used
  11693. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11694. */
  11695. get useRampGradients(): boolean;
  11696. set useRampGradients(value: boolean);
  11697. /**
  11698. * 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.
  11699. * 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: [])
  11700. */
  11701. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11702. private _subEmitters;
  11703. /**
  11704. * @hidden
  11705. * If the particle systems emitter should be disposed when the particle system is disposed
  11706. */
  11707. _disposeEmitterOnDispose: boolean;
  11708. /**
  11709. * The current active Sub-systems, this property is used by the root particle system only.
  11710. */
  11711. activeSubSystems: Array<ParticleSystem>;
  11712. /**
  11713. * Specifies if the particles are updated in emitter local space or world space
  11714. */
  11715. isLocal: boolean;
  11716. private _rootParticleSystem;
  11717. /**
  11718. * Gets the current list of active particles
  11719. */
  11720. get particles(): Particle[];
  11721. /**
  11722. * Gets the number of particles active at the same time.
  11723. * @returns The number of active particles.
  11724. */
  11725. getActiveCount(): number;
  11726. /**
  11727. * Returns the string "ParticleSystem"
  11728. * @returns a string containing the class name
  11729. */
  11730. getClassName(): string;
  11731. /**
  11732. * Gets a boolean indicating that the system is stopping
  11733. * @returns true if the system is currently stopping
  11734. */
  11735. isStopping(): boolean;
  11736. /**
  11737. * Instantiates a particle system.
  11738. * 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.
  11739. * @param name The name of the particle system
  11740. * @param capacity The max number of particles alive at the same time
  11741. * @param scene The scene the particle system belongs to
  11742. * @param customEffect a custom effect used to change the way particles are rendered by default
  11743. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11744. * @param epsilon Offset used to render the particles
  11745. */
  11746. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11747. private _addFactorGradient;
  11748. private _removeFactorGradient;
  11749. /**
  11750. * Adds a new life time gradient
  11751. * @param gradient defines the gradient to use (between 0 and 1)
  11752. * @param factor defines the life time factor to affect to the specified gradient
  11753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11754. * @returns the current particle system
  11755. */
  11756. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11757. /**
  11758. * Remove a specific life time gradient
  11759. * @param gradient defines the gradient to remove
  11760. * @returns the current particle system
  11761. */
  11762. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11763. /**
  11764. * Adds a new size gradient
  11765. * @param gradient defines the gradient to use (between 0 and 1)
  11766. * @param factor defines the size factor to affect to the specified gradient
  11767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11768. * @returns the current particle system
  11769. */
  11770. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11771. /**
  11772. * Remove a specific size gradient
  11773. * @param gradient defines the gradient to remove
  11774. * @returns the current particle system
  11775. */
  11776. removeSizeGradient(gradient: number): IParticleSystem;
  11777. /**
  11778. * Adds a new color remap gradient
  11779. * @param gradient defines the gradient to use (between 0 and 1)
  11780. * @param min defines the color remap minimal range
  11781. * @param max defines the color remap maximal range
  11782. * @returns the current particle system
  11783. */
  11784. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11785. /**
  11786. * Remove a specific color remap gradient
  11787. * @param gradient defines the gradient to remove
  11788. * @returns the current particle system
  11789. */
  11790. removeColorRemapGradient(gradient: number): IParticleSystem;
  11791. /**
  11792. * Adds a new alpha remap gradient
  11793. * @param gradient defines the gradient to use (between 0 and 1)
  11794. * @param min defines the alpha remap minimal range
  11795. * @param max defines the alpha remap maximal range
  11796. * @returns the current particle system
  11797. */
  11798. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11799. /**
  11800. * Remove a specific alpha remap gradient
  11801. * @param gradient defines the gradient to remove
  11802. * @returns the current particle system
  11803. */
  11804. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11805. /**
  11806. * Adds a new angular speed gradient
  11807. * @param gradient defines the gradient to use (between 0 and 1)
  11808. * @param factor defines the angular speed to affect to the specified gradient
  11809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11810. * @returns the current particle system
  11811. */
  11812. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11813. /**
  11814. * Remove a specific angular speed gradient
  11815. * @param gradient defines the gradient to remove
  11816. * @returns the current particle system
  11817. */
  11818. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11819. /**
  11820. * Adds a new velocity gradient
  11821. * @param gradient defines the gradient to use (between 0 and 1)
  11822. * @param factor defines the velocity to affect to the specified gradient
  11823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11824. * @returns the current particle system
  11825. */
  11826. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11827. /**
  11828. * Remove a specific velocity gradient
  11829. * @param gradient defines the gradient to remove
  11830. * @returns the current particle system
  11831. */
  11832. removeVelocityGradient(gradient: number): IParticleSystem;
  11833. /**
  11834. * Adds a new limit velocity gradient
  11835. * @param gradient defines the gradient to use (between 0 and 1)
  11836. * @param factor defines the limit velocity value to affect to the specified gradient
  11837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11838. * @returns the current particle system
  11839. */
  11840. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11841. /**
  11842. * Remove a specific limit velocity gradient
  11843. * @param gradient defines the gradient to remove
  11844. * @returns the current particle system
  11845. */
  11846. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11847. /**
  11848. * Adds a new drag gradient
  11849. * @param gradient defines the gradient to use (between 0 and 1)
  11850. * @param factor defines the drag value to affect to the specified gradient
  11851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11852. * @returns the current particle system
  11853. */
  11854. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11855. /**
  11856. * Remove a specific drag gradient
  11857. * @param gradient defines the gradient to remove
  11858. * @returns the current particle system
  11859. */
  11860. removeDragGradient(gradient: number): IParticleSystem;
  11861. /**
  11862. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11863. * @param gradient defines the gradient to use (between 0 and 1)
  11864. * @param factor defines the emit rate value to affect to the specified gradient
  11865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11866. * @returns the current particle system
  11867. */
  11868. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11869. /**
  11870. * Remove a specific emit rate gradient
  11871. * @param gradient defines the gradient to remove
  11872. * @returns the current particle system
  11873. */
  11874. removeEmitRateGradient(gradient: number): IParticleSystem;
  11875. /**
  11876. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11877. * @param gradient defines the gradient to use (between 0 and 1)
  11878. * @param factor defines the start size value to affect to the specified gradient
  11879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11880. * @returns the current particle system
  11881. */
  11882. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11883. /**
  11884. * Remove a specific start size gradient
  11885. * @param gradient defines the gradient to remove
  11886. * @returns the current particle system
  11887. */
  11888. removeStartSizeGradient(gradient: number): IParticleSystem;
  11889. private _createRampGradientTexture;
  11890. /**
  11891. * Gets the current list of ramp gradients.
  11892. * You must use addRampGradient and removeRampGradient to udpate this list
  11893. * @returns the list of ramp gradients
  11894. */
  11895. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11896. /** Force the system to rebuild all gradients that need to be resync */
  11897. forceRefreshGradients(): void;
  11898. private _syncRampGradientTexture;
  11899. /**
  11900. * Adds a new ramp gradient used to remap particle colors
  11901. * @param gradient defines the gradient to use (between 0 and 1)
  11902. * @param color defines the color to affect to the specified gradient
  11903. * @returns the current particle system
  11904. */
  11905. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11906. /**
  11907. * Remove a specific ramp gradient
  11908. * @param gradient defines the gradient to remove
  11909. * @returns the current particle system
  11910. */
  11911. removeRampGradient(gradient: number): ParticleSystem;
  11912. /**
  11913. * Adds a new color gradient
  11914. * @param gradient defines the gradient to use (between 0 and 1)
  11915. * @param color1 defines the color to affect to the specified gradient
  11916. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11917. * @returns this particle system
  11918. */
  11919. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11920. /**
  11921. * Remove a specific color gradient
  11922. * @param gradient defines the gradient to remove
  11923. * @returns this particle system
  11924. */
  11925. removeColorGradient(gradient: number): IParticleSystem;
  11926. private _fetchR;
  11927. protected _reset(): void;
  11928. private _resetEffect;
  11929. private _createVertexBuffers;
  11930. private _createIndexBuffer;
  11931. /**
  11932. * Gets the maximum number of particles active at the same time.
  11933. * @returns The max number of active particles.
  11934. */
  11935. getCapacity(): number;
  11936. /**
  11937. * Gets whether there are still active particles in the system.
  11938. * @returns True if it is alive, otherwise false.
  11939. */
  11940. isAlive(): boolean;
  11941. /**
  11942. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11943. * @returns True if it has been started, otherwise false.
  11944. */
  11945. isStarted(): boolean;
  11946. private _prepareSubEmitterInternalArray;
  11947. /**
  11948. * Starts the particle system and begins to emit
  11949. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11950. */
  11951. start(delay?: number): void;
  11952. /**
  11953. * Stops the particle system.
  11954. * @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.
  11955. */
  11956. stop(stopSubEmitters?: boolean): void;
  11957. /**
  11958. * Remove all active particles
  11959. */
  11960. reset(): void;
  11961. /**
  11962. * @hidden (for internal use only)
  11963. */
  11964. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11965. /**
  11966. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11967. * Its lifetime will start back at 0.
  11968. */
  11969. recycleParticle: (particle: Particle) => void;
  11970. private _stopSubEmitters;
  11971. private _createParticle;
  11972. private _removeFromRoot;
  11973. private _emitFromParticle;
  11974. private _update;
  11975. /** @hidden */
  11976. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11977. /** @hidden */
  11978. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11979. /** @hidden */
  11980. private _getEffect;
  11981. /**
  11982. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11983. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11984. */
  11985. animate(preWarmOnly?: boolean): void;
  11986. private _appendParticleVertices;
  11987. /**
  11988. * Rebuilds the particle system.
  11989. */
  11990. rebuild(): void;
  11991. /**
  11992. * Is this system ready to be used/rendered
  11993. * @return true if the system is ready
  11994. */
  11995. isReady(): boolean;
  11996. private _render;
  11997. /**
  11998. * Renders the particle system in its current state.
  11999. * @returns the current number of particles
  12000. */
  12001. render(): number;
  12002. /**
  12003. * Disposes the particle system and free the associated resources
  12004. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12005. */
  12006. dispose(disposeTexture?: boolean): void;
  12007. /**
  12008. * Clones the particle system.
  12009. * @param name The name of the cloned object
  12010. * @param newEmitter The new emitter to use
  12011. * @returns the cloned particle system
  12012. */
  12013. clone(name: string, newEmitter: any): ParticleSystem;
  12014. /**
  12015. * Serializes the particle system to a JSON object
  12016. * @param serializeTexture defines if the texture must be serialized as well
  12017. * @returns the JSON object
  12018. */
  12019. serialize(serializeTexture?: boolean): any;
  12020. /** @hidden */
  12021. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12022. /** @hidden */
  12023. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12024. /**
  12025. * Parses a JSON object to create a particle system.
  12026. * @param parsedParticleSystem The JSON object to parse
  12027. * @param scene The scene to create the particle system in
  12028. * @param rootUrl The root url to use to load external dependencies like texture
  12029. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12030. * @returns the Parsed particle system
  12031. */
  12032. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12033. }
  12034. }
  12035. declare module BABYLON {
  12036. /**
  12037. * A particle represents one of the element emitted by a particle system.
  12038. * This is mainly define by its coordinates, direction, velocity and age.
  12039. */
  12040. export class Particle {
  12041. /**
  12042. * The particle system the particle belongs to.
  12043. */
  12044. particleSystem: ParticleSystem;
  12045. private static _Count;
  12046. /**
  12047. * Unique ID of the particle
  12048. */
  12049. id: number;
  12050. /**
  12051. * The world position of the particle in the scene.
  12052. */
  12053. position: Vector3;
  12054. /**
  12055. * The world direction of the particle in the scene.
  12056. */
  12057. direction: Vector3;
  12058. /**
  12059. * The color of the particle.
  12060. */
  12061. color: Color4;
  12062. /**
  12063. * The color change of the particle per step.
  12064. */
  12065. colorStep: Color4;
  12066. /**
  12067. * Defines how long will the life of the particle be.
  12068. */
  12069. lifeTime: number;
  12070. /**
  12071. * The current age of the particle.
  12072. */
  12073. age: number;
  12074. /**
  12075. * The current size of the particle.
  12076. */
  12077. size: number;
  12078. /**
  12079. * The current scale of the particle.
  12080. */
  12081. scale: Vector2;
  12082. /**
  12083. * The current angle of the particle.
  12084. */
  12085. angle: number;
  12086. /**
  12087. * Defines how fast is the angle changing.
  12088. */
  12089. angularSpeed: number;
  12090. /**
  12091. * Defines the cell index used by the particle to be rendered from a sprite.
  12092. */
  12093. cellIndex: number;
  12094. /**
  12095. * The information required to support color remapping
  12096. */
  12097. remapData: Vector4;
  12098. /** @hidden */
  12099. _randomCellOffset?: number;
  12100. /** @hidden */
  12101. _initialDirection: Nullable<Vector3>;
  12102. /** @hidden */
  12103. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12104. /** @hidden */
  12105. _initialStartSpriteCellID: number;
  12106. /** @hidden */
  12107. _initialEndSpriteCellID: number;
  12108. /** @hidden */
  12109. _currentColorGradient: Nullable<ColorGradient>;
  12110. /** @hidden */
  12111. _currentColor1: Color4;
  12112. /** @hidden */
  12113. _currentColor2: Color4;
  12114. /** @hidden */
  12115. _currentSizeGradient: Nullable<FactorGradient>;
  12116. /** @hidden */
  12117. _currentSize1: number;
  12118. /** @hidden */
  12119. _currentSize2: number;
  12120. /** @hidden */
  12121. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12122. /** @hidden */
  12123. _currentAngularSpeed1: number;
  12124. /** @hidden */
  12125. _currentAngularSpeed2: number;
  12126. /** @hidden */
  12127. _currentVelocityGradient: Nullable<FactorGradient>;
  12128. /** @hidden */
  12129. _currentVelocity1: number;
  12130. /** @hidden */
  12131. _currentVelocity2: number;
  12132. /** @hidden */
  12133. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12134. /** @hidden */
  12135. _currentLimitVelocity1: number;
  12136. /** @hidden */
  12137. _currentLimitVelocity2: number;
  12138. /** @hidden */
  12139. _currentDragGradient: Nullable<FactorGradient>;
  12140. /** @hidden */
  12141. _currentDrag1: number;
  12142. /** @hidden */
  12143. _currentDrag2: number;
  12144. /** @hidden */
  12145. _randomNoiseCoordinates1: Vector3;
  12146. /** @hidden */
  12147. _randomNoiseCoordinates2: Vector3;
  12148. /** @hidden */
  12149. _localPosition?: Vector3;
  12150. /**
  12151. * Creates a new instance Particle
  12152. * @param particleSystem the particle system the particle belongs to
  12153. */
  12154. constructor(
  12155. /**
  12156. * The particle system the particle belongs to.
  12157. */
  12158. particleSystem: ParticleSystem);
  12159. private updateCellInfoFromSystem;
  12160. /**
  12161. * Defines how the sprite cell index is updated for the particle
  12162. */
  12163. updateCellIndex(): void;
  12164. /** @hidden */
  12165. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12166. /** @hidden */
  12167. _inheritParticleInfoToSubEmitters(): void;
  12168. /** @hidden */
  12169. _reset(): void;
  12170. /**
  12171. * Copy the properties of particle to another one.
  12172. * @param other the particle to copy the information to.
  12173. */
  12174. copyTo(other: Particle): void;
  12175. }
  12176. }
  12177. declare module BABYLON {
  12178. /**
  12179. * Particle emitter represents a volume emitting particles.
  12180. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12181. */
  12182. export interface IParticleEmitterType {
  12183. /**
  12184. * Called by the particle System when the direction is computed for the created particle.
  12185. * @param worldMatrix is the world matrix of the particle system
  12186. * @param directionToUpdate is the direction vector to update with the result
  12187. * @param particle is the particle we are computed the direction for
  12188. * @param isLocal defines if the direction should be set in local space
  12189. */
  12190. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12191. /**
  12192. * Called by the particle System when the position is computed for the created particle.
  12193. * @param worldMatrix is the world matrix of the particle system
  12194. * @param positionToUpdate is the position vector to update with the result
  12195. * @param particle is the particle we are computed the position for
  12196. * @param isLocal defines if the position should be set in local space
  12197. */
  12198. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12199. /**
  12200. * Clones the current emitter and returns a copy of it
  12201. * @returns the new emitter
  12202. */
  12203. clone(): IParticleEmitterType;
  12204. /**
  12205. * Called by the GPUParticleSystem to setup the update shader
  12206. * @param effect defines the update shader
  12207. */
  12208. applyToShader(effect: Effect): void;
  12209. /**
  12210. * Returns a string to use to update the GPU particles update shader
  12211. * @returns the effect defines string
  12212. */
  12213. getEffectDefines(): string;
  12214. /**
  12215. * Returns a string representing the class name
  12216. * @returns a string containing the class name
  12217. */
  12218. getClassName(): string;
  12219. /**
  12220. * Serializes the particle system to a JSON object.
  12221. * @returns the JSON object
  12222. */
  12223. serialize(): any;
  12224. /**
  12225. * Parse properties from a JSON object
  12226. * @param serializationObject defines the JSON object
  12227. * @param scene defines the hosting scene
  12228. */
  12229. parse(serializationObject: any, scene: Scene): void;
  12230. }
  12231. }
  12232. declare module BABYLON {
  12233. /**
  12234. * Particle emitter emitting particles from the inside of a box.
  12235. * It emits the particles randomly between 2 given directions.
  12236. */
  12237. export class BoxParticleEmitter implements IParticleEmitterType {
  12238. /**
  12239. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12240. */
  12241. direction1: Vector3;
  12242. /**
  12243. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12244. */
  12245. direction2: Vector3;
  12246. /**
  12247. * 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.
  12248. */
  12249. minEmitBox: Vector3;
  12250. /**
  12251. * 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.
  12252. */
  12253. maxEmitBox: Vector3;
  12254. /**
  12255. * Creates a new instance BoxParticleEmitter
  12256. */
  12257. constructor();
  12258. /**
  12259. * Called by the particle System when the direction is computed for the created particle.
  12260. * @param worldMatrix is the world matrix of the particle system
  12261. * @param directionToUpdate is the direction vector to update with the result
  12262. * @param particle is the particle we are computed the direction for
  12263. * @param isLocal defines if the direction should be set in local space
  12264. */
  12265. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12266. /**
  12267. * Called by the particle System when the position is computed for the created particle.
  12268. * @param worldMatrix is the world matrix of the particle system
  12269. * @param positionToUpdate is the position vector to update with the result
  12270. * @param particle is the particle we are computed the position for
  12271. * @param isLocal defines if the position should be set in local space
  12272. */
  12273. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12274. /**
  12275. * Clones the current emitter and returns a copy of it
  12276. * @returns the new emitter
  12277. */
  12278. clone(): BoxParticleEmitter;
  12279. /**
  12280. * Called by the GPUParticleSystem to setup the update shader
  12281. * @param effect defines the update shader
  12282. */
  12283. applyToShader(effect: Effect): void;
  12284. /**
  12285. * Returns a string to use to update the GPU particles update shader
  12286. * @returns a string containng the defines string
  12287. */
  12288. getEffectDefines(): string;
  12289. /**
  12290. * Returns the string "BoxParticleEmitter"
  12291. * @returns a string containing the class name
  12292. */
  12293. getClassName(): string;
  12294. /**
  12295. * Serializes the particle system to a JSON object.
  12296. * @returns the JSON object
  12297. */
  12298. serialize(): any;
  12299. /**
  12300. * Parse properties from a JSON object
  12301. * @param serializationObject defines the JSON object
  12302. */
  12303. parse(serializationObject: any): void;
  12304. }
  12305. }
  12306. declare module BABYLON {
  12307. /**
  12308. * Particle emitter emitting particles from the inside of a cone.
  12309. * It emits the particles alongside the cone volume from the base to the particle.
  12310. * The emission direction might be randomized.
  12311. */
  12312. export class ConeParticleEmitter implements IParticleEmitterType {
  12313. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12314. directionRandomizer: number;
  12315. private _radius;
  12316. private _angle;
  12317. private _height;
  12318. /**
  12319. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12320. */
  12321. radiusRange: number;
  12322. /**
  12323. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12324. */
  12325. heightRange: number;
  12326. /**
  12327. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12328. */
  12329. emitFromSpawnPointOnly: boolean;
  12330. /**
  12331. * Gets or sets the radius of the emission cone
  12332. */
  12333. get radius(): number;
  12334. set radius(value: number);
  12335. /**
  12336. * Gets or sets the angle of the emission cone
  12337. */
  12338. get angle(): number;
  12339. set angle(value: number);
  12340. private _buildHeight;
  12341. /**
  12342. * Creates a new instance ConeParticleEmitter
  12343. * @param radius the radius of the emission cone (1 by default)
  12344. * @param angle the cone base angle (PI by default)
  12345. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12346. */
  12347. constructor(radius?: number, angle?: number,
  12348. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12349. directionRandomizer?: number);
  12350. /**
  12351. * Called by the particle System when the direction is computed for the created particle.
  12352. * @param worldMatrix is the world matrix of the particle system
  12353. * @param directionToUpdate is the direction vector to update with the result
  12354. * @param particle is the particle we are computed the direction for
  12355. * @param isLocal defines if the direction should be set in local space
  12356. */
  12357. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12358. /**
  12359. * Called by the particle System when the position is computed for the created particle.
  12360. * @param worldMatrix is the world matrix of the particle system
  12361. * @param positionToUpdate is the position vector to update with the result
  12362. * @param particle is the particle we are computed the position for
  12363. * @param isLocal defines if the position should be set in local space
  12364. */
  12365. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12366. /**
  12367. * Clones the current emitter and returns a copy of it
  12368. * @returns the new emitter
  12369. */
  12370. clone(): ConeParticleEmitter;
  12371. /**
  12372. * Called by the GPUParticleSystem to setup the update shader
  12373. * @param effect defines the update shader
  12374. */
  12375. applyToShader(effect: Effect): void;
  12376. /**
  12377. * Returns a string to use to update the GPU particles update shader
  12378. * @returns a string containng the defines string
  12379. */
  12380. getEffectDefines(): string;
  12381. /**
  12382. * Returns the string "ConeParticleEmitter"
  12383. * @returns a string containing the class name
  12384. */
  12385. getClassName(): string;
  12386. /**
  12387. * Serializes the particle system to a JSON object.
  12388. * @returns the JSON object
  12389. */
  12390. serialize(): any;
  12391. /**
  12392. * Parse properties from a JSON object
  12393. * @param serializationObject defines the JSON object
  12394. */
  12395. parse(serializationObject: any): void;
  12396. }
  12397. }
  12398. declare module BABYLON {
  12399. /**
  12400. * Particle emitter emitting particles from the inside of a cylinder.
  12401. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12402. */
  12403. export class CylinderParticleEmitter implements IParticleEmitterType {
  12404. /**
  12405. * The radius of the emission cylinder.
  12406. */
  12407. radius: number;
  12408. /**
  12409. * The height of the emission cylinder.
  12410. */
  12411. height: number;
  12412. /**
  12413. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12414. */
  12415. radiusRange: number;
  12416. /**
  12417. * How much to randomize the particle direction [0-1].
  12418. */
  12419. directionRandomizer: number;
  12420. /**
  12421. * Creates a new instance CylinderParticleEmitter
  12422. * @param radius the radius of the emission cylinder (1 by default)
  12423. * @param height the height of the emission cylinder (1 by default)
  12424. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12425. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12426. */
  12427. constructor(
  12428. /**
  12429. * The radius of the emission cylinder.
  12430. */
  12431. radius?: number,
  12432. /**
  12433. * The height of the emission cylinder.
  12434. */
  12435. height?: number,
  12436. /**
  12437. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12438. */
  12439. radiusRange?: number,
  12440. /**
  12441. * How much to randomize the particle direction [0-1].
  12442. */
  12443. directionRandomizer?: number);
  12444. /**
  12445. * Called by the particle System when the direction is computed for the created particle.
  12446. * @param worldMatrix is the world matrix of the particle system
  12447. * @param directionToUpdate is the direction vector to update with the result
  12448. * @param particle is the particle we are computed the direction for
  12449. * @param isLocal defines if the direction should be set in local space
  12450. */
  12451. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12452. /**
  12453. * Called by the particle System when the position is computed for the created particle.
  12454. * @param worldMatrix is the world matrix of the particle system
  12455. * @param positionToUpdate is the position vector to update with the result
  12456. * @param particle is the particle we are computed the position for
  12457. * @param isLocal defines if the position should be set in local space
  12458. */
  12459. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12460. /**
  12461. * Clones the current emitter and returns a copy of it
  12462. * @returns the new emitter
  12463. */
  12464. clone(): CylinderParticleEmitter;
  12465. /**
  12466. * Called by the GPUParticleSystem to setup the update shader
  12467. * @param effect defines the update shader
  12468. */
  12469. applyToShader(effect: Effect): void;
  12470. /**
  12471. * Returns a string to use to update the GPU particles update shader
  12472. * @returns a string containng the defines string
  12473. */
  12474. getEffectDefines(): string;
  12475. /**
  12476. * Returns the string "CylinderParticleEmitter"
  12477. * @returns a string containing the class name
  12478. */
  12479. getClassName(): string;
  12480. /**
  12481. * Serializes the particle system to a JSON object.
  12482. * @returns the JSON object
  12483. */
  12484. serialize(): any;
  12485. /**
  12486. * Parse properties from a JSON object
  12487. * @param serializationObject defines the JSON object
  12488. */
  12489. parse(serializationObject: any): void;
  12490. }
  12491. /**
  12492. * Particle emitter emitting particles from the inside of a cylinder.
  12493. * It emits the particles randomly between two vectors.
  12494. */
  12495. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12496. /**
  12497. * The min limit of the emission direction.
  12498. */
  12499. direction1: Vector3;
  12500. /**
  12501. * The max limit of the emission direction.
  12502. */
  12503. direction2: Vector3;
  12504. /**
  12505. * Creates a new instance CylinderDirectedParticleEmitter
  12506. * @param radius the radius of the emission cylinder (1 by default)
  12507. * @param height the height of the emission cylinder (1 by default)
  12508. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12509. * @param direction1 the min limit of the emission direction (up vector by default)
  12510. * @param direction2 the max limit of the emission direction (up vector by default)
  12511. */
  12512. constructor(radius?: number, height?: number, radiusRange?: number,
  12513. /**
  12514. * The min limit of the emission direction.
  12515. */
  12516. direction1?: Vector3,
  12517. /**
  12518. * The max limit of the emission direction.
  12519. */
  12520. direction2?: Vector3);
  12521. /**
  12522. * Called by the particle System when the direction is computed for the created particle.
  12523. * @param worldMatrix is the world matrix of the particle system
  12524. * @param directionToUpdate is the direction vector to update with the result
  12525. * @param particle is the particle we are computed the direction for
  12526. */
  12527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12528. /**
  12529. * Clones the current emitter and returns a copy of it
  12530. * @returns the new emitter
  12531. */
  12532. clone(): CylinderDirectedParticleEmitter;
  12533. /**
  12534. * Called by the GPUParticleSystem to setup the update shader
  12535. * @param effect defines the update shader
  12536. */
  12537. applyToShader(effect: Effect): void;
  12538. /**
  12539. * Returns a string to use to update the GPU particles update shader
  12540. * @returns a string containng the defines string
  12541. */
  12542. getEffectDefines(): string;
  12543. /**
  12544. * Returns the string "CylinderDirectedParticleEmitter"
  12545. * @returns a string containing the class name
  12546. */
  12547. getClassName(): string;
  12548. /**
  12549. * Serializes the particle system to a JSON object.
  12550. * @returns the JSON object
  12551. */
  12552. serialize(): any;
  12553. /**
  12554. * Parse properties from a JSON object
  12555. * @param serializationObject defines the JSON object
  12556. */
  12557. parse(serializationObject: any): void;
  12558. }
  12559. }
  12560. declare module BABYLON {
  12561. /**
  12562. * Particle emitter emitting particles from the inside of a hemisphere.
  12563. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12564. */
  12565. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12566. /**
  12567. * The radius of the emission hemisphere.
  12568. */
  12569. radius: number;
  12570. /**
  12571. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12572. */
  12573. radiusRange: number;
  12574. /**
  12575. * How much to randomize the particle direction [0-1].
  12576. */
  12577. directionRandomizer: number;
  12578. /**
  12579. * Creates a new instance HemisphericParticleEmitter
  12580. * @param radius the radius of the emission hemisphere (1 by default)
  12581. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12582. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12583. */
  12584. constructor(
  12585. /**
  12586. * The radius of the emission hemisphere.
  12587. */
  12588. radius?: number,
  12589. /**
  12590. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12591. */
  12592. radiusRange?: number,
  12593. /**
  12594. * How much to randomize the particle direction [0-1].
  12595. */
  12596. directionRandomizer?: number);
  12597. /**
  12598. * Called by the particle System when the direction is computed for the created particle.
  12599. * @param worldMatrix is the world matrix of the particle system
  12600. * @param directionToUpdate is the direction vector to update with the result
  12601. * @param particle is the particle we are computed the direction for
  12602. * @param isLocal defines if the direction should be set in local space
  12603. */
  12604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12605. /**
  12606. * Called by the particle System when the position is computed for the created particle.
  12607. * @param worldMatrix is the world matrix of the particle system
  12608. * @param positionToUpdate is the position vector to update with the result
  12609. * @param particle is the particle we are computed the position for
  12610. * @param isLocal defines if the position should be set in local space
  12611. */
  12612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12613. /**
  12614. * Clones the current emitter and returns a copy of it
  12615. * @returns the new emitter
  12616. */
  12617. clone(): HemisphericParticleEmitter;
  12618. /**
  12619. * Called by the GPUParticleSystem to setup the update shader
  12620. * @param effect defines the update shader
  12621. */
  12622. applyToShader(effect: Effect): void;
  12623. /**
  12624. * Returns a string to use to update the GPU particles update shader
  12625. * @returns a string containng the defines string
  12626. */
  12627. getEffectDefines(): string;
  12628. /**
  12629. * Returns the string "HemisphericParticleEmitter"
  12630. * @returns a string containing the class name
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Serializes the particle system to a JSON object.
  12635. * @returns the JSON object
  12636. */
  12637. serialize(): any;
  12638. /**
  12639. * Parse properties from a JSON object
  12640. * @param serializationObject defines the JSON object
  12641. */
  12642. parse(serializationObject: any): void;
  12643. }
  12644. }
  12645. declare module BABYLON {
  12646. /**
  12647. * Particle emitter emitting particles from a point.
  12648. * It emits the particles randomly between 2 given directions.
  12649. */
  12650. export class PointParticleEmitter implements IParticleEmitterType {
  12651. /**
  12652. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12653. */
  12654. direction1: Vector3;
  12655. /**
  12656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12657. */
  12658. direction2: Vector3;
  12659. /**
  12660. * Creates a new instance PointParticleEmitter
  12661. */
  12662. constructor();
  12663. /**
  12664. * Called by the particle System when the direction is computed for the created particle.
  12665. * @param worldMatrix is the world matrix of the particle system
  12666. * @param directionToUpdate is the direction vector to update with the result
  12667. * @param particle is the particle we are computed the direction for
  12668. * @param isLocal defines if the direction should be set in local space
  12669. */
  12670. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12671. /**
  12672. * Called by the particle System when the position is computed for the created particle.
  12673. * @param worldMatrix is the world matrix of the particle system
  12674. * @param positionToUpdate is the position vector to update with the result
  12675. * @param particle is the particle we are computed the position for
  12676. * @param isLocal defines if the position should be set in local space
  12677. */
  12678. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12679. /**
  12680. * Clones the current emitter and returns a copy of it
  12681. * @returns the new emitter
  12682. */
  12683. clone(): PointParticleEmitter;
  12684. /**
  12685. * Called by the GPUParticleSystem to setup the update shader
  12686. * @param effect defines the update shader
  12687. */
  12688. applyToShader(effect: Effect): void;
  12689. /**
  12690. * Returns a string to use to update the GPU particles update shader
  12691. * @returns a string containng the defines string
  12692. */
  12693. getEffectDefines(): string;
  12694. /**
  12695. * Returns the string "PointParticleEmitter"
  12696. * @returns a string containing the class name
  12697. */
  12698. getClassName(): string;
  12699. /**
  12700. * Serializes the particle system to a JSON object.
  12701. * @returns the JSON object
  12702. */
  12703. serialize(): any;
  12704. /**
  12705. * Parse properties from a JSON object
  12706. * @param serializationObject defines the JSON object
  12707. */
  12708. parse(serializationObject: any): void;
  12709. }
  12710. }
  12711. declare module BABYLON {
  12712. /**
  12713. * Particle emitter emitting particles from the inside of a sphere.
  12714. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12715. */
  12716. export class SphereParticleEmitter implements IParticleEmitterType {
  12717. /**
  12718. * The radius of the emission sphere.
  12719. */
  12720. radius: number;
  12721. /**
  12722. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12723. */
  12724. radiusRange: number;
  12725. /**
  12726. * How much to randomize the particle direction [0-1].
  12727. */
  12728. directionRandomizer: number;
  12729. /**
  12730. * Creates a new instance SphereParticleEmitter
  12731. * @param radius the radius of the emission sphere (1 by default)
  12732. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12733. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12734. */
  12735. constructor(
  12736. /**
  12737. * The radius of the emission sphere.
  12738. */
  12739. radius?: number,
  12740. /**
  12741. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12742. */
  12743. radiusRange?: number,
  12744. /**
  12745. * How much to randomize the particle direction [0-1].
  12746. */
  12747. directionRandomizer?: number);
  12748. /**
  12749. * Called by the particle System when the direction is computed for the created particle.
  12750. * @param worldMatrix is the world matrix of the particle system
  12751. * @param directionToUpdate is the direction vector to update with the result
  12752. * @param particle is the particle we are computed the direction for
  12753. * @param isLocal defines if the direction should be set in local space
  12754. */
  12755. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12756. /**
  12757. * Called by the particle System when the position is computed for the created particle.
  12758. * @param worldMatrix is the world matrix of the particle system
  12759. * @param positionToUpdate is the position vector to update with the result
  12760. * @param particle is the particle we are computed the position for
  12761. * @param isLocal defines if the position should be set in local space
  12762. */
  12763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12764. /**
  12765. * Clones the current emitter and returns a copy of it
  12766. * @returns the new emitter
  12767. */
  12768. clone(): SphereParticleEmitter;
  12769. /**
  12770. * Called by the GPUParticleSystem to setup the update shader
  12771. * @param effect defines the update shader
  12772. */
  12773. applyToShader(effect: Effect): void;
  12774. /**
  12775. * Returns a string to use to update the GPU particles update shader
  12776. * @returns a string containng the defines string
  12777. */
  12778. getEffectDefines(): string;
  12779. /**
  12780. * Returns the string "SphereParticleEmitter"
  12781. * @returns a string containing the class name
  12782. */
  12783. getClassName(): string;
  12784. /**
  12785. * Serializes the particle system to a JSON object.
  12786. * @returns the JSON object
  12787. */
  12788. serialize(): any;
  12789. /**
  12790. * Parse properties from a JSON object
  12791. * @param serializationObject defines the JSON object
  12792. */
  12793. parse(serializationObject: any): void;
  12794. }
  12795. /**
  12796. * Particle emitter emitting particles from the inside of a sphere.
  12797. * It emits the particles randomly between two vectors.
  12798. */
  12799. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12800. /**
  12801. * The min limit of the emission direction.
  12802. */
  12803. direction1: Vector3;
  12804. /**
  12805. * The max limit of the emission direction.
  12806. */
  12807. direction2: Vector3;
  12808. /**
  12809. * Creates a new instance SphereDirectedParticleEmitter
  12810. * @param radius the radius of the emission sphere (1 by default)
  12811. * @param direction1 the min limit of the emission direction (up vector by default)
  12812. * @param direction2 the max limit of the emission direction (up vector by default)
  12813. */
  12814. constructor(radius?: number,
  12815. /**
  12816. * The min limit of the emission direction.
  12817. */
  12818. direction1?: Vector3,
  12819. /**
  12820. * The max limit of the emission direction.
  12821. */
  12822. direction2?: Vector3);
  12823. /**
  12824. * Called by the particle System when the direction is computed for the created particle.
  12825. * @param worldMatrix is the world matrix of the particle system
  12826. * @param directionToUpdate is the direction vector to update with the result
  12827. * @param particle is the particle we are computed the direction for
  12828. */
  12829. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12830. /**
  12831. * Clones the current emitter and returns a copy of it
  12832. * @returns the new emitter
  12833. */
  12834. clone(): SphereDirectedParticleEmitter;
  12835. /**
  12836. * Called by the GPUParticleSystem to setup the update shader
  12837. * @param effect defines the update shader
  12838. */
  12839. applyToShader(effect: Effect): void;
  12840. /**
  12841. * Returns a string to use to update the GPU particles update shader
  12842. * @returns a string containng the defines string
  12843. */
  12844. getEffectDefines(): string;
  12845. /**
  12846. * Returns the string "SphereDirectedParticleEmitter"
  12847. * @returns a string containing the class name
  12848. */
  12849. getClassName(): string;
  12850. /**
  12851. * Serializes the particle system to a JSON object.
  12852. * @returns the JSON object
  12853. */
  12854. serialize(): any;
  12855. /**
  12856. * Parse properties from a JSON object
  12857. * @param serializationObject defines the JSON object
  12858. */
  12859. parse(serializationObject: any): void;
  12860. }
  12861. }
  12862. declare module BABYLON {
  12863. /**
  12864. * Particle emitter emitting particles from a custom list of positions.
  12865. */
  12866. export class CustomParticleEmitter implements IParticleEmitterType {
  12867. /**
  12868. * Gets or sets the position generator that will create the inital position of each particle.
  12869. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12870. */
  12871. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12872. /**
  12873. * Gets or sets the destination generator that will create the final destination of each particle.
  12874. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12875. */
  12876. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12877. /**
  12878. * Creates a new instance CustomParticleEmitter
  12879. */
  12880. constructor();
  12881. /**
  12882. * Called by the particle System when the direction is computed for the created particle.
  12883. * @param worldMatrix is the world matrix of the particle system
  12884. * @param directionToUpdate is the direction vector to update with the result
  12885. * @param particle is the particle we are computed the direction for
  12886. * @param isLocal defines if the direction should be set in local space
  12887. */
  12888. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12889. /**
  12890. * Called by the particle System when the position is computed for the created particle.
  12891. * @param worldMatrix is the world matrix of the particle system
  12892. * @param positionToUpdate is the position vector to update with the result
  12893. * @param particle is the particle we are computed the position for
  12894. * @param isLocal defines if the position should be set in local space
  12895. */
  12896. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12897. /**
  12898. * Clones the current emitter and returns a copy of it
  12899. * @returns the new emitter
  12900. */
  12901. clone(): CustomParticleEmitter;
  12902. /**
  12903. * Called by the GPUParticleSystem to setup the update shader
  12904. * @param effect defines the update shader
  12905. */
  12906. applyToShader(effect: Effect): void;
  12907. /**
  12908. * Returns a string to use to update the GPU particles update shader
  12909. * @returns a string containng the defines string
  12910. */
  12911. getEffectDefines(): string;
  12912. /**
  12913. * Returns the string "PointParticleEmitter"
  12914. * @returns a string containing the class name
  12915. */
  12916. getClassName(): string;
  12917. /**
  12918. * Serializes the particle system to a JSON object.
  12919. * @returns the JSON object
  12920. */
  12921. serialize(): any;
  12922. /**
  12923. * Parse properties from a JSON object
  12924. * @param serializationObject defines the JSON object
  12925. */
  12926. parse(serializationObject: any): void;
  12927. }
  12928. }
  12929. declare module BABYLON {
  12930. /**
  12931. * Particle emitter emitting particles from the inside of a box.
  12932. * It emits the particles randomly between 2 given directions.
  12933. */
  12934. export class MeshParticleEmitter implements IParticleEmitterType {
  12935. private _indices;
  12936. private _positions;
  12937. private _normals;
  12938. private _storedNormal;
  12939. private _mesh;
  12940. /**
  12941. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12942. */
  12943. direction1: Vector3;
  12944. /**
  12945. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12946. */
  12947. direction2: Vector3;
  12948. /**
  12949. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12950. */
  12951. useMeshNormalsForDirection: boolean;
  12952. /** Defines the mesh to use as source */
  12953. get mesh(): Nullable<AbstractMesh>;
  12954. set mesh(value: Nullable<AbstractMesh>);
  12955. /**
  12956. * Creates a new instance MeshParticleEmitter
  12957. * @param mesh defines the mesh to use as source
  12958. */
  12959. constructor(mesh?: Nullable<AbstractMesh>);
  12960. /**
  12961. * Called by the particle System when the direction is computed for the created particle.
  12962. * @param worldMatrix is the world matrix of the particle system
  12963. * @param directionToUpdate is the direction vector to update with the result
  12964. * @param particle is the particle we are computed the direction for
  12965. * @param isLocal defines if the direction should be set in local space
  12966. */
  12967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12968. /**
  12969. * Called by the particle System when the position is computed for the created particle.
  12970. * @param worldMatrix is the world matrix of the particle system
  12971. * @param positionToUpdate is the position vector to update with the result
  12972. * @param particle is the particle we are computed the position for
  12973. * @param isLocal defines if the position should be set in local space
  12974. */
  12975. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  12976. /**
  12977. * Clones the current emitter and returns a copy of it
  12978. * @returns the new emitter
  12979. */
  12980. clone(): MeshParticleEmitter;
  12981. /**
  12982. * Called by the GPUParticleSystem to setup the update shader
  12983. * @param effect defines the update shader
  12984. */
  12985. applyToShader(effect: Effect): void;
  12986. /**
  12987. * Returns a string to use to update the GPU particles update shader
  12988. * @returns a string containng the defines string
  12989. */
  12990. getEffectDefines(): string;
  12991. /**
  12992. * Returns the string "BoxParticleEmitter"
  12993. * @returns a string containing the class name
  12994. */
  12995. getClassName(): string;
  12996. /**
  12997. * Serializes the particle system to a JSON object.
  12998. * @returns the JSON object
  12999. */
  13000. serialize(): any;
  13001. /**
  13002. * Parse properties from a JSON object
  13003. * @param serializationObject defines the JSON object
  13004. * @param scene defines the hosting scene
  13005. */
  13006. parse(serializationObject: any, scene: Scene): void;
  13007. }
  13008. }
  13009. declare module BABYLON {
  13010. /**
  13011. * Interface representing a particle system in Babylon.js.
  13012. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13013. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13014. */
  13015. export interface IParticleSystem {
  13016. /**
  13017. * List of animations used by the particle system.
  13018. */
  13019. animations: Animation[];
  13020. /**
  13021. * The id of the Particle system.
  13022. */
  13023. id: string;
  13024. /**
  13025. * The name of the Particle system.
  13026. */
  13027. name: string;
  13028. /**
  13029. * The emitter represents the Mesh or position we are attaching the particle system to.
  13030. */
  13031. emitter: Nullable<AbstractMesh | Vector3>;
  13032. /**
  13033. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13034. */
  13035. isBillboardBased: boolean;
  13036. /**
  13037. * The rendering group used by the Particle system to chose when to render.
  13038. */
  13039. renderingGroupId: number;
  13040. /**
  13041. * The layer mask we are rendering the particles through.
  13042. */
  13043. layerMask: number;
  13044. /**
  13045. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13046. */
  13047. updateSpeed: number;
  13048. /**
  13049. * The amount of time the particle system is running (depends of the overall update speed).
  13050. */
  13051. targetStopDuration: number;
  13052. /**
  13053. * The texture used to render each particle. (this can be a spritesheet)
  13054. */
  13055. particleTexture: Nullable<Texture>;
  13056. /**
  13057. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13058. */
  13059. blendMode: number;
  13060. /**
  13061. * Minimum life time of emitting particles.
  13062. */
  13063. minLifeTime: number;
  13064. /**
  13065. * Maximum life time of emitting particles.
  13066. */
  13067. maxLifeTime: number;
  13068. /**
  13069. * Minimum Size of emitting particles.
  13070. */
  13071. minSize: number;
  13072. /**
  13073. * Maximum Size of emitting particles.
  13074. */
  13075. maxSize: number;
  13076. /**
  13077. * Minimum scale of emitting particles on X axis.
  13078. */
  13079. minScaleX: number;
  13080. /**
  13081. * Maximum scale of emitting particles on X axis.
  13082. */
  13083. maxScaleX: number;
  13084. /**
  13085. * Minimum scale of emitting particles on Y axis.
  13086. */
  13087. minScaleY: number;
  13088. /**
  13089. * Maximum scale of emitting particles on Y axis.
  13090. */
  13091. maxScaleY: number;
  13092. /**
  13093. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13094. */
  13095. color1: Color4;
  13096. /**
  13097. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13098. */
  13099. color2: Color4;
  13100. /**
  13101. * Color the particle will have at the end of its lifetime.
  13102. */
  13103. colorDead: Color4;
  13104. /**
  13105. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13106. */
  13107. emitRate: number;
  13108. /**
  13109. * You can use gravity if you want to give an orientation to your particles.
  13110. */
  13111. gravity: Vector3;
  13112. /**
  13113. * Minimum power of emitting particles.
  13114. */
  13115. minEmitPower: number;
  13116. /**
  13117. * Maximum power of emitting particles.
  13118. */
  13119. maxEmitPower: number;
  13120. /**
  13121. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13122. */
  13123. minAngularSpeed: number;
  13124. /**
  13125. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13126. */
  13127. maxAngularSpeed: number;
  13128. /**
  13129. * Gets or sets the minimal initial rotation in radians.
  13130. */
  13131. minInitialRotation: number;
  13132. /**
  13133. * Gets or sets the maximal initial rotation in radians.
  13134. */
  13135. maxInitialRotation: number;
  13136. /**
  13137. * The particle emitter type defines the emitter used by the particle system.
  13138. * It can be for example box, sphere, or cone...
  13139. */
  13140. particleEmitterType: Nullable<IParticleEmitterType>;
  13141. /**
  13142. * Defines the delay in milliseconds before starting the system (0 by default)
  13143. */
  13144. startDelay: number;
  13145. /**
  13146. * 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
  13147. */
  13148. preWarmCycles: number;
  13149. /**
  13150. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13151. */
  13152. preWarmStepOffset: number;
  13153. /**
  13154. * 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)
  13155. */
  13156. spriteCellChangeSpeed: number;
  13157. /**
  13158. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13159. */
  13160. startSpriteCellID: number;
  13161. /**
  13162. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13163. */
  13164. endSpriteCellID: number;
  13165. /**
  13166. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13167. */
  13168. spriteCellWidth: number;
  13169. /**
  13170. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13171. */
  13172. spriteCellHeight: number;
  13173. /**
  13174. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13175. */
  13176. spriteRandomStartCell: boolean;
  13177. /**
  13178. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13179. */
  13180. isAnimationSheetEnabled: boolean;
  13181. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13182. translationPivot: Vector2;
  13183. /**
  13184. * Gets or sets a texture used to add random noise to particle positions
  13185. */
  13186. noiseTexture: Nullable<BaseTexture>;
  13187. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13188. noiseStrength: Vector3;
  13189. /**
  13190. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13191. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13192. */
  13193. billboardMode: number;
  13194. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13195. limitVelocityDamping: number;
  13196. /**
  13197. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13198. */
  13199. beginAnimationOnStart: boolean;
  13200. /**
  13201. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13202. */
  13203. beginAnimationFrom: number;
  13204. /**
  13205. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13206. */
  13207. beginAnimationTo: number;
  13208. /**
  13209. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13210. */
  13211. beginAnimationLoop: boolean;
  13212. /**
  13213. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13214. */
  13215. disposeOnStop: boolean;
  13216. /**
  13217. * Specifies if the particles are updated in emitter local space or world space
  13218. */
  13219. isLocal: boolean;
  13220. /** Snippet ID if the particle system was created from the snippet server */
  13221. snippetId: string;
  13222. /**
  13223. * Gets the maximum number of particles active at the same time.
  13224. * @returns The max number of active particles.
  13225. */
  13226. getCapacity(): number;
  13227. /**
  13228. * Gets the number of particles active at the same time.
  13229. * @returns The number of active particles.
  13230. */
  13231. getActiveCount(): number;
  13232. /**
  13233. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13234. * @returns True if it has been started, otherwise false.
  13235. */
  13236. isStarted(): boolean;
  13237. /**
  13238. * Animates the particle system for this frame.
  13239. */
  13240. animate(): void;
  13241. /**
  13242. * Renders the particle system in its current state.
  13243. * @returns the current number of particles
  13244. */
  13245. render(): number;
  13246. /**
  13247. * Dispose the particle system and frees its associated resources.
  13248. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13249. */
  13250. dispose(disposeTexture?: boolean): void;
  13251. /**
  13252. * Clones the particle system.
  13253. * @param name The name of the cloned object
  13254. * @param newEmitter The new emitter to use
  13255. * @returns the cloned particle system
  13256. */
  13257. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13258. /**
  13259. * Serializes the particle system to a JSON object
  13260. * @param serializeTexture defines if the texture must be serialized as well
  13261. * @returns the JSON object
  13262. */
  13263. serialize(serializeTexture: boolean): any;
  13264. /**
  13265. * Rebuild the particle system
  13266. */
  13267. rebuild(): void;
  13268. /** Force the system to rebuild all gradients that need to be resync */
  13269. forceRefreshGradients(): void;
  13270. /**
  13271. * Starts the particle system and begins to emit
  13272. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13273. */
  13274. start(delay?: number): void;
  13275. /**
  13276. * Stops the particle system.
  13277. */
  13278. stop(): void;
  13279. /**
  13280. * Remove all active particles
  13281. */
  13282. reset(): void;
  13283. /**
  13284. * Gets a boolean indicating that the system is stopping
  13285. * @returns true if the system is currently stopping
  13286. */
  13287. isStopping(): boolean;
  13288. /**
  13289. * Is this system ready to be used/rendered
  13290. * @return true if the system is ready
  13291. */
  13292. isReady(): boolean;
  13293. /**
  13294. * Returns the string "ParticleSystem"
  13295. * @returns a string containing the class name
  13296. */
  13297. getClassName(): string;
  13298. /**
  13299. * Adds a new color gradient
  13300. * @param gradient defines the gradient to use (between 0 and 1)
  13301. * @param color1 defines the color to affect to the specified gradient
  13302. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13303. * @returns the current particle system
  13304. */
  13305. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13306. /**
  13307. * Remove a specific color gradient
  13308. * @param gradient defines the gradient to remove
  13309. * @returns the current particle system
  13310. */
  13311. removeColorGradient(gradient: number): IParticleSystem;
  13312. /**
  13313. * Adds a new size gradient
  13314. * @param gradient defines the gradient to use (between 0 and 1)
  13315. * @param factor defines the size factor to affect to the specified gradient
  13316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13317. * @returns the current particle system
  13318. */
  13319. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13320. /**
  13321. * Remove a specific size gradient
  13322. * @param gradient defines the gradient to remove
  13323. * @returns the current particle system
  13324. */
  13325. removeSizeGradient(gradient: number): IParticleSystem;
  13326. /**
  13327. * Gets the current list of color gradients.
  13328. * You must use addColorGradient and removeColorGradient to udpate this list
  13329. * @returns the list of color gradients
  13330. */
  13331. getColorGradients(): Nullable<Array<ColorGradient>>;
  13332. /**
  13333. * Gets the current list of size gradients.
  13334. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13335. * @returns the list of size gradients
  13336. */
  13337. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13338. /**
  13339. * Gets the current list of angular speed gradients.
  13340. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13341. * @returns the list of angular speed gradients
  13342. */
  13343. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13344. /**
  13345. * Adds a new angular speed gradient
  13346. * @param gradient defines the gradient to use (between 0 and 1)
  13347. * @param factor defines the angular speed to affect to the specified gradient
  13348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13349. * @returns the current particle system
  13350. */
  13351. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13352. /**
  13353. * Remove a specific angular speed gradient
  13354. * @param gradient defines the gradient to remove
  13355. * @returns the current particle system
  13356. */
  13357. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13358. /**
  13359. * Gets the current list of velocity gradients.
  13360. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13361. * @returns the list of velocity gradients
  13362. */
  13363. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13364. /**
  13365. * Adds a new velocity gradient
  13366. * @param gradient defines the gradient to use (between 0 and 1)
  13367. * @param factor defines the velocity to affect to the specified gradient
  13368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13369. * @returns the current particle system
  13370. */
  13371. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13372. /**
  13373. * Remove a specific velocity gradient
  13374. * @param gradient defines the gradient to remove
  13375. * @returns the current particle system
  13376. */
  13377. removeVelocityGradient(gradient: number): IParticleSystem;
  13378. /**
  13379. * Gets the current list of limit velocity gradients.
  13380. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13381. * @returns the list of limit velocity gradients
  13382. */
  13383. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13384. /**
  13385. * Adds a new limit velocity gradient
  13386. * @param gradient defines the gradient to use (between 0 and 1)
  13387. * @param factor defines the limit velocity to affect to the specified gradient
  13388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13389. * @returns the current particle system
  13390. */
  13391. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13392. /**
  13393. * Remove a specific limit velocity gradient
  13394. * @param gradient defines the gradient to remove
  13395. * @returns the current particle system
  13396. */
  13397. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13398. /**
  13399. * Adds a new drag gradient
  13400. * @param gradient defines the gradient to use (between 0 and 1)
  13401. * @param factor defines the drag to affect to the specified gradient
  13402. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13403. * @returns the current particle system
  13404. */
  13405. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13406. /**
  13407. * Remove a specific drag gradient
  13408. * @param gradient defines the gradient to remove
  13409. * @returns the current particle system
  13410. */
  13411. removeDragGradient(gradient: number): IParticleSystem;
  13412. /**
  13413. * Gets the current list of drag gradients.
  13414. * You must use addDragGradient and removeDragGradient to udpate this list
  13415. * @returns the list of drag gradients
  13416. */
  13417. getDragGradients(): Nullable<Array<FactorGradient>>;
  13418. /**
  13419. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13420. * @param gradient defines the gradient to use (between 0 and 1)
  13421. * @param factor defines the emit rate 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. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13426. /**
  13427. * Remove a specific emit rate gradient
  13428. * @param gradient defines the gradient to remove
  13429. * @returns the current particle system
  13430. */
  13431. removeEmitRateGradient(gradient: number): IParticleSystem;
  13432. /**
  13433. * Gets the current list of emit rate gradients.
  13434. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13435. * @returns the list of emit rate gradients
  13436. */
  13437. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13438. /**
  13439. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13440. * @param gradient defines the gradient to use (between 0 and 1)
  13441. * @param factor defines the start size to affect to the specified gradient
  13442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13443. * @returns the current particle system
  13444. */
  13445. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13446. /**
  13447. * Remove a specific start size gradient
  13448. * @param gradient defines the gradient to remove
  13449. * @returns the current particle system
  13450. */
  13451. removeStartSizeGradient(gradient: number): IParticleSystem;
  13452. /**
  13453. * Gets the current list of start size gradients.
  13454. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13455. * @returns the list of start size gradients
  13456. */
  13457. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13458. /**
  13459. * Adds a new life time gradient
  13460. * @param gradient defines the gradient to use (between 0 and 1)
  13461. * @param factor defines the life time factor to affect to the specified gradient
  13462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13463. * @returns the current particle system
  13464. */
  13465. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13466. /**
  13467. * Remove a specific life time gradient
  13468. * @param gradient defines the gradient to remove
  13469. * @returns the current particle system
  13470. */
  13471. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13472. /**
  13473. * Gets the current list of life time gradients.
  13474. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13475. * @returns the list of life time gradients
  13476. */
  13477. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13478. /**
  13479. * Gets the current list of color gradients.
  13480. * You must use addColorGradient and removeColorGradient to udpate this list
  13481. * @returns the list of color gradients
  13482. */
  13483. getColorGradients(): Nullable<Array<ColorGradient>>;
  13484. /**
  13485. * Adds a new ramp gradient used to remap particle colors
  13486. * @param gradient defines the gradient to use (between 0 and 1)
  13487. * @param color defines the color to affect to the specified gradient
  13488. * @returns the current particle system
  13489. */
  13490. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13491. /**
  13492. * Gets the current list of ramp gradients.
  13493. * You must use addRampGradient and removeRampGradient to udpate this list
  13494. * @returns the list of ramp gradients
  13495. */
  13496. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13497. /** Gets or sets a boolean indicating that ramp gradients must be used
  13498. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13499. */
  13500. useRampGradients: boolean;
  13501. /**
  13502. * Adds a new color remap gradient
  13503. * @param gradient defines the gradient to use (between 0 and 1)
  13504. * @param min defines the color remap minimal range
  13505. * @param max defines the color remap maximal range
  13506. * @returns the current particle system
  13507. */
  13508. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13509. /**
  13510. * Gets the current list of color remap gradients.
  13511. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13512. * @returns the list of color remap gradients
  13513. */
  13514. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13515. /**
  13516. * Adds a new alpha remap gradient
  13517. * @param gradient defines the gradient to use (between 0 and 1)
  13518. * @param min defines the alpha remap minimal range
  13519. * @param max defines the alpha remap maximal range
  13520. * @returns the current particle system
  13521. */
  13522. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13523. /**
  13524. * Gets the current list of alpha remap gradients.
  13525. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13526. * @returns the list of alpha remap gradients
  13527. */
  13528. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13529. /**
  13530. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13533. * @returns the emitter
  13534. */
  13535. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13536. /**
  13537. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13538. * @param radius The radius of the hemisphere to emit from
  13539. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13540. * @returns the emitter
  13541. */
  13542. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13543. /**
  13544. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13545. * @param radius The radius of the sphere to emit from
  13546. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13547. * @returns the emitter
  13548. */
  13549. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13550. /**
  13551. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13552. * @param radius The radius of the sphere to emit from
  13553. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13554. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13555. * @returns the emitter
  13556. */
  13557. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13558. /**
  13559. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13560. * @param radius The radius of the emission cylinder
  13561. * @param height The height of the emission cylinder
  13562. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13563. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13564. * @returns the emitter
  13565. */
  13566. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13567. /**
  13568. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13569. * @param radius The radius of the cylinder to emit from
  13570. * @param height The height of the emission cylinder
  13571. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13572. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13573. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13574. * @returns the emitter
  13575. */
  13576. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13577. /**
  13578. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13579. * @param radius The radius of the cone to emit from
  13580. * @param angle The base angle of the cone
  13581. * @returns the emitter
  13582. */
  13583. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13584. /**
  13585. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13588. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13589. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13590. * @returns the emitter
  13591. */
  13592. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13593. /**
  13594. * Get hosting scene
  13595. * @returns the scene
  13596. */
  13597. getScene(): Scene;
  13598. }
  13599. }
  13600. declare module BABYLON {
  13601. /**
  13602. * 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.
  13603. * @see https://doc.babylonjs.com/how_to/transformnode
  13604. */
  13605. export class TransformNode extends Node {
  13606. /**
  13607. * Object will not rotate to face the camera
  13608. */
  13609. static BILLBOARDMODE_NONE: number;
  13610. /**
  13611. * Object will rotate to face the camera but only on the x axis
  13612. */
  13613. static BILLBOARDMODE_X: number;
  13614. /**
  13615. * Object will rotate to face the camera but only on the y axis
  13616. */
  13617. static BILLBOARDMODE_Y: number;
  13618. /**
  13619. * Object will rotate to face the camera but only on the z axis
  13620. */
  13621. static BILLBOARDMODE_Z: number;
  13622. /**
  13623. * Object will rotate to face the camera
  13624. */
  13625. static BILLBOARDMODE_ALL: number;
  13626. /**
  13627. * Object will rotate to face the camera's position instead of orientation
  13628. */
  13629. static BILLBOARDMODE_USE_POSITION: number;
  13630. private _forward;
  13631. private _forwardInverted;
  13632. private _up;
  13633. private _right;
  13634. private _rightInverted;
  13635. private _position;
  13636. private _rotation;
  13637. private _rotationQuaternion;
  13638. protected _scaling: Vector3;
  13639. protected _isDirty: boolean;
  13640. private _transformToBoneReferal;
  13641. private _isAbsoluteSynced;
  13642. private _billboardMode;
  13643. /**
  13644. * Gets or sets the billboard mode. Default is 0.
  13645. *
  13646. * | Value | Type | Description |
  13647. * | --- | --- | --- |
  13648. * | 0 | BILLBOARDMODE_NONE | |
  13649. * | 1 | BILLBOARDMODE_X | |
  13650. * | 2 | BILLBOARDMODE_Y | |
  13651. * | 4 | BILLBOARDMODE_Z | |
  13652. * | 7 | BILLBOARDMODE_ALL | |
  13653. *
  13654. */
  13655. get billboardMode(): number;
  13656. set billboardMode(value: number);
  13657. private _preserveParentRotationForBillboard;
  13658. /**
  13659. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13660. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13661. */
  13662. get preserveParentRotationForBillboard(): boolean;
  13663. set preserveParentRotationForBillboard(value: boolean);
  13664. /**
  13665. * 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
  13666. */
  13667. scalingDeterminant: number;
  13668. private _infiniteDistance;
  13669. /**
  13670. * Gets or sets the distance of the object to max, often used by skybox
  13671. */
  13672. get infiniteDistance(): boolean;
  13673. set infiniteDistance(value: boolean);
  13674. /**
  13675. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13676. * By default the system will update normals to compensate
  13677. */
  13678. ignoreNonUniformScaling: boolean;
  13679. /**
  13680. * 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
  13681. */
  13682. reIntegrateRotationIntoRotationQuaternion: boolean;
  13683. /** @hidden */
  13684. _poseMatrix: Nullable<Matrix>;
  13685. /** @hidden */
  13686. _localMatrix: Matrix;
  13687. private _usePivotMatrix;
  13688. private _absolutePosition;
  13689. private _absoluteScaling;
  13690. private _absoluteRotationQuaternion;
  13691. private _pivotMatrix;
  13692. private _pivotMatrixInverse;
  13693. protected _postMultiplyPivotMatrix: boolean;
  13694. protected _isWorldMatrixFrozen: boolean;
  13695. /** @hidden */
  13696. _indexInSceneTransformNodesArray: number;
  13697. /**
  13698. * An event triggered after the world matrix is updated
  13699. */
  13700. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13701. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13702. /**
  13703. * Gets a string identifying the name of the class
  13704. * @returns "TransformNode" string
  13705. */
  13706. getClassName(): string;
  13707. /**
  13708. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13709. */
  13710. get position(): Vector3;
  13711. set position(newPosition: Vector3);
  13712. /**
  13713. * 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)).
  13714. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13715. */
  13716. get rotation(): Vector3;
  13717. set rotation(newRotation: Vector3);
  13718. /**
  13719. * 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)).
  13720. */
  13721. get scaling(): Vector3;
  13722. set scaling(newScaling: Vector3);
  13723. /**
  13724. * 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).
  13725. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13726. */
  13727. get rotationQuaternion(): Nullable<Quaternion>;
  13728. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13729. /**
  13730. * The forward direction of that transform in world space.
  13731. */
  13732. get forward(): Vector3;
  13733. /**
  13734. * The up direction of that transform in world space.
  13735. */
  13736. get up(): Vector3;
  13737. /**
  13738. * The right direction of that transform in world space.
  13739. */
  13740. get right(): Vector3;
  13741. /**
  13742. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13743. * @param matrix the matrix to copy the pose from
  13744. * @returns this TransformNode.
  13745. */
  13746. updatePoseMatrix(matrix: Matrix): TransformNode;
  13747. /**
  13748. * Returns the mesh Pose matrix.
  13749. * @returns the pose matrix
  13750. */
  13751. getPoseMatrix(): Matrix;
  13752. /** @hidden */
  13753. _isSynchronized(): boolean;
  13754. /** @hidden */
  13755. _initCache(): void;
  13756. /**
  13757. * Flag the transform node as dirty (Forcing it to update everything)
  13758. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13759. * @returns this transform node
  13760. */
  13761. markAsDirty(property: string): TransformNode;
  13762. /**
  13763. * Returns the current mesh absolute position.
  13764. * Returns a Vector3.
  13765. */
  13766. get absolutePosition(): Vector3;
  13767. /**
  13768. * Returns the current mesh absolute scaling.
  13769. * Returns a Vector3.
  13770. */
  13771. get absoluteScaling(): Vector3;
  13772. /**
  13773. * Returns the current mesh absolute rotation.
  13774. * Returns a Quaternion.
  13775. */
  13776. get absoluteRotationQuaternion(): Quaternion;
  13777. /**
  13778. * Sets a new matrix to apply before all other transformation
  13779. * @param matrix defines the transform matrix
  13780. * @returns the current TransformNode
  13781. */
  13782. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13783. /**
  13784. * Sets a new pivot matrix to the current node
  13785. * @param matrix defines the new pivot matrix to use
  13786. * @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
  13787. * @returns the current TransformNode
  13788. */
  13789. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13790. /**
  13791. * Returns the mesh pivot matrix.
  13792. * Default : Identity.
  13793. * @returns the matrix
  13794. */
  13795. getPivotMatrix(): Matrix;
  13796. /**
  13797. * Instantiate (when possible) or clone that node with its hierarchy
  13798. * @param newParent defines the new parent to use for the instance (or clone)
  13799. * @param options defines options to configure how copy is done
  13800. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13801. * @returns an instance (or a clone) of the current node with its hiearchy
  13802. */
  13803. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13804. doNotInstantiate: boolean;
  13805. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13806. /**
  13807. * Prevents the World matrix to be computed any longer
  13808. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13809. * @returns the TransformNode.
  13810. */
  13811. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13812. /**
  13813. * Allows back the World matrix computation.
  13814. * @returns the TransformNode.
  13815. */
  13816. unfreezeWorldMatrix(): this;
  13817. /**
  13818. * True if the World matrix has been frozen.
  13819. */
  13820. get isWorldMatrixFrozen(): boolean;
  13821. /**
  13822. * Retuns the mesh absolute position in the World.
  13823. * @returns a Vector3.
  13824. */
  13825. getAbsolutePosition(): Vector3;
  13826. /**
  13827. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13828. * @param absolutePosition the absolute position to set
  13829. * @returns the TransformNode.
  13830. */
  13831. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13832. /**
  13833. * Sets the mesh position in its local space.
  13834. * @param vector3 the position to set in localspace
  13835. * @returns the TransformNode.
  13836. */
  13837. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13838. /**
  13839. * Returns the mesh position in the local space from the current World matrix values.
  13840. * @returns a new Vector3.
  13841. */
  13842. getPositionExpressedInLocalSpace(): Vector3;
  13843. /**
  13844. * Translates the mesh along the passed Vector3 in its local space.
  13845. * @param vector3 the distance to translate in localspace
  13846. * @returns the TransformNode.
  13847. */
  13848. locallyTranslate(vector3: Vector3): TransformNode;
  13849. private static _lookAtVectorCache;
  13850. /**
  13851. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13852. * @param targetPoint the position (must be in same space as current mesh) to look at
  13853. * @param yawCor optional yaw (y-axis) correction in radians
  13854. * @param pitchCor optional pitch (x-axis) correction in radians
  13855. * @param rollCor optional roll (z-axis) correction in radians
  13856. * @param space the choosen space of the target
  13857. * @returns the TransformNode.
  13858. */
  13859. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13860. /**
  13861. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13862. * This Vector3 is expressed in the World space.
  13863. * @param localAxis axis to rotate
  13864. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13865. */
  13866. getDirection(localAxis: Vector3): Vector3;
  13867. /**
  13868. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13869. * localAxis is expressed in the mesh local space.
  13870. * result is computed in the Wordl space from the mesh World matrix.
  13871. * @param localAxis axis to rotate
  13872. * @param result the resulting transformnode
  13873. * @returns this TransformNode.
  13874. */
  13875. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13876. /**
  13877. * Sets this transform node rotation to the given local axis.
  13878. * @param localAxis the axis in local space
  13879. * @param yawCor optional yaw (y-axis) correction in radians
  13880. * @param pitchCor optional pitch (x-axis) correction in radians
  13881. * @param rollCor optional roll (z-axis) correction in radians
  13882. * @returns this TransformNode
  13883. */
  13884. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13885. /**
  13886. * Sets a new pivot point to the current node
  13887. * @param point defines the new pivot point to use
  13888. * @param space defines if the point is in world or local space (local by default)
  13889. * @returns the current TransformNode
  13890. */
  13891. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13892. /**
  13893. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13894. * @returns the pivot point
  13895. */
  13896. getPivotPoint(): Vector3;
  13897. /**
  13898. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13899. * @param result the vector3 to store the result
  13900. * @returns this TransformNode.
  13901. */
  13902. getPivotPointToRef(result: Vector3): TransformNode;
  13903. /**
  13904. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13905. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13906. */
  13907. getAbsolutePivotPoint(): Vector3;
  13908. /**
  13909. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13910. * @param result vector3 to store the result
  13911. * @returns this TransformNode.
  13912. */
  13913. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13914. /**
  13915. * Defines the passed node as the parent of the current node.
  13916. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13917. * @see https://doc.babylonjs.com/how_to/parenting
  13918. * @param node the node ot set as the parent
  13919. * @returns this TransformNode.
  13920. */
  13921. setParent(node: Nullable<Node>): TransformNode;
  13922. private _nonUniformScaling;
  13923. /**
  13924. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13925. */
  13926. get nonUniformScaling(): boolean;
  13927. /** @hidden */
  13928. _updateNonUniformScalingState(value: boolean): boolean;
  13929. /**
  13930. * Attach the current TransformNode to another TransformNode associated with a bone
  13931. * @param bone Bone affecting the TransformNode
  13932. * @param affectedTransformNode TransformNode associated with the bone
  13933. * @returns this object
  13934. */
  13935. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13936. /**
  13937. * Detach the transform node if its associated with a bone
  13938. * @returns this object
  13939. */
  13940. detachFromBone(): TransformNode;
  13941. private static _rotationAxisCache;
  13942. /**
  13943. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13944. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13945. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13946. * The passed axis is also normalized.
  13947. * @param axis the axis to rotate around
  13948. * @param amount the amount to rotate in radians
  13949. * @param space Space to rotate in (Default: local)
  13950. * @returns the TransformNode.
  13951. */
  13952. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13953. /**
  13954. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13955. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13956. * The passed axis is also normalized. .
  13957. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13958. * @param point the point to rotate around
  13959. * @param axis the axis to rotate around
  13960. * @param amount the amount to rotate in radians
  13961. * @returns the TransformNode
  13962. */
  13963. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13964. /**
  13965. * Translates the mesh along the axis vector for the passed distance in the given space.
  13966. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13967. * @param axis the axis to translate in
  13968. * @param distance the distance to translate
  13969. * @param space Space to rotate in (Default: local)
  13970. * @returns the TransformNode.
  13971. */
  13972. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13973. /**
  13974. * Adds a rotation step to the mesh current rotation.
  13975. * x, y, z are Euler angles expressed in radians.
  13976. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13977. * This means this rotation is made in the mesh local space only.
  13978. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13979. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13980. * ```javascript
  13981. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13982. * ```
  13983. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13984. * 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.
  13985. * @param x Rotation to add
  13986. * @param y Rotation to add
  13987. * @param z Rotation to add
  13988. * @returns the TransformNode.
  13989. */
  13990. addRotation(x: number, y: number, z: number): TransformNode;
  13991. /**
  13992. * @hidden
  13993. */
  13994. protected _getEffectiveParent(): Nullable<Node>;
  13995. /**
  13996. * Computes the world matrix of the node
  13997. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13998. * @returns the world matrix
  13999. */
  14000. computeWorldMatrix(force?: boolean): Matrix;
  14001. /**
  14002. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14003. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14004. */
  14005. resetLocalMatrix(independentOfChildren?: boolean): void;
  14006. protected _afterComputeWorldMatrix(): void;
  14007. /**
  14008. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14009. * @param func callback function to add
  14010. *
  14011. * @returns the TransformNode.
  14012. */
  14013. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14014. /**
  14015. * Removes a registered callback function.
  14016. * @param func callback function to remove
  14017. * @returns the TransformNode.
  14018. */
  14019. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14020. /**
  14021. * Gets the position of the current mesh in camera space
  14022. * @param camera defines the camera to use
  14023. * @returns a position
  14024. */
  14025. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14026. /**
  14027. * Returns the distance from the mesh to the active camera
  14028. * @param camera defines the camera to use
  14029. * @returns the distance
  14030. */
  14031. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14032. /**
  14033. * Clone the current transform node
  14034. * @param name Name of the new clone
  14035. * @param newParent New parent for the clone
  14036. * @param doNotCloneChildren Do not clone children hierarchy
  14037. * @returns the new transform node
  14038. */
  14039. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14040. /**
  14041. * Serializes the objects information.
  14042. * @param currentSerializationObject defines the object to serialize in
  14043. * @returns the serialized object
  14044. */
  14045. serialize(currentSerializationObject?: any): any;
  14046. /**
  14047. * Returns a new TransformNode object parsed from the source provided.
  14048. * @param parsedTransformNode is the source.
  14049. * @param scene the scne the object belongs to
  14050. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14051. * @returns a new TransformNode object parsed from the source provided.
  14052. */
  14053. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14054. /**
  14055. * Get all child-transformNodes of this node
  14056. * @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
  14057. * @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
  14058. * @returns an array of TransformNode
  14059. */
  14060. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14061. /**
  14062. * Releases resources associated with this transform node.
  14063. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14064. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14065. */
  14066. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14067. /**
  14068. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14069. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14070. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14071. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14072. * @returns the current mesh
  14073. */
  14074. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14075. private _syncAbsoluteScalingAndRotation;
  14076. }
  14077. }
  14078. declare module BABYLON {
  14079. /**
  14080. * Class used to override all child animations of a given target
  14081. */
  14082. export class AnimationPropertiesOverride {
  14083. /**
  14084. * Gets or sets a value indicating if animation blending must be used
  14085. */
  14086. enableBlending: boolean;
  14087. /**
  14088. * Gets or sets the blending speed to use when enableBlending is true
  14089. */
  14090. blendingSpeed: number;
  14091. /**
  14092. * Gets or sets the default loop mode to use
  14093. */
  14094. loopMode: number;
  14095. }
  14096. }
  14097. declare module BABYLON {
  14098. /**
  14099. * Class used to store bone information
  14100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14101. */
  14102. export class Bone extends Node {
  14103. /**
  14104. * defines the bone name
  14105. */
  14106. name: string;
  14107. private static _tmpVecs;
  14108. private static _tmpQuat;
  14109. private static _tmpMats;
  14110. /**
  14111. * Gets the list of child bones
  14112. */
  14113. children: Bone[];
  14114. /** Gets the animations associated with this bone */
  14115. animations: Animation[];
  14116. /**
  14117. * Gets or sets bone length
  14118. */
  14119. length: number;
  14120. /**
  14121. * @hidden Internal only
  14122. * Set this value to map this bone to a different index in the transform matrices
  14123. * Set this value to -1 to exclude the bone from the transform matrices
  14124. */
  14125. _index: Nullable<number>;
  14126. private _skeleton;
  14127. private _localMatrix;
  14128. private _restPose;
  14129. private _baseMatrix;
  14130. private _absoluteTransform;
  14131. private _invertedAbsoluteTransform;
  14132. private _parent;
  14133. private _scalingDeterminant;
  14134. private _worldTransform;
  14135. private _localScaling;
  14136. private _localRotation;
  14137. private _localPosition;
  14138. private _needToDecompose;
  14139. private _needToCompose;
  14140. /** @hidden */
  14141. _linkedTransformNode: Nullable<TransformNode>;
  14142. /** @hidden */
  14143. _waitingTransformNodeId: Nullable<string>;
  14144. /** @hidden */
  14145. get _matrix(): Matrix;
  14146. /** @hidden */
  14147. set _matrix(value: Matrix);
  14148. /**
  14149. * Create a new bone
  14150. * @param name defines the bone name
  14151. * @param skeleton defines the parent skeleton
  14152. * @param parentBone defines the parent (can be null if the bone is the root)
  14153. * @param localMatrix defines the local matrix
  14154. * @param restPose defines the rest pose matrix
  14155. * @param baseMatrix defines the base matrix
  14156. * @param index defines index of the bone in the hiearchy
  14157. */
  14158. constructor(
  14159. /**
  14160. * defines the bone name
  14161. */
  14162. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14163. /**
  14164. * Gets the current object class name.
  14165. * @return the class name
  14166. */
  14167. getClassName(): string;
  14168. /**
  14169. * Gets the parent skeleton
  14170. * @returns a skeleton
  14171. */
  14172. getSkeleton(): Skeleton;
  14173. /**
  14174. * Gets parent bone
  14175. * @returns a bone or null if the bone is the root of the bone hierarchy
  14176. */
  14177. getParent(): Nullable<Bone>;
  14178. /**
  14179. * Returns an array containing the root bones
  14180. * @returns an array containing the root bones
  14181. */
  14182. getChildren(): Array<Bone>;
  14183. /**
  14184. * Gets the node index in matrix array generated for rendering
  14185. * @returns the node index
  14186. */
  14187. getIndex(): number;
  14188. /**
  14189. * Sets the parent bone
  14190. * @param parent defines the parent (can be null if the bone is the root)
  14191. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14192. */
  14193. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14194. /**
  14195. * Gets the local matrix
  14196. * @returns a matrix
  14197. */
  14198. getLocalMatrix(): Matrix;
  14199. /**
  14200. * Gets the base matrix (initial matrix which remains unchanged)
  14201. * @returns a matrix
  14202. */
  14203. getBaseMatrix(): Matrix;
  14204. /**
  14205. * Gets the rest pose matrix
  14206. * @returns a matrix
  14207. */
  14208. getRestPose(): Matrix;
  14209. /**
  14210. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14211. */
  14212. getWorldMatrix(): Matrix;
  14213. /**
  14214. * Sets the local matrix to rest pose matrix
  14215. */
  14216. returnToRest(): void;
  14217. /**
  14218. * Gets the inverse of the absolute transform matrix.
  14219. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14220. * @returns a matrix
  14221. */
  14222. getInvertedAbsoluteTransform(): Matrix;
  14223. /**
  14224. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14225. * @returns a matrix
  14226. */
  14227. getAbsoluteTransform(): Matrix;
  14228. /**
  14229. * Links with the given transform node.
  14230. * The local matrix of this bone is copied from the transform node every frame.
  14231. * @param transformNode defines the transform node to link to
  14232. */
  14233. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14234. /**
  14235. * Gets the node used to drive the bone's transformation
  14236. * @returns a transform node or null
  14237. */
  14238. getTransformNode(): Nullable<TransformNode>;
  14239. /** Gets or sets current position (in local space) */
  14240. get position(): Vector3;
  14241. set position(newPosition: Vector3);
  14242. /** Gets or sets current rotation (in local space) */
  14243. get rotation(): Vector3;
  14244. set rotation(newRotation: Vector3);
  14245. /** Gets or sets current rotation quaternion (in local space) */
  14246. get rotationQuaternion(): Quaternion;
  14247. set rotationQuaternion(newRotation: Quaternion);
  14248. /** Gets or sets current scaling (in local space) */
  14249. get scaling(): Vector3;
  14250. set scaling(newScaling: Vector3);
  14251. /**
  14252. * Gets the animation properties override
  14253. */
  14254. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14255. private _decompose;
  14256. private _compose;
  14257. /**
  14258. * Update the base and local matrices
  14259. * @param matrix defines the new base or local matrix
  14260. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14261. * @param updateLocalMatrix defines if the local matrix should be updated
  14262. */
  14263. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14264. /** @hidden */
  14265. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14266. /**
  14267. * Flag the bone as dirty (Forcing it to update everything)
  14268. */
  14269. markAsDirty(): void;
  14270. /** @hidden */
  14271. _markAsDirtyAndCompose(): void;
  14272. private _markAsDirtyAndDecompose;
  14273. /**
  14274. * Translate the bone in local or world space
  14275. * @param vec The amount to translate the bone
  14276. * @param space The space that the translation is in
  14277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14278. */
  14279. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14280. /**
  14281. * Set the postion of the bone in local or world space
  14282. * @param position The position to set the bone
  14283. * @param space The space that the position is in
  14284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14285. */
  14286. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14287. /**
  14288. * Set the absolute position of the bone (world space)
  14289. * @param position The position to set the bone
  14290. * @param mesh The mesh that this bone is attached to
  14291. */
  14292. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14293. /**
  14294. * Scale the bone on the x, y and z axes (in local space)
  14295. * @param x The amount to scale the bone on the x axis
  14296. * @param y The amount to scale the bone on the y axis
  14297. * @param z The amount to scale the bone on the z axis
  14298. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14299. */
  14300. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14301. /**
  14302. * Set the bone scaling in local space
  14303. * @param scale defines the scaling vector
  14304. */
  14305. setScale(scale: Vector3): void;
  14306. /**
  14307. * Gets the current scaling in local space
  14308. * @returns the current scaling vector
  14309. */
  14310. getScale(): Vector3;
  14311. /**
  14312. * Gets the current scaling in local space and stores it in a target vector
  14313. * @param result defines the target vector
  14314. */
  14315. getScaleToRef(result: Vector3): void;
  14316. /**
  14317. * Set the yaw, pitch, and roll of the bone in local or world space
  14318. * @param yaw The rotation of the bone on the y axis
  14319. * @param pitch The rotation of the bone on the x axis
  14320. * @param roll The rotation of the bone on the z axis
  14321. * @param space The space that the axes of rotation are in
  14322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14323. */
  14324. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14325. /**
  14326. * Add a rotation to the bone on an axis in local or world space
  14327. * @param axis The axis to rotate the bone on
  14328. * @param amount The amount to rotate the bone
  14329. * @param space The space that the axis is in
  14330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14331. */
  14332. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14333. /**
  14334. * Set the rotation of the bone to a particular axis angle in local or world space
  14335. * @param axis The axis to rotate the bone on
  14336. * @param angle The angle that the bone should be rotated to
  14337. * @param space The space that the axis is in
  14338. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14339. */
  14340. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14341. /**
  14342. * Set the euler rotation of the bone in local of world space
  14343. * @param rotation The euler rotation that the bone should be set to
  14344. * @param space The space that the rotation is in
  14345. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14346. */
  14347. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14348. /**
  14349. * Set the quaternion rotation of the bone in local of world space
  14350. * @param quat The quaternion rotation that the bone should be set to
  14351. * @param space The space that the rotation is in
  14352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14353. */
  14354. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14355. /**
  14356. * Set the rotation matrix of the bone in local of world space
  14357. * @param rotMat The rotation matrix that the bone should be set to
  14358. * @param space The space that the rotation is in
  14359. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14360. */
  14361. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14362. private _rotateWithMatrix;
  14363. private _getNegativeRotationToRef;
  14364. /**
  14365. * Get the position of the bone in local or world space
  14366. * @param space The space that the returned position is in
  14367. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14368. * @returns The position of the bone
  14369. */
  14370. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14371. /**
  14372. * Copy the position of the bone to a vector3 in local or world space
  14373. * @param space The space that the returned position is in
  14374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14375. * @param result The vector3 to copy the position to
  14376. */
  14377. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14378. /**
  14379. * Get the absolute position of the bone (world space)
  14380. * @param mesh The mesh that this bone is attached to
  14381. * @returns The absolute position of the bone
  14382. */
  14383. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14384. /**
  14385. * Copy the absolute position of the bone (world space) to the result param
  14386. * @param mesh The mesh that this bone is attached to
  14387. * @param result The vector3 to copy the absolute position to
  14388. */
  14389. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14390. /**
  14391. * Compute the absolute transforms of this bone and its children
  14392. */
  14393. computeAbsoluteTransforms(): void;
  14394. /**
  14395. * Get the world direction from an axis that is in the local space of the bone
  14396. * @param localAxis The local direction that is used to compute the world direction
  14397. * @param mesh The mesh that this bone is attached to
  14398. * @returns The world direction
  14399. */
  14400. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14401. /**
  14402. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14403. * @param localAxis The local direction that is used to compute the world direction
  14404. * @param mesh The mesh that this bone is attached to
  14405. * @param result The vector3 that the world direction will be copied to
  14406. */
  14407. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14408. /**
  14409. * Get the euler rotation of the bone in local or world space
  14410. * @param space The space that the rotation should be in
  14411. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14412. * @returns The euler rotation
  14413. */
  14414. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14415. /**
  14416. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14417. * @param space The space that the rotation should be in
  14418. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14419. * @param result The vector3 that the rotation should be copied to
  14420. */
  14421. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14422. /**
  14423. * Get the quaternion rotation of the bone in either local or world space
  14424. * @param space The space that the rotation should be in
  14425. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14426. * @returns The quaternion rotation
  14427. */
  14428. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14429. /**
  14430. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14431. * @param space The space that the rotation should be in
  14432. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14433. * @param result The quaternion that the rotation should be copied to
  14434. */
  14435. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14436. /**
  14437. * Get the rotation matrix of the bone in local or world space
  14438. * @param space The space that the rotation should be in
  14439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14440. * @returns The rotation matrix
  14441. */
  14442. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14443. /**
  14444. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14445. * @param space The space that the rotation should be in
  14446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14447. * @param result The quaternion that the rotation should be copied to
  14448. */
  14449. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14450. /**
  14451. * Get the world position of a point that is in the local space of the bone
  14452. * @param position The local position
  14453. * @param mesh The mesh that this bone is attached to
  14454. * @returns The world position
  14455. */
  14456. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14457. /**
  14458. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14459. * @param position The local position
  14460. * @param mesh The mesh that this bone is attached to
  14461. * @param result The vector3 that the world position should be copied to
  14462. */
  14463. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14464. /**
  14465. * Get the local position of a point that is in world space
  14466. * @param position The world position
  14467. * @param mesh The mesh that this bone is attached to
  14468. * @returns The local position
  14469. */
  14470. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14471. /**
  14472. * Get the local position of a point that is in world space and copy it to the result param
  14473. * @param position The world position
  14474. * @param mesh The mesh that this bone is attached to
  14475. * @param result The vector3 that the local position should be copied to
  14476. */
  14477. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14478. }
  14479. }
  14480. declare module BABYLON {
  14481. /**
  14482. * Defines a runtime animation
  14483. */
  14484. export class RuntimeAnimation {
  14485. private _events;
  14486. /**
  14487. * The current frame of the runtime animation
  14488. */
  14489. private _currentFrame;
  14490. /**
  14491. * The animation used by the runtime animation
  14492. */
  14493. private _animation;
  14494. /**
  14495. * The target of the runtime animation
  14496. */
  14497. private _target;
  14498. /**
  14499. * The initiating animatable
  14500. */
  14501. private _host;
  14502. /**
  14503. * The original value of the runtime animation
  14504. */
  14505. private _originalValue;
  14506. /**
  14507. * The original blend value of the runtime animation
  14508. */
  14509. private _originalBlendValue;
  14510. /**
  14511. * The offsets cache of the runtime animation
  14512. */
  14513. private _offsetsCache;
  14514. /**
  14515. * The high limits cache of the runtime animation
  14516. */
  14517. private _highLimitsCache;
  14518. /**
  14519. * Specifies if the runtime animation has been stopped
  14520. */
  14521. private _stopped;
  14522. /**
  14523. * The blending factor of the runtime animation
  14524. */
  14525. private _blendingFactor;
  14526. /**
  14527. * The BabylonJS scene
  14528. */
  14529. private _scene;
  14530. /**
  14531. * The current value of the runtime animation
  14532. */
  14533. private _currentValue;
  14534. /** @hidden */
  14535. _animationState: _IAnimationState;
  14536. /**
  14537. * The active target of the runtime animation
  14538. */
  14539. private _activeTargets;
  14540. private _currentActiveTarget;
  14541. private _directTarget;
  14542. /**
  14543. * The target path of the runtime animation
  14544. */
  14545. private _targetPath;
  14546. /**
  14547. * The weight of the runtime animation
  14548. */
  14549. private _weight;
  14550. /**
  14551. * The ratio offset of the runtime animation
  14552. */
  14553. private _ratioOffset;
  14554. /**
  14555. * The previous delay of the runtime animation
  14556. */
  14557. private _previousDelay;
  14558. /**
  14559. * The previous ratio of the runtime animation
  14560. */
  14561. private _previousRatio;
  14562. private _enableBlending;
  14563. private _keys;
  14564. private _minFrame;
  14565. private _maxFrame;
  14566. private _minValue;
  14567. private _maxValue;
  14568. private _targetIsArray;
  14569. /**
  14570. * Gets the current frame of the runtime animation
  14571. */
  14572. get currentFrame(): number;
  14573. /**
  14574. * Gets the weight of the runtime animation
  14575. */
  14576. get weight(): number;
  14577. /**
  14578. * Gets the current value of the runtime animation
  14579. */
  14580. get currentValue(): any;
  14581. /**
  14582. * Gets the target path of the runtime animation
  14583. */
  14584. get targetPath(): string;
  14585. /**
  14586. * Gets the actual target of the runtime animation
  14587. */
  14588. get target(): any;
  14589. /**
  14590. * Gets the additive state of the runtime animation
  14591. */
  14592. get isAdditive(): boolean;
  14593. /** @hidden */
  14594. _onLoop: () => void;
  14595. /**
  14596. * Create a new RuntimeAnimation object
  14597. * @param target defines the target of the animation
  14598. * @param animation defines the source animation object
  14599. * @param scene defines the hosting scene
  14600. * @param host defines the initiating Animatable
  14601. */
  14602. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14603. private _preparePath;
  14604. /**
  14605. * Gets the animation from the runtime animation
  14606. */
  14607. get animation(): Animation;
  14608. /**
  14609. * Resets the runtime animation to the beginning
  14610. * @param restoreOriginal defines whether to restore the target property to the original value
  14611. */
  14612. reset(restoreOriginal?: boolean): void;
  14613. /**
  14614. * Specifies if the runtime animation is stopped
  14615. * @returns Boolean specifying if the runtime animation is stopped
  14616. */
  14617. isStopped(): boolean;
  14618. /**
  14619. * Disposes of the runtime animation
  14620. */
  14621. dispose(): void;
  14622. /**
  14623. * Apply the interpolated value to the target
  14624. * @param currentValue defines the value computed by the animation
  14625. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14626. */
  14627. setValue(currentValue: any, weight: number): void;
  14628. private _getOriginalValues;
  14629. private _setValue;
  14630. /**
  14631. * Gets the loop pmode of the runtime animation
  14632. * @returns Loop Mode
  14633. */
  14634. private _getCorrectLoopMode;
  14635. /**
  14636. * Move the current animation to a given frame
  14637. * @param frame defines the frame to move to
  14638. */
  14639. goToFrame(frame: number): void;
  14640. /**
  14641. * @hidden Internal use only
  14642. */
  14643. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14644. /**
  14645. * Execute the current animation
  14646. * @param delay defines the delay to add to the current frame
  14647. * @param from defines the lower bound of the animation range
  14648. * @param to defines the upper bound of the animation range
  14649. * @param loop defines if the current animation must loop
  14650. * @param speedRatio defines the current speed ratio
  14651. * @param weight defines the weight of the animation (default is -1 so no weight)
  14652. * @param onLoop optional callback called when animation loops
  14653. * @returns a boolean indicating if the animation is running
  14654. */
  14655. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14656. }
  14657. }
  14658. declare module BABYLON {
  14659. /**
  14660. * Class used to store an actual running animation
  14661. */
  14662. export class Animatable {
  14663. /** defines the target object */
  14664. target: any;
  14665. /** defines the starting frame number (default is 0) */
  14666. fromFrame: number;
  14667. /** defines the ending frame number (default is 100) */
  14668. toFrame: number;
  14669. /** defines if the animation must loop (default is false) */
  14670. loopAnimation: boolean;
  14671. /** defines a callback to call when animation ends if it is not looping */
  14672. onAnimationEnd?: (() => void) | null | undefined;
  14673. /** defines a callback to call when animation loops */
  14674. onAnimationLoop?: (() => void) | null | undefined;
  14675. /** defines whether the animation should be evaluated additively */
  14676. isAdditive: boolean;
  14677. private _localDelayOffset;
  14678. private _pausedDelay;
  14679. private _runtimeAnimations;
  14680. private _paused;
  14681. private _scene;
  14682. private _speedRatio;
  14683. private _weight;
  14684. private _syncRoot;
  14685. /**
  14686. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14687. * This will only apply for non looping animation (default is true)
  14688. */
  14689. disposeOnEnd: boolean;
  14690. /**
  14691. * Gets a boolean indicating if the animation has started
  14692. */
  14693. animationStarted: boolean;
  14694. /**
  14695. * Observer raised when the animation ends
  14696. */
  14697. onAnimationEndObservable: Observable<Animatable>;
  14698. /**
  14699. * Observer raised when the animation loops
  14700. */
  14701. onAnimationLoopObservable: Observable<Animatable>;
  14702. /**
  14703. * Gets the root Animatable used to synchronize and normalize animations
  14704. */
  14705. get syncRoot(): Nullable<Animatable>;
  14706. /**
  14707. * Gets the current frame of the first RuntimeAnimation
  14708. * Used to synchronize Animatables
  14709. */
  14710. get masterFrame(): number;
  14711. /**
  14712. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14713. */
  14714. get weight(): number;
  14715. set weight(value: number);
  14716. /**
  14717. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14718. */
  14719. get speedRatio(): number;
  14720. set speedRatio(value: number);
  14721. /**
  14722. * Creates a new Animatable
  14723. * @param scene defines the hosting scene
  14724. * @param target defines the target object
  14725. * @param fromFrame defines the starting frame number (default is 0)
  14726. * @param toFrame defines the ending frame number (default is 100)
  14727. * @param loopAnimation defines if the animation must loop (default is false)
  14728. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14729. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14730. * @param animations defines a group of animation to add to the new Animatable
  14731. * @param onAnimationLoop defines a callback to call when animation loops
  14732. * @param isAdditive defines whether the animation should be evaluated additively
  14733. */
  14734. constructor(scene: Scene,
  14735. /** defines the target object */
  14736. target: any,
  14737. /** defines the starting frame number (default is 0) */
  14738. fromFrame?: number,
  14739. /** defines the ending frame number (default is 100) */
  14740. toFrame?: number,
  14741. /** defines if the animation must loop (default is false) */
  14742. loopAnimation?: boolean, speedRatio?: number,
  14743. /** defines a callback to call when animation ends if it is not looping */
  14744. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14745. /** defines a callback to call when animation loops */
  14746. onAnimationLoop?: (() => void) | null | undefined,
  14747. /** defines whether the animation should be evaluated additively */
  14748. isAdditive?: boolean);
  14749. /**
  14750. * Synchronize and normalize current Animatable with a source Animatable
  14751. * This is useful when using animation weights and when animations are not of the same length
  14752. * @param root defines the root Animatable to synchronize with
  14753. * @returns the current Animatable
  14754. */
  14755. syncWith(root: Animatable): Animatable;
  14756. /**
  14757. * Gets the list of runtime animations
  14758. * @returns an array of RuntimeAnimation
  14759. */
  14760. getAnimations(): RuntimeAnimation[];
  14761. /**
  14762. * Adds more animations to the current animatable
  14763. * @param target defines the target of the animations
  14764. * @param animations defines the new animations to add
  14765. */
  14766. appendAnimations(target: any, animations: Animation[]): void;
  14767. /**
  14768. * Gets the source animation for a specific property
  14769. * @param property defines the propertyu to look for
  14770. * @returns null or the source animation for the given property
  14771. */
  14772. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14773. /**
  14774. * Gets the runtime animation for a specific property
  14775. * @param property defines the propertyu to look for
  14776. * @returns null or the runtime animation for the given property
  14777. */
  14778. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14779. /**
  14780. * Resets the animatable to its original state
  14781. */
  14782. reset(): void;
  14783. /**
  14784. * Allows the animatable to blend with current running animations
  14785. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14786. * @param blendingSpeed defines the blending speed to use
  14787. */
  14788. enableBlending(blendingSpeed: number): void;
  14789. /**
  14790. * Disable animation blending
  14791. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14792. */
  14793. disableBlending(): void;
  14794. /**
  14795. * Jump directly to a given frame
  14796. * @param frame defines the frame to jump to
  14797. */
  14798. goToFrame(frame: number): void;
  14799. /**
  14800. * Pause the animation
  14801. */
  14802. pause(): void;
  14803. /**
  14804. * Restart the animation
  14805. */
  14806. restart(): void;
  14807. private _raiseOnAnimationEnd;
  14808. /**
  14809. * Stop and delete the current animation
  14810. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14811. * @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)
  14812. */
  14813. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14814. /**
  14815. * Wait asynchronously for the animation to end
  14816. * @returns a promise which will be fullfilled when the animation ends
  14817. */
  14818. waitAsync(): Promise<Animatable>;
  14819. /** @hidden */
  14820. _animate(delay: number): boolean;
  14821. }
  14822. interface Scene {
  14823. /** @hidden */
  14824. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14825. /** @hidden */
  14826. _processLateAnimationBindingsForMatrices(holder: {
  14827. totalWeight: number;
  14828. totalAdditiveWeight: number;
  14829. animations: RuntimeAnimation[];
  14830. additiveAnimations: RuntimeAnimation[];
  14831. originalValue: Matrix;
  14832. }): any;
  14833. /** @hidden */
  14834. _processLateAnimationBindingsForQuaternions(holder: {
  14835. totalWeight: number;
  14836. totalAdditiveWeight: number;
  14837. animations: RuntimeAnimation[];
  14838. additiveAnimations: RuntimeAnimation[];
  14839. originalValue: Quaternion;
  14840. }, refQuaternion: Quaternion): Quaternion;
  14841. /** @hidden */
  14842. _processLateAnimationBindings(): void;
  14843. /**
  14844. * Will start the animation sequence of a given target
  14845. * @param target defines the target
  14846. * @param from defines from which frame should animation start
  14847. * @param to defines until which frame should animation run.
  14848. * @param weight defines the weight to apply to the animation (1.0 by default)
  14849. * @param loop defines if the animation loops
  14850. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14851. * @param onAnimationEnd defines the function to be executed when the animation ends
  14852. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14853. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14854. * @param onAnimationLoop defines the callback to call when an animation loops
  14855. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14856. * @returns the animatable object created for this animation
  14857. */
  14858. 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;
  14859. /**
  14860. * Will start the animation sequence of a given target
  14861. * @param target defines the target
  14862. * @param from defines from which frame should animation start
  14863. * @param to defines until which frame should animation run.
  14864. * @param loop defines if the animation loops
  14865. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14866. * @param onAnimationEnd defines the function to be executed when the animation ends
  14867. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14868. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14869. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14870. * @param onAnimationLoop defines the callback to call when an animation loops
  14871. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14872. * @returns the animatable object created for this animation
  14873. */
  14874. 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;
  14875. /**
  14876. * Will start the animation sequence of a given target and its hierarchy
  14877. * @param target defines the target
  14878. * @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.
  14879. * @param from defines from which frame should animation start
  14880. * @param to defines until which frame should animation run.
  14881. * @param loop defines if the animation loops
  14882. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14883. * @param onAnimationEnd defines the function to be executed when the animation ends
  14884. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14885. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14886. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14887. * @param onAnimationLoop defines the callback to call when an animation loops
  14888. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14889. * @returns the list of created animatables
  14890. */
  14891. 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[];
  14892. /**
  14893. * Begin a new animation on a given node
  14894. * @param target defines the target where the animation will take place
  14895. * @param animations defines the list of animations to start
  14896. * @param from defines the initial value
  14897. * @param to defines the final value
  14898. * @param loop defines if you want animation to loop (off by default)
  14899. * @param speedRatio defines the speed ratio to apply to all animations
  14900. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14901. * @param onAnimationLoop defines the callback to call when an animation loops
  14902. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14903. * @returns the list of created animatables
  14904. */
  14905. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  14906. /**
  14907. * Begin a new animation on a given node and its hierarchy
  14908. * @param target defines the root node where the animation will take place
  14909. * @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.
  14910. * @param animations defines the list of animations to start
  14911. * @param from defines the initial value
  14912. * @param to defines the final value
  14913. * @param loop defines if you want animation to loop (off by default)
  14914. * @param speedRatio defines the speed ratio to apply to all animations
  14915. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14916. * @param onAnimationLoop defines the callback to call when an animation loops
  14917. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  14918. * @returns the list of animatables created for all nodes
  14919. */
  14920. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  14921. /**
  14922. * Gets the animatable associated with a specific target
  14923. * @param target defines the target of the animatable
  14924. * @returns the required animatable if found
  14925. */
  14926. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14927. /**
  14928. * Gets all animatables associated with a given target
  14929. * @param target defines the target to look animatables for
  14930. * @returns an array of Animatables
  14931. */
  14932. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14933. /**
  14934. * Stops and removes all animations that have been applied to the scene
  14935. */
  14936. stopAllAnimations(): void;
  14937. /**
  14938. * Gets the current delta time used by animation engine
  14939. */
  14940. deltaTime: number;
  14941. }
  14942. interface Bone {
  14943. /**
  14944. * Copy an animation range from another bone
  14945. * @param source defines the source bone
  14946. * @param rangeName defines the range name to copy
  14947. * @param frameOffset defines the frame offset
  14948. * @param rescaleAsRequired defines if rescaling must be applied if required
  14949. * @param skelDimensionsRatio defines the scaling ratio
  14950. * @returns true if operation was successful
  14951. */
  14952. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14953. }
  14954. }
  14955. declare module BABYLON {
  14956. /**
  14957. * Class used to handle skinning animations
  14958. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14959. */
  14960. export class Skeleton implements IAnimatable {
  14961. /** defines the skeleton name */
  14962. name: string;
  14963. /** defines the skeleton Id */
  14964. id: string;
  14965. /**
  14966. * Defines the list of child bones
  14967. */
  14968. bones: Bone[];
  14969. /**
  14970. * Defines an estimate of the dimension of the skeleton at rest
  14971. */
  14972. dimensionsAtRest: Vector3;
  14973. /**
  14974. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14975. */
  14976. needInitialSkinMatrix: boolean;
  14977. /**
  14978. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14979. */
  14980. overrideMesh: Nullable<AbstractMesh>;
  14981. /**
  14982. * Gets the list of animations attached to this skeleton
  14983. */
  14984. animations: Array<Animation>;
  14985. private _scene;
  14986. private _isDirty;
  14987. private _transformMatrices;
  14988. private _transformMatrixTexture;
  14989. private _meshesWithPoseMatrix;
  14990. private _animatables;
  14991. private _identity;
  14992. private _synchronizedWithMesh;
  14993. private _ranges;
  14994. private _lastAbsoluteTransformsUpdateId;
  14995. private _canUseTextureForBones;
  14996. private _uniqueId;
  14997. /** @hidden */
  14998. _numBonesWithLinkedTransformNode: number;
  14999. /** @hidden */
  15000. _hasWaitingData: Nullable<boolean>;
  15001. /**
  15002. * Specifies if the skeleton should be serialized
  15003. */
  15004. doNotSerialize: boolean;
  15005. private _useTextureToStoreBoneMatrices;
  15006. /**
  15007. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15008. * Please note that this option is not available if the hardware does not support it
  15009. */
  15010. get useTextureToStoreBoneMatrices(): boolean;
  15011. set useTextureToStoreBoneMatrices(value: boolean);
  15012. private _animationPropertiesOverride;
  15013. /**
  15014. * Gets or sets the animation properties override
  15015. */
  15016. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15017. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15018. /**
  15019. * List of inspectable custom properties (used by the Inspector)
  15020. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15021. */
  15022. inspectableCustomProperties: IInspectable[];
  15023. /**
  15024. * An observable triggered before computing the skeleton's matrices
  15025. */
  15026. onBeforeComputeObservable: Observable<Skeleton>;
  15027. /**
  15028. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15029. */
  15030. get isUsingTextureForMatrices(): boolean;
  15031. /**
  15032. * Gets the unique ID of this skeleton
  15033. */
  15034. get uniqueId(): number;
  15035. /**
  15036. * Creates a new skeleton
  15037. * @param name defines the skeleton name
  15038. * @param id defines the skeleton Id
  15039. * @param scene defines the hosting scene
  15040. */
  15041. constructor(
  15042. /** defines the skeleton name */
  15043. name: string,
  15044. /** defines the skeleton Id */
  15045. id: string, scene: Scene);
  15046. /**
  15047. * Gets the current object class name.
  15048. * @return the class name
  15049. */
  15050. getClassName(): string;
  15051. /**
  15052. * Returns an array containing the root bones
  15053. * @returns an array containing the root bones
  15054. */
  15055. getChildren(): Array<Bone>;
  15056. /**
  15057. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15058. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15059. * @returns a Float32Array containing matrices data
  15060. */
  15061. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15062. /**
  15063. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15064. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15065. * @returns a raw texture containing the data
  15066. */
  15067. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15068. /**
  15069. * Gets the current hosting scene
  15070. * @returns a scene object
  15071. */
  15072. getScene(): Scene;
  15073. /**
  15074. * Gets a string representing the current skeleton data
  15075. * @param fullDetails defines a boolean indicating if we want a verbose version
  15076. * @returns a string representing the current skeleton data
  15077. */
  15078. toString(fullDetails?: boolean): string;
  15079. /**
  15080. * Get bone's index searching by name
  15081. * @param name defines bone's name to search for
  15082. * @return the indice of the bone. Returns -1 if not found
  15083. */
  15084. getBoneIndexByName(name: string): number;
  15085. /**
  15086. * Creater a new animation range
  15087. * @param name defines the name of the range
  15088. * @param from defines the start key
  15089. * @param to defines the end key
  15090. */
  15091. createAnimationRange(name: string, from: number, to: number): void;
  15092. /**
  15093. * Delete a specific animation range
  15094. * @param name defines the name of the range
  15095. * @param deleteFrames defines if frames must be removed as well
  15096. */
  15097. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15098. /**
  15099. * Gets a specific animation range
  15100. * @param name defines the name of the range to look for
  15101. * @returns the requested animation range or null if not found
  15102. */
  15103. getAnimationRange(name: string): Nullable<AnimationRange>;
  15104. /**
  15105. * Gets the list of all animation ranges defined on this skeleton
  15106. * @returns an array
  15107. */
  15108. getAnimationRanges(): Nullable<AnimationRange>[];
  15109. /**
  15110. * Copy animation range from a source skeleton.
  15111. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15112. * @param source defines the source skeleton
  15113. * @param name defines the name of the range to copy
  15114. * @param rescaleAsRequired defines if rescaling must be applied if required
  15115. * @returns true if operation was successful
  15116. */
  15117. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15118. /**
  15119. * Forces the skeleton to go to rest pose
  15120. */
  15121. returnToRest(): void;
  15122. private _getHighestAnimationFrame;
  15123. /**
  15124. * Begin a specific animation range
  15125. * @param name defines the name of the range to start
  15126. * @param loop defines if looping must be turned on (false by default)
  15127. * @param speedRatio defines the speed ratio to apply (1 by default)
  15128. * @param onAnimationEnd defines a callback which will be called when animation will end
  15129. * @returns a new animatable
  15130. */
  15131. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15132. /**
  15133. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  15134. * @param skeleton defines the Skeleton containing the animation range to convert
  15135. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  15136. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  15137. * @returns the original skeleton
  15138. */
  15139. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  15140. /** @hidden */
  15141. _markAsDirty(): void;
  15142. /** @hidden */
  15143. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15144. /** @hidden */
  15145. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15146. private _computeTransformMatrices;
  15147. /**
  15148. * Build all resources required to render a skeleton
  15149. */
  15150. prepare(): void;
  15151. /**
  15152. * Gets the list of animatables currently running for this skeleton
  15153. * @returns an array of animatables
  15154. */
  15155. getAnimatables(): IAnimatable[];
  15156. /**
  15157. * Clone the current skeleton
  15158. * @param name defines the name of the new skeleton
  15159. * @param id defines the id of the new skeleton
  15160. * @returns the new skeleton
  15161. */
  15162. clone(name: string, id?: string): Skeleton;
  15163. /**
  15164. * Enable animation blending for this skeleton
  15165. * @param blendingSpeed defines the blending speed to apply
  15166. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15167. */
  15168. enableBlending(blendingSpeed?: number): void;
  15169. /**
  15170. * Releases all resources associated with the current skeleton
  15171. */
  15172. dispose(): void;
  15173. /**
  15174. * Serialize the skeleton in a JSON object
  15175. * @returns a JSON object
  15176. */
  15177. serialize(): any;
  15178. /**
  15179. * Creates a new skeleton from serialized data
  15180. * @param parsedSkeleton defines the serialized data
  15181. * @param scene defines the hosting scene
  15182. * @returns a new skeleton
  15183. */
  15184. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15185. /**
  15186. * Compute all node absolute transforms
  15187. * @param forceUpdate defines if computation must be done even if cache is up to date
  15188. */
  15189. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15190. /**
  15191. * Gets the root pose matrix
  15192. * @returns a matrix
  15193. */
  15194. getPoseMatrix(): Nullable<Matrix>;
  15195. /**
  15196. * Sorts bones per internal index
  15197. */
  15198. sortBones(): void;
  15199. private _sortBones;
  15200. }
  15201. }
  15202. declare module BABYLON {
  15203. /**
  15204. * Creates an instance based on a source mesh.
  15205. */
  15206. export class InstancedMesh extends AbstractMesh {
  15207. private _sourceMesh;
  15208. private _currentLOD;
  15209. /** @hidden */
  15210. _indexInSourceMeshInstanceArray: number;
  15211. constructor(name: string, source: Mesh);
  15212. /**
  15213. * Returns the string "InstancedMesh".
  15214. */
  15215. getClassName(): string;
  15216. /** Gets the list of lights affecting that mesh */
  15217. get lightSources(): Light[];
  15218. _resyncLightSources(): void;
  15219. _resyncLightSource(light: Light): void;
  15220. _removeLightSource(light: Light, dispose: boolean): void;
  15221. /**
  15222. * If the source mesh receives shadows
  15223. */
  15224. get receiveShadows(): boolean;
  15225. /**
  15226. * The material of the source mesh
  15227. */
  15228. get material(): Nullable<Material>;
  15229. /**
  15230. * Visibility of the source mesh
  15231. */
  15232. get visibility(): number;
  15233. /**
  15234. * Skeleton of the source mesh
  15235. */
  15236. get skeleton(): Nullable<Skeleton>;
  15237. /**
  15238. * Rendering ground id of the source mesh
  15239. */
  15240. get renderingGroupId(): number;
  15241. set renderingGroupId(value: number);
  15242. /**
  15243. * Returns the total number of vertices (integer).
  15244. */
  15245. getTotalVertices(): number;
  15246. /**
  15247. * Returns a positive integer : the total number of indices in this mesh geometry.
  15248. * @returns the numner of indices or zero if the mesh has no geometry.
  15249. */
  15250. getTotalIndices(): number;
  15251. /**
  15252. * The source mesh of the instance
  15253. */
  15254. get sourceMesh(): Mesh;
  15255. /**
  15256. * Is this node ready to be used/rendered
  15257. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15258. * @return {boolean} is it ready
  15259. */
  15260. isReady(completeCheck?: boolean): boolean;
  15261. /**
  15262. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15263. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15264. * @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.
  15265. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15266. */
  15267. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15268. /**
  15269. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15270. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15271. * The `data` are either a numeric array either a Float32Array.
  15272. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15273. * 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).
  15274. * Note that a new underlying VertexBuffer object is created each call.
  15275. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15276. *
  15277. * Possible `kind` values :
  15278. * - VertexBuffer.PositionKind
  15279. * - VertexBuffer.UVKind
  15280. * - VertexBuffer.UV2Kind
  15281. * - VertexBuffer.UV3Kind
  15282. * - VertexBuffer.UV4Kind
  15283. * - VertexBuffer.UV5Kind
  15284. * - VertexBuffer.UV6Kind
  15285. * - VertexBuffer.ColorKind
  15286. * - VertexBuffer.MatricesIndicesKind
  15287. * - VertexBuffer.MatricesIndicesExtraKind
  15288. * - VertexBuffer.MatricesWeightsKind
  15289. * - VertexBuffer.MatricesWeightsExtraKind
  15290. *
  15291. * Returns the Mesh.
  15292. */
  15293. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15294. /**
  15295. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15296. * If the mesh has no geometry, it is simply returned as it is.
  15297. * The `data` are either a numeric array either a Float32Array.
  15298. * No new underlying VertexBuffer object is created.
  15299. * 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.
  15300. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15301. *
  15302. * Possible `kind` values :
  15303. * - VertexBuffer.PositionKind
  15304. * - VertexBuffer.UVKind
  15305. * - VertexBuffer.UV2Kind
  15306. * - VertexBuffer.UV3Kind
  15307. * - VertexBuffer.UV4Kind
  15308. * - VertexBuffer.UV5Kind
  15309. * - VertexBuffer.UV6Kind
  15310. * - VertexBuffer.ColorKind
  15311. * - VertexBuffer.MatricesIndicesKind
  15312. * - VertexBuffer.MatricesIndicesExtraKind
  15313. * - VertexBuffer.MatricesWeightsKind
  15314. * - VertexBuffer.MatricesWeightsExtraKind
  15315. *
  15316. * Returns the Mesh.
  15317. */
  15318. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15319. /**
  15320. * Sets the mesh indices.
  15321. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15322. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15323. * This method creates a new index buffer each call.
  15324. * Returns the Mesh.
  15325. */
  15326. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15327. /**
  15328. * Boolean : True if the mesh owns the requested kind of data.
  15329. */
  15330. isVerticesDataPresent(kind: string): boolean;
  15331. /**
  15332. * Returns an array of indices (IndicesArray).
  15333. */
  15334. getIndices(): Nullable<IndicesArray>;
  15335. get _positions(): Nullable<Vector3[]>;
  15336. /**
  15337. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15338. * This means the mesh underlying bounding box and sphere are recomputed.
  15339. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15340. * @returns the current mesh
  15341. */
  15342. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15343. /** @hidden */
  15344. _preActivate(): InstancedMesh;
  15345. /** @hidden */
  15346. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15347. /** @hidden */
  15348. _postActivate(): void;
  15349. getWorldMatrix(): Matrix;
  15350. get isAnInstance(): boolean;
  15351. /**
  15352. * Returns the current associated LOD AbstractMesh.
  15353. */
  15354. getLOD(camera: Camera): AbstractMesh;
  15355. /** @hidden */
  15356. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15357. /** @hidden */
  15358. _syncSubMeshes(): InstancedMesh;
  15359. /** @hidden */
  15360. _generatePointsArray(): boolean;
  15361. /**
  15362. * Creates a new InstancedMesh from the current mesh.
  15363. * - name (string) : the cloned mesh name
  15364. * - newParent (optional Node) : the optional Node to parent the clone to.
  15365. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15366. *
  15367. * Returns the clone.
  15368. */
  15369. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15370. /**
  15371. * Disposes the InstancedMesh.
  15372. * Returns nothing.
  15373. */
  15374. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15375. }
  15376. interface Mesh {
  15377. /**
  15378. * Register a custom buffer that will be instanced
  15379. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15380. * @param kind defines the buffer kind
  15381. * @param stride defines the stride in floats
  15382. */
  15383. registerInstancedBuffer(kind: string, stride: number): void;
  15384. /** @hidden */
  15385. _userInstancedBuffersStorage: {
  15386. data: {
  15387. [key: string]: Float32Array;
  15388. };
  15389. sizes: {
  15390. [key: string]: number;
  15391. };
  15392. vertexBuffers: {
  15393. [key: string]: Nullable<VertexBuffer>;
  15394. };
  15395. strides: {
  15396. [key: string]: number;
  15397. };
  15398. };
  15399. }
  15400. interface AbstractMesh {
  15401. /**
  15402. * Object used to store instanced buffers defined by user
  15403. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15404. */
  15405. instancedBuffers: {
  15406. [key: string]: any;
  15407. };
  15408. }
  15409. }
  15410. declare module BABYLON {
  15411. /**
  15412. * Defines the options associated with the creation of a shader material.
  15413. */
  15414. export interface IShaderMaterialOptions {
  15415. /**
  15416. * Does the material work in alpha blend mode
  15417. */
  15418. needAlphaBlending: boolean;
  15419. /**
  15420. * Does the material work in alpha test mode
  15421. */
  15422. needAlphaTesting: boolean;
  15423. /**
  15424. * The list of attribute names used in the shader
  15425. */
  15426. attributes: string[];
  15427. /**
  15428. * The list of unifrom names used in the shader
  15429. */
  15430. uniforms: string[];
  15431. /**
  15432. * The list of UBO names used in the shader
  15433. */
  15434. uniformBuffers: string[];
  15435. /**
  15436. * The list of sampler names used in the shader
  15437. */
  15438. samplers: string[];
  15439. /**
  15440. * The list of defines used in the shader
  15441. */
  15442. defines: string[];
  15443. }
  15444. /**
  15445. * 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.
  15446. *
  15447. * This returned material effects how the mesh will look based on the code in the shaders.
  15448. *
  15449. * @see http://doc.babylonjs.com/how_to/shader_material
  15450. */
  15451. export class ShaderMaterial extends Material {
  15452. private _shaderPath;
  15453. private _options;
  15454. private _textures;
  15455. private _textureArrays;
  15456. private _floats;
  15457. private _ints;
  15458. private _floatsArrays;
  15459. private _colors3;
  15460. private _colors3Arrays;
  15461. private _colors4;
  15462. private _colors4Arrays;
  15463. private _vectors2;
  15464. private _vectors3;
  15465. private _vectors4;
  15466. private _matrices;
  15467. private _matrixArrays;
  15468. private _matrices3x3;
  15469. private _matrices2x2;
  15470. private _vectors2Arrays;
  15471. private _vectors3Arrays;
  15472. private _vectors4Arrays;
  15473. private _cachedWorldViewMatrix;
  15474. private _cachedWorldViewProjectionMatrix;
  15475. private _renderId;
  15476. private _multiview;
  15477. /**
  15478. * Instantiate a new shader material.
  15479. * 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.
  15480. * This returned material effects how the mesh will look based on the code in the shaders.
  15481. * @see http://doc.babylonjs.com/how_to/shader_material
  15482. * @param name Define the name of the material in the scene
  15483. * @param scene Define the scene the material belongs to
  15484. * @param shaderPath Defines the route to the shader code in one of three ways:
  15485. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15486. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15487. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15488. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15489. * @param options Define the options used to create the shader
  15490. */
  15491. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15492. /**
  15493. * Gets the shader path used to define the shader code
  15494. * It can be modified to trigger a new compilation
  15495. */
  15496. get shaderPath(): any;
  15497. /**
  15498. * Sets the shader path used to define the shader code
  15499. * It can be modified to trigger a new compilation
  15500. */
  15501. set shaderPath(shaderPath: any);
  15502. /**
  15503. * Gets the options used to compile the shader.
  15504. * They can be modified to trigger a new compilation
  15505. */
  15506. get options(): IShaderMaterialOptions;
  15507. /**
  15508. * Gets the current class name of the material e.g. "ShaderMaterial"
  15509. * Mainly use in serialization.
  15510. * @returns the class name
  15511. */
  15512. getClassName(): string;
  15513. /**
  15514. * Specifies if the material will require alpha blending
  15515. * @returns a boolean specifying if alpha blending is needed
  15516. */
  15517. needAlphaBlending(): boolean;
  15518. /**
  15519. * Specifies if this material should be rendered in alpha test mode
  15520. * @returns a boolean specifying if an alpha test is needed.
  15521. */
  15522. needAlphaTesting(): boolean;
  15523. private _checkUniform;
  15524. /**
  15525. * Set a texture in the shader.
  15526. * @param name Define the name of the uniform samplers as defined in the shader
  15527. * @param texture Define the texture to bind to this sampler
  15528. * @return the material itself allowing "fluent" like uniform updates
  15529. */
  15530. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  15531. /**
  15532. * Set a texture array in the shader.
  15533. * @param name Define the name of the uniform sampler array as defined in the shader
  15534. * @param textures Define the list of textures to bind to this sampler
  15535. * @return the material itself allowing "fluent" like uniform updates
  15536. */
  15537. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  15538. /**
  15539. * Set a float in the shader.
  15540. * @param name Define the name of the uniform as defined in the shader
  15541. * @param value Define the value to give to the uniform
  15542. * @return the material itself allowing "fluent" like uniform updates
  15543. */
  15544. setFloat(name: string, value: number): ShaderMaterial;
  15545. /**
  15546. * Set a int in the shader.
  15547. * @param name Define the name of the uniform as defined in the shader
  15548. * @param value Define the value to give to the uniform
  15549. * @return the material itself allowing "fluent" like uniform updates
  15550. */
  15551. setInt(name: string, value: number): ShaderMaterial;
  15552. /**
  15553. * Set an array of floats in the shader.
  15554. * @param name Define the name of the uniform as defined in the shader
  15555. * @param value Define the value to give to the uniform
  15556. * @return the material itself allowing "fluent" like uniform updates
  15557. */
  15558. setFloats(name: string, value: number[]): ShaderMaterial;
  15559. /**
  15560. * Set a vec3 in the shader from a Color3.
  15561. * @param name Define the name of the uniform as defined in the shader
  15562. * @param value Define the value to give to the uniform
  15563. * @return the material itself allowing "fluent" like uniform updates
  15564. */
  15565. setColor3(name: string, value: Color3): ShaderMaterial;
  15566. /**
  15567. * Set a vec3 array in the shader from a Color3 array.
  15568. * @param name Define the name of the uniform as defined in the shader
  15569. * @param value Define the value to give to the uniform
  15570. * @return the material itself allowing "fluent" like uniform updates
  15571. */
  15572. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15573. /**
  15574. * Set a vec4 in the shader from a Color4.
  15575. * @param name Define the name of the uniform as defined in the shader
  15576. * @param value Define the value to give to the uniform
  15577. * @return the material itself allowing "fluent" like uniform updates
  15578. */
  15579. setColor4(name: string, value: Color4): ShaderMaterial;
  15580. /**
  15581. * Set a vec4 array in the shader from a Color4 array.
  15582. * @param name Define the name of the uniform as defined in the shader
  15583. * @param value Define the value to give to the uniform
  15584. * @return the material itself allowing "fluent" like uniform updates
  15585. */
  15586. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15587. /**
  15588. * Set a vec2 in the shader from a Vector2.
  15589. * @param name Define the name of the uniform as defined in the shader
  15590. * @param value Define the value to give to the uniform
  15591. * @return the material itself allowing "fluent" like uniform updates
  15592. */
  15593. setVector2(name: string, value: Vector2): ShaderMaterial;
  15594. /**
  15595. * Set a vec3 in the shader from a Vector3.
  15596. * @param name Define the name of the uniform as defined in the shader
  15597. * @param value Define the value to give to the uniform
  15598. * @return the material itself allowing "fluent" like uniform updates
  15599. */
  15600. setVector3(name: string, value: Vector3): ShaderMaterial;
  15601. /**
  15602. * Set a vec4 in the shader from a Vector4.
  15603. * @param name Define the name of the uniform as defined in the shader
  15604. * @param value Define the value to give to the uniform
  15605. * @return the material itself allowing "fluent" like uniform updates
  15606. */
  15607. setVector4(name: string, value: Vector4): ShaderMaterial;
  15608. /**
  15609. * Set a mat4 in the shader from a Matrix.
  15610. * @param name Define the name of the uniform as defined in the shader
  15611. * @param value Define the value to give to the uniform
  15612. * @return the material itself allowing "fluent" like uniform updates
  15613. */
  15614. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15615. /**
  15616. * Set a float32Array in the shader from a matrix array.
  15617. * @param name Define the name of the uniform as defined in the shader
  15618. * @param value Define the value to give to the uniform
  15619. * @return the material itself allowing "fluent" like uniform updates
  15620. */
  15621. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15622. /**
  15623. * Set a mat3 in the shader from a Float32Array.
  15624. * @param name Define the name of the uniform as defined in the shader
  15625. * @param value Define the value to give to the uniform
  15626. * @return the material itself allowing "fluent" like uniform updates
  15627. */
  15628. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15629. /**
  15630. * Set a mat2 in the shader from a Float32Array.
  15631. * @param name Define the name of the uniform as defined in the shader
  15632. * @param value Define the value to give to the uniform
  15633. * @return the material itself allowing "fluent" like uniform updates
  15634. */
  15635. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15636. /**
  15637. * Set a vec2 array in the shader from a number array.
  15638. * @param name Define the name of the uniform as defined in the shader
  15639. * @param value Define the value to give to the uniform
  15640. * @return the material itself allowing "fluent" like uniform updates
  15641. */
  15642. setArray2(name: string, value: number[]): ShaderMaterial;
  15643. /**
  15644. * Set a vec3 array in the shader from a number array.
  15645. * @param name Define the name of the uniform as defined in the shader
  15646. * @param value Define the value to give to the uniform
  15647. * @return the material itself allowing "fluent" like uniform updates
  15648. */
  15649. setArray3(name: string, value: number[]): ShaderMaterial;
  15650. /**
  15651. * Set a vec4 array in the shader from a number array.
  15652. * @param name Define the name of the uniform as defined in the shader
  15653. * @param value Define the value to give to the uniform
  15654. * @return the material itself allowing "fluent" like uniform updates
  15655. */
  15656. setArray4(name: string, value: number[]): ShaderMaterial;
  15657. private _checkCache;
  15658. /**
  15659. * Specifies that the submesh is ready to be used
  15660. * @param mesh defines the mesh to check
  15661. * @param subMesh defines which submesh to check
  15662. * @param useInstances specifies that instances should be used
  15663. * @returns a boolean indicating that the submesh is ready or not
  15664. */
  15665. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15666. /**
  15667. * Checks if the material is ready to render the requested mesh
  15668. * @param mesh Define the mesh to render
  15669. * @param useInstances Define whether or not the material is used with instances
  15670. * @returns true if ready, otherwise false
  15671. */
  15672. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15673. /**
  15674. * Binds the world matrix to the material
  15675. * @param world defines the world transformation matrix
  15676. */
  15677. bindOnlyWorldMatrix(world: Matrix): void;
  15678. /**
  15679. * Binds the material to the mesh
  15680. * @param world defines the world transformation matrix
  15681. * @param mesh defines the mesh to bind the material to
  15682. */
  15683. bind(world: Matrix, mesh?: Mesh): void;
  15684. /**
  15685. * Gets the active textures from the material
  15686. * @returns an array of textures
  15687. */
  15688. getActiveTextures(): BaseTexture[];
  15689. /**
  15690. * Specifies if the material uses a texture
  15691. * @param texture defines the texture to check against the material
  15692. * @returns a boolean specifying if the material uses the texture
  15693. */
  15694. hasTexture(texture: BaseTexture): boolean;
  15695. /**
  15696. * Makes a duplicate of the material, and gives it a new name
  15697. * @param name defines the new name for the duplicated material
  15698. * @returns the cloned material
  15699. */
  15700. clone(name: string): ShaderMaterial;
  15701. /**
  15702. * Disposes the material
  15703. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15704. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15705. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15706. */
  15707. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15708. /**
  15709. * Serializes this material in a JSON representation
  15710. * @returns the serialized material object
  15711. */
  15712. serialize(): any;
  15713. /**
  15714. * Creates a shader material from parsed shader material data
  15715. * @param source defines the JSON represnetation of the material
  15716. * @param scene defines the hosting scene
  15717. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15718. * @returns a new material
  15719. */
  15720. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15721. }
  15722. }
  15723. declare module BABYLON {
  15724. /** @hidden */
  15725. export var colorPixelShader: {
  15726. name: string;
  15727. shader: string;
  15728. };
  15729. }
  15730. declare module BABYLON {
  15731. /** @hidden */
  15732. export var colorVertexShader: {
  15733. name: string;
  15734. shader: string;
  15735. };
  15736. }
  15737. declare module BABYLON {
  15738. /**
  15739. * Line mesh
  15740. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15741. */
  15742. export class LinesMesh extends Mesh {
  15743. /**
  15744. * If vertex color should be applied to the mesh
  15745. */
  15746. readonly useVertexColor?: boolean | undefined;
  15747. /**
  15748. * If vertex alpha should be applied to the mesh
  15749. */
  15750. readonly useVertexAlpha?: boolean | undefined;
  15751. /**
  15752. * Color of the line (Default: White)
  15753. */
  15754. color: Color3;
  15755. /**
  15756. * Alpha of the line (Default: 1)
  15757. */
  15758. alpha: number;
  15759. /**
  15760. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15761. * This margin is expressed in world space coordinates, so its value may vary.
  15762. * Default value is 0.1
  15763. */
  15764. intersectionThreshold: number;
  15765. private _colorShader;
  15766. private color4;
  15767. /**
  15768. * Creates a new LinesMesh
  15769. * @param name defines the name
  15770. * @param scene defines the hosting scene
  15771. * @param parent defines the parent mesh if any
  15772. * @param source defines the optional source LinesMesh used to clone data from
  15773. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15774. * When false, achieved by calling a clone(), also passing False.
  15775. * This will make creation of children, recursive.
  15776. * @param useVertexColor defines if this LinesMesh supports vertex color
  15777. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15778. */
  15779. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15780. /**
  15781. * If vertex color should be applied to the mesh
  15782. */
  15783. useVertexColor?: boolean | undefined,
  15784. /**
  15785. * If vertex alpha should be applied to the mesh
  15786. */
  15787. useVertexAlpha?: boolean | undefined);
  15788. private _addClipPlaneDefine;
  15789. private _removeClipPlaneDefine;
  15790. isReady(): boolean;
  15791. /**
  15792. * Returns the string "LineMesh"
  15793. */
  15794. getClassName(): string;
  15795. /**
  15796. * @hidden
  15797. */
  15798. get material(): Material;
  15799. /**
  15800. * @hidden
  15801. */
  15802. set material(value: Material);
  15803. /**
  15804. * @hidden
  15805. */
  15806. get checkCollisions(): boolean;
  15807. /** @hidden */
  15808. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15809. /** @hidden */
  15810. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15811. /**
  15812. * Disposes of the line mesh
  15813. * @param doNotRecurse If children should be disposed
  15814. */
  15815. dispose(doNotRecurse?: boolean): void;
  15816. /**
  15817. * Returns a new LineMesh object cloned from the current one.
  15818. */
  15819. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15820. /**
  15821. * Creates a new InstancedLinesMesh object from the mesh model.
  15822. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15823. * @param name defines the name of the new instance
  15824. * @returns a new InstancedLinesMesh
  15825. */
  15826. createInstance(name: string): InstancedLinesMesh;
  15827. }
  15828. /**
  15829. * Creates an instance based on a source LinesMesh
  15830. */
  15831. export class InstancedLinesMesh extends InstancedMesh {
  15832. /**
  15833. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15834. * This margin is expressed in world space coordinates, so its value may vary.
  15835. * Initilized with the intersectionThreshold value of the source LinesMesh
  15836. */
  15837. intersectionThreshold: number;
  15838. constructor(name: string, source: LinesMesh);
  15839. /**
  15840. * Returns the string "InstancedLinesMesh".
  15841. */
  15842. getClassName(): string;
  15843. }
  15844. }
  15845. declare module BABYLON {
  15846. /** @hidden */
  15847. export var linePixelShader: {
  15848. name: string;
  15849. shader: string;
  15850. };
  15851. }
  15852. declare module BABYLON {
  15853. /** @hidden */
  15854. export var lineVertexShader: {
  15855. name: string;
  15856. shader: string;
  15857. };
  15858. }
  15859. declare module BABYLON {
  15860. interface AbstractMesh {
  15861. /**
  15862. * Gets the edgesRenderer associated with the mesh
  15863. */
  15864. edgesRenderer: Nullable<EdgesRenderer>;
  15865. }
  15866. interface LinesMesh {
  15867. /**
  15868. * Enables the edge rendering mode on the mesh.
  15869. * This mode makes the mesh edges visible
  15870. * @param epsilon defines the maximal distance between two angles to detect a face
  15871. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15872. * @returns the currentAbstractMesh
  15873. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15874. */
  15875. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15876. }
  15877. interface InstancedLinesMesh {
  15878. /**
  15879. * Enables the edge rendering mode on the mesh.
  15880. * This mode makes the mesh edges visible
  15881. * @param epsilon defines the maximal distance between two angles to detect a face
  15882. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15883. * @returns the current InstancedLinesMesh
  15884. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15885. */
  15886. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15887. }
  15888. /**
  15889. * Defines the minimum contract an Edges renderer should follow.
  15890. */
  15891. export interface IEdgesRenderer extends IDisposable {
  15892. /**
  15893. * Gets or sets a boolean indicating if the edgesRenderer is active
  15894. */
  15895. isEnabled: boolean;
  15896. /**
  15897. * Renders the edges of the attached mesh,
  15898. */
  15899. render(): void;
  15900. /**
  15901. * Checks wether or not the edges renderer is ready to render.
  15902. * @return true if ready, otherwise false.
  15903. */
  15904. isReady(): boolean;
  15905. }
  15906. /**
  15907. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15908. */
  15909. export class EdgesRenderer implements IEdgesRenderer {
  15910. /**
  15911. * Define the size of the edges with an orthographic camera
  15912. */
  15913. edgesWidthScalerForOrthographic: number;
  15914. /**
  15915. * Define the size of the edges with a perspective camera
  15916. */
  15917. edgesWidthScalerForPerspective: number;
  15918. protected _source: AbstractMesh;
  15919. protected _linesPositions: number[];
  15920. protected _linesNormals: number[];
  15921. protected _linesIndices: number[];
  15922. protected _epsilon: number;
  15923. protected _indicesCount: number;
  15924. protected _lineShader: ShaderMaterial;
  15925. protected _ib: DataBuffer;
  15926. protected _buffers: {
  15927. [key: string]: Nullable<VertexBuffer>;
  15928. };
  15929. protected _checkVerticesInsteadOfIndices: boolean;
  15930. private _meshRebuildObserver;
  15931. private _meshDisposeObserver;
  15932. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15933. isEnabled: boolean;
  15934. /**
  15935. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15936. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15937. * @param source Mesh used to create edges
  15938. * @param epsilon sum of angles in adjacency to check for edge
  15939. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15940. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15941. */
  15942. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15943. protected _prepareRessources(): void;
  15944. /** @hidden */
  15945. _rebuild(): void;
  15946. /**
  15947. * Releases the required resources for the edges renderer
  15948. */
  15949. dispose(): void;
  15950. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15951. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15952. /**
  15953. * Checks if the pair of p0 and p1 is en edge
  15954. * @param faceIndex
  15955. * @param edge
  15956. * @param faceNormals
  15957. * @param p0
  15958. * @param p1
  15959. * @private
  15960. */
  15961. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15962. /**
  15963. * push line into the position, normal and index buffer
  15964. * @protected
  15965. */
  15966. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15967. /**
  15968. * Generates lines edges from adjacencjes
  15969. * @private
  15970. */
  15971. _generateEdgesLines(): void;
  15972. /**
  15973. * Checks wether or not the edges renderer is ready to render.
  15974. * @return true if ready, otherwise false.
  15975. */
  15976. isReady(): boolean;
  15977. /**
  15978. * Renders the edges of the attached mesh,
  15979. */
  15980. render(): void;
  15981. }
  15982. /**
  15983. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15984. */
  15985. export class LineEdgesRenderer extends EdgesRenderer {
  15986. /**
  15987. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15988. * @param source LineMesh used to generate edges
  15989. * @param epsilon not important (specified angle for edge detection)
  15990. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15991. */
  15992. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15993. /**
  15994. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15995. */
  15996. _generateEdgesLines(): void;
  15997. }
  15998. }
  15999. declare module BABYLON {
  16000. /**
  16001. * This represents the object necessary to create a rendering group.
  16002. * This is exclusively used and created by the rendering manager.
  16003. * To modify the behavior, you use the available helpers in your scene or meshes.
  16004. * @hidden
  16005. */
  16006. export class RenderingGroup {
  16007. index: number;
  16008. private static _zeroVector;
  16009. private _scene;
  16010. private _opaqueSubMeshes;
  16011. private _transparentSubMeshes;
  16012. private _alphaTestSubMeshes;
  16013. private _depthOnlySubMeshes;
  16014. private _particleSystems;
  16015. private _spriteManagers;
  16016. private _opaqueSortCompareFn;
  16017. private _alphaTestSortCompareFn;
  16018. private _transparentSortCompareFn;
  16019. private _renderOpaque;
  16020. private _renderAlphaTest;
  16021. private _renderTransparent;
  16022. /** @hidden */
  16023. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16024. onBeforeTransparentRendering: () => void;
  16025. /**
  16026. * Set the opaque sort comparison function.
  16027. * If null the sub meshes will be render in the order they were created
  16028. */
  16029. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16030. /**
  16031. * Set the alpha test sort comparison function.
  16032. * If null the sub meshes will be render in the order they were created
  16033. */
  16034. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16035. /**
  16036. * Set the transparent sort comparison function.
  16037. * If null the sub meshes will be render in the order they were created
  16038. */
  16039. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16040. /**
  16041. * Creates a new rendering group.
  16042. * @param index The rendering group index
  16043. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16044. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16045. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16046. */
  16047. 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>);
  16048. /**
  16049. * Render all the sub meshes contained in the group.
  16050. * @param customRenderFunction Used to override the default render behaviour of the group.
  16051. * @returns true if rendered some submeshes.
  16052. */
  16053. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16054. /**
  16055. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16056. * @param subMeshes The submeshes to render
  16057. */
  16058. private renderOpaqueSorted;
  16059. /**
  16060. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16061. * @param subMeshes The submeshes to render
  16062. */
  16063. private renderAlphaTestSorted;
  16064. /**
  16065. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16066. * @param subMeshes The submeshes to render
  16067. */
  16068. private renderTransparentSorted;
  16069. /**
  16070. * Renders the submeshes in a specified order.
  16071. * @param subMeshes The submeshes to sort before render
  16072. * @param sortCompareFn The comparison function use to sort
  16073. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16074. * @param transparent Specifies to activate blending if true
  16075. */
  16076. private static renderSorted;
  16077. /**
  16078. * Renders the submeshes in the order they were dispatched (no sort applied).
  16079. * @param subMeshes The submeshes to render
  16080. */
  16081. private static renderUnsorted;
  16082. /**
  16083. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16084. * are rendered back to front if in the same alpha index.
  16085. *
  16086. * @param a The first submesh
  16087. * @param b The second submesh
  16088. * @returns The result of the comparison
  16089. */
  16090. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16091. /**
  16092. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16093. * are rendered back to front.
  16094. *
  16095. * @param a The first submesh
  16096. * @param b The second submesh
  16097. * @returns The result of the comparison
  16098. */
  16099. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16100. /**
  16101. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16102. * are rendered front to back (prevent overdraw).
  16103. *
  16104. * @param a The first submesh
  16105. * @param b The second submesh
  16106. * @returns The result of the comparison
  16107. */
  16108. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16109. /**
  16110. * Resets the different lists of submeshes to prepare a new frame.
  16111. */
  16112. prepare(): void;
  16113. dispose(): void;
  16114. /**
  16115. * Inserts the submesh in its correct queue depending on its material.
  16116. * @param subMesh The submesh to dispatch
  16117. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16118. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16119. */
  16120. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16121. dispatchSprites(spriteManager: ISpriteManager): void;
  16122. dispatchParticles(particleSystem: IParticleSystem): void;
  16123. private _renderParticles;
  16124. private _renderSprites;
  16125. }
  16126. }
  16127. declare module BABYLON {
  16128. /**
  16129. * Interface describing the different options available in the rendering manager
  16130. * regarding Auto Clear between groups.
  16131. */
  16132. export interface IRenderingManagerAutoClearSetup {
  16133. /**
  16134. * Defines whether or not autoclear is enable.
  16135. */
  16136. autoClear: boolean;
  16137. /**
  16138. * Defines whether or not to autoclear the depth buffer.
  16139. */
  16140. depth: boolean;
  16141. /**
  16142. * Defines whether or not to autoclear the stencil buffer.
  16143. */
  16144. stencil: boolean;
  16145. }
  16146. /**
  16147. * This class is used by the onRenderingGroupObservable
  16148. */
  16149. export class RenderingGroupInfo {
  16150. /**
  16151. * The Scene that being rendered
  16152. */
  16153. scene: Scene;
  16154. /**
  16155. * The camera currently used for the rendering pass
  16156. */
  16157. camera: Nullable<Camera>;
  16158. /**
  16159. * The ID of the renderingGroup being processed
  16160. */
  16161. renderingGroupId: number;
  16162. }
  16163. /**
  16164. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16165. * It is enable to manage the different groups as well as the different necessary sort functions.
  16166. * This should not be used directly aside of the few static configurations
  16167. */
  16168. export class RenderingManager {
  16169. /**
  16170. * The max id used for rendering groups (not included)
  16171. */
  16172. static MAX_RENDERINGGROUPS: number;
  16173. /**
  16174. * The min id used for rendering groups (included)
  16175. */
  16176. static MIN_RENDERINGGROUPS: number;
  16177. /**
  16178. * Used to globally prevent autoclearing scenes.
  16179. */
  16180. static AUTOCLEAR: boolean;
  16181. /**
  16182. * @hidden
  16183. */
  16184. _useSceneAutoClearSetup: boolean;
  16185. private _scene;
  16186. private _renderingGroups;
  16187. private _depthStencilBufferAlreadyCleaned;
  16188. private _autoClearDepthStencil;
  16189. private _customOpaqueSortCompareFn;
  16190. private _customAlphaTestSortCompareFn;
  16191. private _customTransparentSortCompareFn;
  16192. private _renderingGroupInfo;
  16193. /**
  16194. * Instantiates a new rendering group for a particular scene
  16195. * @param scene Defines the scene the groups belongs to
  16196. */
  16197. constructor(scene: Scene);
  16198. private _clearDepthStencilBuffer;
  16199. /**
  16200. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16201. * @hidden
  16202. */
  16203. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16204. /**
  16205. * Resets the different information of the group to prepare a new frame
  16206. * @hidden
  16207. */
  16208. reset(): void;
  16209. /**
  16210. * Dispose and release the group and its associated resources.
  16211. * @hidden
  16212. */
  16213. dispose(): void;
  16214. /**
  16215. * Clear the info related to rendering groups preventing retention points during dispose.
  16216. */
  16217. freeRenderingGroups(): void;
  16218. private _prepareRenderingGroup;
  16219. /**
  16220. * Add a sprite manager to the rendering manager in order to render it this frame.
  16221. * @param spriteManager Define the sprite manager to render
  16222. */
  16223. dispatchSprites(spriteManager: ISpriteManager): void;
  16224. /**
  16225. * Add a particle system to the rendering manager in order to render it this frame.
  16226. * @param particleSystem Define the particle system to render
  16227. */
  16228. dispatchParticles(particleSystem: IParticleSystem): void;
  16229. /**
  16230. * Add a submesh to the manager in order to render it this frame
  16231. * @param subMesh The submesh to dispatch
  16232. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16233. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16234. */
  16235. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16236. /**
  16237. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16238. * This allowed control for front to back rendering or reversly depending of the special needs.
  16239. *
  16240. * @param renderingGroupId The rendering group id corresponding to its index
  16241. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16242. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16243. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16244. */
  16245. 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;
  16246. /**
  16247. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16248. *
  16249. * @param renderingGroupId The rendering group id corresponding to its index
  16250. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16251. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16252. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16253. */
  16254. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16255. /**
  16256. * Gets the current auto clear configuration for one rendering group of the rendering
  16257. * manager.
  16258. * @param index the rendering group index to get the information for
  16259. * @returns The auto clear setup for the requested rendering group
  16260. */
  16261. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16262. }
  16263. }
  16264. declare module BABYLON {
  16265. /**
  16266. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16267. */
  16268. export interface ICustomShaderOptions {
  16269. /**
  16270. * Gets or sets the custom shader name to use
  16271. */
  16272. shaderName: string;
  16273. /**
  16274. * The list of attribute names used in the shader
  16275. */
  16276. attributes?: string[];
  16277. /**
  16278. * The list of unifrom names used in the shader
  16279. */
  16280. uniforms?: string[];
  16281. /**
  16282. * The list of sampler names used in the shader
  16283. */
  16284. samplers?: string[];
  16285. /**
  16286. * The list of defines used in the shader
  16287. */
  16288. defines?: string[];
  16289. }
  16290. /**
  16291. * Interface to implement to create a shadow generator compatible with BJS.
  16292. */
  16293. export interface IShadowGenerator {
  16294. /**
  16295. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16296. * @returns The render target texture if present otherwise, null
  16297. */
  16298. getShadowMap(): Nullable<RenderTargetTexture>;
  16299. /**
  16300. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16301. * @param subMesh The submesh we want to render in the shadow map
  16302. * @param useInstances Defines wether will draw in the map using instances
  16303. * @returns true if ready otherwise, false
  16304. */
  16305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16306. /**
  16307. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16308. * @param defines Defines of the material we want to update
  16309. * @param lightIndex Index of the light in the enabled light list of the material
  16310. */
  16311. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16312. /**
  16313. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16314. * defined in the generator but impacting the effect).
  16315. * It implies the unifroms available on the materials are the standard BJS ones.
  16316. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16317. * @param effect The effect we are binfing the information for
  16318. */
  16319. bindShadowLight(lightIndex: string, effect: Effect): void;
  16320. /**
  16321. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16322. * (eq to shadow prjection matrix * light transform matrix)
  16323. * @returns The transform matrix used to create the shadow map
  16324. */
  16325. getTransformMatrix(): Matrix;
  16326. /**
  16327. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16328. * Cube and 2D textures for instance.
  16329. */
  16330. recreateShadowMap(): void;
  16331. /**
  16332. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16333. * @param onCompiled Callback triggered at the and of the effects compilation
  16334. * @param options Sets of optional options forcing the compilation with different modes
  16335. */
  16336. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16337. useInstances: boolean;
  16338. }>): void;
  16339. /**
  16340. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16341. * @param options Sets of optional options forcing the compilation with different modes
  16342. * @returns A promise that resolves when the compilation completes
  16343. */
  16344. forceCompilationAsync(options?: Partial<{
  16345. useInstances: boolean;
  16346. }>): Promise<void>;
  16347. /**
  16348. * Serializes the shadow generator setup to a json object.
  16349. * @returns The serialized JSON object
  16350. */
  16351. serialize(): any;
  16352. /**
  16353. * Disposes the Shadow map and related Textures and effects.
  16354. */
  16355. dispose(): void;
  16356. }
  16357. /**
  16358. * Default implementation IShadowGenerator.
  16359. * This is the main object responsible of generating shadows in the framework.
  16360. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16361. */
  16362. export class ShadowGenerator implements IShadowGenerator {
  16363. /**
  16364. * Name of the shadow generator class
  16365. */
  16366. static CLASSNAME: string;
  16367. /**
  16368. * Shadow generator mode None: no filtering applied.
  16369. */
  16370. static readonly FILTER_NONE: number;
  16371. /**
  16372. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16373. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16374. */
  16375. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16376. /**
  16377. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16378. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16379. */
  16380. static readonly FILTER_POISSONSAMPLING: number;
  16381. /**
  16382. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16383. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16384. */
  16385. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16386. /**
  16387. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16388. * edge artifacts on steep falloff.
  16389. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16390. */
  16391. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16392. /**
  16393. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16394. * edge artifacts on steep falloff.
  16395. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16396. */
  16397. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16398. /**
  16399. * Shadow generator mode PCF: Percentage Closer Filtering
  16400. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16401. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16402. */
  16403. static readonly FILTER_PCF: number;
  16404. /**
  16405. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16406. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16407. * Contact Hardening
  16408. */
  16409. static readonly FILTER_PCSS: number;
  16410. /**
  16411. * Reserved for PCF and PCSS
  16412. * Highest Quality.
  16413. *
  16414. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16415. *
  16416. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16417. */
  16418. static readonly QUALITY_HIGH: number;
  16419. /**
  16420. * Reserved for PCF and PCSS
  16421. * Good tradeoff for quality/perf cross devices
  16422. *
  16423. * Execute PCF on a 3*3 kernel.
  16424. *
  16425. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16426. */
  16427. static readonly QUALITY_MEDIUM: number;
  16428. /**
  16429. * Reserved for PCF and PCSS
  16430. * The lowest quality but the fastest.
  16431. *
  16432. * Execute PCF on a 1*1 kernel.
  16433. *
  16434. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16435. */
  16436. static readonly QUALITY_LOW: number;
  16437. /** Gets or sets the custom shader name to use */
  16438. customShaderOptions: ICustomShaderOptions;
  16439. /**
  16440. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16441. */
  16442. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16443. /**
  16444. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16445. */
  16446. onAfterShadowMapRenderObservable: Observable<Effect>;
  16447. /**
  16448. * Observable triggered before a mesh is rendered in the shadow map.
  16449. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16450. */
  16451. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16452. /**
  16453. * Observable triggered after a mesh is rendered in the shadow map.
  16454. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16455. */
  16456. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16457. protected _bias: number;
  16458. /**
  16459. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16460. */
  16461. get bias(): number;
  16462. /**
  16463. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16464. */
  16465. set bias(bias: number);
  16466. protected _normalBias: number;
  16467. /**
  16468. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16469. */
  16470. get normalBias(): number;
  16471. /**
  16472. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16473. */
  16474. set normalBias(normalBias: number);
  16475. protected _blurBoxOffset: number;
  16476. /**
  16477. * Gets the blur box offset: offset applied during the blur pass.
  16478. * Only useful if useKernelBlur = false
  16479. */
  16480. get blurBoxOffset(): number;
  16481. /**
  16482. * Sets the blur box offset: offset applied during the blur pass.
  16483. * Only useful if useKernelBlur = false
  16484. */
  16485. set blurBoxOffset(value: number);
  16486. protected _blurScale: number;
  16487. /**
  16488. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16489. * 2 means half of the size.
  16490. */
  16491. get blurScale(): number;
  16492. /**
  16493. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16494. * 2 means half of the size.
  16495. */
  16496. set blurScale(value: number);
  16497. protected _blurKernel: number;
  16498. /**
  16499. * Gets the blur kernel: kernel size of the blur pass.
  16500. * Only useful if useKernelBlur = true
  16501. */
  16502. get blurKernel(): number;
  16503. /**
  16504. * Sets the blur kernel: kernel size of the blur pass.
  16505. * Only useful if useKernelBlur = true
  16506. */
  16507. set blurKernel(value: number);
  16508. protected _useKernelBlur: boolean;
  16509. /**
  16510. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16512. */
  16513. get useKernelBlur(): boolean;
  16514. /**
  16515. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16516. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16517. */
  16518. set useKernelBlur(value: boolean);
  16519. protected _depthScale: number;
  16520. /**
  16521. * Gets the depth scale used in ESM mode.
  16522. */
  16523. get depthScale(): number;
  16524. /**
  16525. * Sets the depth scale used in ESM mode.
  16526. * This can override the scale stored on the light.
  16527. */
  16528. set depthScale(value: number);
  16529. protected _validateFilter(filter: number): number;
  16530. protected _filter: number;
  16531. /**
  16532. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16533. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16534. */
  16535. get filter(): number;
  16536. /**
  16537. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16538. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16539. */
  16540. set filter(value: number);
  16541. /**
  16542. * Gets if the current filter is set to Poisson Sampling.
  16543. */
  16544. get usePoissonSampling(): boolean;
  16545. /**
  16546. * Sets the current filter to Poisson Sampling.
  16547. */
  16548. set usePoissonSampling(value: boolean);
  16549. /**
  16550. * Gets if the current filter is set to ESM.
  16551. */
  16552. get useExponentialShadowMap(): boolean;
  16553. /**
  16554. * Sets the current filter is to ESM.
  16555. */
  16556. set useExponentialShadowMap(value: boolean);
  16557. /**
  16558. * Gets if the current filter is set to filtered ESM.
  16559. */
  16560. get useBlurExponentialShadowMap(): boolean;
  16561. /**
  16562. * Gets if the current filter is set to filtered ESM.
  16563. */
  16564. set useBlurExponentialShadowMap(value: boolean);
  16565. /**
  16566. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16567. * exponential to prevent steep falloff artifacts).
  16568. */
  16569. get useCloseExponentialShadowMap(): boolean;
  16570. /**
  16571. * Sets the current filter to "close ESM" (using the inverse of the
  16572. * exponential to prevent steep falloff artifacts).
  16573. */
  16574. set useCloseExponentialShadowMap(value: boolean);
  16575. /**
  16576. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16577. * exponential to prevent steep falloff artifacts).
  16578. */
  16579. get useBlurCloseExponentialShadowMap(): boolean;
  16580. /**
  16581. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16582. * exponential to prevent steep falloff artifacts).
  16583. */
  16584. set useBlurCloseExponentialShadowMap(value: boolean);
  16585. /**
  16586. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16587. */
  16588. get usePercentageCloserFiltering(): boolean;
  16589. /**
  16590. * Sets the current filter to "PCF" (percentage closer filtering).
  16591. */
  16592. set usePercentageCloserFiltering(value: boolean);
  16593. protected _filteringQuality: number;
  16594. /**
  16595. * Gets the PCF or PCSS Quality.
  16596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16597. */
  16598. get filteringQuality(): number;
  16599. /**
  16600. * Sets the PCF or PCSS Quality.
  16601. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16602. */
  16603. set filteringQuality(filteringQuality: number);
  16604. /**
  16605. * Gets if the current filter is set to "PCSS" (contact hardening).
  16606. */
  16607. get useContactHardeningShadow(): boolean;
  16608. /**
  16609. * Sets the current filter to "PCSS" (contact hardening).
  16610. */
  16611. set useContactHardeningShadow(value: boolean);
  16612. protected _contactHardeningLightSizeUVRatio: number;
  16613. /**
  16614. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16615. * Using a ratio helps keeping shape stability independently of the map size.
  16616. *
  16617. * It does not account for the light projection as it was having too much
  16618. * instability during the light setup or during light position changes.
  16619. *
  16620. * Only valid if useContactHardeningShadow is true.
  16621. */
  16622. get contactHardeningLightSizeUVRatio(): number;
  16623. /**
  16624. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16625. * Using a ratio helps keeping shape stability independently of the map size.
  16626. *
  16627. * It does not account for the light projection as it was having too much
  16628. * instability during the light setup or during light position changes.
  16629. *
  16630. * Only valid if useContactHardeningShadow is true.
  16631. */
  16632. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16633. protected _darkness: number;
  16634. /** Gets or sets the actual darkness of a shadow */
  16635. get darkness(): number;
  16636. set darkness(value: number);
  16637. /**
  16638. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16639. * 0 means strongest and 1 would means no shadow.
  16640. * @returns the darkness.
  16641. */
  16642. getDarkness(): number;
  16643. /**
  16644. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16645. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16646. * @returns the shadow generator allowing fluent coding.
  16647. */
  16648. setDarkness(darkness: number): ShadowGenerator;
  16649. protected _transparencyShadow: boolean;
  16650. /** Gets or sets the ability to have transparent shadow */
  16651. get transparencyShadow(): boolean;
  16652. set transparencyShadow(value: boolean);
  16653. /**
  16654. * Sets the ability to have transparent shadow (boolean).
  16655. * @param transparent True if transparent else False
  16656. * @returns the shadow generator allowing fluent coding
  16657. */
  16658. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16659. protected _shadowMap: Nullable<RenderTargetTexture>;
  16660. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16661. /**
  16662. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16663. * @returns The render target texture if present otherwise, null
  16664. */
  16665. getShadowMap(): Nullable<RenderTargetTexture>;
  16666. /**
  16667. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16668. * @returns The render target texture if the shadow map is present otherwise, null
  16669. */
  16670. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16671. /**
  16672. * Gets the class name of that object
  16673. * @returns "ShadowGenerator"
  16674. */
  16675. getClassName(): string;
  16676. /**
  16677. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16678. * @param mesh Mesh to add
  16679. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16680. * @returns the Shadow Generator itself
  16681. */
  16682. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16683. /**
  16684. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16685. * @param mesh Mesh to remove
  16686. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16687. * @returns the Shadow Generator itself
  16688. */
  16689. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16690. /**
  16691. * Controls the extent to which the shadows fade out at the edge of the frustum
  16692. */
  16693. frustumEdgeFalloff: number;
  16694. protected _light: IShadowLight;
  16695. /**
  16696. * Returns the associated light object.
  16697. * @returns the light generating the shadow
  16698. */
  16699. getLight(): IShadowLight;
  16700. /**
  16701. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16702. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16703. * It might on the other hand introduce peter panning.
  16704. */
  16705. forceBackFacesOnly: boolean;
  16706. protected _scene: Scene;
  16707. protected _lightDirection: Vector3;
  16708. protected _effect: Effect;
  16709. protected _viewMatrix: Matrix;
  16710. protected _projectionMatrix: Matrix;
  16711. protected _transformMatrix: Matrix;
  16712. protected _cachedPosition: Vector3;
  16713. protected _cachedDirection: Vector3;
  16714. protected _cachedDefines: string;
  16715. protected _currentRenderID: number;
  16716. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16717. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16718. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16719. protected _blurPostProcesses: PostProcess[];
  16720. protected _mapSize: number;
  16721. protected _currentFaceIndex: number;
  16722. protected _currentFaceIndexCache: number;
  16723. protected _textureType: number;
  16724. protected _defaultTextureMatrix: Matrix;
  16725. protected _storedUniqueId: Nullable<number>;
  16726. /** @hidden */
  16727. static _SceneComponentInitialization: (scene: Scene) => void;
  16728. /**
  16729. * Creates a ShadowGenerator object.
  16730. * A ShadowGenerator is the required tool to use the shadows.
  16731. * Each light casting shadows needs to use its own ShadowGenerator.
  16732. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16733. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16734. * @param light The light object generating the shadows.
  16735. * @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.
  16736. */
  16737. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16738. protected _initializeGenerator(): void;
  16739. protected _createTargetRenderTexture(): void;
  16740. protected _initializeShadowMap(): void;
  16741. protected _initializeBlurRTTAndPostProcesses(): void;
  16742. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16743. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16744. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16745. protected _applyFilterValues(): void;
  16746. /**
  16747. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16748. * @param onCompiled Callback triggered at the and of the effects compilation
  16749. * @param options Sets of optional options forcing the compilation with different modes
  16750. */
  16751. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16752. useInstances: boolean;
  16753. }>): void;
  16754. /**
  16755. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16756. * @param options Sets of optional options forcing the compilation with different modes
  16757. * @returns A promise that resolves when the compilation completes
  16758. */
  16759. forceCompilationAsync(options?: Partial<{
  16760. useInstances: boolean;
  16761. }>): Promise<void>;
  16762. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16763. /**
  16764. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16765. * @param subMesh The submesh we want to render in the shadow map
  16766. * @param useInstances Defines wether will draw in the map using instances
  16767. * @returns true if ready otherwise, false
  16768. */
  16769. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16770. /**
  16771. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16772. * @param defines Defines of the material we want to update
  16773. * @param lightIndex Index of the light in the enabled light list of the material
  16774. */
  16775. prepareDefines(defines: any, lightIndex: number): void;
  16776. /**
  16777. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16778. * defined in the generator but impacting the effect).
  16779. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16780. * @param effect The effect we are binfing the information for
  16781. */
  16782. bindShadowLight(lightIndex: string, effect: Effect): void;
  16783. /**
  16784. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16785. * (eq to shadow prjection matrix * light transform matrix)
  16786. * @returns The transform matrix used to create the shadow map
  16787. */
  16788. getTransformMatrix(): Matrix;
  16789. /**
  16790. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16791. * Cube and 2D textures for instance.
  16792. */
  16793. recreateShadowMap(): void;
  16794. protected _disposeBlurPostProcesses(): void;
  16795. protected _disposeRTTandPostProcesses(): void;
  16796. /**
  16797. * Disposes the ShadowGenerator.
  16798. * Returns nothing.
  16799. */
  16800. dispose(): void;
  16801. /**
  16802. * Serializes the shadow generator setup to a json object.
  16803. * @returns The serialized JSON object
  16804. */
  16805. serialize(): any;
  16806. /**
  16807. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16808. * @param parsedShadowGenerator The JSON object to parse
  16809. * @param scene The scene to create the shadow map for
  16810. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16811. * @returns The parsed shadow generator
  16812. */
  16813. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16814. }
  16815. }
  16816. declare module BABYLON {
  16817. /**
  16818. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16819. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16820. * 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.
  16821. */
  16822. export abstract class Light extends Node {
  16823. /**
  16824. * Falloff Default: light is falling off following the material specification:
  16825. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16826. */
  16827. static readonly FALLOFF_DEFAULT: number;
  16828. /**
  16829. * Falloff Physical: light is falling off following the inverse squared distance law.
  16830. */
  16831. static readonly FALLOFF_PHYSICAL: number;
  16832. /**
  16833. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16834. * to enhance interoperability with other engines.
  16835. */
  16836. static readonly FALLOFF_GLTF: number;
  16837. /**
  16838. * Falloff Standard: light is falling off like in the standard material
  16839. * to enhance interoperability with other materials.
  16840. */
  16841. static readonly FALLOFF_STANDARD: number;
  16842. /**
  16843. * If every light affecting the material is in this lightmapMode,
  16844. * material.lightmapTexture adds or multiplies
  16845. * (depends on material.useLightmapAsShadowmap)
  16846. * after every other light calculations.
  16847. */
  16848. static readonly LIGHTMAP_DEFAULT: number;
  16849. /**
  16850. * material.lightmapTexture as only diffuse lighting from this light
  16851. * adds only specular lighting from this light
  16852. * adds dynamic shadows
  16853. */
  16854. static readonly LIGHTMAP_SPECULAR: number;
  16855. /**
  16856. * material.lightmapTexture as only lighting
  16857. * no light calculation from this light
  16858. * only adds dynamic shadows from this light
  16859. */
  16860. static readonly LIGHTMAP_SHADOWSONLY: number;
  16861. /**
  16862. * Each light type uses the default quantity according to its type:
  16863. * point/spot lights use luminous intensity
  16864. * directional lights use illuminance
  16865. */
  16866. static readonly INTENSITYMODE_AUTOMATIC: number;
  16867. /**
  16868. * lumen (lm)
  16869. */
  16870. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16871. /**
  16872. * candela (lm/sr)
  16873. */
  16874. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16875. /**
  16876. * lux (lm/m^2)
  16877. */
  16878. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16879. /**
  16880. * nit (cd/m^2)
  16881. */
  16882. static readonly INTENSITYMODE_LUMINANCE: number;
  16883. /**
  16884. * Light type const id of the point light.
  16885. */
  16886. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16887. /**
  16888. * Light type const id of the directional light.
  16889. */
  16890. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16891. /**
  16892. * Light type const id of the spot light.
  16893. */
  16894. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16895. /**
  16896. * Light type const id of the hemispheric light.
  16897. */
  16898. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16899. /**
  16900. * Diffuse gives the basic color to an object.
  16901. */
  16902. diffuse: Color3;
  16903. /**
  16904. * Specular produces a highlight color on an object.
  16905. * Note: This is note affecting PBR materials.
  16906. */
  16907. specular: Color3;
  16908. /**
  16909. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16910. * falling off base on range or angle.
  16911. * This can be set to any values in Light.FALLOFF_x.
  16912. *
  16913. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16914. * other types of materials.
  16915. */
  16916. falloffType: number;
  16917. /**
  16918. * Strength of the light.
  16919. * Note: By default it is define in the framework own unit.
  16920. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16921. */
  16922. intensity: number;
  16923. private _range;
  16924. protected _inverseSquaredRange: number;
  16925. /**
  16926. * Defines how far from the source the light is impacting in scene units.
  16927. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16928. */
  16929. get range(): number;
  16930. /**
  16931. * Defines how far from the source the light is impacting in scene units.
  16932. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16933. */
  16934. set range(value: number);
  16935. /**
  16936. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16937. * of light.
  16938. */
  16939. private _photometricScale;
  16940. private _intensityMode;
  16941. /**
  16942. * Gets the photometric scale used to interpret the intensity.
  16943. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16944. */
  16945. get intensityMode(): number;
  16946. /**
  16947. * Sets the photometric scale used to interpret the intensity.
  16948. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16949. */
  16950. set intensityMode(value: number);
  16951. private _radius;
  16952. /**
  16953. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16954. */
  16955. get radius(): number;
  16956. /**
  16957. * sets the light radius used by PBR Materials to simulate soft area lights.
  16958. */
  16959. set radius(value: number);
  16960. private _renderPriority;
  16961. /**
  16962. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16963. * exceeding the number allowed of the materials.
  16964. */
  16965. renderPriority: number;
  16966. private _shadowEnabled;
  16967. /**
  16968. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16969. * the current shadow generator.
  16970. */
  16971. get shadowEnabled(): boolean;
  16972. /**
  16973. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16974. * the current shadow generator.
  16975. */
  16976. set shadowEnabled(value: boolean);
  16977. private _includedOnlyMeshes;
  16978. /**
  16979. * Gets the only meshes impacted by this light.
  16980. */
  16981. get includedOnlyMeshes(): AbstractMesh[];
  16982. /**
  16983. * Sets the only meshes impacted by this light.
  16984. */
  16985. set includedOnlyMeshes(value: AbstractMesh[]);
  16986. private _excludedMeshes;
  16987. /**
  16988. * Gets the meshes not impacted by this light.
  16989. */
  16990. get excludedMeshes(): AbstractMesh[];
  16991. /**
  16992. * Sets the meshes not impacted by this light.
  16993. */
  16994. set excludedMeshes(value: AbstractMesh[]);
  16995. private _excludeWithLayerMask;
  16996. /**
  16997. * Gets the layer id use to find what meshes are not impacted by the light.
  16998. * Inactive if 0
  16999. */
  17000. get excludeWithLayerMask(): number;
  17001. /**
  17002. * Sets the layer id use to find what meshes are not impacted by the light.
  17003. * Inactive if 0
  17004. */
  17005. set excludeWithLayerMask(value: number);
  17006. private _includeOnlyWithLayerMask;
  17007. /**
  17008. * Gets the layer id use to find what meshes are impacted by the light.
  17009. * Inactive if 0
  17010. */
  17011. get includeOnlyWithLayerMask(): number;
  17012. /**
  17013. * Sets the layer id use to find what meshes are impacted by the light.
  17014. * Inactive if 0
  17015. */
  17016. set includeOnlyWithLayerMask(value: number);
  17017. private _lightmapMode;
  17018. /**
  17019. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17020. */
  17021. get lightmapMode(): number;
  17022. /**
  17023. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17024. */
  17025. set lightmapMode(value: number);
  17026. /**
  17027. * Shadow generator associted to the light.
  17028. * @hidden Internal use only.
  17029. */
  17030. _shadowGenerator: Nullable<IShadowGenerator>;
  17031. /**
  17032. * @hidden Internal use only.
  17033. */
  17034. _excludedMeshesIds: string[];
  17035. /**
  17036. * @hidden Internal use only.
  17037. */
  17038. _includedOnlyMeshesIds: string[];
  17039. /**
  17040. * The current light unifom buffer.
  17041. * @hidden Internal use only.
  17042. */
  17043. _uniformBuffer: UniformBuffer;
  17044. /** @hidden */
  17045. _renderId: number;
  17046. /**
  17047. * Creates a Light object in the scene.
  17048. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17049. * @param name The firendly name of the light
  17050. * @param scene The scene the light belongs too
  17051. */
  17052. constructor(name: string, scene: Scene);
  17053. protected abstract _buildUniformLayout(): void;
  17054. /**
  17055. * Sets the passed Effect "effect" with the Light information.
  17056. * @param effect The effect to update
  17057. * @param lightIndex The index of the light in the effect to update
  17058. * @returns The light
  17059. */
  17060. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17061. /**
  17062. * Sets the passed Effect "effect" with the Light textures.
  17063. * @param effect The effect to update
  17064. * @param lightIndex The index of the light in the effect to update
  17065. * @returns The light
  17066. */
  17067. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17068. /**
  17069. * Binds the lights information from the scene to the effect for the given mesh.
  17070. * @param lightIndex Light index
  17071. * @param scene The scene where the light belongs to
  17072. * @param effect The effect we are binding the data to
  17073. * @param useSpecular Defines if specular is supported
  17074. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17075. */
  17076. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17077. /**
  17078. * Sets the passed Effect "effect" with the Light information.
  17079. * @param effect The effect to update
  17080. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17081. * @returns The light
  17082. */
  17083. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17084. /**
  17085. * Returns the string "Light".
  17086. * @returns the class name
  17087. */
  17088. getClassName(): string;
  17089. /** @hidden */
  17090. readonly _isLight: boolean;
  17091. /**
  17092. * Converts the light information to a readable string for debug purpose.
  17093. * @param fullDetails Supports for multiple levels of logging within scene loading
  17094. * @returns the human readable light info
  17095. */
  17096. toString(fullDetails?: boolean): string;
  17097. /** @hidden */
  17098. protected _syncParentEnabledState(): void;
  17099. /**
  17100. * Set the enabled state of this node.
  17101. * @param value - the new enabled state
  17102. */
  17103. setEnabled(value: boolean): void;
  17104. /**
  17105. * Returns the Light associated shadow generator if any.
  17106. * @return the associated shadow generator.
  17107. */
  17108. getShadowGenerator(): Nullable<IShadowGenerator>;
  17109. /**
  17110. * Returns a Vector3, the absolute light position in the World.
  17111. * @returns the world space position of the light
  17112. */
  17113. getAbsolutePosition(): Vector3;
  17114. /**
  17115. * Specifies if the light will affect the passed mesh.
  17116. * @param mesh The mesh to test against the light
  17117. * @return true the mesh is affected otherwise, false.
  17118. */
  17119. canAffectMesh(mesh: AbstractMesh): boolean;
  17120. /**
  17121. * Sort function to order lights for rendering.
  17122. * @param a First Light object to compare to second.
  17123. * @param b Second Light object to compare first.
  17124. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17125. */
  17126. static CompareLightsPriority(a: Light, b: Light): number;
  17127. /**
  17128. * Releases resources associated with this node.
  17129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17131. */
  17132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17133. /**
  17134. * Returns the light type ID (integer).
  17135. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17136. */
  17137. getTypeID(): number;
  17138. /**
  17139. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17140. * @returns the scaled intensity in intensity mode unit
  17141. */
  17142. getScaledIntensity(): number;
  17143. /**
  17144. * Returns a new Light object, named "name", from the current one.
  17145. * @param name The name of the cloned light
  17146. * @returns the new created light
  17147. */
  17148. clone(name: string): Nullable<Light>;
  17149. /**
  17150. * Serializes the current light into a Serialization object.
  17151. * @returns the serialized object.
  17152. */
  17153. serialize(): any;
  17154. /**
  17155. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17156. * This new light is named "name" and added to the passed scene.
  17157. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17158. * @param name The friendly name of the light
  17159. * @param scene The scene the new light will belong to
  17160. * @returns the constructor function
  17161. */
  17162. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17163. /**
  17164. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17165. * @param parsedLight The JSON representation of the light
  17166. * @param scene The scene to create the parsed light in
  17167. * @returns the created light after parsing
  17168. */
  17169. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17170. private _hookArrayForExcluded;
  17171. private _hookArrayForIncludedOnly;
  17172. private _resyncMeshes;
  17173. /**
  17174. * Forces the meshes to update their light related information in their rendering used effects
  17175. * @hidden Internal Use Only
  17176. */
  17177. _markMeshesAsLightDirty(): void;
  17178. /**
  17179. * Recomputes the cached photometric scale if needed.
  17180. */
  17181. private _computePhotometricScale;
  17182. /**
  17183. * Returns the Photometric Scale according to the light type and intensity mode.
  17184. */
  17185. private _getPhotometricScale;
  17186. /**
  17187. * Reorder the light in the scene according to their defined priority.
  17188. * @hidden Internal Use Only
  17189. */
  17190. _reorderLightsInScene(): void;
  17191. /**
  17192. * Prepares the list of defines specific to the light type.
  17193. * @param defines the list of defines
  17194. * @param lightIndex defines the index of the light for the effect
  17195. */
  17196. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17197. }
  17198. }
  17199. declare module BABYLON {
  17200. /**
  17201. * Interface used to define Action
  17202. */
  17203. export interface IAction {
  17204. /**
  17205. * Trigger for the action
  17206. */
  17207. trigger: number;
  17208. /** Options of the trigger */
  17209. triggerOptions: any;
  17210. /**
  17211. * Gets the trigger parameters
  17212. * @returns the trigger parameters
  17213. */
  17214. getTriggerParameter(): any;
  17215. /**
  17216. * Internal only - executes current action event
  17217. * @hidden
  17218. */
  17219. _executeCurrent(evt?: ActionEvent): void;
  17220. /**
  17221. * Serialize placeholder for child classes
  17222. * @param parent of child
  17223. * @returns the serialized object
  17224. */
  17225. serialize(parent: any): any;
  17226. /**
  17227. * Internal only
  17228. * @hidden
  17229. */
  17230. _prepare(): void;
  17231. /**
  17232. * Internal only - manager for action
  17233. * @hidden
  17234. */
  17235. _actionManager: AbstractActionManager;
  17236. /**
  17237. * Adds action to chain of actions, may be a DoNothingAction
  17238. * @param action defines the next action to execute
  17239. * @returns The action passed in
  17240. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17241. */
  17242. then(action: IAction): IAction;
  17243. }
  17244. /**
  17245. * The action to be carried out following a trigger
  17246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17247. */
  17248. export class Action implements IAction {
  17249. /** the trigger, with or without parameters, for the action */
  17250. triggerOptions: any;
  17251. /**
  17252. * Trigger for the action
  17253. */
  17254. trigger: number;
  17255. /**
  17256. * Internal only - manager for action
  17257. * @hidden
  17258. */
  17259. _actionManager: ActionManager;
  17260. private _nextActiveAction;
  17261. private _child;
  17262. private _condition?;
  17263. private _triggerParameter;
  17264. /**
  17265. * An event triggered prior to action being executed.
  17266. */
  17267. onBeforeExecuteObservable: Observable<Action>;
  17268. /**
  17269. * Creates a new Action
  17270. * @param triggerOptions the trigger, with or without parameters, for the action
  17271. * @param condition an optional determinant of action
  17272. */
  17273. constructor(
  17274. /** the trigger, with or without parameters, for the action */
  17275. triggerOptions: any, condition?: Condition);
  17276. /**
  17277. * Internal only
  17278. * @hidden
  17279. */
  17280. _prepare(): void;
  17281. /**
  17282. * Gets the trigger parameters
  17283. * @returns the trigger parameters
  17284. */
  17285. getTriggerParameter(): any;
  17286. /**
  17287. * Internal only - executes current action event
  17288. * @hidden
  17289. */
  17290. _executeCurrent(evt?: ActionEvent): void;
  17291. /**
  17292. * Execute placeholder for child classes
  17293. * @param evt optional action event
  17294. */
  17295. execute(evt?: ActionEvent): void;
  17296. /**
  17297. * Skips to next active action
  17298. */
  17299. skipToNextActiveAction(): void;
  17300. /**
  17301. * Adds action to chain of actions, may be a DoNothingAction
  17302. * @param action defines the next action to execute
  17303. * @returns The action passed in
  17304. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17305. */
  17306. then(action: Action): Action;
  17307. /**
  17308. * Internal only
  17309. * @hidden
  17310. */
  17311. _getProperty(propertyPath: string): string;
  17312. /**
  17313. * Internal only
  17314. * @hidden
  17315. */
  17316. _getEffectiveTarget(target: any, propertyPath: string): any;
  17317. /**
  17318. * Serialize placeholder for child classes
  17319. * @param parent of child
  17320. * @returns the serialized object
  17321. */
  17322. serialize(parent: any): any;
  17323. /**
  17324. * Internal only called by serialize
  17325. * @hidden
  17326. */
  17327. protected _serialize(serializedAction: any, parent?: any): any;
  17328. /**
  17329. * Internal only
  17330. * @hidden
  17331. */
  17332. static _SerializeValueAsString: (value: any) => string;
  17333. /**
  17334. * Internal only
  17335. * @hidden
  17336. */
  17337. static _GetTargetProperty: (target: Node | Scene) => {
  17338. name: string;
  17339. targetType: string;
  17340. value: string;
  17341. };
  17342. }
  17343. }
  17344. declare module BABYLON {
  17345. /**
  17346. * A Condition applied to an Action
  17347. */
  17348. export class Condition {
  17349. /**
  17350. * Internal only - manager for action
  17351. * @hidden
  17352. */
  17353. _actionManager: ActionManager;
  17354. /**
  17355. * Internal only
  17356. * @hidden
  17357. */
  17358. _evaluationId: number;
  17359. /**
  17360. * Internal only
  17361. * @hidden
  17362. */
  17363. _currentResult: boolean;
  17364. /**
  17365. * Creates a new Condition
  17366. * @param actionManager the manager of the action the condition is applied to
  17367. */
  17368. constructor(actionManager: ActionManager);
  17369. /**
  17370. * Check if the current condition is valid
  17371. * @returns a boolean
  17372. */
  17373. isValid(): boolean;
  17374. /**
  17375. * Internal only
  17376. * @hidden
  17377. */
  17378. _getProperty(propertyPath: string): string;
  17379. /**
  17380. * Internal only
  17381. * @hidden
  17382. */
  17383. _getEffectiveTarget(target: any, propertyPath: string): any;
  17384. /**
  17385. * Serialize placeholder for child classes
  17386. * @returns the serialized object
  17387. */
  17388. serialize(): any;
  17389. /**
  17390. * Internal only
  17391. * @hidden
  17392. */
  17393. protected _serialize(serializedCondition: any): any;
  17394. }
  17395. /**
  17396. * Defines specific conditional operators as extensions of Condition
  17397. */
  17398. export class ValueCondition extends Condition {
  17399. /** path to specify the property of the target the conditional operator uses */
  17400. propertyPath: string;
  17401. /** the value compared by the conditional operator against the current value of the property */
  17402. value: any;
  17403. /** the conditional operator, default ValueCondition.IsEqual */
  17404. operator: number;
  17405. /**
  17406. * Internal only
  17407. * @hidden
  17408. */
  17409. private static _IsEqual;
  17410. /**
  17411. * Internal only
  17412. * @hidden
  17413. */
  17414. private static _IsDifferent;
  17415. /**
  17416. * Internal only
  17417. * @hidden
  17418. */
  17419. private static _IsGreater;
  17420. /**
  17421. * Internal only
  17422. * @hidden
  17423. */
  17424. private static _IsLesser;
  17425. /**
  17426. * returns the number for IsEqual
  17427. */
  17428. static get IsEqual(): number;
  17429. /**
  17430. * Returns the number for IsDifferent
  17431. */
  17432. static get IsDifferent(): number;
  17433. /**
  17434. * Returns the number for IsGreater
  17435. */
  17436. static get IsGreater(): number;
  17437. /**
  17438. * Returns the number for IsLesser
  17439. */
  17440. static get IsLesser(): number;
  17441. /**
  17442. * Internal only The action manager for the condition
  17443. * @hidden
  17444. */
  17445. _actionManager: ActionManager;
  17446. /**
  17447. * Internal only
  17448. * @hidden
  17449. */
  17450. private _target;
  17451. /**
  17452. * Internal only
  17453. * @hidden
  17454. */
  17455. private _effectiveTarget;
  17456. /**
  17457. * Internal only
  17458. * @hidden
  17459. */
  17460. private _property;
  17461. /**
  17462. * Creates a new ValueCondition
  17463. * @param actionManager manager for the action the condition applies to
  17464. * @param target for the action
  17465. * @param propertyPath path to specify the property of the target the conditional operator uses
  17466. * @param value the value compared by the conditional operator against the current value of the property
  17467. * @param operator the conditional operator, default ValueCondition.IsEqual
  17468. */
  17469. constructor(actionManager: ActionManager, target: any,
  17470. /** path to specify the property of the target the conditional operator uses */
  17471. propertyPath: string,
  17472. /** the value compared by the conditional operator against the current value of the property */
  17473. value: any,
  17474. /** the conditional operator, default ValueCondition.IsEqual */
  17475. operator?: number);
  17476. /**
  17477. * Compares the given value with the property value for the specified conditional operator
  17478. * @returns the result of the comparison
  17479. */
  17480. isValid(): boolean;
  17481. /**
  17482. * Serialize the ValueCondition into a JSON compatible object
  17483. * @returns serialization object
  17484. */
  17485. serialize(): any;
  17486. /**
  17487. * Gets the name of the conditional operator for the ValueCondition
  17488. * @param operator the conditional operator
  17489. * @returns the name
  17490. */
  17491. static GetOperatorName(operator: number): string;
  17492. }
  17493. /**
  17494. * Defines a predicate condition as an extension of Condition
  17495. */
  17496. export class PredicateCondition extends Condition {
  17497. /** defines the predicate function used to validate the condition */
  17498. predicate: () => boolean;
  17499. /**
  17500. * Internal only - manager for action
  17501. * @hidden
  17502. */
  17503. _actionManager: ActionManager;
  17504. /**
  17505. * Creates a new PredicateCondition
  17506. * @param actionManager manager for the action the condition applies to
  17507. * @param predicate defines the predicate function used to validate the condition
  17508. */
  17509. constructor(actionManager: ActionManager,
  17510. /** defines the predicate function used to validate the condition */
  17511. predicate: () => boolean);
  17512. /**
  17513. * @returns the validity of the predicate condition
  17514. */
  17515. isValid(): boolean;
  17516. }
  17517. /**
  17518. * Defines a state condition as an extension of Condition
  17519. */
  17520. export class StateCondition extends Condition {
  17521. /** Value to compare with target state */
  17522. value: string;
  17523. /**
  17524. * Internal only - manager for action
  17525. * @hidden
  17526. */
  17527. _actionManager: ActionManager;
  17528. /**
  17529. * Internal only
  17530. * @hidden
  17531. */
  17532. private _target;
  17533. /**
  17534. * Creates a new StateCondition
  17535. * @param actionManager manager for the action the condition applies to
  17536. * @param target of the condition
  17537. * @param value to compare with target state
  17538. */
  17539. constructor(actionManager: ActionManager, target: any,
  17540. /** Value to compare with target state */
  17541. value: string);
  17542. /**
  17543. * Gets a boolean indicating if the current condition is met
  17544. * @returns the validity of the state
  17545. */
  17546. isValid(): boolean;
  17547. /**
  17548. * Serialize the StateCondition into a JSON compatible object
  17549. * @returns serialization object
  17550. */
  17551. serialize(): any;
  17552. }
  17553. }
  17554. declare module BABYLON {
  17555. /**
  17556. * This defines an action responsible to toggle a boolean once triggered.
  17557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17558. */
  17559. export class SwitchBooleanAction extends Action {
  17560. /**
  17561. * The path to the boolean property in the target object
  17562. */
  17563. propertyPath: string;
  17564. private _target;
  17565. private _effectiveTarget;
  17566. private _property;
  17567. /**
  17568. * Instantiate the action
  17569. * @param triggerOptions defines the trigger options
  17570. * @param target defines the object containing the boolean
  17571. * @param propertyPath defines the path to the boolean property in the target object
  17572. * @param condition defines the trigger related conditions
  17573. */
  17574. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17575. /** @hidden */
  17576. _prepare(): void;
  17577. /**
  17578. * Execute the action toggle the boolean value.
  17579. */
  17580. execute(): void;
  17581. /**
  17582. * Serializes the actions and its related information.
  17583. * @param parent defines the object to serialize in
  17584. * @returns the serialized object
  17585. */
  17586. serialize(parent: any): any;
  17587. }
  17588. /**
  17589. * This defines an action responsible to set a the state field of the target
  17590. * to a desired value once triggered.
  17591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17592. */
  17593. export class SetStateAction extends Action {
  17594. /**
  17595. * The value to store in the state field.
  17596. */
  17597. value: string;
  17598. private _target;
  17599. /**
  17600. * Instantiate the action
  17601. * @param triggerOptions defines the trigger options
  17602. * @param target defines the object containing the state property
  17603. * @param value defines the value to store in the state field
  17604. * @param condition defines the trigger related conditions
  17605. */
  17606. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17607. /**
  17608. * Execute the action and store the value on the target state property.
  17609. */
  17610. execute(): void;
  17611. /**
  17612. * Serializes the actions and its related information.
  17613. * @param parent defines the object to serialize in
  17614. * @returns the serialized object
  17615. */
  17616. serialize(parent: any): any;
  17617. }
  17618. /**
  17619. * This defines an action responsible to set a property of the target
  17620. * to a desired value once triggered.
  17621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17622. */
  17623. export class SetValueAction extends Action {
  17624. /**
  17625. * The path of the property to set in the target.
  17626. */
  17627. propertyPath: string;
  17628. /**
  17629. * The value to set in the property
  17630. */
  17631. value: any;
  17632. private _target;
  17633. private _effectiveTarget;
  17634. private _property;
  17635. /**
  17636. * Instantiate the action
  17637. * @param triggerOptions defines the trigger options
  17638. * @param target defines the object containing the property
  17639. * @param propertyPath defines the path of the property to set in the target
  17640. * @param value defines the value to set in the property
  17641. * @param condition defines the trigger related conditions
  17642. */
  17643. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17644. /** @hidden */
  17645. _prepare(): void;
  17646. /**
  17647. * Execute the action and set the targetted property to the desired value.
  17648. */
  17649. execute(): void;
  17650. /**
  17651. * Serializes the actions and its related information.
  17652. * @param parent defines the object to serialize in
  17653. * @returns the serialized object
  17654. */
  17655. serialize(parent: any): any;
  17656. }
  17657. /**
  17658. * This defines an action responsible to increment the target value
  17659. * to a desired value once triggered.
  17660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17661. */
  17662. export class IncrementValueAction extends Action {
  17663. /**
  17664. * The path of the property to increment in the target.
  17665. */
  17666. propertyPath: string;
  17667. /**
  17668. * The value we should increment the property by.
  17669. */
  17670. value: any;
  17671. private _target;
  17672. private _effectiveTarget;
  17673. private _property;
  17674. /**
  17675. * Instantiate the action
  17676. * @param triggerOptions defines the trigger options
  17677. * @param target defines the object containing the property
  17678. * @param propertyPath defines the path of the property to increment in the target
  17679. * @param value defines the value value we should increment the property by
  17680. * @param condition defines the trigger related conditions
  17681. */
  17682. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17683. /** @hidden */
  17684. _prepare(): void;
  17685. /**
  17686. * Execute the action and increment the target of the value amount.
  17687. */
  17688. execute(): void;
  17689. /**
  17690. * Serializes the actions and its related information.
  17691. * @param parent defines the object to serialize in
  17692. * @returns the serialized object
  17693. */
  17694. serialize(parent: any): any;
  17695. }
  17696. /**
  17697. * This defines an action responsible to start an animation once triggered.
  17698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17699. */
  17700. export class PlayAnimationAction extends Action {
  17701. /**
  17702. * Where the animation should start (animation frame)
  17703. */
  17704. from: number;
  17705. /**
  17706. * Where the animation should stop (animation frame)
  17707. */
  17708. to: number;
  17709. /**
  17710. * Define if the animation should loop or stop after the first play.
  17711. */
  17712. loop?: boolean;
  17713. private _target;
  17714. /**
  17715. * Instantiate the action
  17716. * @param triggerOptions defines the trigger options
  17717. * @param target defines the target animation or animation name
  17718. * @param from defines from where the animation should start (animation frame)
  17719. * @param end defines where the animation should stop (animation frame)
  17720. * @param loop defines if the animation should loop or stop after the first play
  17721. * @param condition defines the trigger related conditions
  17722. */
  17723. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17724. /** @hidden */
  17725. _prepare(): void;
  17726. /**
  17727. * Execute the action and play the animation.
  17728. */
  17729. execute(): void;
  17730. /**
  17731. * Serializes the actions and its related information.
  17732. * @param parent defines the object to serialize in
  17733. * @returns the serialized object
  17734. */
  17735. serialize(parent: any): any;
  17736. }
  17737. /**
  17738. * This defines an action responsible to stop an animation once triggered.
  17739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17740. */
  17741. export class StopAnimationAction extends Action {
  17742. private _target;
  17743. /**
  17744. * Instantiate the action
  17745. * @param triggerOptions defines the trigger options
  17746. * @param target defines the target animation or animation name
  17747. * @param condition defines the trigger related conditions
  17748. */
  17749. constructor(triggerOptions: any, target: any, condition?: Condition);
  17750. /** @hidden */
  17751. _prepare(): void;
  17752. /**
  17753. * Execute the action and stop the animation.
  17754. */
  17755. execute(): void;
  17756. /**
  17757. * Serializes the actions and its related information.
  17758. * @param parent defines the object to serialize in
  17759. * @returns the serialized object
  17760. */
  17761. serialize(parent: any): any;
  17762. }
  17763. /**
  17764. * This defines an action responsible that does nothing once triggered.
  17765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17766. */
  17767. export class DoNothingAction extends Action {
  17768. /**
  17769. * Instantiate the action
  17770. * @param triggerOptions defines the trigger options
  17771. * @param condition defines the trigger related conditions
  17772. */
  17773. constructor(triggerOptions?: any, condition?: Condition);
  17774. /**
  17775. * Execute the action and do nothing.
  17776. */
  17777. execute(): void;
  17778. /**
  17779. * Serializes the actions and its related information.
  17780. * @param parent defines the object to serialize in
  17781. * @returns the serialized object
  17782. */
  17783. serialize(parent: any): any;
  17784. }
  17785. /**
  17786. * This defines an action responsible to trigger several actions once triggered.
  17787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17788. */
  17789. export class CombineAction extends Action {
  17790. /**
  17791. * The list of aggregated animations to run.
  17792. */
  17793. children: Action[];
  17794. /**
  17795. * Instantiate the action
  17796. * @param triggerOptions defines the trigger options
  17797. * @param children defines the list of aggregated animations to run
  17798. * @param condition defines the trigger related conditions
  17799. */
  17800. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17801. /** @hidden */
  17802. _prepare(): void;
  17803. /**
  17804. * Execute the action and executes all the aggregated actions.
  17805. */
  17806. execute(evt: ActionEvent): void;
  17807. /**
  17808. * Serializes the actions and its related information.
  17809. * @param parent defines the object to serialize in
  17810. * @returns the serialized object
  17811. */
  17812. serialize(parent: any): any;
  17813. }
  17814. /**
  17815. * This defines an action responsible to run code (external event) once triggered.
  17816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17817. */
  17818. export class ExecuteCodeAction extends Action {
  17819. /**
  17820. * The callback function to run.
  17821. */
  17822. func: (evt: ActionEvent) => void;
  17823. /**
  17824. * Instantiate the action
  17825. * @param triggerOptions defines the trigger options
  17826. * @param func defines the callback function to run
  17827. * @param condition defines the trigger related conditions
  17828. */
  17829. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17830. /**
  17831. * Execute the action and run the attached code.
  17832. */
  17833. execute(evt: ActionEvent): void;
  17834. }
  17835. /**
  17836. * This defines an action responsible to set the parent property of the target once triggered.
  17837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17838. */
  17839. export class SetParentAction extends Action {
  17840. private _parent;
  17841. private _target;
  17842. /**
  17843. * Instantiate the action
  17844. * @param triggerOptions defines the trigger options
  17845. * @param target defines the target containing the parent property
  17846. * @param parent defines from where the animation should start (animation frame)
  17847. * @param condition defines the trigger related conditions
  17848. */
  17849. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17850. /** @hidden */
  17851. _prepare(): void;
  17852. /**
  17853. * Execute the action and set the parent property.
  17854. */
  17855. execute(): void;
  17856. /**
  17857. * Serializes the actions and its related information.
  17858. * @param parent defines the object to serialize in
  17859. * @returns the serialized object
  17860. */
  17861. serialize(parent: any): any;
  17862. }
  17863. }
  17864. declare module BABYLON {
  17865. /**
  17866. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17867. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17869. */
  17870. export class ActionManager extends AbstractActionManager {
  17871. /**
  17872. * Nothing
  17873. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17874. */
  17875. static readonly NothingTrigger: number;
  17876. /**
  17877. * On pick
  17878. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17879. */
  17880. static readonly OnPickTrigger: number;
  17881. /**
  17882. * On left pick
  17883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17884. */
  17885. static readonly OnLeftPickTrigger: number;
  17886. /**
  17887. * On right pick
  17888. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17889. */
  17890. static readonly OnRightPickTrigger: number;
  17891. /**
  17892. * On center pick
  17893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17894. */
  17895. static readonly OnCenterPickTrigger: number;
  17896. /**
  17897. * On pick down
  17898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17899. */
  17900. static readonly OnPickDownTrigger: number;
  17901. /**
  17902. * On double pick
  17903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17904. */
  17905. static readonly OnDoublePickTrigger: number;
  17906. /**
  17907. * On pick up
  17908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17909. */
  17910. static readonly OnPickUpTrigger: number;
  17911. /**
  17912. * On pick out.
  17913. * This trigger will only be raised if you also declared a OnPickDown
  17914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17915. */
  17916. static readonly OnPickOutTrigger: number;
  17917. /**
  17918. * On long press
  17919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17920. */
  17921. static readonly OnLongPressTrigger: number;
  17922. /**
  17923. * On pointer over
  17924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17925. */
  17926. static readonly OnPointerOverTrigger: number;
  17927. /**
  17928. * On pointer out
  17929. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17930. */
  17931. static readonly OnPointerOutTrigger: number;
  17932. /**
  17933. * On every frame
  17934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17935. */
  17936. static readonly OnEveryFrameTrigger: number;
  17937. /**
  17938. * On intersection enter
  17939. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17940. */
  17941. static readonly OnIntersectionEnterTrigger: number;
  17942. /**
  17943. * On intersection exit
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17945. */
  17946. static readonly OnIntersectionExitTrigger: number;
  17947. /**
  17948. * On key down
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17950. */
  17951. static readonly OnKeyDownTrigger: number;
  17952. /**
  17953. * On key up
  17954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17955. */
  17956. static readonly OnKeyUpTrigger: number;
  17957. private _scene;
  17958. /**
  17959. * Creates a new action manager
  17960. * @param scene defines the hosting scene
  17961. */
  17962. constructor(scene: Scene);
  17963. /**
  17964. * Releases all associated resources
  17965. */
  17966. dispose(): void;
  17967. /**
  17968. * Gets hosting scene
  17969. * @returns the hosting scene
  17970. */
  17971. getScene(): Scene;
  17972. /**
  17973. * Does this action manager handles actions of any of the given triggers
  17974. * @param triggers defines the triggers to be tested
  17975. * @return a boolean indicating whether one (or more) of the triggers is handled
  17976. */
  17977. hasSpecificTriggers(triggers: number[]): boolean;
  17978. /**
  17979. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17980. * speed.
  17981. * @param triggerA defines the trigger to be tested
  17982. * @param triggerB defines the trigger to be tested
  17983. * @return a boolean indicating whether one (or more) of the triggers is handled
  17984. */
  17985. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17986. /**
  17987. * Does this action manager handles actions of a given trigger
  17988. * @param trigger defines the trigger to be tested
  17989. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17990. * @return whether the trigger is handled
  17991. */
  17992. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17993. /**
  17994. * Does this action manager has pointer triggers
  17995. */
  17996. get hasPointerTriggers(): boolean;
  17997. /**
  17998. * Does this action manager has pick triggers
  17999. */
  18000. get hasPickTriggers(): boolean;
  18001. /**
  18002. * Registers an action to this action manager
  18003. * @param action defines the action to be registered
  18004. * @return the action amended (prepared) after registration
  18005. */
  18006. registerAction(action: IAction): Nullable<IAction>;
  18007. /**
  18008. * Unregisters an action to this action manager
  18009. * @param action defines the action to be unregistered
  18010. * @return a boolean indicating whether the action has been unregistered
  18011. */
  18012. unregisterAction(action: IAction): Boolean;
  18013. /**
  18014. * Process a specific trigger
  18015. * @param trigger defines the trigger to process
  18016. * @param evt defines the event details to be processed
  18017. */
  18018. processTrigger(trigger: number, evt?: IActionEvent): void;
  18019. /** @hidden */
  18020. _getEffectiveTarget(target: any, propertyPath: string): any;
  18021. /** @hidden */
  18022. _getProperty(propertyPath: string): string;
  18023. /**
  18024. * Serialize this manager to a JSON object
  18025. * @param name defines the property name to store this manager
  18026. * @returns a JSON representation of this manager
  18027. */
  18028. serialize(name: string): any;
  18029. /**
  18030. * Creates a new ActionManager from a JSON data
  18031. * @param parsedActions defines the JSON data to read from
  18032. * @param object defines the hosting mesh
  18033. * @param scene defines the hosting scene
  18034. */
  18035. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18036. /**
  18037. * Get a trigger name by index
  18038. * @param trigger defines the trigger index
  18039. * @returns a trigger name
  18040. */
  18041. static GetTriggerName(trigger: number): string;
  18042. }
  18043. }
  18044. declare module BABYLON {
  18045. /**
  18046. * Class used to represent a sprite
  18047. * @see http://doc.babylonjs.com/babylon101/sprites
  18048. */
  18049. export class Sprite {
  18050. /** defines the name */
  18051. name: string;
  18052. /** Gets or sets the current world position */
  18053. position: Vector3;
  18054. /** Gets or sets the main color */
  18055. color: Color4;
  18056. /** Gets or sets the width */
  18057. width: number;
  18058. /** Gets or sets the height */
  18059. height: number;
  18060. /** Gets or sets rotation angle */
  18061. angle: number;
  18062. /** Gets or sets the cell index in the sprite sheet */
  18063. cellIndex: number;
  18064. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18065. cellRef: string;
  18066. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18067. invertU: number;
  18068. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18069. invertV: number;
  18070. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18071. disposeWhenFinishedAnimating: boolean;
  18072. /** Gets the list of attached animations */
  18073. animations: Animation[];
  18074. /** Gets or sets a boolean indicating if the sprite can be picked */
  18075. isPickable: boolean;
  18076. /**
  18077. * Gets or sets the associated action manager
  18078. */
  18079. actionManager: Nullable<ActionManager>;
  18080. private _animationStarted;
  18081. private _loopAnimation;
  18082. private _fromIndex;
  18083. private _toIndex;
  18084. private _delay;
  18085. private _direction;
  18086. private _manager;
  18087. private _time;
  18088. private _onAnimationEnd;
  18089. /**
  18090. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18091. */
  18092. isVisible: boolean;
  18093. /**
  18094. * Gets or sets the sprite size
  18095. */
  18096. get size(): number;
  18097. set size(value: number);
  18098. /**
  18099. * Creates a new Sprite
  18100. * @param name defines the name
  18101. * @param manager defines the manager
  18102. */
  18103. constructor(
  18104. /** defines the name */
  18105. name: string, manager: ISpriteManager);
  18106. /**
  18107. * Starts an animation
  18108. * @param from defines the initial key
  18109. * @param to defines the end key
  18110. * @param loop defines if the animation must loop
  18111. * @param delay defines the start delay (in ms)
  18112. * @param onAnimationEnd defines a callback to call when animation ends
  18113. */
  18114. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18115. /** Stops current animation (if any) */
  18116. stopAnimation(): void;
  18117. /** @hidden */
  18118. _animate(deltaTime: number): void;
  18119. /** Release associated resources */
  18120. dispose(): void;
  18121. }
  18122. }
  18123. declare module BABYLON {
  18124. /**
  18125. * Information about the result of picking within a scene
  18126. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18127. */
  18128. export class PickingInfo {
  18129. /** @hidden */
  18130. _pickingUnavailable: boolean;
  18131. /**
  18132. * If the pick collided with an object
  18133. */
  18134. hit: boolean;
  18135. /**
  18136. * Distance away where the pick collided
  18137. */
  18138. distance: number;
  18139. /**
  18140. * The location of pick collision
  18141. */
  18142. pickedPoint: Nullable<Vector3>;
  18143. /**
  18144. * The mesh corresponding the the pick collision
  18145. */
  18146. pickedMesh: Nullable<AbstractMesh>;
  18147. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18148. bu: number;
  18149. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18150. bv: number;
  18151. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18152. faceId: number;
  18153. /** Id of the the submesh that was picked */
  18154. subMeshId: number;
  18155. /** If a sprite was picked, this will be the sprite the pick collided with */
  18156. pickedSprite: Nullable<Sprite>;
  18157. /**
  18158. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18159. */
  18160. originMesh: Nullable<AbstractMesh>;
  18161. /**
  18162. * The ray that was used to perform the picking.
  18163. */
  18164. ray: Nullable<Ray>;
  18165. /**
  18166. * Gets the normal correspodning to the face the pick collided with
  18167. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18168. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18169. * @returns The normal correspodning to the face the pick collided with
  18170. */
  18171. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18172. /**
  18173. * Gets the texture coordinates of where the pick occured
  18174. * @returns the vector containing the coordnates of the texture
  18175. */
  18176. getTextureCoordinates(): Nullable<Vector2>;
  18177. }
  18178. }
  18179. declare module BABYLON {
  18180. /**
  18181. * Gather the list of pointer event types as constants.
  18182. */
  18183. export class PointerEventTypes {
  18184. /**
  18185. * 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.
  18186. */
  18187. static readonly POINTERDOWN: number;
  18188. /**
  18189. * The pointerup event is fired when a pointer is no longer active.
  18190. */
  18191. static readonly POINTERUP: number;
  18192. /**
  18193. * The pointermove event is fired when a pointer changes coordinates.
  18194. */
  18195. static readonly POINTERMOVE: number;
  18196. /**
  18197. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18198. */
  18199. static readonly POINTERWHEEL: number;
  18200. /**
  18201. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18202. */
  18203. static readonly POINTERPICK: number;
  18204. /**
  18205. * The pointertap event is fired when a the object has been touched and released without drag.
  18206. */
  18207. static readonly POINTERTAP: number;
  18208. /**
  18209. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18210. */
  18211. static readonly POINTERDOUBLETAP: number;
  18212. }
  18213. /**
  18214. * Base class of pointer info types.
  18215. */
  18216. export class PointerInfoBase {
  18217. /**
  18218. * Defines the type of event (PointerEventTypes)
  18219. */
  18220. type: number;
  18221. /**
  18222. * Defines the related dom event
  18223. */
  18224. event: PointerEvent | MouseWheelEvent;
  18225. /**
  18226. * Instantiates the base class of pointers info.
  18227. * @param type Defines the type of event (PointerEventTypes)
  18228. * @param event Defines the related dom event
  18229. */
  18230. constructor(
  18231. /**
  18232. * Defines the type of event (PointerEventTypes)
  18233. */
  18234. type: number,
  18235. /**
  18236. * Defines the related dom event
  18237. */
  18238. event: PointerEvent | MouseWheelEvent);
  18239. }
  18240. /**
  18241. * This class is used to store pointer related info for the onPrePointerObservable event.
  18242. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18243. */
  18244. export class PointerInfoPre extends PointerInfoBase {
  18245. /**
  18246. * Ray from a pointer if availible (eg. 6dof controller)
  18247. */
  18248. ray: Nullable<Ray>;
  18249. /**
  18250. * Defines the local position of the pointer on the canvas.
  18251. */
  18252. localPosition: Vector2;
  18253. /**
  18254. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18255. */
  18256. skipOnPointerObservable: boolean;
  18257. /**
  18258. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18259. * @param type Defines the type of event (PointerEventTypes)
  18260. * @param event Defines the related dom event
  18261. * @param localX Defines the local x coordinates of the pointer when the event occured
  18262. * @param localY Defines the local y coordinates of the pointer when the event occured
  18263. */
  18264. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18265. }
  18266. /**
  18267. * This type contains all the data related to a pointer event in Babylon.js.
  18268. * 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.
  18269. */
  18270. export class PointerInfo extends PointerInfoBase {
  18271. /**
  18272. * Defines the picking info associated to the info (if any)\
  18273. */
  18274. pickInfo: Nullable<PickingInfo>;
  18275. /**
  18276. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18277. * @param type Defines the type of event (PointerEventTypes)
  18278. * @param event Defines the related dom event
  18279. * @param pickInfo Defines the picking info associated to the info (if any)\
  18280. */
  18281. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18282. /**
  18283. * Defines the picking info associated to the info (if any)\
  18284. */
  18285. pickInfo: Nullable<PickingInfo>);
  18286. }
  18287. /**
  18288. * Data relating to a touch event on the screen.
  18289. */
  18290. export interface PointerTouch {
  18291. /**
  18292. * X coordinate of touch.
  18293. */
  18294. x: number;
  18295. /**
  18296. * Y coordinate of touch.
  18297. */
  18298. y: number;
  18299. /**
  18300. * Id of touch. Unique for each finger.
  18301. */
  18302. pointerId: number;
  18303. /**
  18304. * Event type passed from DOM.
  18305. */
  18306. type: any;
  18307. }
  18308. }
  18309. declare module BABYLON {
  18310. /**
  18311. * Manage the mouse inputs to control the movement of a free camera.
  18312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18313. */
  18314. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18315. /**
  18316. * Define if touch is enabled in the mouse input
  18317. */
  18318. touchEnabled: boolean;
  18319. /**
  18320. * Defines the camera the input is attached to.
  18321. */
  18322. camera: FreeCamera;
  18323. /**
  18324. * Defines the buttons associated with the input to handle camera move.
  18325. */
  18326. buttons: number[];
  18327. /**
  18328. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18329. */
  18330. angularSensibility: number;
  18331. private _pointerInput;
  18332. private _onMouseMove;
  18333. private _observer;
  18334. private previousPosition;
  18335. /**
  18336. * Observable for when a pointer move event occurs containing the move offset
  18337. */
  18338. onPointerMovedObservable: Observable<{
  18339. offsetX: number;
  18340. offsetY: number;
  18341. }>;
  18342. /**
  18343. * @hidden
  18344. * If the camera should be rotated automatically based on pointer movement
  18345. */
  18346. _allowCameraRotation: boolean;
  18347. /**
  18348. * Manage the mouse inputs to control the movement of a free camera.
  18349. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18350. * @param touchEnabled Defines if touch is enabled or not
  18351. */
  18352. constructor(
  18353. /**
  18354. * Define if touch is enabled in the mouse input
  18355. */
  18356. touchEnabled?: boolean);
  18357. /**
  18358. * Attach the input controls to a specific dom element to get the input from.
  18359. * @param element Defines the element the controls should be listened from
  18360. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18361. */
  18362. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18363. /**
  18364. * Called on JS contextmenu event.
  18365. * Override this method to provide functionality.
  18366. */
  18367. protected onContextMenu(evt: PointerEvent): void;
  18368. /**
  18369. * Detach the current controls from the specified dom element.
  18370. * @param element Defines the element to stop listening the inputs from
  18371. */
  18372. detachControl(element: Nullable<HTMLElement>): void;
  18373. /**
  18374. * Gets the class name of the current intput.
  18375. * @returns the class name
  18376. */
  18377. getClassName(): string;
  18378. /**
  18379. * Get the friendly name associated with the input class.
  18380. * @returns the input friendly name
  18381. */
  18382. getSimpleName(): string;
  18383. }
  18384. }
  18385. declare module BABYLON {
  18386. /**
  18387. * Manage the touch inputs to control the movement of a free camera.
  18388. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18389. */
  18390. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18391. /**
  18392. * Defines the camera the input is attached to.
  18393. */
  18394. camera: FreeCamera;
  18395. /**
  18396. * Defines the touch sensibility for rotation.
  18397. * The higher the faster.
  18398. */
  18399. touchAngularSensibility: number;
  18400. /**
  18401. * Defines the touch sensibility for move.
  18402. * The higher the faster.
  18403. */
  18404. touchMoveSensibility: number;
  18405. private _offsetX;
  18406. private _offsetY;
  18407. private _pointerPressed;
  18408. private _pointerInput;
  18409. private _observer;
  18410. private _onLostFocus;
  18411. /**
  18412. * Attach the input controls to a specific dom element to get the input from.
  18413. * @param element Defines the element the controls should be listened from
  18414. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18415. */
  18416. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18417. /**
  18418. * Detach the current controls from the specified dom element.
  18419. * @param element Defines the element to stop listening the inputs from
  18420. */
  18421. detachControl(element: Nullable<HTMLElement>): void;
  18422. /**
  18423. * Update the current camera state depending on the inputs that have been used this frame.
  18424. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18425. */
  18426. checkInputs(): void;
  18427. /**
  18428. * Gets the class name of the current intput.
  18429. * @returns the class name
  18430. */
  18431. getClassName(): string;
  18432. /**
  18433. * Get the friendly name associated with the input class.
  18434. * @returns the input friendly name
  18435. */
  18436. getSimpleName(): string;
  18437. }
  18438. }
  18439. declare module BABYLON {
  18440. /**
  18441. * Default Inputs manager for the FreeCamera.
  18442. * It groups all the default supported inputs for ease of use.
  18443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18444. */
  18445. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18446. /**
  18447. * @hidden
  18448. */
  18449. _mouseInput: Nullable<FreeCameraMouseInput>;
  18450. /**
  18451. * Instantiates a new FreeCameraInputsManager.
  18452. * @param camera Defines the camera the inputs belong to
  18453. */
  18454. constructor(camera: FreeCamera);
  18455. /**
  18456. * Add keyboard input support to the input manager.
  18457. * @returns the current input manager
  18458. */
  18459. addKeyboard(): FreeCameraInputsManager;
  18460. /**
  18461. * Add mouse input support to the input manager.
  18462. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18463. * @returns the current input manager
  18464. */
  18465. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18466. /**
  18467. * Removes the mouse input support from the manager
  18468. * @returns the current input manager
  18469. */
  18470. removeMouse(): FreeCameraInputsManager;
  18471. /**
  18472. * Add touch input support to the input manager.
  18473. * @returns the current input manager
  18474. */
  18475. addTouch(): FreeCameraInputsManager;
  18476. /**
  18477. * Remove all attached input methods from a camera
  18478. */
  18479. clear(): void;
  18480. }
  18481. }
  18482. declare module BABYLON {
  18483. /**
  18484. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18485. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18487. */
  18488. export class FreeCamera extends TargetCamera {
  18489. /**
  18490. * Define the collision ellipsoid of the camera.
  18491. * This is helpful to simulate a camera body like the player body around the camera
  18492. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18493. */
  18494. ellipsoid: Vector3;
  18495. /**
  18496. * Define an offset for the position of the ellipsoid around the camera.
  18497. * This can be helpful to determine the center of the body near the gravity center of the body
  18498. * instead of its head.
  18499. */
  18500. ellipsoidOffset: Vector3;
  18501. /**
  18502. * Enable or disable collisions of the camera with the rest of the scene objects.
  18503. */
  18504. checkCollisions: boolean;
  18505. /**
  18506. * Enable or disable gravity on the camera.
  18507. */
  18508. applyGravity: boolean;
  18509. /**
  18510. * Define the input manager associated to the camera.
  18511. */
  18512. inputs: FreeCameraInputsManager;
  18513. /**
  18514. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18515. * Higher values reduce sensitivity.
  18516. */
  18517. get angularSensibility(): number;
  18518. /**
  18519. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18520. * Higher values reduce sensitivity.
  18521. */
  18522. set angularSensibility(value: number);
  18523. /**
  18524. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18525. */
  18526. get keysUp(): number[];
  18527. set keysUp(value: number[]);
  18528. /**
  18529. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18530. */
  18531. get keysUpward(): number[];
  18532. set keysUpward(value: number[]);
  18533. /**
  18534. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18535. */
  18536. get keysDown(): number[];
  18537. set keysDown(value: number[]);
  18538. /**
  18539. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18540. */
  18541. get keysDownward(): number[];
  18542. set keysDownward(value: number[]);
  18543. /**
  18544. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18545. */
  18546. get keysLeft(): number[];
  18547. set keysLeft(value: number[]);
  18548. /**
  18549. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18550. */
  18551. get keysRight(): number[];
  18552. set keysRight(value: number[]);
  18553. /**
  18554. * Event raised when the camera collide with a mesh in the scene.
  18555. */
  18556. onCollide: (collidedMesh: AbstractMesh) => void;
  18557. private _collider;
  18558. private _needMoveForGravity;
  18559. private _oldPosition;
  18560. private _diffPosition;
  18561. private _newPosition;
  18562. /** @hidden */
  18563. _localDirection: Vector3;
  18564. /** @hidden */
  18565. _transformedDirection: Vector3;
  18566. /**
  18567. * Instantiates a Free Camera.
  18568. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18569. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18570. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18571. * @param name Define the name of the camera in the scene
  18572. * @param position Define the start position of the camera in the scene
  18573. * @param scene Define the scene the camera belongs to
  18574. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18575. */
  18576. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18577. /**
  18578. * Attached controls to the current camera.
  18579. * @param element Defines the element the controls should be listened from
  18580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18581. */
  18582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18583. /**
  18584. * Detach the current controls from the camera.
  18585. * The camera will stop reacting to inputs.
  18586. * @param element Defines the element to stop listening the inputs from
  18587. */
  18588. detachControl(element: HTMLElement): void;
  18589. private _collisionMask;
  18590. /**
  18591. * Define a collision mask to limit the list of object the camera can collide with
  18592. */
  18593. get collisionMask(): number;
  18594. set collisionMask(mask: number);
  18595. /** @hidden */
  18596. _collideWithWorld(displacement: Vector3): void;
  18597. private _onCollisionPositionChange;
  18598. /** @hidden */
  18599. _checkInputs(): void;
  18600. /** @hidden */
  18601. _decideIfNeedsToMove(): boolean;
  18602. /** @hidden */
  18603. _updatePosition(): void;
  18604. /**
  18605. * Destroy the camera and release the current resources hold by it.
  18606. */
  18607. dispose(): void;
  18608. /**
  18609. * Gets the current object class name.
  18610. * @return the class name
  18611. */
  18612. getClassName(): string;
  18613. }
  18614. }
  18615. declare module BABYLON {
  18616. /**
  18617. * Represents a gamepad control stick position
  18618. */
  18619. export class StickValues {
  18620. /**
  18621. * The x component of the control stick
  18622. */
  18623. x: number;
  18624. /**
  18625. * The y component of the control stick
  18626. */
  18627. y: number;
  18628. /**
  18629. * Initializes the gamepad x and y control stick values
  18630. * @param x The x component of the gamepad control stick value
  18631. * @param y The y component of the gamepad control stick value
  18632. */
  18633. constructor(
  18634. /**
  18635. * The x component of the control stick
  18636. */
  18637. x: number,
  18638. /**
  18639. * The y component of the control stick
  18640. */
  18641. y: number);
  18642. }
  18643. /**
  18644. * An interface which manages callbacks for gamepad button changes
  18645. */
  18646. export interface GamepadButtonChanges {
  18647. /**
  18648. * Called when a gamepad has been changed
  18649. */
  18650. changed: boolean;
  18651. /**
  18652. * Called when a gamepad press event has been triggered
  18653. */
  18654. pressChanged: boolean;
  18655. /**
  18656. * Called when a touch event has been triggered
  18657. */
  18658. touchChanged: boolean;
  18659. /**
  18660. * Called when a value has changed
  18661. */
  18662. valueChanged: boolean;
  18663. }
  18664. /**
  18665. * Represents a gamepad
  18666. */
  18667. export class Gamepad {
  18668. /**
  18669. * The id of the gamepad
  18670. */
  18671. id: string;
  18672. /**
  18673. * The index of the gamepad
  18674. */
  18675. index: number;
  18676. /**
  18677. * The browser gamepad
  18678. */
  18679. browserGamepad: any;
  18680. /**
  18681. * Specifies what type of gamepad this represents
  18682. */
  18683. type: number;
  18684. private _leftStick;
  18685. private _rightStick;
  18686. /** @hidden */
  18687. _isConnected: boolean;
  18688. private _leftStickAxisX;
  18689. private _leftStickAxisY;
  18690. private _rightStickAxisX;
  18691. private _rightStickAxisY;
  18692. /**
  18693. * Triggered when the left control stick has been changed
  18694. */
  18695. private _onleftstickchanged;
  18696. /**
  18697. * Triggered when the right control stick has been changed
  18698. */
  18699. private _onrightstickchanged;
  18700. /**
  18701. * Represents a gamepad controller
  18702. */
  18703. static GAMEPAD: number;
  18704. /**
  18705. * Represents a generic controller
  18706. */
  18707. static GENERIC: number;
  18708. /**
  18709. * Represents an XBox controller
  18710. */
  18711. static XBOX: number;
  18712. /**
  18713. * Represents a pose-enabled controller
  18714. */
  18715. static POSE_ENABLED: number;
  18716. /**
  18717. * Represents an Dual Shock controller
  18718. */
  18719. static DUALSHOCK: number;
  18720. /**
  18721. * Specifies whether the left control stick should be Y-inverted
  18722. */
  18723. protected _invertLeftStickY: boolean;
  18724. /**
  18725. * Specifies if the gamepad has been connected
  18726. */
  18727. get isConnected(): boolean;
  18728. /**
  18729. * Initializes the gamepad
  18730. * @param id The id of the gamepad
  18731. * @param index The index of the gamepad
  18732. * @param browserGamepad The browser gamepad
  18733. * @param leftStickX The x component of the left joystick
  18734. * @param leftStickY The y component of the left joystick
  18735. * @param rightStickX The x component of the right joystick
  18736. * @param rightStickY The y component of the right joystick
  18737. */
  18738. constructor(
  18739. /**
  18740. * The id of the gamepad
  18741. */
  18742. id: string,
  18743. /**
  18744. * The index of the gamepad
  18745. */
  18746. index: number,
  18747. /**
  18748. * The browser gamepad
  18749. */
  18750. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18751. /**
  18752. * Callback triggered when the left joystick has changed
  18753. * @param callback
  18754. */
  18755. onleftstickchanged(callback: (values: StickValues) => void): void;
  18756. /**
  18757. * Callback triggered when the right joystick has changed
  18758. * @param callback
  18759. */
  18760. onrightstickchanged(callback: (values: StickValues) => void): void;
  18761. /**
  18762. * Gets the left joystick
  18763. */
  18764. get leftStick(): StickValues;
  18765. /**
  18766. * Sets the left joystick values
  18767. */
  18768. set leftStick(newValues: StickValues);
  18769. /**
  18770. * Gets the right joystick
  18771. */
  18772. get rightStick(): StickValues;
  18773. /**
  18774. * Sets the right joystick value
  18775. */
  18776. set rightStick(newValues: StickValues);
  18777. /**
  18778. * Updates the gamepad joystick positions
  18779. */
  18780. update(): void;
  18781. /**
  18782. * Disposes the gamepad
  18783. */
  18784. dispose(): void;
  18785. }
  18786. /**
  18787. * Represents a generic gamepad
  18788. */
  18789. export class GenericPad extends Gamepad {
  18790. private _buttons;
  18791. private _onbuttondown;
  18792. private _onbuttonup;
  18793. /**
  18794. * Observable triggered when a button has been pressed
  18795. */
  18796. onButtonDownObservable: Observable<number>;
  18797. /**
  18798. * Observable triggered when a button has been released
  18799. */
  18800. onButtonUpObservable: Observable<number>;
  18801. /**
  18802. * Callback triggered when a button has been pressed
  18803. * @param callback Called when a button has been pressed
  18804. */
  18805. onbuttondown(callback: (buttonPressed: number) => void): void;
  18806. /**
  18807. * Callback triggered when a button has been released
  18808. * @param callback Called when a button has been released
  18809. */
  18810. onbuttonup(callback: (buttonReleased: number) => void): void;
  18811. /**
  18812. * Initializes the generic gamepad
  18813. * @param id The id of the generic gamepad
  18814. * @param index The index of the generic gamepad
  18815. * @param browserGamepad The browser gamepad
  18816. */
  18817. constructor(id: string, index: number, browserGamepad: any);
  18818. private _setButtonValue;
  18819. /**
  18820. * Updates the generic gamepad
  18821. */
  18822. update(): void;
  18823. /**
  18824. * Disposes the generic gamepad
  18825. */
  18826. dispose(): void;
  18827. }
  18828. }
  18829. declare module BABYLON {
  18830. /**
  18831. * Defines the types of pose enabled controllers that are supported
  18832. */
  18833. export enum PoseEnabledControllerType {
  18834. /**
  18835. * HTC Vive
  18836. */
  18837. VIVE = 0,
  18838. /**
  18839. * Oculus Rift
  18840. */
  18841. OCULUS = 1,
  18842. /**
  18843. * Windows mixed reality
  18844. */
  18845. WINDOWS = 2,
  18846. /**
  18847. * Samsung gear VR
  18848. */
  18849. GEAR_VR = 3,
  18850. /**
  18851. * Google Daydream
  18852. */
  18853. DAYDREAM = 4,
  18854. /**
  18855. * Generic
  18856. */
  18857. GENERIC = 5
  18858. }
  18859. /**
  18860. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18861. */
  18862. export interface MutableGamepadButton {
  18863. /**
  18864. * Value of the button/trigger
  18865. */
  18866. value: number;
  18867. /**
  18868. * If the button/trigger is currently touched
  18869. */
  18870. touched: boolean;
  18871. /**
  18872. * If the button/trigger is currently pressed
  18873. */
  18874. pressed: boolean;
  18875. }
  18876. /**
  18877. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18878. * @hidden
  18879. */
  18880. export interface ExtendedGamepadButton extends GamepadButton {
  18881. /**
  18882. * If the button/trigger is currently pressed
  18883. */
  18884. readonly pressed: boolean;
  18885. /**
  18886. * If the button/trigger is currently touched
  18887. */
  18888. readonly touched: boolean;
  18889. /**
  18890. * Value of the button/trigger
  18891. */
  18892. readonly value: number;
  18893. }
  18894. /** @hidden */
  18895. export interface _GamePadFactory {
  18896. /**
  18897. * Returns whether or not the current gamepad can be created for this type of controller.
  18898. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18899. * @returns true if it can be created, otherwise false
  18900. */
  18901. canCreate(gamepadInfo: any): boolean;
  18902. /**
  18903. * Creates a new instance of the Gamepad.
  18904. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18905. * @returns the new gamepad instance
  18906. */
  18907. create(gamepadInfo: any): Gamepad;
  18908. }
  18909. /**
  18910. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18911. */
  18912. export class PoseEnabledControllerHelper {
  18913. /** @hidden */
  18914. static _ControllerFactories: _GamePadFactory[];
  18915. /** @hidden */
  18916. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18917. /**
  18918. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18919. * @param vrGamepad the gamepad to initialized
  18920. * @returns a vr controller of the type the gamepad identified as
  18921. */
  18922. static InitiateController(vrGamepad: any): Gamepad;
  18923. }
  18924. /**
  18925. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18926. */
  18927. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18928. /**
  18929. * If the controller is used in a webXR session
  18930. */
  18931. isXR: boolean;
  18932. private _deviceRoomPosition;
  18933. private _deviceRoomRotationQuaternion;
  18934. /**
  18935. * The device position in babylon space
  18936. */
  18937. devicePosition: Vector3;
  18938. /**
  18939. * The device rotation in babylon space
  18940. */
  18941. deviceRotationQuaternion: Quaternion;
  18942. /**
  18943. * The scale factor of the device in babylon space
  18944. */
  18945. deviceScaleFactor: number;
  18946. /**
  18947. * (Likely devicePosition should be used instead) The device position in its room space
  18948. */
  18949. position: Vector3;
  18950. /**
  18951. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18952. */
  18953. rotationQuaternion: Quaternion;
  18954. /**
  18955. * The type of controller (Eg. Windows mixed reality)
  18956. */
  18957. controllerType: PoseEnabledControllerType;
  18958. protected _calculatedPosition: Vector3;
  18959. private _calculatedRotation;
  18960. /**
  18961. * The raw pose from the device
  18962. */
  18963. rawPose: DevicePose;
  18964. private _trackPosition;
  18965. private _maxRotationDistFromHeadset;
  18966. private _draggedRoomRotation;
  18967. /**
  18968. * @hidden
  18969. */
  18970. _disableTrackPosition(fixedPosition: Vector3): void;
  18971. /**
  18972. * Internal, the mesh attached to the controller
  18973. * @hidden
  18974. */
  18975. _mesh: Nullable<AbstractMesh>;
  18976. private _poseControlledCamera;
  18977. private _leftHandSystemQuaternion;
  18978. /**
  18979. * Internal, matrix used to convert room space to babylon space
  18980. * @hidden
  18981. */
  18982. _deviceToWorld: Matrix;
  18983. /**
  18984. * Node to be used when casting a ray from the controller
  18985. * @hidden
  18986. */
  18987. _pointingPoseNode: Nullable<TransformNode>;
  18988. /**
  18989. * Name of the child mesh that can be used to cast a ray from the controller
  18990. */
  18991. static readonly POINTING_POSE: string;
  18992. /**
  18993. * Creates a new PoseEnabledController from a gamepad
  18994. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18995. */
  18996. constructor(browserGamepad: any);
  18997. private _workingMatrix;
  18998. /**
  18999. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19000. */
  19001. update(): void;
  19002. /**
  19003. * Updates only the pose device and mesh without doing any button event checking
  19004. */
  19005. protected _updatePoseAndMesh(): void;
  19006. /**
  19007. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19008. * @param poseData raw pose fromthe device
  19009. */
  19010. updateFromDevice(poseData: DevicePose): void;
  19011. /**
  19012. * @hidden
  19013. */
  19014. _meshAttachedObservable: Observable<AbstractMesh>;
  19015. /**
  19016. * Attaches a mesh to the controller
  19017. * @param mesh the mesh to be attached
  19018. */
  19019. attachToMesh(mesh: AbstractMesh): void;
  19020. /**
  19021. * Attaches the controllers mesh to a camera
  19022. * @param camera the camera the mesh should be attached to
  19023. */
  19024. attachToPoseControlledCamera(camera: TargetCamera): void;
  19025. /**
  19026. * Disposes of the controller
  19027. */
  19028. dispose(): void;
  19029. /**
  19030. * The mesh that is attached to the controller
  19031. */
  19032. get mesh(): Nullable<AbstractMesh>;
  19033. /**
  19034. * Gets the ray of the controller in the direction the controller is pointing
  19035. * @param length the length the resulting ray should be
  19036. * @returns a ray in the direction the controller is pointing
  19037. */
  19038. getForwardRay(length?: number): Ray;
  19039. }
  19040. }
  19041. declare module BABYLON {
  19042. /**
  19043. * Defines the WebVRController object that represents controllers tracked in 3D space
  19044. */
  19045. export abstract class WebVRController extends PoseEnabledController {
  19046. /**
  19047. * Internal, the default controller model for the controller
  19048. */
  19049. protected _defaultModel: Nullable<AbstractMesh>;
  19050. /**
  19051. * Fired when the trigger state has changed
  19052. */
  19053. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19054. /**
  19055. * Fired when the main button state has changed
  19056. */
  19057. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19058. /**
  19059. * Fired when the secondary button state has changed
  19060. */
  19061. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19062. /**
  19063. * Fired when the pad state has changed
  19064. */
  19065. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19066. /**
  19067. * Fired when controllers stick values have changed
  19068. */
  19069. onPadValuesChangedObservable: Observable<StickValues>;
  19070. /**
  19071. * Array of button availible on the controller
  19072. */
  19073. protected _buttons: Array<MutableGamepadButton>;
  19074. private _onButtonStateChange;
  19075. /**
  19076. * Fired when a controller button's state has changed
  19077. * @param callback the callback containing the button that was modified
  19078. */
  19079. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19080. /**
  19081. * X and Y axis corresponding to the controllers joystick
  19082. */
  19083. pad: StickValues;
  19084. /**
  19085. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19086. */
  19087. hand: string;
  19088. /**
  19089. * The default controller model for the controller
  19090. */
  19091. get defaultModel(): Nullable<AbstractMesh>;
  19092. /**
  19093. * Creates a new WebVRController from a gamepad
  19094. * @param vrGamepad the gamepad that the WebVRController should be created from
  19095. */
  19096. constructor(vrGamepad: any);
  19097. /**
  19098. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19099. */
  19100. update(): void;
  19101. /**
  19102. * Function to be called when a button is modified
  19103. */
  19104. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19105. /**
  19106. * Loads a mesh and attaches it to the controller
  19107. * @param scene the scene the mesh should be added to
  19108. * @param meshLoaded callback for when the mesh has been loaded
  19109. */
  19110. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19111. private _setButtonValue;
  19112. private _changes;
  19113. private _checkChanges;
  19114. /**
  19115. * Disposes of th webVRCOntroller
  19116. */
  19117. dispose(): void;
  19118. }
  19119. }
  19120. declare module BABYLON {
  19121. /**
  19122. * The HemisphericLight simulates the ambient environment light,
  19123. * so the passed direction is the light reflection direction, not the incoming direction.
  19124. */
  19125. export class HemisphericLight extends Light {
  19126. /**
  19127. * The groundColor is the light in the opposite direction to the one specified during creation.
  19128. * 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.
  19129. */
  19130. groundColor: Color3;
  19131. /**
  19132. * The light reflection direction, not the incoming direction.
  19133. */
  19134. direction: Vector3;
  19135. /**
  19136. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19137. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19138. * The HemisphericLight can't cast shadows.
  19139. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19140. * @param name The friendly name of the light
  19141. * @param direction The direction of the light reflection
  19142. * @param scene The scene the light belongs to
  19143. */
  19144. constructor(name: string, direction: Vector3, scene: Scene);
  19145. protected _buildUniformLayout(): void;
  19146. /**
  19147. * Returns the string "HemisphericLight".
  19148. * @return The class name
  19149. */
  19150. getClassName(): string;
  19151. /**
  19152. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19153. * Returns the updated direction.
  19154. * @param target The target the direction should point to
  19155. * @return The computed direction
  19156. */
  19157. setDirectionToTarget(target: Vector3): Vector3;
  19158. /**
  19159. * Returns the shadow generator associated to the light.
  19160. * @returns Always null for hemispheric lights because it does not support shadows.
  19161. */
  19162. getShadowGenerator(): Nullable<IShadowGenerator>;
  19163. /**
  19164. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19165. * @param effect The effect to update
  19166. * @param lightIndex The index of the light in the effect to update
  19167. * @returns The hemispheric light
  19168. */
  19169. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19170. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19171. /**
  19172. * Computes the world matrix of the node
  19173. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19174. * @param useWasUpdatedFlag defines a reserved property
  19175. * @returns the world matrix
  19176. */
  19177. computeWorldMatrix(): Matrix;
  19178. /**
  19179. * Returns the integer 3.
  19180. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19181. */
  19182. getTypeID(): number;
  19183. /**
  19184. * Prepares the list of defines specific to the light type.
  19185. * @param defines the list of defines
  19186. * @param lightIndex defines the index of the light for the effect
  19187. */
  19188. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19189. }
  19190. }
  19191. declare module BABYLON {
  19192. /** @hidden */
  19193. export var vrMultiviewToSingleviewPixelShader: {
  19194. name: string;
  19195. shader: string;
  19196. };
  19197. }
  19198. declare module BABYLON {
  19199. /**
  19200. * Renders to multiple views with a single draw call
  19201. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19202. */
  19203. export class MultiviewRenderTarget extends RenderTargetTexture {
  19204. /**
  19205. * Creates a multiview render target
  19206. * @param scene scene used with the render target
  19207. * @param size the size of the render target (used for each view)
  19208. */
  19209. constructor(scene: Scene, size?: number | {
  19210. width: number;
  19211. height: number;
  19212. } | {
  19213. ratio: number;
  19214. });
  19215. /**
  19216. * @hidden
  19217. * @param faceIndex the face index, if its a cube texture
  19218. */
  19219. _bindFrameBuffer(faceIndex?: number): void;
  19220. /**
  19221. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19222. * @returns the view count
  19223. */
  19224. getViewCount(): number;
  19225. }
  19226. }
  19227. declare module BABYLON {
  19228. /**
  19229. * Represents a camera frustum
  19230. */
  19231. export class Frustum {
  19232. /**
  19233. * Gets the planes representing the frustum
  19234. * @param transform matrix to be applied to the returned planes
  19235. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19236. */
  19237. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19238. /**
  19239. * Gets the near frustum plane transformed by the transform matrix
  19240. * @param transform transformation matrix to be applied to the resulting frustum plane
  19241. * @param frustumPlane the resuling frustum plane
  19242. */
  19243. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19244. /**
  19245. * Gets the far frustum plane transformed by the transform matrix
  19246. * @param transform transformation matrix to be applied to the resulting frustum plane
  19247. * @param frustumPlane the resuling frustum plane
  19248. */
  19249. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19250. /**
  19251. * Gets the left frustum plane transformed by the transform matrix
  19252. * @param transform transformation matrix to be applied to the resulting frustum plane
  19253. * @param frustumPlane the resuling frustum plane
  19254. */
  19255. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19256. /**
  19257. * Gets the right frustum plane transformed by the transform matrix
  19258. * @param transform transformation matrix to be applied to the resulting frustum plane
  19259. * @param frustumPlane the resuling frustum plane
  19260. */
  19261. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19262. /**
  19263. * Gets the top frustum plane transformed by the transform matrix
  19264. * @param transform transformation matrix to be applied to the resulting frustum plane
  19265. * @param frustumPlane the resuling frustum plane
  19266. */
  19267. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19268. /**
  19269. * Gets the bottom frustum plane transformed by the transform matrix
  19270. * @param transform transformation matrix to be applied to the resulting frustum plane
  19271. * @param frustumPlane the resuling frustum plane
  19272. */
  19273. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19274. /**
  19275. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19276. * @param transform transformation matrix to be applied to the resulting frustum planes
  19277. * @param frustumPlanes the resuling frustum planes
  19278. */
  19279. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19280. }
  19281. }
  19282. declare module BABYLON {
  19283. interface Engine {
  19284. /**
  19285. * Creates a new multiview render target
  19286. * @param width defines the width of the texture
  19287. * @param height defines the height of the texture
  19288. * @returns the created multiview texture
  19289. */
  19290. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19291. /**
  19292. * Binds a multiview framebuffer to be drawn to
  19293. * @param multiviewTexture texture to bind
  19294. */
  19295. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19296. }
  19297. interface Camera {
  19298. /**
  19299. * @hidden
  19300. * 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)
  19301. */
  19302. _useMultiviewToSingleView: boolean;
  19303. /**
  19304. * @hidden
  19305. * 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)
  19306. */
  19307. _multiviewTexture: Nullable<RenderTargetTexture>;
  19308. /**
  19309. * @hidden
  19310. * ensures the multiview texture of the camera exists and has the specified width/height
  19311. * @param width height to set on the multiview texture
  19312. * @param height width to set on the multiview texture
  19313. */
  19314. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19315. }
  19316. interface Scene {
  19317. /** @hidden */
  19318. _transformMatrixR: Matrix;
  19319. /** @hidden */
  19320. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19321. /** @hidden */
  19322. _createMultiviewUbo(): void;
  19323. /** @hidden */
  19324. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19325. /** @hidden */
  19326. _renderMultiviewToSingleView(camera: Camera): void;
  19327. }
  19328. }
  19329. declare module BABYLON {
  19330. /**
  19331. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19332. * This will not be used for webXR as it supports displaying texture arrays directly
  19333. */
  19334. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19335. /**
  19336. * Initializes a VRMultiviewToSingleview
  19337. * @param name name of the post process
  19338. * @param camera camera to be applied to
  19339. * @param scaleFactor scaling factor to the size of the output texture
  19340. */
  19341. constructor(name: string, camera: Camera, scaleFactor: number);
  19342. }
  19343. }
  19344. declare module BABYLON {
  19345. /**
  19346. * Interface used to define additional presentation attributes
  19347. */
  19348. export interface IVRPresentationAttributes {
  19349. /**
  19350. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19351. */
  19352. highRefreshRate: boolean;
  19353. /**
  19354. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19355. */
  19356. foveationLevel: number;
  19357. }
  19358. interface Engine {
  19359. /** @hidden */
  19360. _vrDisplay: any;
  19361. /** @hidden */
  19362. _vrSupported: boolean;
  19363. /** @hidden */
  19364. _oldSize: Size;
  19365. /** @hidden */
  19366. _oldHardwareScaleFactor: number;
  19367. /** @hidden */
  19368. _vrExclusivePointerMode: boolean;
  19369. /** @hidden */
  19370. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19371. /** @hidden */
  19372. _onVRDisplayPointerRestricted: () => void;
  19373. /** @hidden */
  19374. _onVRDisplayPointerUnrestricted: () => void;
  19375. /** @hidden */
  19376. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19377. /** @hidden */
  19378. _onVrDisplayDisconnect: Nullable<() => void>;
  19379. /** @hidden */
  19380. _onVrDisplayPresentChange: Nullable<() => void>;
  19381. /**
  19382. * Observable signaled when VR display mode changes
  19383. */
  19384. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19385. /**
  19386. * Observable signaled when VR request present is complete
  19387. */
  19388. onVRRequestPresentComplete: Observable<boolean>;
  19389. /**
  19390. * Observable signaled when VR request present starts
  19391. */
  19392. onVRRequestPresentStart: Observable<Engine>;
  19393. /**
  19394. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19395. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19396. */
  19397. isInVRExclusivePointerMode: boolean;
  19398. /**
  19399. * Gets a boolean indicating if a webVR device was detected
  19400. * @returns true if a webVR device was detected
  19401. */
  19402. isVRDevicePresent(): boolean;
  19403. /**
  19404. * Gets the current webVR device
  19405. * @returns the current webVR device (or null)
  19406. */
  19407. getVRDevice(): any;
  19408. /**
  19409. * Initializes a webVR display and starts listening to display change events
  19410. * The onVRDisplayChangedObservable will be notified upon these changes
  19411. * @returns A promise containing a VRDisplay and if vr is supported
  19412. */
  19413. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19414. /** @hidden */
  19415. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19416. /**
  19417. * Gets or sets the presentation attributes used to configure VR rendering
  19418. */
  19419. vrPresentationAttributes?: IVRPresentationAttributes;
  19420. /**
  19421. * Call this function to switch to webVR mode
  19422. * Will do nothing if webVR is not supported or if there is no webVR device
  19423. * @param options the webvr options provided to the camera. mainly used for multiview
  19424. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19425. */
  19426. enableVR(options: WebVROptions): void;
  19427. /** @hidden */
  19428. _onVRFullScreenTriggered(): void;
  19429. }
  19430. }
  19431. declare module BABYLON {
  19432. /**
  19433. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19434. * IMPORTANT!! The data is right-hand data.
  19435. * @export
  19436. * @interface DevicePose
  19437. */
  19438. export interface DevicePose {
  19439. /**
  19440. * The position of the device, values in array are [x,y,z].
  19441. */
  19442. readonly position: Nullable<Float32Array>;
  19443. /**
  19444. * The linearVelocity of the device, values in array are [x,y,z].
  19445. */
  19446. readonly linearVelocity: Nullable<Float32Array>;
  19447. /**
  19448. * The linearAcceleration of the device, values in array are [x,y,z].
  19449. */
  19450. readonly linearAcceleration: Nullable<Float32Array>;
  19451. /**
  19452. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19453. */
  19454. readonly orientation: Nullable<Float32Array>;
  19455. /**
  19456. * The angularVelocity of the device, values in array are [x,y,z].
  19457. */
  19458. readonly angularVelocity: Nullable<Float32Array>;
  19459. /**
  19460. * The angularAcceleration of the device, values in array are [x,y,z].
  19461. */
  19462. readonly angularAcceleration: Nullable<Float32Array>;
  19463. }
  19464. /**
  19465. * Interface representing a pose controlled object in Babylon.
  19466. * A pose controlled object has both regular pose values as well as pose values
  19467. * from an external device such as a VR head mounted display
  19468. */
  19469. export interface PoseControlled {
  19470. /**
  19471. * The position of the object in babylon space.
  19472. */
  19473. position: Vector3;
  19474. /**
  19475. * The rotation quaternion of the object in babylon space.
  19476. */
  19477. rotationQuaternion: Quaternion;
  19478. /**
  19479. * The position of the device in babylon space.
  19480. */
  19481. devicePosition?: Vector3;
  19482. /**
  19483. * The rotation quaternion of the device in babylon space.
  19484. */
  19485. deviceRotationQuaternion: Quaternion;
  19486. /**
  19487. * The raw pose coming from the device.
  19488. */
  19489. rawPose: Nullable<DevicePose>;
  19490. /**
  19491. * The scale of the device to be used when translating from device space to babylon space.
  19492. */
  19493. deviceScaleFactor: number;
  19494. /**
  19495. * Updates the poseControlled values based on the input device pose.
  19496. * @param poseData the pose data to update the object with
  19497. */
  19498. updateFromDevice(poseData: DevicePose): void;
  19499. }
  19500. /**
  19501. * Set of options to customize the webVRCamera
  19502. */
  19503. export interface WebVROptions {
  19504. /**
  19505. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19506. */
  19507. trackPosition?: boolean;
  19508. /**
  19509. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19510. */
  19511. positionScale?: number;
  19512. /**
  19513. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19514. */
  19515. displayName?: string;
  19516. /**
  19517. * Should the native controller meshes be initialized. (default: true)
  19518. */
  19519. controllerMeshes?: boolean;
  19520. /**
  19521. * Creating a default HemiLight only on controllers. (default: true)
  19522. */
  19523. defaultLightingOnControllers?: boolean;
  19524. /**
  19525. * If you don't want to use the default VR button of the helper. (default: false)
  19526. */
  19527. useCustomVRButton?: boolean;
  19528. /**
  19529. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19530. */
  19531. customVRButton?: HTMLButtonElement;
  19532. /**
  19533. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19534. */
  19535. rayLength?: number;
  19536. /**
  19537. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19538. */
  19539. defaultHeight?: number;
  19540. /**
  19541. * If multiview should be used if availible (default: false)
  19542. */
  19543. useMultiview?: boolean;
  19544. }
  19545. /**
  19546. * This represents a WebVR camera.
  19547. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19548. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19549. */
  19550. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19551. private webVROptions;
  19552. /**
  19553. * @hidden
  19554. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19555. */
  19556. _vrDevice: any;
  19557. /**
  19558. * The rawPose of the vrDevice.
  19559. */
  19560. rawPose: Nullable<DevicePose>;
  19561. private _onVREnabled;
  19562. private _specsVersion;
  19563. private _attached;
  19564. private _frameData;
  19565. protected _descendants: Array<Node>;
  19566. private _deviceRoomPosition;
  19567. /** @hidden */
  19568. _deviceRoomRotationQuaternion: Quaternion;
  19569. private _standingMatrix;
  19570. /**
  19571. * Represents device position in babylon space.
  19572. */
  19573. devicePosition: Vector3;
  19574. /**
  19575. * Represents device rotation in babylon space.
  19576. */
  19577. deviceRotationQuaternion: Quaternion;
  19578. /**
  19579. * The scale of the device to be used when translating from device space to babylon space.
  19580. */
  19581. deviceScaleFactor: number;
  19582. private _deviceToWorld;
  19583. private _worldToDevice;
  19584. /**
  19585. * References to the webVR controllers for the vrDevice.
  19586. */
  19587. controllers: Array<WebVRController>;
  19588. /**
  19589. * Emits an event when a controller is attached.
  19590. */
  19591. onControllersAttachedObservable: Observable<WebVRController[]>;
  19592. /**
  19593. * Emits an event when a controller's mesh has been loaded;
  19594. */
  19595. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19596. /**
  19597. * Emits an event when the HMD's pose has been updated.
  19598. */
  19599. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19600. private _poseSet;
  19601. /**
  19602. * If the rig cameras be used as parent instead of this camera.
  19603. */
  19604. rigParenting: boolean;
  19605. private _lightOnControllers;
  19606. private _defaultHeight?;
  19607. /**
  19608. * Instantiates a WebVRFreeCamera.
  19609. * @param name The name of the WebVRFreeCamera
  19610. * @param position The starting anchor position for the camera
  19611. * @param scene The scene the camera belongs to
  19612. * @param webVROptions a set of customizable options for the webVRCamera
  19613. */
  19614. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19615. /**
  19616. * Gets the device distance from the ground in meters.
  19617. * @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.
  19618. */
  19619. deviceDistanceToRoomGround(): number;
  19620. /**
  19621. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19622. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19623. */
  19624. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19625. /**
  19626. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19627. * @returns A promise with a boolean set to if the standing matrix is supported.
  19628. */
  19629. useStandingMatrixAsync(): Promise<boolean>;
  19630. /**
  19631. * Disposes the camera
  19632. */
  19633. dispose(): void;
  19634. /**
  19635. * Gets a vrController by name.
  19636. * @param name The name of the controller to retreive
  19637. * @returns the controller matching the name specified or null if not found
  19638. */
  19639. getControllerByName(name: string): Nullable<WebVRController>;
  19640. private _leftController;
  19641. /**
  19642. * The controller corresponding to the users left hand.
  19643. */
  19644. get leftController(): Nullable<WebVRController>;
  19645. private _rightController;
  19646. /**
  19647. * The controller corresponding to the users right hand.
  19648. */
  19649. get rightController(): Nullable<WebVRController>;
  19650. /**
  19651. * Casts a ray forward from the vrCamera's gaze.
  19652. * @param length Length of the ray (default: 100)
  19653. * @returns the ray corresponding to the gaze
  19654. */
  19655. getForwardRay(length?: number): Ray;
  19656. /**
  19657. * @hidden
  19658. * Updates the camera based on device's frame data
  19659. */
  19660. _checkInputs(): void;
  19661. /**
  19662. * Updates the poseControlled values based on the input device pose.
  19663. * @param poseData Pose coming from the device
  19664. */
  19665. updateFromDevice(poseData: DevicePose): void;
  19666. private _htmlElementAttached;
  19667. private _detachIfAttached;
  19668. /**
  19669. * WebVR's attach control will start broadcasting frames to the device.
  19670. * Note that in certain browsers (chrome for example) this function must be called
  19671. * within a user-interaction callback. Example:
  19672. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19673. *
  19674. * @param element html element to attach the vrDevice to
  19675. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19676. */
  19677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19678. /**
  19679. * Detaches the camera from the html element and disables VR
  19680. *
  19681. * @param element html element to detach from
  19682. */
  19683. detachControl(element: HTMLElement): void;
  19684. /**
  19685. * @returns the name of this class
  19686. */
  19687. getClassName(): string;
  19688. /**
  19689. * Calls resetPose on the vrDisplay
  19690. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19691. */
  19692. resetToCurrentRotation(): void;
  19693. /**
  19694. * @hidden
  19695. * Updates the rig cameras (left and right eye)
  19696. */
  19697. _updateRigCameras(): void;
  19698. private _workingVector;
  19699. private _oneVector;
  19700. private _workingMatrix;
  19701. private updateCacheCalled;
  19702. private _correctPositionIfNotTrackPosition;
  19703. /**
  19704. * @hidden
  19705. * Updates the cached values of the camera
  19706. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19707. */
  19708. _updateCache(ignoreParentClass?: boolean): void;
  19709. /**
  19710. * @hidden
  19711. * Get current device position in babylon world
  19712. */
  19713. _computeDevicePosition(): void;
  19714. /**
  19715. * Updates the current device position and rotation in the babylon world
  19716. */
  19717. update(): void;
  19718. /**
  19719. * @hidden
  19720. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19721. * @returns an identity matrix
  19722. */
  19723. _getViewMatrix(): Matrix;
  19724. private _tmpMatrix;
  19725. /**
  19726. * This function is called by the two RIG cameras.
  19727. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19728. * @hidden
  19729. */
  19730. _getWebVRViewMatrix(): Matrix;
  19731. /** @hidden */
  19732. _getWebVRProjectionMatrix(): Matrix;
  19733. private _onGamepadConnectedObserver;
  19734. private _onGamepadDisconnectedObserver;
  19735. private _updateCacheWhenTrackingDisabledObserver;
  19736. /**
  19737. * Initializes the controllers and their meshes
  19738. */
  19739. initControllers(): void;
  19740. }
  19741. }
  19742. declare module BABYLON {
  19743. /**
  19744. * Size options for a post process
  19745. */
  19746. export type PostProcessOptions = {
  19747. width: number;
  19748. height: number;
  19749. };
  19750. /**
  19751. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19752. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19753. */
  19754. export class PostProcess {
  19755. /** Name of the PostProcess. */
  19756. name: string;
  19757. /**
  19758. * Gets or sets the unique id of the post process
  19759. */
  19760. uniqueId: number;
  19761. /**
  19762. * Width of the texture to apply the post process on
  19763. */
  19764. width: number;
  19765. /**
  19766. * Height of the texture to apply the post process on
  19767. */
  19768. height: number;
  19769. /**
  19770. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19771. * @hidden
  19772. */
  19773. _outputTexture: Nullable<InternalTexture>;
  19774. /**
  19775. * Sampling mode used by the shader
  19776. * See https://doc.babylonjs.com/classes/3.1/texture
  19777. */
  19778. renderTargetSamplingMode: number;
  19779. /**
  19780. * Clear color to use when screen clearing
  19781. */
  19782. clearColor: Color4;
  19783. /**
  19784. * If the buffer needs to be cleared before applying the post process. (default: true)
  19785. * Should be set to false if shader will overwrite all previous pixels.
  19786. */
  19787. autoClear: boolean;
  19788. /**
  19789. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19790. */
  19791. alphaMode: number;
  19792. /**
  19793. * Sets the setAlphaBlendConstants of the babylon engine
  19794. */
  19795. alphaConstants: Color4;
  19796. /**
  19797. * Animations to be used for the post processing
  19798. */
  19799. animations: Animation[];
  19800. /**
  19801. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19802. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19803. */
  19804. enablePixelPerfectMode: boolean;
  19805. /**
  19806. * Force the postprocess to be applied without taking in account viewport
  19807. */
  19808. forceFullscreenViewport: boolean;
  19809. /**
  19810. * List of inspectable custom properties (used by the Inspector)
  19811. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19812. */
  19813. inspectableCustomProperties: IInspectable[];
  19814. /**
  19815. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19816. *
  19817. * | Value | Type | Description |
  19818. * | ----- | ----------------------------------- | ----------- |
  19819. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19820. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19821. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19822. *
  19823. */
  19824. scaleMode: number;
  19825. /**
  19826. * Force textures to be a power of two (default: false)
  19827. */
  19828. alwaysForcePOT: boolean;
  19829. private _samples;
  19830. /**
  19831. * Number of sample textures (default: 1)
  19832. */
  19833. get samples(): number;
  19834. set samples(n: number);
  19835. /**
  19836. * Modify the scale of the post process to be the same as the viewport (default: false)
  19837. */
  19838. adaptScaleToCurrentViewport: boolean;
  19839. private _camera;
  19840. private _scene;
  19841. private _engine;
  19842. private _options;
  19843. private _reusable;
  19844. private _textureType;
  19845. private _textureFormat;
  19846. /**
  19847. * Smart array of input and output textures for the post process.
  19848. * @hidden
  19849. */
  19850. _textures: SmartArray<InternalTexture>;
  19851. /**
  19852. * The index in _textures that corresponds to the output texture.
  19853. * @hidden
  19854. */
  19855. _currentRenderTextureInd: number;
  19856. private _effect;
  19857. private _samplers;
  19858. private _fragmentUrl;
  19859. private _vertexUrl;
  19860. private _parameters;
  19861. private _scaleRatio;
  19862. protected _indexParameters: any;
  19863. private _shareOutputWithPostProcess;
  19864. private _texelSize;
  19865. private _forcedOutputTexture;
  19866. /**
  19867. * Returns the fragment url or shader name used in the post process.
  19868. * @returns the fragment url or name in the shader store.
  19869. */
  19870. getEffectName(): string;
  19871. /**
  19872. * An event triggered when the postprocess is activated.
  19873. */
  19874. onActivateObservable: Observable<Camera>;
  19875. private _onActivateObserver;
  19876. /**
  19877. * A function that is added to the onActivateObservable
  19878. */
  19879. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19880. /**
  19881. * An event triggered when the postprocess changes its size.
  19882. */
  19883. onSizeChangedObservable: Observable<PostProcess>;
  19884. private _onSizeChangedObserver;
  19885. /**
  19886. * A function that is added to the onSizeChangedObservable
  19887. */
  19888. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19889. /**
  19890. * An event triggered when the postprocess applies its effect.
  19891. */
  19892. onApplyObservable: Observable<Effect>;
  19893. private _onApplyObserver;
  19894. /**
  19895. * A function that is added to the onApplyObservable
  19896. */
  19897. set onApply(callback: (effect: Effect) => void);
  19898. /**
  19899. * An event triggered before rendering the postprocess
  19900. */
  19901. onBeforeRenderObservable: Observable<Effect>;
  19902. private _onBeforeRenderObserver;
  19903. /**
  19904. * A function that is added to the onBeforeRenderObservable
  19905. */
  19906. set onBeforeRender(callback: (effect: Effect) => void);
  19907. /**
  19908. * An event triggered after rendering the postprocess
  19909. */
  19910. onAfterRenderObservable: Observable<Effect>;
  19911. private _onAfterRenderObserver;
  19912. /**
  19913. * A function that is added to the onAfterRenderObservable
  19914. */
  19915. set onAfterRender(callback: (efect: Effect) => void);
  19916. /**
  19917. * 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
  19918. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19919. */
  19920. get inputTexture(): InternalTexture;
  19921. set inputTexture(value: InternalTexture);
  19922. /**
  19923. * Gets the camera which post process is applied to.
  19924. * @returns The camera the post process is applied to.
  19925. */
  19926. getCamera(): Camera;
  19927. /**
  19928. * Gets the texel size of the postprocess.
  19929. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19930. */
  19931. get texelSize(): Vector2;
  19932. /**
  19933. * Creates a new instance PostProcess
  19934. * @param name The name of the PostProcess.
  19935. * @param fragmentUrl The url of the fragment shader to be used.
  19936. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19937. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19938. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19939. * @param camera The camera to apply the render pass to.
  19940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19941. * @param engine The engine which the post process will be applied. (default: current engine)
  19942. * @param reusable If the post process can be reused on the same frame. (default: false)
  19943. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19944. * @param textureType Type of textures used when performing the post process. (default: 0)
  19945. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19946. * @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
  19947. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19948. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19949. */
  19950. constructor(
  19951. /** Name of the PostProcess. */
  19952. 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);
  19953. /**
  19954. * Gets a string idenfifying the name of the class
  19955. * @returns "PostProcess" string
  19956. */
  19957. getClassName(): string;
  19958. /**
  19959. * Gets the engine which this post process belongs to.
  19960. * @returns The engine the post process was enabled with.
  19961. */
  19962. getEngine(): Engine;
  19963. /**
  19964. * The effect that is created when initializing the post process.
  19965. * @returns The created effect corresponding the the postprocess.
  19966. */
  19967. getEffect(): Effect;
  19968. /**
  19969. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19970. * @param postProcess The post process to share the output with.
  19971. * @returns This post process.
  19972. */
  19973. shareOutputWith(postProcess: PostProcess): PostProcess;
  19974. /**
  19975. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19976. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19977. */
  19978. useOwnOutput(): void;
  19979. /**
  19980. * Updates the effect with the current post process compile time values and recompiles the shader.
  19981. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19982. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19983. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19984. * @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
  19985. * @param onCompiled Called when the shader has been compiled.
  19986. * @param onError Called if there is an error when compiling a shader.
  19987. */
  19988. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19989. /**
  19990. * The post process is reusable if it can be used multiple times within one frame.
  19991. * @returns If the post process is reusable
  19992. */
  19993. isReusable(): boolean;
  19994. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19995. markTextureDirty(): void;
  19996. /**
  19997. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19998. * 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.
  19999. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20000. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20001. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20002. * @returns The target texture that was bound to be written to.
  20003. */
  20004. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20005. /**
  20006. * If the post process is supported.
  20007. */
  20008. get isSupported(): boolean;
  20009. /**
  20010. * The aspect ratio of the output texture.
  20011. */
  20012. get aspectRatio(): number;
  20013. /**
  20014. * Get a value indicating if the post-process is ready to be used
  20015. * @returns true if the post-process is ready (shader is compiled)
  20016. */
  20017. isReady(): boolean;
  20018. /**
  20019. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20020. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20021. */
  20022. apply(): Nullable<Effect>;
  20023. private _disposeTextures;
  20024. /**
  20025. * Disposes the post process.
  20026. * @param camera The camera to dispose the post process on.
  20027. */
  20028. dispose(camera?: Camera): void;
  20029. }
  20030. }
  20031. declare module BABYLON {
  20032. /** @hidden */
  20033. export var kernelBlurVaryingDeclaration: {
  20034. name: string;
  20035. shader: string;
  20036. };
  20037. }
  20038. declare module BABYLON {
  20039. /** @hidden */
  20040. export var kernelBlurFragment: {
  20041. name: string;
  20042. shader: string;
  20043. };
  20044. }
  20045. declare module BABYLON {
  20046. /** @hidden */
  20047. export var kernelBlurFragment2: {
  20048. name: string;
  20049. shader: string;
  20050. };
  20051. }
  20052. declare module BABYLON {
  20053. /** @hidden */
  20054. export var kernelBlurPixelShader: {
  20055. name: string;
  20056. shader: string;
  20057. };
  20058. }
  20059. declare module BABYLON {
  20060. /** @hidden */
  20061. export var kernelBlurVertex: {
  20062. name: string;
  20063. shader: string;
  20064. };
  20065. }
  20066. declare module BABYLON {
  20067. /** @hidden */
  20068. export var kernelBlurVertexShader: {
  20069. name: string;
  20070. shader: string;
  20071. };
  20072. }
  20073. declare module BABYLON {
  20074. /**
  20075. * The Blur Post Process which blurs an image based on a kernel and direction.
  20076. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20077. */
  20078. export class BlurPostProcess extends PostProcess {
  20079. /** The direction in which to blur the image. */
  20080. direction: Vector2;
  20081. private blockCompilation;
  20082. protected _kernel: number;
  20083. protected _idealKernel: number;
  20084. protected _packedFloat: boolean;
  20085. private _staticDefines;
  20086. /**
  20087. * Sets the length in pixels of the blur sample region
  20088. */
  20089. set kernel(v: number);
  20090. /**
  20091. * Gets the length in pixels of the blur sample region
  20092. */
  20093. get kernel(): number;
  20094. /**
  20095. * Sets wether or not the blur needs to unpack/repack floats
  20096. */
  20097. set packedFloat(v: boolean);
  20098. /**
  20099. * Gets wether or not the blur is unpacking/repacking floats
  20100. */
  20101. get packedFloat(): boolean;
  20102. /**
  20103. * Creates a new instance BlurPostProcess
  20104. * @param name The name of the effect.
  20105. * @param direction The direction in which to blur the image.
  20106. * @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.
  20107. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20108. * @param camera The camera to apply the render pass to.
  20109. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20110. * @param engine The engine which the post process will be applied. (default: current engine)
  20111. * @param reusable If the post process can be reused on the same frame. (default: false)
  20112. * @param textureType Type of textures used when performing the post process. (default: 0)
  20113. * @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)
  20114. */
  20115. constructor(name: string,
  20116. /** The direction in which to blur the image. */
  20117. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20118. /**
  20119. * Updates the effect with the current post process compile time values and recompiles the shader.
  20120. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20121. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20122. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20123. * @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
  20124. * @param onCompiled Called when the shader has been compiled.
  20125. * @param onError Called if there is an error when compiling a shader.
  20126. */
  20127. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20128. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20129. /**
  20130. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20131. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20132. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20133. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20134. * The gaps between physical kernels are compensated for in the weighting of the samples
  20135. * @param idealKernel Ideal blur kernel.
  20136. * @return Nearest best kernel.
  20137. */
  20138. protected _nearestBestKernel(idealKernel: number): number;
  20139. /**
  20140. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20141. * @param x The point on the Gaussian distribution to sample.
  20142. * @return the value of the Gaussian function at x.
  20143. */
  20144. protected _gaussianWeight(x: number): number;
  20145. /**
  20146. * Generates a string that can be used as a floating point number in GLSL.
  20147. * @param x Value to print.
  20148. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20149. * @return GLSL float string.
  20150. */
  20151. protected _glslFloat(x: number, decimalFigures?: number): string;
  20152. }
  20153. }
  20154. declare module BABYLON {
  20155. /**
  20156. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20157. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20158. * You can then easily use it as a reflectionTexture on a flat surface.
  20159. * In case the surface is not a plane, please consider relying on reflection probes.
  20160. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20161. */
  20162. export class MirrorTexture extends RenderTargetTexture {
  20163. private scene;
  20164. /**
  20165. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20166. * 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.
  20167. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20168. */
  20169. mirrorPlane: Plane;
  20170. /**
  20171. * Define the blur ratio used to blur the reflection if needed.
  20172. */
  20173. set blurRatio(value: number);
  20174. get blurRatio(): number;
  20175. /**
  20176. * Define the adaptive blur kernel used to blur the reflection if needed.
  20177. * This will autocompute the closest best match for the `blurKernel`
  20178. */
  20179. set adaptiveBlurKernel(value: number);
  20180. /**
  20181. * Define the blur kernel used to blur the reflection if needed.
  20182. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20183. */
  20184. set blurKernel(value: number);
  20185. /**
  20186. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20187. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20188. */
  20189. set blurKernelX(value: number);
  20190. get blurKernelX(): number;
  20191. /**
  20192. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20193. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20194. */
  20195. set blurKernelY(value: number);
  20196. get blurKernelY(): number;
  20197. private _autoComputeBlurKernel;
  20198. protected _onRatioRescale(): void;
  20199. private _updateGammaSpace;
  20200. private _imageProcessingConfigChangeObserver;
  20201. private _transformMatrix;
  20202. private _mirrorMatrix;
  20203. private _savedViewMatrix;
  20204. private _blurX;
  20205. private _blurY;
  20206. private _adaptiveBlurKernel;
  20207. private _blurKernelX;
  20208. private _blurKernelY;
  20209. private _blurRatio;
  20210. /**
  20211. * Instantiates a Mirror Texture.
  20212. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20213. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20214. * You can then easily use it as a reflectionTexture on a flat surface.
  20215. * In case the surface is not a plane, please consider relying on reflection probes.
  20216. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20217. * @param name
  20218. * @param size
  20219. * @param scene
  20220. * @param generateMipMaps
  20221. * @param type
  20222. * @param samplingMode
  20223. * @param generateDepthBuffer
  20224. */
  20225. constructor(name: string, size: number | {
  20226. width: number;
  20227. height: number;
  20228. } | {
  20229. ratio: number;
  20230. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20231. private _preparePostProcesses;
  20232. /**
  20233. * Clone the mirror texture.
  20234. * @returns the cloned texture
  20235. */
  20236. clone(): MirrorTexture;
  20237. /**
  20238. * Serialize the texture to a JSON representation you could use in Parse later on
  20239. * @returns the serialized JSON representation
  20240. */
  20241. serialize(): any;
  20242. /**
  20243. * Dispose the texture and release its associated resources.
  20244. */
  20245. dispose(): void;
  20246. }
  20247. }
  20248. declare module BABYLON {
  20249. /**
  20250. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20251. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20252. */
  20253. export class Texture extends BaseTexture {
  20254. /**
  20255. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20256. */
  20257. static SerializeBuffers: boolean;
  20258. /** @hidden */
  20259. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20260. /** @hidden */
  20261. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20262. /** @hidden */
  20263. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20264. /** nearest is mag = nearest and min = nearest and mip = linear */
  20265. static readonly NEAREST_SAMPLINGMODE: number;
  20266. /** nearest is mag = nearest and min = nearest and mip = linear */
  20267. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20268. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20269. static readonly BILINEAR_SAMPLINGMODE: number;
  20270. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20271. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20272. /** Trilinear is mag = linear and min = linear and mip = linear */
  20273. static readonly TRILINEAR_SAMPLINGMODE: number;
  20274. /** Trilinear is mag = linear and min = linear and mip = linear */
  20275. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20276. /** mag = nearest and min = nearest and mip = nearest */
  20277. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20278. /** mag = nearest and min = linear and mip = nearest */
  20279. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20280. /** mag = nearest and min = linear and mip = linear */
  20281. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20282. /** mag = nearest and min = linear and mip = none */
  20283. static readonly NEAREST_LINEAR: number;
  20284. /** mag = nearest and min = nearest and mip = none */
  20285. static readonly NEAREST_NEAREST: number;
  20286. /** mag = linear and min = nearest and mip = nearest */
  20287. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20288. /** mag = linear and min = nearest and mip = linear */
  20289. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20290. /** mag = linear and min = linear and mip = none */
  20291. static readonly LINEAR_LINEAR: number;
  20292. /** mag = linear and min = nearest and mip = none */
  20293. static readonly LINEAR_NEAREST: number;
  20294. /** Explicit coordinates mode */
  20295. static readonly EXPLICIT_MODE: number;
  20296. /** Spherical coordinates mode */
  20297. static readonly SPHERICAL_MODE: number;
  20298. /** Planar coordinates mode */
  20299. static readonly PLANAR_MODE: number;
  20300. /** Cubic coordinates mode */
  20301. static readonly CUBIC_MODE: number;
  20302. /** Projection coordinates mode */
  20303. static readonly PROJECTION_MODE: number;
  20304. /** Inverse Cubic coordinates mode */
  20305. static readonly SKYBOX_MODE: number;
  20306. /** Inverse Cubic coordinates mode */
  20307. static readonly INVCUBIC_MODE: number;
  20308. /** Equirectangular coordinates mode */
  20309. static readonly EQUIRECTANGULAR_MODE: number;
  20310. /** Equirectangular Fixed coordinates mode */
  20311. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20312. /** Equirectangular Fixed Mirrored coordinates mode */
  20313. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20314. /** Texture is not repeating outside of 0..1 UVs */
  20315. static readonly CLAMP_ADDRESSMODE: number;
  20316. /** Texture is repeating outside of 0..1 UVs */
  20317. static readonly WRAP_ADDRESSMODE: number;
  20318. /** Texture is repeating and mirrored */
  20319. static readonly MIRROR_ADDRESSMODE: number;
  20320. /**
  20321. * 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
  20322. */
  20323. static UseSerializedUrlIfAny: boolean;
  20324. /**
  20325. * Define the url of the texture.
  20326. */
  20327. url: Nullable<string>;
  20328. /**
  20329. * Define an offset on the texture to offset the u coordinates of the UVs
  20330. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20331. */
  20332. uOffset: number;
  20333. /**
  20334. * Define an offset on the texture to offset the v coordinates of the UVs
  20335. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20336. */
  20337. vOffset: number;
  20338. /**
  20339. * Define an offset on the texture to scale the u coordinates of the UVs
  20340. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20341. */
  20342. uScale: number;
  20343. /**
  20344. * Define an offset on the texture to scale the v coordinates of the UVs
  20345. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20346. */
  20347. vScale: number;
  20348. /**
  20349. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20350. * @see http://doc.babylonjs.com/how_to/more_materials
  20351. */
  20352. uAng: number;
  20353. /**
  20354. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20355. * @see http://doc.babylonjs.com/how_to/more_materials
  20356. */
  20357. vAng: number;
  20358. /**
  20359. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20360. * @see http://doc.babylonjs.com/how_to/more_materials
  20361. */
  20362. wAng: number;
  20363. /**
  20364. * Defines the center of rotation (U)
  20365. */
  20366. uRotationCenter: number;
  20367. /**
  20368. * Defines the center of rotation (V)
  20369. */
  20370. vRotationCenter: number;
  20371. /**
  20372. * Defines the center of rotation (W)
  20373. */
  20374. wRotationCenter: number;
  20375. /**
  20376. * Are mip maps generated for this texture or not.
  20377. */
  20378. get noMipmap(): boolean;
  20379. /**
  20380. * List of inspectable custom properties (used by the Inspector)
  20381. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20382. */
  20383. inspectableCustomProperties: Nullable<IInspectable[]>;
  20384. private _noMipmap;
  20385. /** @hidden */
  20386. _invertY: boolean;
  20387. private _rowGenerationMatrix;
  20388. private _cachedTextureMatrix;
  20389. private _projectionModeMatrix;
  20390. private _t0;
  20391. private _t1;
  20392. private _t2;
  20393. private _cachedUOffset;
  20394. private _cachedVOffset;
  20395. private _cachedUScale;
  20396. private _cachedVScale;
  20397. private _cachedUAng;
  20398. private _cachedVAng;
  20399. private _cachedWAng;
  20400. private _cachedProjectionMatrixId;
  20401. private _cachedCoordinatesMode;
  20402. /** @hidden */
  20403. protected _initialSamplingMode: number;
  20404. /** @hidden */
  20405. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20406. private _deleteBuffer;
  20407. protected _format: Nullable<number>;
  20408. private _delayedOnLoad;
  20409. private _delayedOnError;
  20410. private _mimeType?;
  20411. /**
  20412. * Observable triggered once the texture has been loaded.
  20413. */
  20414. onLoadObservable: Observable<Texture>;
  20415. protected _isBlocking: boolean;
  20416. /**
  20417. * Is the texture preventing material to render while loading.
  20418. * If false, a default texture will be used instead of the loading one during the preparation step.
  20419. */
  20420. set isBlocking(value: boolean);
  20421. get isBlocking(): boolean;
  20422. /**
  20423. * Get the current sampling mode associated with the texture.
  20424. */
  20425. get samplingMode(): number;
  20426. /**
  20427. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20428. */
  20429. get invertY(): boolean;
  20430. /**
  20431. * Instantiates a new texture.
  20432. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20433. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20434. * @param url defines the url of the picture to load as a texture
  20435. * @param scene defines the scene or engine the texture will belong to
  20436. * @param noMipmap defines if the texture will require mip maps or not
  20437. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20438. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20439. * @param onLoad defines a callback triggered when the texture has been loaded
  20440. * @param onError defines a callback triggered when an error occurred during the loading session
  20441. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20442. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20443. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20444. * @param mimeType defines an optional mime type information
  20445. */
  20446. 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);
  20447. /**
  20448. * Update the url (and optional buffer) of this texture if url was null during construction.
  20449. * @param url the url of the texture
  20450. * @param buffer the buffer of the texture (defaults to null)
  20451. * @param onLoad callback called when the texture is loaded (defaults to null)
  20452. */
  20453. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20454. /**
  20455. * Finish the loading sequence of a texture flagged as delayed load.
  20456. * @hidden
  20457. */
  20458. delayLoad(): void;
  20459. private _prepareRowForTextureGeneration;
  20460. /**
  20461. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20462. * @returns the transform matrix of the texture.
  20463. */
  20464. getTextureMatrix(uBase?: number): Matrix;
  20465. /**
  20466. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20467. * @returns The reflection texture transform
  20468. */
  20469. getReflectionTextureMatrix(): Matrix;
  20470. /**
  20471. * Clones the texture.
  20472. * @returns the cloned texture
  20473. */
  20474. clone(): Texture;
  20475. /**
  20476. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20477. * @returns The JSON representation of the texture
  20478. */
  20479. serialize(): any;
  20480. /**
  20481. * Get the current class name of the texture useful for serialization or dynamic coding.
  20482. * @returns "Texture"
  20483. */
  20484. getClassName(): string;
  20485. /**
  20486. * Dispose the texture and release its associated resources.
  20487. */
  20488. dispose(): void;
  20489. /**
  20490. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20491. * @param parsedTexture Define the JSON representation of the texture
  20492. * @param scene Define the scene the parsed texture should be instantiated in
  20493. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20494. * @returns The parsed texture if successful
  20495. */
  20496. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20497. /**
  20498. * Creates a texture from its base 64 representation.
  20499. * @param data Define the base64 payload without the data: prefix
  20500. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20501. * @param scene Define the scene the texture should belong to
  20502. * @param noMipmap Forces the texture to not create mip map information if true
  20503. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20504. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20505. * @param onLoad define a callback triggered when the texture has been loaded
  20506. * @param onError define a callback triggered when an error occurred during the loading session
  20507. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20508. * @returns the created texture
  20509. */
  20510. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20511. /**
  20512. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20513. * @param data Define the base64 payload without the data: prefix
  20514. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20515. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20516. * @param scene Define the scene the texture should belong to
  20517. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20518. * @param noMipmap Forces the texture to not create mip map information if true
  20519. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20520. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20521. * @param onLoad define a callback triggered when the texture has been loaded
  20522. * @param onError define a callback triggered when an error occurred during the loading session
  20523. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20524. * @returns the created texture
  20525. */
  20526. 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;
  20527. }
  20528. }
  20529. declare module BABYLON {
  20530. /**
  20531. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20532. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20533. */
  20534. export class PostProcessManager {
  20535. private _scene;
  20536. private _indexBuffer;
  20537. private _vertexBuffers;
  20538. /**
  20539. * Creates a new instance PostProcess
  20540. * @param scene The scene that the post process is associated with.
  20541. */
  20542. constructor(scene: Scene);
  20543. private _prepareBuffers;
  20544. private _buildIndexBuffer;
  20545. /**
  20546. * Rebuilds the vertex buffers of the manager.
  20547. * @hidden
  20548. */
  20549. _rebuild(): void;
  20550. /**
  20551. * Prepares a frame to be run through a post process.
  20552. * @param sourceTexture The input texture to the post procesess. (default: null)
  20553. * @param postProcesses An array of post processes to be run. (default: null)
  20554. * @returns True if the post processes were able to be run.
  20555. * @hidden
  20556. */
  20557. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20558. /**
  20559. * Manually render a set of post processes to a texture.
  20560. * @param postProcesses An array of post processes to be run.
  20561. * @param targetTexture The target texture to render to.
  20562. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20563. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20564. * @param lodLevel defines which lod of the texture to render to
  20565. */
  20566. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20567. /**
  20568. * Finalize the result of the output of the postprocesses.
  20569. * @param doNotPresent If true the result will not be displayed to the screen.
  20570. * @param targetTexture The target texture to render to.
  20571. * @param faceIndex The index of the face to bind the target texture to.
  20572. * @param postProcesses The array of post processes to render.
  20573. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20574. * @hidden
  20575. */
  20576. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20577. /**
  20578. * Disposes of the post process manager.
  20579. */
  20580. dispose(): void;
  20581. }
  20582. }
  20583. declare module BABYLON {
  20584. /**
  20585. * This Helps creating a texture that will be created from a camera in your scene.
  20586. * It is basically a dynamic texture that could be used to create special effects for instance.
  20587. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20588. */
  20589. export class RenderTargetTexture extends Texture {
  20590. isCube: boolean;
  20591. /**
  20592. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20593. */
  20594. static readonly REFRESHRATE_RENDER_ONCE: number;
  20595. /**
  20596. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20597. */
  20598. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20599. /**
  20600. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20601. * the central point of your effect and can save a lot of performances.
  20602. */
  20603. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20604. /**
  20605. * Use this predicate to dynamically define the list of mesh you want to render.
  20606. * If set, the renderList property will be overwritten.
  20607. */
  20608. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20609. private _renderList;
  20610. /**
  20611. * Use this list to define the list of mesh you want to render.
  20612. */
  20613. get renderList(): Nullable<Array<AbstractMesh>>;
  20614. set renderList(value: Nullable<Array<AbstractMesh>>);
  20615. /**
  20616. * Use this function to overload the renderList array at rendering time.
  20617. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20618. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20619. * the cube (if the RTT is a cube, else layerOrFace=0).
  20620. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  20621. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  20622. * hold dummy elements!
  20623. */
  20624. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  20625. private _hookArray;
  20626. /**
  20627. * Define if particles should be rendered in your texture.
  20628. */
  20629. renderParticles: boolean;
  20630. /**
  20631. * Define if sprites should be rendered in your texture.
  20632. */
  20633. renderSprites: boolean;
  20634. /**
  20635. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20636. */
  20637. coordinatesMode: number;
  20638. /**
  20639. * Define the camera used to render the texture.
  20640. */
  20641. activeCamera: Nullable<Camera>;
  20642. /**
  20643. * Override the mesh isReady function with your own one.
  20644. */
  20645. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  20646. /**
  20647. * Override the render function of the texture with your own one.
  20648. */
  20649. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20650. /**
  20651. * Define if camera post processes should be use while rendering the texture.
  20652. */
  20653. useCameraPostProcesses: boolean;
  20654. /**
  20655. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20656. */
  20657. ignoreCameraViewport: boolean;
  20658. private _postProcessManager;
  20659. private _postProcesses;
  20660. private _resizeObserver;
  20661. /**
  20662. * An event triggered when the texture is unbind.
  20663. */
  20664. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20665. /**
  20666. * An event triggered when the texture is unbind.
  20667. */
  20668. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20669. private _onAfterUnbindObserver;
  20670. /**
  20671. * Set a after unbind callback in the texture.
  20672. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20673. */
  20674. set onAfterUnbind(callback: () => void);
  20675. /**
  20676. * An event triggered before rendering the texture
  20677. */
  20678. onBeforeRenderObservable: Observable<number>;
  20679. private _onBeforeRenderObserver;
  20680. /**
  20681. * Set a before render callback in the texture.
  20682. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20683. */
  20684. set onBeforeRender(callback: (faceIndex: number) => void);
  20685. /**
  20686. * An event triggered after rendering the texture
  20687. */
  20688. onAfterRenderObservable: Observable<number>;
  20689. private _onAfterRenderObserver;
  20690. /**
  20691. * Set a after render callback in the texture.
  20692. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20693. */
  20694. set onAfterRender(callback: (faceIndex: number) => void);
  20695. /**
  20696. * An event triggered after the texture clear
  20697. */
  20698. onClearObservable: Observable<Engine>;
  20699. private _onClearObserver;
  20700. /**
  20701. * Set a clear callback in the texture.
  20702. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20703. */
  20704. set onClear(callback: (Engine: Engine) => void);
  20705. /**
  20706. * An event triggered when the texture is resized.
  20707. */
  20708. onResizeObservable: Observable<RenderTargetTexture>;
  20709. /**
  20710. * Define the clear color of the Render Target if it should be different from the scene.
  20711. */
  20712. clearColor: Color4;
  20713. protected _size: number | {
  20714. width: number;
  20715. height: number;
  20716. layers?: number;
  20717. };
  20718. protected _initialSizeParameter: number | {
  20719. width: number;
  20720. height: number;
  20721. } | {
  20722. ratio: number;
  20723. };
  20724. protected _sizeRatio: Nullable<number>;
  20725. /** @hidden */
  20726. _generateMipMaps: boolean;
  20727. protected _renderingManager: RenderingManager;
  20728. /** @hidden */
  20729. _waitingRenderList: string[];
  20730. protected _doNotChangeAspectRatio: boolean;
  20731. protected _currentRefreshId: number;
  20732. protected _refreshRate: number;
  20733. protected _textureMatrix: Matrix;
  20734. protected _samples: number;
  20735. protected _renderTargetOptions: RenderTargetCreationOptions;
  20736. /**
  20737. * Gets render target creation options that were used.
  20738. */
  20739. get renderTargetOptions(): RenderTargetCreationOptions;
  20740. protected _engine: Engine;
  20741. protected _onRatioRescale(): void;
  20742. /**
  20743. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20744. * It must define where the camera used to render the texture is set
  20745. */
  20746. boundingBoxPosition: Vector3;
  20747. private _boundingBoxSize;
  20748. /**
  20749. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20750. * When defined, the cubemap will switch to local mode
  20751. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20752. * @example https://www.babylonjs-playground.com/#RNASML
  20753. */
  20754. set boundingBoxSize(value: Vector3);
  20755. get boundingBoxSize(): Vector3;
  20756. /**
  20757. * In case the RTT has been created with a depth texture, get the associated
  20758. * depth texture.
  20759. * Otherwise, return null.
  20760. */
  20761. get depthStencilTexture(): Nullable<InternalTexture>;
  20762. /**
  20763. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20764. * or used a shadow, depth texture...
  20765. * @param name The friendly name of the texture
  20766. * @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)
  20767. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20768. * @param generateMipMaps True if mip maps need to be generated after render.
  20769. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20770. * @param type The type of the buffer in the RTT (int, half float, float...)
  20771. * @param isCube True if a cube texture needs to be created
  20772. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20773. * @param generateDepthBuffer True to generate a depth buffer
  20774. * @param generateStencilBuffer True to generate a stencil buffer
  20775. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20776. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20777. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20778. */
  20779. constructor(name: string, size: number | {
  20780. width: number;
  20781. height: number;
  20782. layers?: number;
  20783. } | {
  20784. ratio: number;
  20785. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20786. /**
  20787. * Creates a depth stencil texture.
  20788. * This is only available in WebGL 2 or with the depth texture extension available.
  20789. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20790. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20791. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20792. */
  20793. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20794. private _processSizeParameter;
  20795. /**
  20796. * Define the number of samples to use in case of MSAA.
  20797. * It defaults to one meaning no MSAA has been enabled.
  20798. */
  20799. get samples(): number;
  20800. set samples(value: number);
  20801. /**
  20802. * Resets the refresh counter of the texture and start bak from scratch.
  20803. * Could be useful to regenerate the texture if it is setup to render only once.
  20804. */
  20805. resetRefreshCounter(): void;
  20806. /**
  20807. * Define the refresh rate of the texture or the rendering frequency.
  20808. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20809. */
  20810. get refreshRate(): number;
  20811. set refreshRate(value: number);
  20812. /**
  20813. * Adds a post process to the render target rendering passes.
  20814. * @param postProcess define the post process to add
  20815. */
  20816. addPostProcess(postProcess: PostProcess): void;
  20817. /**
  20818. * Clear all the post processes attached to the render target
  20819. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20820. */
  20821. clearPostProcesses(dispose?: boolean): void;
  20822. /**
  20823. * Remove one of the post process from the list of attached post processes to the texture
  20824. * @param postProcess define the post process to remove from the list
  20825. */
  20826. removePostProcess(postProcess: PostProcess): void;
  20827. /** @hidden */
  20828. _shouldRender(): boolean;
  20829. /**
  20830. * Gets the actual render size of the texture.
  20831. * @returns the width of the render size
  20832. */
  20833. getRenderSize(): number;
  20834. /**
  20835. * Gets the actual render width of the texture.
  20836. * @returns the width of the render size
  20837. */
  20838. getRenderWidth(): number;
  20839. /**
  20840. * Gets the actual render height of the texture.
  20841. * @returns the height of the render size
  20842. */
  20843. getRenderHeight(): number;
  20844. /**
  20845. * Gets the actual number of layers of the texture.
  20846. * @returns the number of layers
  20847. */
  20848. getRenderLayers(): number;
  20849. /**
  20850. * Get if the texture can be rescaled or not.
  20851. */
  20852. get canRescale(): boolean;
  20853. /**
  20854. * Resize the texture using a ratio.
  20855. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20856. */
  20857. scale(ratio: number): void;
  20858. /**
  20859. * Get the texture reflection matrix used to rotate/transform the reflection.
  20860. * @returns the reflection matrix
  20861. */
  20862. getReflectionTextureMatrix(): Matrix;
  20863. /**
  20864. * Resize the texture to a new desired size.
  20865. * Be carrefull as it will recreate all the data in the new texture.
  20866. * @param size Define the new size. It can be:
  20867. * - a number for squared texture,
  20868. * - an object containing { width: number, height: number }
  20869. * - or an object containing a ratio { ratio: number }
  20870. */
  20871. resize(size: number | {
  20872. width: number;
  20873. height: number;
  20874. } | {
  20875. ratio: number;
  20876. }): void;
  20877. private _defaultRenderListPrepared;
  20878. /**
  20879. * Renders all the objects from the render list into the texture.
  20880. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20881. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20882. */
  20883. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20884. private _bestReflectionRenderTargetDimension;
  20885. private _prepareRenderingManager;
  20886. /**
  20887. * @hidden
  20888. * @param faceIndex face index to bind to if this is a cubetexture
  20889. * @param layer defines the index of the texture to bind in the array
  20890. */
  20891. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20892. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20893. private renderToTarget;
  20894. /**
  20895. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20896. * This allowed control for front to back rendering or reversly depending of the special needs.
  20897. *
  20898. * @param renderingGroupId The rendering group id corresponding to its index
  20899. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20900. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20901. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20902. */
  20903. 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;
  20904. /**
  20905. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20906. *
  20907. * @param renderingGroupId The rendering group id corresponding to its index
  20908. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20909. */
  20910. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20911. /**
  20912. * Clones the texture.
  20913. * @returns the cloned texture
  20914. */
  20915. clone(): RenderTargetTexture;
  20916. /**
  20917. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20918. * @returns The JSON representation of the texture
  20919. */
  20920. serialize(): any;
  20921. /**
  20922. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20923. */
  20924. disposeFramebufferObjects(): void;
  20925. /**
  20926. * Dispose the texture and release its associated resources.
  20927. */
  20928. dispose(): void;
  20929. /** @hidden */
  20930. _rebuild(): void;
  20931. /**
  20932. * Clear the info related to rendering groups preventing retention point in material dispose.
  20933. */
  20934. freeRenderingGroups(): void;
  20935. /**
  20936. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20937. * @returns the view count
  20938. */
  20939. getViewCount(): number;
  20940. }
  20941. }
  20942. declare module BABYLON {
  20943. /**
  20944. * Options for compiling materials.
  20945. */
  20946. export interface IMaterialCompilationOptions {
  20947. /**
  20948. * Defines whether clip planes are enabled.
  20949. */
  20950. clipPlane: boolean;
  20951. /**
  20952. * Defines whether instances are enabled.
  20953. */
  20954. useInstances: boolean;
  20955. }
  20956. /**
  20957. * Base class for the main features of a material in Babylon.js
  20958. */
  20959. export class Material implements IAnimatable {
  20960. /**
  20961. * Returns the triangle fill mode
  20962. */
  20963. static readonly TriangleFillMode: number;
  20964. /**
  20965. * Returns the wireframe mode
  20966. */
  20967. static readonly WireFrameFillMode: number;
  20968. /**
  20969. * Returns the point fill mode
  20970. */
  20971. static readonly PointFillMode: number;
  20972. /**
  20973. * Returns the point list draw mode
  20974. */
  20975. static readonly PointListDrawMode: number;
  20976. /**
  20977. * Returns the line list draw mode
  20978. */
  20979. static readonly LineListDrawMode: number;
  20980. /**
  20981. * Returns the line loop draw mode
  20982. */
  20983. static readonly LineLoopDrawMode: number;
  20984. /**
  20985. * Returns the line strip draw mode
  20986. */
  20987. static readonly LineStripDrawMode: number;
  20988. /**
  20989. * Returns the triangle strip draw mode
  20990. */
  20991. static readonly TriangleStripDrawMode: number;
  20992. /**
  20993. * Returns the triangle fan draw mode
  20994. */
  20995. static readonly TriangleFanDrawMode: number;
  20996. /**
  20997. * Stores the clock-wise side orientation
  20998. */
  20999. static readonly ClockWiseSideOrientation: number;
  21000. /**
  21001. * Stores the counter clock-wise side orientation
  21002. */
  21003. static readonly CounterClockWiseSideOrientation: number;
  21004. /**
  21005. * The dirty texture flag value
  21006. */
  21007. static readonly TextureDirtyFlag: number;
  21008. /**
  21009. * The dirty light flag value
  21010. */
  21011. static readonly LightDirtyFlag: number;
  21012. /**
  21013. * The dirty fresnel flag value
  21014. */
  21015. static readonly FresnelDirtyFlag: number;
  21016. /**
  21017. * The dirty attribute flag value
  21018. */
  21019. static readonly AttributesDirtyFlag: number;
  21020. /**
  21021. * The dirty misc flag value
  21022. */
  21023. static readonly MiscDirtyFlag: number;
  21024. /**
  21025. * The all dirty flag value
  21026. */
  21027. static readonly AllDirtyFlag: number;
  21028. /**
  21029. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21030. */
  21031. static readonly MATERIAL_OPAQUE: number;
  21032. /**
  21033. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21034. */
  21035. static readonly MATERIAL_ALPHATEST: number;
  21036. /**
  21037. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21038. */
  21039. static readonly MATERIAL_ALPHABLEND: number;
  21040. /**
  21041. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21042. * They are also discarded below the alpha cutoff threshold to improve performances.
  21043. */
  21044. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  21045. /**
  21046. * The ID of the material
  21047. */
  21048. id: string;
  21049. /**
  21050. * Gets or sets the unique id of the material
  21051. */
  21052. uniqueId: number;
  21053. /**
  21054. * The name of the material
  21055. */
  21056. name: string;
  21057. /**
  21058. * Gets or sets user defined metadata
  21059. */
  21060. metadata: any;
  21061. /**
  21062. * For internal use only. Please do not use.
  21063. */
  21064. reservedDataStore: any;
  21065. /**
  21066. * Specifies if the ready state should be checked on each call
  21067. */
  21068. checkReadyOnEveryCall: boolean;
  21069. /**
  21070. * Specifies if the ready state should be checked once
  21071. */
  21072. checkReadyOnlyOnce: boolean;
  21073. /**
  21074. * The state of the material
  21075. */
  21076. state: string;
  21077. /**
  21078. * The alpha value of the material
  21079. */
  21080. protected _alpha: number;
  21081. /**
  21082. * List of inspectable custom properties (used by the Inspector)
  21083. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21084. */
  21085. inspectableCustomProperties: IInspectable[];
  21086. /**
  21087. * Sets the alpha value of the material
  21088. */
  21089. set alpha(value: number);
  21090. /**
  21091. * Gets the alpha value of the material
  21092. */
  21093. get alpha(): number;
  21094. /**
  21095. * Specifies if back face culling is enabled
  21096. */
  21097. protected _backFaceCulling: boolean;
  21098. /**
  21099. * Sets the back-face culling state
  21100. */
  21101. set backFaceCulling(value: boolean);
  21102. /**
  21103. * Gets the back-face culling state
  21104. */
  21105. get backFaceCulling(): boolean;
  21106. /**
  21107. * Stores the value for side orientation
  21108. */
  21109. sideOrientation: number;
  21110. /**
  21111. * Callback triggered when the material is compiled
  21112. */
  21113. onCompiled: Nullable<(effect: Effect) => void>;
  21114. /**
  21115. * Callback triggered when an error occurs
  21116. */
  21117. onError: Nullable<(effect: Effect, errors: string) => void>;
  21118. /**
  21119. * Callback triggered to get the render target textures
  21120. */
  21121. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21122. /**
  21123. * Gets a boolean indicating that current material needs to register RTT
  21124. */
  21125. get hasRenderTargetTextures(): boolean;
  21126. /**
  21127. * Specifies if the material should be serialized
  21128. */
  21129. doNotSerialize: boolean;
  21130. /**
  21131. * @hidden
  21132. */
  21133. _storeEffectOnSubMeshes: boolean;
  21134. /**
  21135. * Stores the animations for the material
  21136. */
  21137. animations: Nullable<Array<Animation>>;
  21138. /**
  21139. * An event triggered when the material is disposed
  21140. */
  21141. onDisposeObservable: Observable<Material>;
  21142. /**
  21143. * An observer which watches for dispose events
  21144. */
  21145. private _onDisposeObserver;
  21146. private _onUnBindObservable;
  21147. /**
  21148. * Called during a dispose event
  21149. */
  21150. set onDispose(callback: () => void);
  21151. private _onBindObservable;
  21152. /**
  21153. * An event triggered when the material is bound
  21154. */
  21155. get onBindObservable(): Observable<AbstractMesh>;
  21156. /**
  21157. * An observer which watches for bind events
  21158. */
  21159. private _onBindObserver;
  21160. /**
  21161. * Called during a bind event
  21162. */
  21163. set onBind(callback: (Mesh: AbstractMesh) => void);
  21164. /**
  21165. * An event triggered when the material is unbound
  21166. */
  21167. get onUnBindObservable(): Observable<Material>;
  21168. /**
  21169. * Stores the value of the alpha mode
  21170. */
  21171. private _alphaMode;
  21172. /**
  21173. * Sets the value of the alpha mode.
  21174. *
  21175. * | Value | Type | Description |
  21176. * | --- | --- | --- |
  21177. * | 0 | ALPHA_DISABLE | |
  21178. * | 1 | ALPHA_ADD | |
  21179. * | 2 | ALPHA_COMBINE | |
  21180. * | 3 | ALPHA_SUBTRACT | |
  21181. * | 4 | ALPHA_MULTIPLY | |
  21182. * | 5 | ALPHA_MAXIMIZED | |
  21183. * | 6 | ALPHA_ONEONE | |
  21184. * | 7 | ALPHA_PREMULTIPLIED | |
  21185. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21186. * | 9 | ALPHA_INTERPOLATE | |
  21187. * | 10 | ALPHA_SCREENMODE | |
  21188. *
  21189. */
  21190. set alphaMode(value: number);
  21191. /**
  21192. * Gets the value of the alpha mode
  21193. */
  21194. get alphaMode(): number;
  21195. /**
  21196. * Stores the state of the need depth pre-pass value
  21197. */
  21198. private _needDepthPrePass;
  21199. /**
  21200. * Sets the need depth pre-pass value
  21201. */
  21202. set needDepthPrePass(value: boolean);
  21203. /**
  21204. * Gets the depth pre-pass value
  21205. */
  21206. get needDepthPrePass(): boolean;
  21207. /**
  21208. * Specifies if depth writing should be disabled
  21209. */
  21210. disableDepthWrite: boolean;
  21211. /**
  21212. * Specifies if depth writing should be forced
  21213. */
  21214. forceDepthWrite: boolean;
  21215. /**
  21216. * Specifies the depth function that should be used. 0 means the default engine function
  21217. */
  21218. depthFunction: number;
  21219. /**
  21220. * Specifies if there should be a separate pass for culling
  21221. */
  21222. separateCullingPass: boolean;
  21223. /**
  21224. * Stores the state specifing if fog should be enabled
  21225. */
  21226. private _fogEnabled;
  21227. /**
  21228. * Sets the state for enabling fog
  21229. */
  21230. set fogEnabled(value: boolean);
  21231. /**
  21232. * Gets the value of the fog enabled state
  21233. */
  21234. get fogEnabled(): boolean;
  21235. /**
  21236. * Stores the size of points
  21237. */
  21238. pointSize: number;
  21239. /**
  21240. * Stores the z offset value
  21241. */
  21242. zOffset: number;
  21243. /**
  21244. * Gets a value specifying if wireframe mode is enabled
  21245. */
  21246. get wireframe(): boolean;
  21247. /**
  21248. * Sets the state of wireframe mode
  21249. */
  21250. set wireframe(value: boolean);
  21251. /**
  21252. * Gets the value specifying if point clouds are enabled
  21253. */
  21254. get pointsCloud(): boolean;
  21255. /**
  21256. * Sets the state of point cloud mode
  21257. */
  21258. set pointsCloud(value: boolean);
  21259. /**
  21260. * Gets the material fill mode
  21261. */
  21262. get fillMode(): number;
  21263. /**
  21264. * Sets the material fill mode
  21265. */
  21266. set fillMode(value: number);
  21267. /**
  21268. * @hidden
  21269. * Stores the effects for the material
  21270. */
  21271. _effect: Nullable<Effect>;
  21272. /**
  21273. * Specifies if uniform buffers should be used
  21274. */
  21275. private _useUBO;
  21276. /**
  21277. * Stores a reference to the scene
  21278. */
  21279. private _scene;
  21280. /**
  21281. * Stores the fill mode state
  21282. */
  21283. private _fillMode;
  21284. /**
  21285. * Specifies if the depth write state should be cached
  21286. */
  21287. private _cachedDepthWriteState;
  21288. /**
  21289. * Specifies if the depth function state should be cached
  21290. */
  21291. private _cachedDepthFunctionState;
  21292. /**
  21293. * Stores the uniform buffer
  21294. */
  21295. protected _uniformBuffer: UniformBuffer;
  21296. /** @hidden */
  21297. _indexInSceneMaterialArray: number;
  21298. /** @hidden */
  21299. meshMap: Nullable<{
  21300. [id: string]: AbstractMesh | undefined;
  21301. }>;
  21302. /**
  21303. * Creates a material instance
  21304. * @param name defines the name of the material
  21305. * @param scene defines the scene to reference
  21306. * @param doNotAdd specifies if the material should be added to the scene
  21307. */
  21308. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21309. /**
  21310. * Returns a string representation of the current material
  21311. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21312. * @returns a string with material information
  21313. */
  21314. toString(fullDetails?: boolean): string;
  21315. /**
  21316. * Gets the class name of the material
  21317. * @returns a string with the class name of the material
  21318. */
  21319. getClassName(): string;
  21320. /**
  21321. * Specifies if updates for the material been locked
  21322. */
  21323. get isFrozen(): boolean;
  21324. /**
  21325. * Locks updates for the material
  21326. */
  21327. freeze(): void;
  21328. /**
  21329. * Unlocks updates for the material
  21330. */
  21331. unfreeze(): void;
  21332. /**
  21333. * Specifies if the material is ready to be used
  21334. * @param mesh defines the mesh to check
  21335. * @param useInstances specifies if instances should be used
  21336. * @returns a boolean indicating if the material is ready to be used
  21337. */
  21338. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21339. /**
  21340. * Specifies that the submesh is ready to be used
  21341. * @param mesh defines the mesh to check
  21342. * @param subMesh defines which submesh to check
  21343. * @param useInstances specifies that instances should be used
  21344. * @returns a boolean indicating that the submesh is ready or not
  21345. */
  21346. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21347. /**
  21348. * Returns the material effect
  21349. * @returns the effect associated with the material
  21350. */
  21351. getEffect(): Nullable<Effect>;
  21352. /**
  21353. * Returns the current scene
  21354. * @returns a Scene
  21355. */
  21356. getScene(): Scene;
  21357. /**
  21358. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21359. */
  21360. protected _forceAlphaTest: boolean;
  21361. /**
  21362. * The transparency mode of the material.
  21363. */
  21364. protected _transparencyMode: Nullable<number>;
  21365. /**
  21366. * Gets the current transparency mode.
  21367. */
  21368. get transparencyMode(): Nullable<number>;
  21369. /**
  21370. * Sets the transparency mode of the material.
  21371. *
  21372. * | Value | Type | Description |
  21373. * | ----- | ----------------------------------- | ----------- |
  21374. * | 0 | OPAQUE | |
  21375. * | 1 | ALPHATEST | |
  21376. * | 2 | ALPHABLEND | |
  21377. * | 3 | ALPHATESTANDBLEND | |
  21378. *
  21379. */
  21380. set transparencyMode(value: Nullable<number>);
  21381. /**
  21382. * Returns true if alpha blending should be disabled.
  21383. */
  21384. protected get _disableAlphaBlending(): boolean;
  21385. /**
  21386. * Specifies whether or not this material should be rendered in alpha blend mode.
  21387. * @returns a boolean specifying if alpha blending is needed
  21388. */
  21389. needAlphaBlending(): boolean;
  21390. /**
  21391. * Specifies if the mesh will require alpha blending
  21392. * @param mesh defines the mesh to check
  21393. * @returns a boolean specifying if alpha blending is needed for the mesh
  21394. */
  21395. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21396. /**
  21397. * Specifies whether or not this material should be rendered in alpha test mode.
  21398. * @returns a boolean specifying if an alpha test is needed.
  21399. */
  21400. needAlphaTesting(): boolean;
  21401. /**
  21402. * Specifies if material alpha testing should be turned on for the mesh
  21403. * @param mesh defines the mesh to check
  21404. */
  21405. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21406. /**
  21407. * Gets the texture used for the alpha test
  21408. * @returns the texture to use for alpha testing
  21409. */
  21410. getAlphaTestTexture(): Nullable<BaseTexture>;
  21411. /**
  21412. * Marks the material to indicate that it needs to be re-calculated
  21413. */
  21414. markDirty(): void;
  21415. /** @hidden */
  21416. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21417. /**
  21418. * Binds the material to the mesh
  21419. * @param world defines the world transformation matrix
  21420. * @param mesh defines the mesh to bind the material to
  21421. */
  21422. bind(world: Matrix, mesh?: Mesh): void;
  21423. /**
  21424. * Binds the submesh to the material
  21425. * @param world defines the world transformation matrix
  21426. * @param mesh defines the mesh containing the submesh
  21427. * @param subMesh defines the submesh to bind the material to
  21428. */
  21429. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21430. /**
  21431. * Binds the world matrix to the material
  21432. * @param world defines the world transformation matrix
  21433. */
  21434. bindOnlyWorldMatrix(world: Matrix): void;
  21435. /**
  21436. * Binds the scene's uniform buffer to the effect.
  21437. * @param effect defines the effect to bind to the scene uniform buffer
  21438. * @param sceneUbo defines the uniform buffer storing scene data
  21439. */
  21440. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21441. /**
  21442. * Binds the view matrix to the effect
  21443. * @param effect defines the effect to bind the view matrix to
  21444. */
  21445. bindView(effect: Effect): void;
  21446. /**
  21447. * Binds the view projection matrix to the effect
  21448. * @param effect defines the effect to bind the view projection matrix to
  21449. */
  21450. bindViewProjection(effect: Effect): void;
  21451. /**
  21452. * Processes to execute after binding the material to a mesh
  21453. * @param mesh defines the rendered mesh
  21454. */
  21455. protected _afterBind(mesh?: Mesh): void;
  21456. /**
  21457. * Unbinds the material from the mesh
  21458. */
  21459. unbind(): void;
  21460. /**
  21461. * Gets the active textures from the material
  21462. * @returns an array of textures
  21463. */
  21464. getActiveTextures(): BaseTexture[];
  21465. /**
  21466. * Specifies if the material uses a texture
  21467. * @param texture defines the texture to check against the material
  21468. * @returns a boolean specifying if the material uses the texture
  21469. */
  21470. hasTexture(texture: BaseTexture): boolean;
  21471. /**
  21472. * Makes a duplicate of the material, and gives it a new name
  21473. * @param name defines the new name for the duplicated material
  21474. * @returns the cloned material
  21475. */
  21476. clone(name: string): Nullable<Material>;
  21477. /**
  21478. * Gets the meshes bound to the material
  21479. * @returns an array of meshes bound to the material
  21480. */
  21481. getBindedMeshes(): AbstractMesh[];
  21482. /**
  21483. * Force shader compilation
  21484. * @param mesh defines the mesh associated with this material
  21485. * @param onCompiled defines a function to execute once the material is compiled
  21486. * @param options defines the options to configure the compilation
  21487. * @param onError defines a function to execute if the material fails compiling
  21488. */
  21489. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21490. /**
  21491. * Force shader compilation
  21492. * @param mesh defines the mesh that will use this material
  21493. * @param options defines additional options for compiling the shaders
  21494. * @returns a promise that resolves when the compilation completes
  21495. */
  21496. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21497. private static readonly _AllDirtyCallBack;
  21498. private static readonly _ImageProcessingDirtyCallBack;
  21499. private static readonly _TextureDirtyCallBack;
  21500. private static readonly _FresnelDirtyCallBack;
  21501. private static readonly _MiscDirtyCallBack;
  21502. private static readonly _LightsDirtyCallBack;
  21503. private static readonly _AttributeDirtyCallBack;
  21504. private static _FresnelAndMiscDirtyCallBack;
  21505. private static _TextureAndMiscDirtyCallBack;
  21506. private static readonly _DirtyCallbackArray;
  21507. private static readonly _RunDirtyCallBacks;
  21508. /**
  21509. * Marks a define in the material to indicate that it needs to be re-computed
  21510. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21511. */
  21512. markAsDirty(flag: number): void;
  21513. /**
  21514. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21515. * @param func defines a function which checks material defines against the submeshes
  21516. */
  21517. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21518. /**
  21519. * Indicates that we need to re-calculated for all submeshes
  21520. */
  21521. protected _markAllSubMeshesAsAllDirty(): void;
  21522. /**
  21523. * Indicates that image processing needs to be re-calculated for all submeshes
  21524. */
  21525. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21526. /**
  21527. * Indicates that textures need to be re-calculated for all submeshes
  21528. */
  21529. protected _markAllSubMeshesAsTexturesDirty(): void;
  21530. /**
  21531. * Indicates that fresnel needs to be re-calculated for all submeshes
  21532. */
  21533. protected _markAllSubMeshesAsFresnelDirty(): void;
  21534. /**
  21535. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21536. */
  21537. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21538. /**
  21539. * Indicates that lights need to be re-calculated for all submeshes
  21540. */
  21541. protected _markAllSubMeshesAsLightsDirty(): void;
  21542. /**
  21543. * Indicates that attributes need to be re-calculated for all submeshes
  21544. */
  21545. protected _markAllSubMeshesAsAttributesDirty(): void;
  21546. /**
  21547. * Indicates that misc needs to be re-calculated for all submeshes
  21548. */
  21549. protected _markAllSubMeshesAsMiscDirty(): void;
  21550. /**
  21551. * Indicates that textures and misc need to be re-calculated for all submeshes
  21552. */
  21553. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21554. /**
  21555. * Disposes the material
  21556. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21557. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21558. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21559. */
  21560. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21561. /** @hidden */
  21562. private releaseVertexArrayObject;
  21563. /**
  21564. * Serializes this material
  21565. * @returns the serialized material object
  21566. */
  21567. serialize(): any;
  21568. /**
  21569. * Creates a material from parsed material data
  21570. * @param parsedMaterial defines parsed material data
  21571. * @param scene defines the hosting scene
  21572. * @param rootUrl defines the root URL to use to load textures
  21573. * @returns a new material
  21574. */
  21575. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21576. }
  21577. }
  21578. declare module BABYLON {
  21579. /**
  21580. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21581. * separate meshes. This can be use to improve performances.
  21582. * @see http://doc.babylonjs.com/how_to/multi_materials
  21583. */
  21584. export class MultiMaterial extends Material {
  21585. private _subMaterials;
  21586. /**
  21587. * Gets or Sets the list of Materials used within the multi material.
  21588. * They need to be ordered according to the submeshes order in the associated mesh
  21589. */
  21590. get subMaterials(): Nullable<Material>[];
  21591. set subMaterials(value: Nullable<Material>[]);
  21592. /**
  21593. * Function used to align with Node.getChildren()
  21594. * @returns the list of Materials used within the multi material
  21595. */
  21596. getChildren(): Nullable<Material>[];
  21597. /**
  21598. * Instantiates a new Multi Material
  21599. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21600. * separate meshes. This can be use to improve performances.
  21601. * @see http://doc.babylonjs.com/how_to/multi_materials
  21602. * @param name Define the name in the scene
  21603. * @param scene Define the scene the material belongs to
  21604. */
  21605. constructor(name: string, scene: Scene);
  21606. private _hookArray;
  21607. /**
  21608. * Get one of the submaterial by its index in the submaterials array
  21609. * @param index The index to look the sub material at
  21610. * @returns The Material if the index has been defined
  21611. */
  21612. getSubMaterial(index: number): Nullable<Material>;
  21613. /**
  21614. * Get the list of active textures for the whole sub materials list.
  21615. * @returns All the textures that will be used during the rendering
  21616. */
  21617. getActiveTextures(): BaseTexture[];
  21618. /**
  21619. * Gets the current class name of the material e.g. "MultiMaterial"
  21620. * Mainly use in serialization.
  21621. * @returns the class name
  21622. */
  21623. getClassName(): string;
  21624. /**
  21625. * Checks if the material is ready to render the requested sub mesh
  21626. * @param mesh Define the mesh the submesh belongs to
  21627. * @param subMesh Define the sub mesh to look readyness for
  21628. * @param useInstances Define whether or not the material is used with instances
  21629. * @returns true if ready, otherwise false
  21630. */
  21631. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21632. /**
  21633. * Clones the current material and its related sub materials
  21634. * @param name Define the name of the newly cloned material
  21635. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21636. * @returns the cloned material
  21637. */
  21638. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21639. /**
  21640. * Serializes the materials into a JSON representation.
  21641. * @returns the JSON representation
  21642. */
  21643. serialize(): any;
  21644. /**
  21645. * Dispose the material and release its associated resources
  21646. * @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)
  21647. * @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)
  21648. * @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)
  21649. */
  21650. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21651. /**
  21652. * Creates a MultiMaterial from parsed MultiMaterial data.
  21653. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21654. * @param scene defines the hosting scene
  21655. * @returns a new MultiMaterial
  21656. */
  21657. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21658. }
  21659. }
  21660. declare module BABYLON {
  21661. /**
  21662. * Base class for submeshes
  21663. */
  21664. export class BaseSubMesh {
  21665. /** @hidden */
  21666. _materialDefines: Nullable<MaterialDefines>;
  21667. /** @hidden */
  21668. _materialEffect: Nullable<Effect>;
  21669. /**
  21670. * Gets material defines used by the effect associated to the sub mesh
  21671. */
  21672. get materialDefines(): Nullable<MaterialDefines>;
  21673. /**
  21674. * Sets material defines used by the effect associated to the sub mesh
  21675. */
  21676. set materialDefines(defines: Nullable<MaterialDefines>);
  21677. /**
  21678. * Gets associated effect
  21679. */
  21680. get effect(): Nullable<Effect>;
  21681. /**
  21682. * Sets associated effect (effect used to render this submesh)
  21683. * @param effect defines the effect to associate with
  21684. * @param defines defines the set of defines used to compile this effect
  21685. */
  21686. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21687. }
  21688. /**
  21689. * Defines a subdivision inside a mesh
  21690. */
  21691. export class SubMesh extends BaseSubMesh implements ICullable {
  21692. /** the material index to use */
  21693. materialIndex: number;
  21694. /** vertex index start */
  21695. verticesStart: number;
  21696. /** vertices count */
  21697. verticesCount: number;
  21698. /** index start */
  21699. indexStart: number;
  21700. /** indices count */
  21701. indexCount: number;
  21702. /** @hidden */
  21703. _linesIndexCount: number;
  21704. private _mesh;
  21705. private _renderingMesh;
  21706. private _boundingInfo;
  21707. private _linesIndexBuffer;
  21708. /** @hidden */
  21709. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21710. /** @hidden */
  21711. _trianglePlanes: Plane[];
  21712. /** @hidden */
  21713. _lastColliderTransformMatrix: Nullable<Matrix>;
  21714. /** @hidden */
  21715. _renderId: number;
  21716. /** @hidden */
  21717. _alphaIndex: number;
  21718. /** @hidden */
  21719. _distanceToCamera: number;
  21720. /** @hidden */
  21721. _id: number;
  21722. private _currentMaterial;
  21723. /**
  21724. * Add a new submesh to a mesh
  21725. * @param materialIndex defines the material index to use
  21726. * @param verticesStart defines vertex index start
  21727. * @param verticesCount defines vertices count
  21728. * @param indexStart defines index start
  21729. * @param indexCount defines indices count
  21730. * @param mesh defines the parent mesh
  21731. * @param renderingMesh defines an optional rendering mesh
  21732. * @param createBoundingBox defines if bounding box should be created for this submesh
  21733. * @returns the new submesh
  21734. */
  21735. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21736. /**
  21737. * Creates a new submesh
  21738. * @param materialIndex defines the material index to use
  21739. * @param verticesStart defines vertex index start
  21740. * @param verticesCount defines vertices count
  21741. * @param indexStart defines index start
  21742. * @param indexCount defines indices count
  21743. * @param mesh defines the parent mesh
  21744. * @param renderingMesh defines an optional rendering mesh
  21745. * @param createBoundingBox defines if bounding box should be created for this submesh
  21746. */
  21747. constructor(
  21748. /** the material index to use */
  21749. materialIndex: number,
  21750. /** vertex index start */
  21751. verticesStart: number,
  21752. /** vertices count */
  21753. verticesCount: number,
  21754. /** index start */
  21755. indexStart: number,
  21756. /** indices count */
  21757. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21758. /**
  21759. * Returns true if this submesh covers the entire parent mesh
  21760. * @ignorenaming
  21761. */
  21762. get IsGlobal(): boolean;
  21763. /**
  21764. * Returns the submesh BoudingInfo object
  21765. * @returns current bounding info (or mesh's one if the submesh is global)
  21766. */
  21767. getBoundingInfo(): BoundingInfo;
  21768. /**
  21769. * Sets the submesh BoundingInfo
  21770. * @param boundingInfo defines the new bounding info to use
  21771. * @returns the SubMesh
  21772. */
  21773. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21774. /**
  21775. * Returns the mesh of the current submesh
  21776. * @return the parent mesh
  21777. */
  21778. getMesh(): AbstractMesh;
  21779. /**
  21780. * Returns the rendering mesh of the submesh
  21781. * @returns the rendering mesh (could be different from parent mesh)
  21782. */
  21783. getRenderingMesh(): Mesh;
  21784. /**
  21785. * Returns the submesh material
  21786. * @returns null or the current material
  21787. */
  21788. getMaterial(): Nullable<Material>;
  21789. /**
  21790. * Sets a new updated BoundingInfo object to the submesh
  21791. * @param data defines an optional position array to use to determine the bounding info
  21792. * @returns the SubMesh
  21793. */
  21794. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21795. /** @hidden */
  21796. _checkCollision(collider: Collider): boolean;
  21797. /**
  21798. * Updates the submesh BoundingInfo
  21799. * @param world defines the world matrix to use to update the bounding info
  21800. * @returns the submesh
  21801. */
  21802. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21803. /**
  21804. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21805. * @param frustumPlanes defines the frustum planes
  21806. * @returns true if the submesh is intersecting with the frustum
  21807. */
  21808. isInFrustum(frustumPlanes: Plane[]): boolean;
  21809. /**
  21810. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21811. * @param frustumPlanes defines the frustum planes
  21812. * @returns true if the submesh is inside the frustum
  21813. */
  21814. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21815. /**
  21816. * Renders the submesh
  21817. * @param enableAlphaMode defines if alpha needs to be used
  21818. * @returns the submesh
  21819. */
  21820. render(enableAlphaMode: boolean): SubMesh;
  21821. /**
  21822. * @hidden
  21823. */
  21824. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21825. /**
  21826. * Checks if the submesh intersects with a ray
  21827. * @param ray defines the ray to test
  21828. * @returns true is the passed ray intersects the submesh bounding box
  21829. */
  21830. canIntersects(ray: Ray): boolean;
  21831. /**
  21832. * Intersects current submesh with a ray
  21833. * @param ray defines the ray to test
  21834. * @param positions defines mesh's positions array
  21835. * @param indices defines mesh's indices array
  21836. * @param fastCheck defines if only bounding info should be used
  21837. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21838. * @returns intersection info or null if no intersection
  21839. */
  21840. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21841. /** @hidden */
  21842. private _intersectLines;
  21843. /** @hidden */
  21844. private _intersectUnIndexedLines;
  21845. /** @hidden */
  21846. private _intersectTriangles;
  21847. /** @hidden */
  21848. private _intersectUnIndexedTriangles;
  21849. /** @hidden */
  21850. _rebuild(): void;
  21851. /**
  21852. * Creates a new submesh from the passed mesh
  21853. * @param newMesh defines the new hosting mesh
  21854. * @param newRenderingMesh defines an optional rendering mesh
  21855. * @returns the new submesh
  21856. */
  21857. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21858. /**
  21859. * Release associated resources
  21860. */
  21861. dispose(): void;
  21862. /**
  21863. * Gets the class name
  21864. * @returns the string "SubMesh".
  21865. */
  21866. getClassName(): string;
  21867. /**
  21868. * Creates a new submesh from indices data
  21869. * @param materialIndex the index of the main mesh material
  21870. * @param startIndex the index where to start the copy in the mesh indices array
  21871. * @param indexCount the number of indices to copy then from the startIndex
  21872. * @param mesh the main mesh to create the submesh from
  21873. * @param renderingMesh the optional rendering mesh
  21874. * @returns a new submesh
  21875. */
  21876. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21877. }
  21878. }
  21879. declare module BABYLON {
  21880. /**
  21881. * Class used to represent data loading progression
  21882. */
  21883. export class SceneLoaderFlags {
  21884. private static _ForceFullSceneLoadingForIncremental;
  21885. private static _ShowLoadingScreen;
  21886. private static _CleanBoneMatrixWeights;
  21887. private static _loggingLevel;
  21888. /**
  21889. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21890. */
  21891. static get ForceFullSceneLoadingForIncremental(): boolean;
  21892. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21893. /**
  21894. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21895. */
  21896. static get ShowLoadingScreen(): boolean;
  21897. static set ShowLoadingScreen(value: boolean);
  21898. /**
  21899. * Defines the current logging level (while loading the scene)
  21900. * @ignorenaming
  21901. */
  21902. static get loggingLevel(): number;
  21903. static set loggingLevel(value: number);
  21904. /**
  21905. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21906. */
  21907. static get CleanBoneMatrixWeights(): boolean;
  21908. static set CleanBoneMatrixWeights(value: boolean);
  21909. }
  21910. }
  21911. declare module BABYLON {
  21912. /**
  21913. * Class used to store geometry data (vertex buffers + index buffer)
  21914. */
  21915. export class Geometry implements IGetSetVerticesData {
  21916. /**
  21917. * Gets or sets the ID of the geometry
  21918. */
  21919. id: string;
  21920. /**
  21921. * Gets or sets the unique ID of the geometry
  21922. */
  21923. uniqueId: number;
  21924. /**
  21925. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21926. */
  21927. delayLoadState: number;
  21928. /**
  21929. * Gets the file containing the data to load when running in delay load state
  21930. */
  21931. delayLoadingFile: Nullable<string>;
  21932. /**
  21933. * Callback called when the geometry is updated
  21934. */
  21935. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21936. private _scene;
  21937. private _engine;
  21938. private _meshes;
  21939. private _totalVertices;
  21940. /** @hidden */
  21941. _indices: IndicesArray;
  21942. /** @hidden */
  21943. _vertexBuffers: {
  21944. [key: string]: VertexBuffer;
  21945. };
  21946. private _isDisposed;
  21947. private _extend;
  21948. private _boundingBias;
  21949. /** @hidden */
  21950. _delayInfo: Array<string>;
  21951. private _indexBuffer;
  21952. private _indexBufferIsUpdatable;
  21953. /** @hidden */
  21954. _boundingInfo: Nullable<BoundingInfo>;
  21955. /** @hidden */
  21956. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21957. /** @hidden */
  21958. _softwareSkinningFrameId: number;
  21959. private _vertexArrayObjects;
  21960. private _updatable;
  21961. /** @hidden */
  21962. _positions: Nullable<Vector3[]>;
  21963. /**
  21964. * 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
  21965. */
  21966. get boundingBias(): Vector2;
  21967. /**
  21968. * 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
  21969. */
  21970. set boundingBias(value: Vector2);
  21971. /**
  21972. * Static function used to attach a new empty geometry to a mesh
  21973. * @param mesh defines the mesh to attach the geometry to
  21974. * @returns the new Geometry
  21975. */
  21976. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21977. /** Get the list of meshes using this geometry */
  21978. get meshes(): Mesh[];
  21979. /**
  21980. * Creates a new geometry
  21981. * @param id defines the unique ID
  21982. * @param scene defines the hosting scene
  21983. * @param vertexData defines the VertexData used to get geometry data
  21984. * @param updatable defines if geometry must be updatable (false by default)
  21985. * @param mesh defines the mesh that will be associated with the geometry
  21986. */
  21987. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21988. /**
  21989. * Gets the current extend of the geometry
  21990. */
  21991. get extend(): {
  21992. minimum: Vector3;
  21993. maximum: Vector3;
  21994. };
  21995. /**
  21996. * Gets the hosting scene
  21997. * @returns the hosting Scene
  21998. */
  21999. getScene(): Scene;
  22000. /**
  22001. * Gets the hosting engine
  22002. * @returns the hosting Engine
  22003. */
  22004. getEngine(): Engine;
  22005. /**
  22006. * Defines if the geometry is ready to use
  22007. * @returns true if the geometry is ready to be used
  22008. */
  22009. isReady(): boolean;
  22010. /**
  22011. * Gets a value indicating that the geometry should not be serialized
  22012. */
  22013. get doNotSerialize(): boolean;
  22014. /** @hidden */
  22015. _rebuild(): void;
  22016. /**
  22017. * Affects all geometry data in one call
  22018. * @param vertexData defines the geometry data
  22019. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22020. */
  22021. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22022. /**
  22023. * Set specific vertex data
  22024. * @param kind defines the data kind (Position, normal, etc...)
  22025. * @param data defines the vertex data to use
  22026. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22027. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22028. */
  22029. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22030. /**
  22031. * Removes a specific vertex data
  22032. * @param kind defines the data kind (Position, normal, etc...)
  22033. */
  22034. removeVerticesData(kind: string): void;
  22035. /**
  22036. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22037. * @param buffer defines the vertex buffer to use
  22038. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22039. */
  22040. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22041. /**
  22042. * Update a specific vertex buffer
  22043. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22044. * It will do nothing if the buffer is not updatable
  22045. * @param kind defines the data kind (Position, normal, etc...)
  22046. * @param data defines the data to use
  22047. * @param offset defines the offset in the target buffer where to store the data
  22048. * @param useBytes set to true if the offset is in bytes
  22049. */
  22050. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22051. /**
  22052. * Update a specific vertex buffer
  22053. * This function will create a new buffer if the current one is not updatable
  22054. * @param kind defines the data kind (Position, normal, etc...)
  22055. * @param data defines the data to use
  22056. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22057. */
  22058. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22059. private _updateBoundingInfo;
  22060. /** @hidden */
  22061. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22062. /**
  22063. * Gets total number of vertices
  22064. * @returns the total number of vertices
  22065. */
  22066. getTotalVertices(): number;
  22067. /**
  22068. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22069. * @param kind defines the data kind (Position, normal, etc...)
  22070. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22071. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22072. * @returns a float array containing vertex data
  22073. */
  22074. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22075. /**
  22076. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22077. * @param kind defines the data kind (Position, normal, etc...)
  22078. * @returns true if the vertex buffer with the specified kind is updatable
  22079. */
  22080. isVertexBufferUpdatable(kind: string): boolean;
  22081. /**
  22082. * Gets a specific vertex buffer
  22083. * @param kind defines the data kind (Position, normal, etc...)
  22084. * @returns a VertexBuffer
  22085. */
  22086. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22087. /**
  22088. * Returns all vertex buffers
  22089. * @return an object holding all vertex buffers indexed by kind
  22090. */
  22091. getVertexBuffers(): Nullable<{
  22092. [key: string]: VertexBuffer;
  22093. }>;
  22094. /**
  22095. * Gets a boolean indicating if specific vertex buffer is present
  22096. * @param kind defines the data kind (Position, normal, etc...)
  22097. * @returns true if data is present
  22098. */
  22099. isVerticesDataPresent(kind: string): boolean;
  22100. /**
  22101. * Gets a list of all attached data kinds (Position, normal, etc...)
  22102. * @returns a list of string containing all kinds
  22103. */
  22104. getVerticesDataKinds(): string[];
  22105. /**
  22106. * Update index buffer
  22107. * @param indices defines the indices to store in the index buffer
  22108. * @param offset defines the offset in the target buffer where to store the data
  22109. * @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)
  22110. */
  22111. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22112. /**
  22113. * Creates a new index buffer
  22114. * @param indices defines the indices to store in the index buffer
  22115. * @param totalVertices defines the total number of vertices (could be null)
  22116. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22117. */
  22118. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22119. /**
  22120. * Return the total number of indices
  22121. * @returns the total number of indices
  22122. */
  22123. getTotalIndices(): number;
  22124. /**
  22125. * Gets the index buffer array
  22126. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22127. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22128. * @returns the index buffer array
  22129. */
  22130. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22131. /**
  22132. * Gets the index buffer
  22133. * @return the index buffer
  22134. */
  22135. getIndexBuffer(): Nullable<DataBuffer>;
  22136. /** @hidden */
  22137. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22138. /**
  22139. * Release the associated resources for a specific mesh
  22140. * @param mesh defines the source mesh
  22141. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22142. */
  22143. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22144. /**
  22145. * Apply current geometry to a given mesh
  22146. * @param mesh defines the mesh to apply geometry to
  22147. */
  22148. applyToMesh(mesh: Mesh): void;
  22149. private _updateExtend;
  22150. private _applyToMesh;
  22151. private notifyUpdate;
  22152. /**
  22153. * Load the geometry if it was flagged as delay loaded
  22154. * @param scene defines the hosting scene
  22155. * @param onLoaded defines a callback called when the geometry is loaded
  22156. */
  22157. load(scene: Scene, onLoaded?: () => void): void;
  22158. private _queueLoad;
  22159. /**
  22160. * Invert the geometry to move from a right handed system to a left handed one.
  22161. */
  22162. toLeftHanded(): void;
  22163. /** @hidden */
  22164. _resetPointsArrayCache(): void;
  22165. /** @hidden */
  22166. _generatePointsArray(): boolean;
  22167. /**
  22168. * Gets a value indicating if the geometry is disposed
  22169. * @returns true if the geometry was disposed
  22170. */
  22171. isDisposed(): boolean;
  22172. private _disposeVertexArrayObjects;
  22173. /**
  22174. * Free all associated resources
  22175. */
  22176. dispose(): void;
  22177. /**
  22178. * Clone the current geometry into a new geometry
  22179. * @param id defines the unique ID of the new geometry
  22180. * @returns a new geometry object
  22181. */
  22182. copy(id: string): Geometry;
  22183. /**
  22184. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22185. * @return a JSON representation of the current geometry data (without the vertices data)
  22186. */
  22187. serialize(): any;
  22188. private toNumberArray;
  22189. /**
  22190. * Serialize all vertices data into a JSON oject
  22191. * @returns a JSON representation of the current geometry data
  22192. */
  22193. serializeVerticeData(): any;
  22194. /**
  22195. * Extracts a clone of a mesh geometry
  22196. * @param mesh defines the source mesh
  22197. * @param id defines the unique ID of the new geometry object
  22198. * @returns the new geometry object
  22199. */
  22200. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22201. /**
  22202. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22203. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22204. * Be aware Math.random() could cause collisions, but:
  22205. * "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"
  22206. * @returns a string containing a new GUID
  22207. */
  22208. static RandomId(): string;
  22209. /** @hidden */
  22210. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22211. private static _CleanMatricesWeights;
  22212. /**
  22213. * Create a new geometry from persisted data (Using .babylon file format)
  22214. * @param parsedVertexData defines the persisted data
  22215. * @param scene defines the hosting scene
  22216. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22217. * @returns the new geometry object
  22218. */
  22219. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22220. }
  22221. }
  22222. declare module BABYLON {
  22223. /**
  22224. * Define an interface for all classes that will get and set the data on vertices
  22225. */
  22226. export interface IGetSetVerticesData {
  22227. /**
  22228. * Gets a boolean indicating if specific vertex data is present
  22229. * @param kind defines the vertex data kind to use
  22230. * @returns true is data kind is present
  22231. */
  22232. isVerticesDataPresent(kind: string): boolean;
  22233. /**
  22234. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22235. * @param kind defines the data kind (Position, normal, etc...)
  22236. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22237. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22238. * @returns a float array containing vertex data
  22239. */
  22240. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22241. /**
  22242. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22243. * @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.
  22244. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22245. * @returns the indices array or an empty array if the mesh has no geometry
  22246. */
  22247. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22248. /**
  22249. * Set specific vertex data
  22250. * @param kind defines the data kind (Position, normal, etc...)
  22251. * @param data defines the vertex data to use
  22252. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22253. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22254. */
  22255. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22256. /**
  22257. * Update a specific associated vertex buffer
  22258. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22259. * - VertexBuffer.PositionKind
  22260. * - VertexBuffer.UVKind
  22261. * - VertexBuffer.UV2Kind
  22262. * - VertexBuffer.UV3Kind
  22263. * - VertexBuffer.UV4Kind
  22264. * - VertexBuffer.UV5Kind
  22265. * - VertexBuffer.UV6Kind
  22266. * - VertexBuffer.ColorKind
  22267. * - VertexBuffer.MatricesIndicesKind
  22268. * - VertexBuffer.MatricesIndicesExtraKind
  22269. * - VertexBuffer.MatricesWeightsKind
  22270. * - VertexBuffer.MatricesWeightsExtraKind
  22271. * @param data defines the data source
  22272. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22273. * @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)
  22274. */
  22275. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22276. /**
  22277. * Creates a new index buffer
  22278. * @param indices defines the indices to store in the index buffer
  22279. * @param totalVertices defines the total number of vertices (could be null)
  22280. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22281. */
  22282. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22283. }
  22284. /**
  22285. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22286. */
  22287. export class VertexData {
  22288. /**
  22289. * Mesh side orientation : usually the external or front surface
  22290. */
  22291. static readonly FRONTSIDE: number;
  22292. /**
  22293. * Mesh side orientation : usually the internal or back surface
  22294. */
  22295. static readonly BACKSIDE: number;
  22296. /**
  22297. * Mesh side orientation : both internal and external or front and back surfaces
  22298. */
  22299. static readonly DOUBLESIDE: number;
  22300. /**
  22301. * Mesh side orientation : by default, `FRONTSIDE`
  22302. */
  22303. static readonly DEFAULTSIDE: number;
  22304. /**
  22305. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22306. */
  22307. positions: Nullable<FloatArray>;
  22308. /**
  22309. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22310. */
  22311. normals: Nullable<FloatArray>;
  22312. /**
  22313. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22314. */
  22315. tangents: Nullable<FloatArray>;
  22316. /**
  22317. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22318. */
  22319. uvs: Nullable<FloatArray>;
  22320. /**
  22321. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22322. */
  22323. uvs2: Nullable<FloatArray>;
  22324. /**
  22325. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22326. */
  22327. uvs3: Nullable<FloatArray>;
  22328. /**
  22329. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22330. */
  22331. uvs4: Nullable<FloatArray>;
  22332. /**
  22333. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22334. */
  22335. uvs5: Nullable<FloatArray>;
  22336. /**
  22337. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22338. */
  22339. uvs6: Nullable<FloatArray>;
  22340. /**
  22341. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22342. */
  22343. colors: Nullable<FloatArray>;
  22344. /**
  22345. * 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).
  22346. */
  22347. matricesIndices: Nullable<FloatArray>;
  22348. /**
  22349. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22350. */
  22351. matricesWeights: Nullable<FloatArray>;
  22352. /**
  22353. * An array extending the number of possible indices
  22354. */
  22355. matricesIndicesExtra: Nullable<FloatArray>;
  22356. /**
  22357. * An array extending the number of possible weights when the number of indices is extended
  22358. */
  22359. matricesWeightsExtra: Nullable<FloatArray>;
  22360. /**
  22361. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22362. */
  22363. indices: Nullable<IndicesArray>;
  22364. /**
  22365. * Uses the passed data array to set the set the values for the specified kind of data
  22366. * @param data a linear array of floating numbers
  22367. * @param kind the type of data that is being set, eg positions, colors etc
  22368. */
  22369. set(data: FloatArray, kind: string): void;
  22370. /**
  22371. * Associates the vertexData to the passed Mesh.
  22372. * Sets it as updatable or not (default `false`)
  22373. * @param mesh the mesh the vertexData is applied to
  22374. * @param updatable when used and having the value true allows new data to update the vertexData
  22375. * @returns the VertexData
  22376. */
  22377. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22378. /**
  22379. * Associates the vertexData to the passed Geometry.
  22380. * Sets it as updatable or not (default `false`)
  22381. * @param geometry the geometry the vertexData is applied to
  22382. * @param updatable when used and having the value true allows new data to update the vertexData
  22383. * @returns VertexData
  22384. */
  22385. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22386. /**
  22387. * Updates the associated mesh
  22388. * @param mesh the mesh to be updated
  22389. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22390. * @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
  22391. * @returns VertexData
  22392. */
  22393. updateMesh(mesh: Mesh): VertexData;
  22394. /**
  22395. * Updates the associated geometry
  22396. * @param geometry the geometry to be updated
  22397. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22398. * @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
  22399. * @returns VertexData.
  22400. */
  22401. updateGeometry(geometry: Geometry): VertexData;
  22402. private _applyTo;
  22403. private _update;
  22404. /**
  22405. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22406. * @param matrix the transforming matrix
  22407. * @returns the VertexData
  22408. */
  22409. transform(matrix: Matrix): VertexData;
  22410. /**
  22411. * Merges the passed VertexData into the current one
  22412. * @param other the VertexData to be merged into the current one
  22413. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22414. * @returns the modified VertexData
  22415. */
  22416. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22417. private _mergeElement;
  22418. private _validate;
  22419. /**
  22420. * Serializes the VertexData
  22421. * @returns a serialized object
  22422. */
  22423. serialize(): any;
  22424. /**
  22425. * Extracts the vertexData from a mesh
  22426. * @param mesh the mesh from which to extract the VertexData
  22427. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22428. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22429. * @returns the object VertexData associated to the passed mesh
  22430. */
  22431. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22432. /**
  22433. * Extracts the vertexData from the geometry
  22434. * @param geometry the geometry from which to extract the VertexData
  22435. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22436. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22437. * @returns the object VertexData associated to the passed mesh
  22438. */
  22439. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22440. private static _ExtractFrom;
  22441. /**
  22442. * Creates the VertexData for a Ribbon
  22443. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22444. * * pathArray array of paths, each of which an array of successive Vector3
  22445. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22446. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22447. * * 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
  22448. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22449. * * 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)
  22450. * * 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)
  22451. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22452. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22453. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22454. * @returns the VertexData of the ribbon
  22455. */
  22456. static CreateRibbon(options: {
  22457. pathArray: Vector3[][];
  22458. closeArray?: boolean;
  22459. closePath?: boolean;
  22460. offset?: number;
  22461. sideOrientation?: number;
  22462. frontUVs?: Vector4;
  22463. backUVs?: Vector4;
  22464. invertUV?: boolean;
  22465. uvs?: Vector2[];
  22466. colors?: Color4[];
  22467. }): VertexData;
  22468. /**
  22469. * Creates the VertexData for a box
  22470. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22471. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22472. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22473. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22474. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22475. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22476. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22477. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22478. * * 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)
  22479. * * 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)
  22480. * @returns the VertexData of the box
  22481. */
  22482. static CreateBox(options: {
  22483. size?: number;
  22484. width?: number;
  22485. height?: number;
  22486. depth?: number;
  22487. faceUV?: Vector4[];
  22488. faceColors?: Color4[];
  22489. sideOrientation?: number;
  22490. frontUVs?: Vector4;
  22491. backUVs?: Vector4;
  22492. }): VertexData;
  22493. /**
  22494. * Creates the VertexData for a tiled box
  22495. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22496. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22497. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22498. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22499. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22500. * @returns the VertexData of the box
  22501. */
  22502. static CreateTiledBox(options: {
  22503. pattern?: number;
  22504. width?: number;
  22505. height?: number;
  22506. depth?: number;
  22507. tileSize?: number;
  22508. tileWidth?: number;
  22509. tileHeight?: number;
  22510. alignHorizontal?: number;
  22511. alignVertical?: number;
  22512. faceUV?: Vector4[];
  22513. faceColors?: Color4[];
  22514. sideOrientation?: number;
  22515. }): VertexData;
  22516. /**
  22517. * Creates the VertexData for a tiled plane
  22518. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22519. * * pattern a limited pattern arrangement depending on the number
  22520. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22521. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22522. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22523. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22524. * * 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)
  22525. * * 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)
  22526. * @returns the VertexData of the tiled plane
  22527. */
  22528. static CreateTiledPlane(options: {
  22529. pattern?: number;
  22530. tileSize?: number;
  22531. tileWidth?: number;
  22532. tileHeight?: number;
  22533. size?: number;
  22534. width?: number;
  22535. height?: number;
  22536. alignHorizontal?: number;
  22537. alignVertical?: number;
  22538. sideOrientation?: number;
  22539. frontUVs?: Vector4;
  22540. backUVs?: Vector4;
  22541. }): VertexData;
  22542. /**
  22543. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22544. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22545. * * segments sets the number of horizontal strips optional, default 32
  22546. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22547. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22548. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22549. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22550. * * 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
  22551. * * 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
  22552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22553. * * 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)
  22554. * * 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)
  22555. * @returns the VertexData of the ellipsoid
  22556. */
  22557. static CreateSphere(options: {
  22558. segments?: number;
  22559. diameter?: number;
  22560. diameterX?: number;
  22561. diameterY?: number;
  22562. diameterZ?: number;
  22563. arc?: number;
  22564. slice?: number;
  22565. sideOrientation?: number;
  22566. frontUVs?: Vector4;
  22567. backUVs?: Vector4;
  22568. }): VertexData;
  22569. /**
  22570. * Creates the VertexData for a cylinder, cone or prism
  22571. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22572. * * height sets the height (y direction) of the cylinder, optional, default 2
  22573. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22574. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22575. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22576. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22577. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22578. * * 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
  22579. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22580. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22581. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22582. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22583. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22584. * * 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)
  22585. * * 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)
  22586. * @returns the VertexData of the cylinder, cone or prism
  22587. */
  22588. static CreateCylinder(options: {
  22589. height?: number;
  22590. diameterTop?: number;
  22591. diameterBottom?: number;
  22592. diameter?: number;
  22593. tessellation?: number;
  22594. subdivisions?: number;
  22595. arc?: number;
  22596. faceColors?: Color4[];
  22597. faceUV?: Vector4[];
  22598. hasRings?: boolean;
  22599. enclose?: boolean;
  22600. sideOrientation?: number;
  22601. frontUVs?: Vector4;
  22602. backUVs?: Vector4;
  22603. }): VertexData;
  22604. /**
  22605. * Creates the VertexData for a torus
  22606. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22607. * * diameter the diameter of the torus, optional default 1
  22608. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22609. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22610. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22611. * * 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)
  22612. * * 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)
  22613. * @returns the VertexData of the torus
  22614. */
  22615. static CreateTorus(options: {
  22616. diameter?: number;
  22617. thickness?: number;
  22618. tessellation?: number;
  22619. sideOrientation?: number;
  22620. frontUVs?: Vector4;
  22621. backUVs?: Vector4;
  22622. }): VertexData;
  22623. /**
  22624. * Creates the VertexData of the LineSystem
  22625. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22626. * - lines an array of lines, each line being an array of successive Vector3
  22627. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22628. * @returns the VertexData of the LineSystem
  22629. */
  22630. static CreateLineSystem(options: {
  22631. lines: Vector3[][];
  22632. colors?: Nullable<Color4[][]>;
  22633. }): VertexData;
  22634. /**
  22635. * Create the VertexData for a DashedLines
  22636. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22637. * - points an array successive Vector3
  22638. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22639. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22640. * - dashNb the intended total number of dashes, optional, default 200
  22641. * @returns the VertexData for the DashedLines
  22642. */
  22643. static CreateDashedLines(options: {
  22644. points: Vector3[];
  22645. dashSize?: number;
  22646. gapSize?: number;
  22647. dashNb?: number;
  22648. }): VertexData;
  22649. /**
  22650. * Creates the VertexData for a Ground
  22651. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22652. * - width the width (x direction) of the ground, optional, default 1
  22653. * - height the height (z direction) of the ground, optional, default 1
  22654. * - subdivisions the number of subdivisions per side, optional, default 1
  22655. * @returns the VertexData of the Ground
  22656. */
  22657. static CreateGround(options: {
  22658. width?: number;
  22659. height?: number;
  22660. subdivisions?: number;
  22661. subdivisionsX?: number;
  22662. subdivisionsY?: number;
  22663. }): VertexData;
  22664. /**
  22665. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22666. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22667. * * xmin the ground minimum X coordinate, optional, default -1
  22668. * * zmin the ground minimum Z coordinate, optional, default -1
  22669. * * xmax the ground maximum X coordinate, optional, default 1
  22670. * * zmax the ground maximum Z coordinate, optional, default 1
  22671. * * 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}
  22672. * * 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}
  22673. * @returns the VertexData of the TiledGround
  22674. */
  22675. static CreateTiledGround(options: {
  22676. xmin: number;
  22677. zmin: number;
  22678. xmax: number;
  22679. zmax: number;
  22680. subdivisions?: {
  22681. w: number;
  22682. h: number;
  22683. };
  22684. precision?: {
  22685. w: number;
  22686. h: number;
  22687. };
  22688. }): VertexData;
  22689. /**
  22690. * Creates the VertexData of the Ground designed from a heightmap
  22691. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22692. * * width the width (x direction) of the ground
  22693. * * height the height (z direction) of the ground
  22694. * * subdivisions the number of subdivisions per side
  22695. * * minHeight the minimum altitude on the ground, optional, default 0
  22696. * * maxHeight the maximum altitude on the ground, optional default 1
  22697. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22698. * * buffer the array holding the image color data
  22699. * * bufferWidth the width of image
  22700. * * bufferHeight the height of image
  22701. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22702. * @returns the VertexData of the Ground designed from a heightmap
  22703. */
  22704. static CreateGroundFromHeightMap(options: {
  22705. width: number;
  22706. height: number;
  22707. subdivisions: number;
  22708. minHeight: number;
  22709. maxHeight: number;
  22710. colorFilter: Color3;
  22711. buffer: Uint8Array;
  22712. bufferWidth: number;
  22713. bufferHeight: number;
  22714. alphaFilter: number;
  22715. }): VertexData;
  22716. /**
  22717. * Creates the VertexData for a Plane
  22718. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22719. * * size sets the width and height of the plane to the value of size, optional default 1
  22720. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22721. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22722. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22723. * * 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)
  22724. * * 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)
  22725. * @returns the VertexData of the box
  22726. */
  22727. static CreatePlane(options: {
  22728. size?: number;
  22729. width?: number;
  22730. height?: number;
  22731. sideOrientation?: number;
  22732. frontUVs?: Vector4;
  22733. backUVs?: Vector4;
  22734. }): VertexData;
  22735. /**
  22736. * Creates the VertexData of the Disc or regular Polygon
  22737. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22738. * * radius the radius of the disc, optional default 0.5
  22739. * * tessellation the number of polygon sides, optional, default 64
  22740. * * 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
  22741. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22742. * * 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)
  22743. * * 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)
  22744. * @returns the VertexData of the box
  22745. */
  22746. static CreateDisc(options: {
  22747. radius?: number;
  22748. tessellation?: number;
  22749. arc?: number;
  22750. sideOrientation?: number;
  22751. frontUVs?: Vector4;
  22752. backUVs?: Vector4;
  22753. }): VertexData;
  22754. /**
  22755. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22756. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22757. * @param polygon a mesh built from polygonTriangulation.build()
  22758. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22759. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22760. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22761. * @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)
  22762. * @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)
  22763. * @returns the VertexData of the Polygon
  22764. */
  22765. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22766. /**
  22767. * Creates the VertexData of the IcoSphere
  22768. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22769. * * radius the radius of the IcoSphere, optional default 1
  22770. * * radiusX allows stretching in the x direction, optional, default radius
  22771. * * radiusY allows stretching in the y direction, optional, default radius
  22772. * * radiusZ allows stretching in the z direction, optional, default radius
  22773. * * flat when true creates a flat shaded mesh, optional, default true
  22774. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22775. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22776. * * 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)
  22777. * * 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)
  22778. * @returns the VertexData of the IcoSphere
  22779. */
  22780. static CreateIcoSphere(options: {
  22781. radius?: number;
  22782. radiusX?: number;
  22783. radiusY?: number;
  22784. radiusZ?: number;
  22785. flat?: boolean;
  22786. subdivisions?: number;
  22787. sideOrientation?: number;
  22788. frontUVs?: Vector4;
  22789. backUVs?: Vector4;
  22790. }): VertexData;
  22791. /**
  22792. * Creates the VertexData for a Polyhedron
  22793. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22794. * * type provided types are:
  22795. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22796. * * 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)
  22797. * * size the size of the IcoSphere, optional default 1
  22798. * * sizeX allows stretching in the x direction, optional, default size
  22799. * * sizeY allows stretching in the y direction, optional, default size
  22800. * * sizeZ allows stretching in the z direction, optional, default size
  22801. * * 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
  22802. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22803. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22804. * * flat when true creates a flat shaded mesh, optional, default true
  22805. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22807. * * 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)
  22808. * * 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)
  22809. * @returns the VertexData of the Polyhedron
  22810. */
  22811. static CreatePolyhedron(options: {
  22812. type?: number;
  22813. size?: number;
  22814. sizeX?: number;
  22815. sizeY?: number;
  22816. sizeZ?: number;
  22817. custom?: any;
  22818. faceUV?: Vector4[];
  22819. faceColors?: Color4[];
  22820. flat?: boolean;
  22821. sideOrientation?: number;
  22822. frontUVs?: Vector4;
  22823. backUVs?: Vector4;
  22824. }): VertexData;
  22825. /**
  22826. * Creates the VertexData for a TorusKnot
  22827. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22828. * * radius the radius of the torus knot, optional, default 2
  22829. * * tube the thickness of the tube, optional, default 0.5
  22830. * * radialSegments the number of sides on each tube segments, optional, default 32
  22831. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22832. * * p the number of windings around the z axis, optional, default 2
  22833. * * q the number of windings around the x axis, optional, default 3
  22834. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22835. * * 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)
  22836. * * 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)
  22837. * @returns the VertexData of the Torus Knot
  22838. */
  22839. static CreateTorusKnot(options: {
  22840. radius?: number;
  22841. tube?: number;
  22842. radialSegments?: number;
  22843. tubularSegments?: number;
  22844. p?: number;
  22845. q?: number;
  22846. sideOrientation?: number;
  22847. frontUVs?: Vector4;
  22848. backUVs?: Vector4;
  22849. }): VertexData;
  22850. /**
  22851. * Compute normals for given positions and indices
  22852. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22853. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22854. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22855. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22856. * * facetNormals : optional array of facet normals (vector3)
  22857. * * facetPositions : optional array of facet positions (vector3)
  22858. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22859. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22860. * * bInfo : optional bounding info, required for facetPartitioning computation
  22861. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22862. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22863. * * useRightHandedSystem: optional boolean to for right handed system computation
  22864. * * depthSort : optional boolean to enable the facet depth sort computation
  22865. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22866. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22867. */
  22868. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22869. facetNormals?: any;
  22870. facetPositions?: any;
  22871. facetPartitioning?: any;
  22872. ratio?: number;
  22873. bInfo?: any;
  22874. bbSize?: Vector3;
  22875. subDiv?: any;
  22876. useRightHandedSystem?: boolean;
  22877. depthSort?: boolean;
  22878. distanceTo?: Vector3;
  22879. depthSortedFacets?: any;
  22880. }): void;
  22881. /** @hidden */
  22882. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22883. /**
  22884. * Applies VertexData created from the imported parameters to the geometry
  22885. * @param parsedVertexData the parsed data from an imported file
  22886. * @param geometry the geometry to apply the VertexData to
  22887. */
  22888. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22889. }
  22890. }
  22891. declare module BABYLON {
  22892. /**
  22893. * Defines a target to use with MorphTargetManager
  22894. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22895. */
  22896. export class MorphTarget implements IAnimatable {
  22897. /** defines the name of the target */
  22898. name: string;
  22899. /**
  22900. * Gets or sets the list of animations
  22901. */
  22902. animations: Animation[];
  22903. private _scene;
  22904. private _positions;
  22905. private _normals;
  22906. private _tangents;
  22907. private _uvs;
  22908. private _influence;
  22909. private _uniqueId;
  22910. /**
  22911. * Observable raised when the influence changes
  22912. */
  22913. onInfluenceChanged: Observable<boolean>;
  22914. /** @hidden */
  22915. _onDataLayoutChanged: Observable<void>;
  22916. /**
  22917. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22918. */
  22919. get influence(): number;
  22920. set influence(influence: number);
  22921. /**
  22922. * Gets or sets the id of the morph Target
  22923. */
  22924. id: string;
  22925. private _animationPropertiesOverride;
  22926. /**
  22927. * Gets or sets the animation properties override
  22928. */
  22929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22931. /**
  22932. * Creates a new MorphTarget
  22933. * @param name defines the name of the target
  22934. * @param influence defines the influence to use
  22935. * @param scene defines the scene the morphtarget belongs to
  22936. */
  22937. constructor(
  22938. /** defines the name of the target */
  22939. name: string, influence?: number, scene?: Nullable<Scene>);
  22940. /**
  22941. * Gets the unique ID of this manager
  22942. */
  22943. get uniqueId(): number;
  22944. /**
  22945. * Gets a boolean defining if the target contains position data
  22946. */
  22947. get hasPositions(): boolean;
  22948. /**
  22949. * Gets a boolean defining if the target contains normal data
  22950. */
  22951. get hasNormals(): boolean;
  22952. /**
  22953. * Gets a boolean defining if the target contains tangent data
  22954. */
  22955. get hasTangents(): boolean;
  22956. /**
  22957. * Gets a boolean defining if the target contains texture coordinates data
  22958. */
  22959. get hasUVs(): boolean;
  22960. /**
  22961. * Affects position data to this target
  22962. * @param data defines the position data to use
  22963. */
  22964. setPositions(data: Nullable<FloatArray>): void;
  22965. /**
  22966. * Gets the position data stored in this target
  22967. * @returns a FloatArray containing the position data (or null if not present)
  22968. */
  22969. getPositions(): Nullable<FloatArray>;
  22970. /**
  22971. * Affects normal data to this target
  22972. * @param data defines the normal data to use
  22973. */
  22974. setNormals(data: Nullable<FloatArray>): void;
  22975. /**
  22976. * Gets the normal data stored in this target
  22977. * @returns a FloatArray containing the normal data (or null if not present)
  22978. */
  22979. getNormals(): Nullable<FloatArray>;
  22980. /**
  22981. * Affects tangent data to this target
  22982. * @param data defines the tangent data to use
  22983. */
  22984. setTangents(data: Nullable<FloatArray>): void;
  22985. /**
  22986. * Gets the tangent data stored in this target
  22987. * @returns a FloatArray containing the tangent data (or null if not present)
  22988. */
  22989. getTangents(): Nullable<FloatArray>;
  22990. /**
  22991. * Affects texture coordinates data to this target
  22992. * @param data defines the texture coordinates data to use
  22993. */
  22994. setUVs(data: Nullable<FloatArray>): void;
  22995. /**
  22996. * Gets the texture coordinates data stored in this target
  22997. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22998. */
  22999. getUVs(): Nullable<FloatArray>;
  23000. /**
  23001. * Clone the current target
  23002. * @returns a new MorphTarget
  23003. */
  23004. clone(): MorphTarget;
  23005. /**
  23006. * Serializes the current target into a Serialization object
  23007. * @returns the serialized object
  23008. */
  23009. serialize(): any;
  23010. /**
  23011. * Returns the string "MorphTarget"
  23012. * @returns "MorphTarget"
  23013. */
  23014. getClassName(): string;
  23015. /**
  23016. * Creates a new target from serialized data
  23017. * @param serializationObject defines the serialized data to use
  23018. * @returns a new MorphTarget
  23019. */
  23020. static Parse(serializationObject: any): MorphTarget;
  23021. /**
  23022. * Creates a MorphTarget from mesh data
  23023. * @param mesh defines the source mesh
  23024. * @param name defines the name to use for the new target
  23025. * @param influence defines the influence to attach to the target
  23026. * @returns a new MorphTarget
  23027. */
  23028. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23029. }
  23030. }
  23031. declare module BABYLON {
  23032. /**
  23033. * This class is used to deform meshes using morphing between different targets
  23034. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23035. */
  23036. export class MorphTargetManager {
  23037. private _targets;
  23038. private _targetInfluenceChangedObservers;
  23039. private _targetDataLayoutChangedObservers;
  23040. private _activeTargets;
  23041. private _scene;
  23042. private _influences;
  23043. private _supportsNormals;
  23044. private _supportsTangents;
  23045. private _supportsUVs;
  23046. private _vertexCount;
  23047. private _uniqueId;
  23048. private _tempInfluences;
  23049. /**
  23050. * Gets or sets a boolean indicating if normals must be morphed
  23051. */
  23052. enableNormalMorphing: boolean;
  23053. /**
  23054. * Gets or sets a boolean indicating if tangents must be morphed
  23055. */
  23056. enableTangentMorphing: boolean;
  23057. /**
  23058. * Gets or sets a boolean indicating if UV must be morphed
  23059. */
  23060. enableUVMorphing: boolean;
  23061. /**
  23062. * Creates a new MorphTargetManager
  23063. * @param scene defines the current scene
  23064. */
  23065. constructor(scene?: Nullable<Scene>);
  23066. /**
  23067. * Gets the unique ID of this manager
  23068. */
  23069. get uniqueId(): number;
  23070. /**
  23071. * Gets the number of vertices handled by this manager
  23072. */
  23073. get vertexCount(): number;
  23074. /**
  23075. * Gets a boolean indicating if this manager supports morphing of normals
  23076. */
  23077. get supportsNormals(): boolean;
  23078. /**
  23079. * Gets a boolean indicating if this manager supports morphing of tangents
  23080. */
  23081. get supportsTangents(): boolean;
  23082. /**
  23083. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23084. */
  23085. get supportsUVs(): boolean;
  23086. /**
  23087. * Gets the number of targets stored in this manager
  23088. */
  23089. get numTargets(): number;
  23090. /**
  23091. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23092. */
  23093. get numInfluencers(): number;
  23094. /**
  23095. * Gets the list of influences (one per target)
  23096. */
  23097. get influences(): Float32Array;
  23098. /**
  23099. * Gets the active target at specified index. An active target is a target with an influence > 0
  23100. * @param index defines the index to check
  23101. * @returns the requested target
  23102. */
  23103. getActiveTarget(index: number): MorphTarget;
  23104. /**
  23105. * Gets the target at specified index
  23106. * @param index defines the index to check
  23107. * @returns the requested target
  23108. */
  23109. getTarget(index: number): MorphTarget;
  23110. /**
  23111. * Add a new target to this manager
  23112. * @param target defines the target to add
  23113. */
  23114. addTarget(target: MorphTarget): void;
  23115. /**
  23116. * Removes a target from the manager
  23117. * @param target defines the target to remove
  23118. */
  23119. removeTarget(target: MorphTarget): void;
  23120. /**
  23121. * Clone the current manager
  23122. * @returns a new MorphTargetManager
  23123. */
  23124. clone(): MorphTargetManager;
  23125. /**
  23126. * Serializes the current manager into a Serialization object
  23127. * @returns the serialized object
  23128. */
  23129. serialize(): any;
  23130. private _syncActiveTargets;
  23131. /**
  23132. * Syncrhonize the targets with all the meshes using this morph target manager
  23133. */
  23134. synchronize(): void;
  23135. /**
  23136. * Creates a new MorphTargetManager from serialized data
  23137. * @param serializationObject defines the serialized data
  23138. * @param scene defines the hosting scene
  23139. * @returns the new MorphTargetManager
  23140. */
  23141. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23142. }
  23143. }
  23144. declare module BABYLON {
  23145. /**
  23146. * Class used to represent a specific level of detail of a mesh
  23147. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23148. */
  23149. export class MeshLODLevel {
  23150. /** Defines the distance where this level should start being displayed */
  23151. distance: number;
  23152. /** Defines the mesh to use to render this level */
  23153. mesh: Nullable<Mesh>;
  23154. /**
  23155. * Creates a new LOD level
  23156. * @param distance defines the distance where this level should star being displayed
  23157. * @param mesh defines the mesh to use to render this level
  23158. */
  23159. constructor(
  23160. /** Defines the distance where this level should start being displayed */
  23161. distance: number,
  23162. /** Defines the mesh to use to render this level */
  23163. mesh: Nullable<Mesh>);
  23164. }
  23165. }
  23166. declare module BABYLON {
  23167. /**
  23168. * Mesh representing the gorund
  23169. */
  23170. export class GroundMesh extends Mesh {
  23171. /** If octree should be generated */
  23172. generateOctree: boolean;
  23173. private _heightQuads;
  23174. /** @hidden */
  23175. _subdivisionsX: number;
  23176. /** @hidden */
  23177. _subdivisionsY: number;
  23178. /** @hidden */
  23179. _width: number;
  23180. /** @hidden */
  23181. _height: number;
  23182. /** @hidden */
  23183. _minX: number;
  23184. /** @hidden */
  23185. _maxX: number;
  23186. /** @hidden */
  23187. _minZ: number;
  23188. /** @hidden */
  23189. _maxZ: number;
  23190. constructor(name: string, scene: Scene);
  23191. /**
  23192. * "GroundMesh"
  23193. * @returns "GroundMesh"
  23194. */
  23195. getClassName(): string;
  23196. /**
  23197. * The minimum of x and y subdivisions
  23198. */
  23199. get subdivisions(): number;
  23200. /**
  23201. * X subdivisions
  23202. */
  23203. get subdivisionsX(): number;
  23204. /**
  23205. * Y subdivisions
  23206. */
  23207. get subdivisionsY(): number;
  23208. /**
  23209. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23210. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23211. * @param chunksCount the number of subdivisions for x and y
  23212. * @param octreeBlocksSize (Default: 32)
  23213. */
  23214. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23215. /**
  23216. * Returns a height (y) value in the Worl system :
  23217. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23218. * @param x x coordinate
  23219. * @param z z coordinate
  23220. * @returns the ground y position if (x, z) are outside the ground surface.
  23221. */
  23222. getHeightAtCoordinates(x: number, z: number): number;
  23223. /**
  23224. * Returns a normalized vector (Vector3) orthogonal to the ground
  23225. * at the ground coordinates (x, z) expressed in the World system.
  23226. * @param x x coordinate
  23227. * @param z z coordinate
  23228. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23229. */
  23230. getNormalAtCoordinates(x: number, z: number): Vector3;
  23231. /**
  23232. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23233. * at the ground coordinates (x, z) expressed in the World system.
  23234. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23235. * @param x x coordinate
  23236. * @param z z coordinate
  23237. * @param ref vector to store the result
  23238. * @returns the GroundMesh.
  23239. */
  23240. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23241. /**
  23242. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23243. * if the ground has been updated.
  23244. * This can be used in the render loop.
  23245. * @returns the GroundMesh.
  23246. */
  23247. updateCoordinateHeights(): GroundMesh;
  23248. private _getFacetAt;
  23249. private _initHeightQuads;
  23250. private _computeHeightQuads;
  23251. /**
  23252. * Serializes this ground mesh
  23253. * @param serializationObject object to write serialization to
  23254. */
  23255. serialize(serializationObject: any): void;
  23256. /**
  23257. * Parses a serialized ground mesh
  23258. * @param parsedMesh the serialized mesh
  23259. * @param scene the scene to create the ground mesh in
  23260. * @returns the created ground mesh
  23261. */
  23262. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23263. }
  23264. }
  23265. declare module BABYLON {
  23266. /**
  23267. * Interface for Physics-Joint data
  23268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23269. */
  23270. export interface PhysicsJointData {
  23271. /**
  23272. * The main pivot of the joint
  23273. */
  23274. mainPivot?: Vector3;
  23275. /**
  23276. * The connected pivot of the joint
  23277. */
  23278. connectedPivot?: Vector3;
  23279. /**
  23280. * The main axis of the joint
  23281. */
  23282. mainAxis?: Vector3;
  23283. /**
  23284. * The connected axis of the joint
  23285. */
  23286. connectedAxis?: Vector3;
  23287. /**
  23288. * The collision of the joint
  23289. */
  23290. collision?: boolean;
  23291. /**
  23292. * Native Oimo/Cannon/Energy data
  23293. */
  23294. nativeParams?: any;
  23295. }
  23296. /**
  23297. * This is a holder class for the physics joint created by the physics plugin
  23298. * It holds a set of functions to control the underlying joint
  23299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23300. */
  23301. export class PhysicsJoint {
  23302. /**
  23303. * The type of the physics joint
  23304. */
  23305. type: number;
  23306. /**
  23307. * The data for the physics joint
  23308. */
  23309. jointData: PhysicsJointData;
  23310. private _physicsJoint;
  23311. protected _physicsPlugin: IPhysicsEnginePlugin;
  23312. /**
  23313. * Initializes the physics joint
  23314. * @param type The type of the physics joint
  23315. * @param jointData The data for the physics joint
  23316. */
  23317. constructor(
  23318. /**
  23319. * The type of the physics joint
  23320. */
  23321. type: number,
  23322. /**
  23323. * The data for the physics joint
  23324. */
  23325. jointData: PhysicsJointData);
  23326. /**
  23327. * Gets the physics joint
  23328. */
  23329. get physicsJoint(): any;
  23330. /**
  23331. * Sets the physics joint
  23332. */
  23333. set physicsJoint(newJoint: any);
  23334. /**
  23335. * Sets the physics plugin
  23336. */
  23337. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23338. /**
  23339. * Execute a function that is physics-plugin specific.
  23340. * @param {Function} func the function that will be executed.
  23341. * It accepts two parameters: the physics world and the physics joint
  23342. */
  23343. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23344. /**
  23345. * Distance-Joint type
  23346. */
  23347. static DistanceJoint: number;
  23348. /**
  23349. * Hinge-Joint type
  23350. */
  23351. static HingeJoint: number;
  23352. /**
  23353. * Ball-and-Socket joint type
  23354. */
  23355. static BallAndSocketJoint: number;
  23356. /**
  23357. * Wheel-Joint type
  23358. */
  23359. static WheelJoint: number;
  23360. /**
  23361. * Slider-Joint type
  23362. */
  23363. static SliderJoint: number;
  23364. /**
  23365. * Prismatic-Joint type
  23366. */
  23367. static PrismaticJoint: number;
  23368. /**
  23369. * Universal-Joint type
  23370. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23371. */
  23372. static UniversalJoint: number;
  23373. /**
  23374. * Hinge-Joint 2 type
  23375. */
  23376. static Hinge2Joint: number;
  23377. /**
  23378. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23379. */
  23380. static PointToPointJoint: number;
  23381. /**
  23382. * Spring-Joint type
  23383. */
  23384. static SpringJoint: number;
  23385. /**
  23386. * Lock-Joint type
  23387. */
  23388. static LockJoint: number;
  23389. }
  23390. /**
  23391. * A class representing a physics distance joint
  23392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23393. */
  23394. export class DistanceJoint extends PhysicsJoint {
  23395. /**
  23396. *
  23397. * @param jointData The data for the Distance-Joint
  23398. */
  23399. constructor(jointData: DistanceJointData);
  23400. /**
  23401. * Update the predefined distance.
  23402. * @param maxDistance The maximum preferred distance
  23403. * @param minDistance The minimum preferred distance
  23404. */
  23405. updateDistance(maxDistance: number, minDistance?: number): void;
  23406. }
  23407. /**
  23408. * Represents a Motor-Enabled Joint
  23409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23410. */
  23411. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23412. /**
  23413. * Initializes the Motor-Enabled Joint
  23414. * @param type The type of the joint
  23415. * @param jointData The physica joint data for the joint
  23416. */
  23417. constructor(type: number, jointData: PhysicsJointData);
  23418. /**
  23419. * Set the motor values.
  23420. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23421. * @param force the force to apply
  23422. * @param maxForce max force for this motor.
  23423. */
  23424. setMotor(force?: number, maxForce?: number): void;
  23425. /**
  23426. * Set the motor's limits.
  23427. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23428. * @param upperLimit The upper limit of the motor
  23429. * @param lowerLimit The lower limit of the motor
  23430. */
  23431. setLimit(upperLimit: number, lowerLimit?: number): void;
  23432. }
  23433. /**
  23434. * This class represents a single physics Hinge-Joint
  23435. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23436. */
  23437. export class HingeJoint extends MotorEnabledJoint {
  23438. /**
  23439. * Initializes the Hinge-Joint
  23440. * @param jointData The joint data for the Hinge-Joint
  23441. */
  23442. constructor(jointData: PhysicsJointData);
  23443. /**
  23444. * Set the motor values.
  23445. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23446. * @param {number} force the force to apply
  23447. * @param {number} maxForce max force for this motor.
  23448. */
  23449. setMotor(force?: number, maxForce?: number): void;
  23450. /**
  23451. * Set the motor's limits.
  23452. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23453. * @param upperLimit The upper limit of the motor
  23454. * @param lowerLimit The lower limit of the motor
  23455. */
  23456. setLimit(upperLimit: number, lowerLimit?: number): void;
  23457. }
  23458. /**
  23459. * This class represents a dual hinge physics joint (same as wheel joint)
  23460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23461. */
  23462. export class Hinge2Joint extends MotorEnabledJoint {
  23463. /**
  23464. * Initializes the Hinge2-Joint
  23465. * @param jointData The joint data for the Hinge2-Joint
  23466. */
  23467. constructor(jointData: PhysicsJointData);
  23468. /**
  23469. * Set the motor values.
  23470. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23471. * @param {number} targetSpeed the speed the motor is to reach
  23472. * @param {number} maxForce max force for this motor.
  23473. * @param {motorIndex} the motor's index, 0 or 1.
  23474. */
  23475. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23476. /**
  23477. * Set the motor limits.
  23478. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23479. * @param {number} upperLimit the upper limit
  23480. * @param {number} lowerLimit lower limit
  23481. * @param {motorIndex} the motor's index, 0 or 1.
  23482. */
  23483. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23484. }
  23485. /**
  23486. * Interface for a motor enabled joint
  23487. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23488. */
  23489. export interface IMotorEnabledJoint {
  23490. /**
  23491. * Physics joint
  23492. */
  23493. physicsJoint: any;
  23494. /**
  23495. * Sets the motor of the motor-enabled joint
  23496. * @param force The force of the motor
  23497. * @param maxForce The maximum force of the motor
  23498. * @param motorIndex The index of the motor
  23499. */
  23500. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23501. /**
  23502. * Sets the limit of the motor
  23503. * @param upperLimit The upper limit of the motor
  23504. * @param lowerLimit The lower limit of the motor
  23505. * @param motorIndex The index of the motor
  23506. */
  23507. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23508. }
  23509. /**
  23510. * Joint data for a Distance-Joint
  23511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23512. */
  23513. export interface DistanceJointData extends PhysicsJointData {
  23514. /**
  23515. * Max distance the 2 joint objects can be apart
  23516. */
  23517. maxDistance: number;
  23518. }
  23519. /**
  23520. * Joint data from a spring joint
  23521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23522. */
  23523. export interface SpringJointData extends PhysicsJointData {
  23524. /**
  23525. * Length of the spring
  23526. */
  23527. length: number;
  23528. /**
  23529. * Stiffness of the spring
  23530. */
  23531. stiffness: number;
  23532. /**
  23533. * Damping of the spring
  23534. */
  23535. damping: number;
  23536. /** this callback will be called when applying the force to the impostors. */
  23537. forceApplicationCallback: () => void;
  23538. }
  23539. }
  23540. declare module BABYLON {
  23541. /**
  23542. * Holds the data for the raycast result
  23543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23544. */
  23545. export class PhysicsRaycastResult {
  23546. private _hasHit;
  23547. private _hitDistance;
  23548. private _hitNormalWorld;
  23549. private _hitPointWorld;
  23550. private _rayFromWorld;
  23551. private _rayToWorld;
  23552. /**
  23553. * Gets if there was a hit
  23554. */
  23555. get hasHit(): boolean;
  23556. /**
  23557. * Gets the distance from the hit
  23558. */
  23559. get hitDistance(): number;
  23560. /**
  23561. * Gets the hit normal/direction in the world
  23562. */
  23563. get hitNormalWorld(): Vector3;
  23564. /**
  23565. * Gets the hit point in the world
  23566. */
  23567. get hitPointWorld(): Vector3;
  23568. /**
  23569. * Gets the ray "start point" of the ray in the world
  23570. */
  23571. get rayFromWorld(): Vector3;
  23572. /**
  23573. * Gets the ray "end point" of the ray in the world
  23574. */
  23575. get rayToWorld(): Vector3;
  23576. /**
  23577. * Sets the hit data (normal & point in world space)
  23578. * @param hitNormalWorld defines the normal in world space
  23579. * @param hitPointWorld defines the point in world space
  23580. */
  23581. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23582. /**
  23583. * Sets the distance from the start point to the hit point
  23584. * @param distance
  23585. */
  23586. setHitDistance(distance: number): void;
  23587. /**
  23588. * Calculates the distance manually
  23589. */
  23590. calculateHitDistance(): void;
  23591. /**
  23592. * Resets all the values to default
  23593. * @param from The from point on world space
  23594. * @param to The to point on world space
  23595. */
  23596. reset(from?: Vector3, to?: Vector3): void;
  23597. }
  23598. /**
  23599. * Interface for the size containing width and height
  23600. */
  23601. interface IXYZ {
  23602. /**
  23603. * X
  23604. */
  23605. x: number;
  23606. /**
  23607. * Y
  23608. */
  23609. y: number;
  23610. /**
  23611. * Z
  23612. */
  23613. z: number;
  23614. }
  23615. }
  23616. declare module BABYLON {
  23617. /**
  23618. * Interface used to describe a physics joint
  23619. */
  23620. export interface PhysicsImpostorJoint {
  23621. /** Defines the main impostor to which the joint is linked */
  23622. mainImpostor: PhysicsImpostor;
  23623. /** Defines the impostor that is connected to the main impostor using this joint */
  23624. connectedImpostor: PhysicsImpostor;
  23625. /** Defines the joint itself */
  23626. joint: PhysicsJoint;
  23627. }
  23628. /** @hidden */
  23629. export interface IPhysicsEnginePlugin {
  23630. world: any;
  23631. name: string;
  23632. setGravity(gravity: Vector3): void;
  23633. setTimeStep(timeStep: number): void;
  23634. getTimeStep(): number;
  23635. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23636. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23637. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23638. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23639. removePhysicsBody(impostor: PhysicsImpostor): void;
  23640. generateJoint(joint: PhysicsImpostorJoint): void;
  23641. removeJoint(joint: PhysicsImpostorJoint): void;
  23642. isSupported(): boolean;
  23643. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23644. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23645. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23646. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23647. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23648. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23649. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23650. getBodyMass(impostor: PhysicsImpostor): number;
  23651. getBodyFriction(impostor: PhysicsImpostor): number;
  23652. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23653. getBodyRestitution(impostor: PhysicsImpostor): number;
  23654. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23655. getBodyPressure?(impostor: PhysicsImpostor): number;
  23656. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23657. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23658. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23659. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23660. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23661. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23662. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23663. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23664. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23665. sleepBody(impostor: PhysicsImpostor): void;
  23666. wakeUpBody(impostor: PhysicsImpostor): void;
  23667. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23668. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23669. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23670. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23671. getRadius(impostor: PhysicsImpostor): number;
  23672. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23673. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23674. dispose(): void;
  23675. }
  23676. /**
  23677. * Interface used to define a physics engine
  23678. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23679. */
  23680. export interface IPhysicsEngine {
  23681. /**
  23682. * Gets the gravity vector used by the simulation
  23683. */
  23684. gravity: Vector3;
  23685. /**
  23686. * Sets the gravity vector used by the simulation
  23687. * @param gravity defines the gravity vector to use
  23688. */
  23689. setGravity(gravity: Vector3): void;
  23690. /**
  23691. * Set the time step of the physics engine.
  23692. * Default is 1/60.
  23693. * To slow it down, enter 1/600 for example.
  23694. * To speed it up, 1/30
  23695. * @param newTimeStep the new timestep to apply to this world.
  23696. */
  23697. setTimeStep(newTimeStep: number): void;
  23698. /**
  23699. * Get the time step of the physics engine.
  23700. * @returns the current time step
  23701. */
  23702. getTimeStep(): number;
  23703. /**
  23704. * Set the sub time step of the physics engine.
  23705. * Default is 0 meaning there is no sub steps
  23706. * To increase physics resolution precision, set a small value (like 1 ms)
  23707. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23708. */
  23709. setSubTimeStep(subTimeStep: number): void;
  23710. /**
  23711. * Get the sub time step of the physics engine.
  23712. * @returns the current sub time step
  23713. */
  23714. getSubTimeStep(): number;
  23715. /**
  23716. * Release all resources
  23717. */
  23718. dispose(): void;
  23719. /**
  23720. * Gets the name of the current physics plugin
  23721. * @returns the name of the plugin
  23722. */
  23723. getPhysicsPluginName(): string;
  23724. /**
  23725. * Adding a new impostor for the impostor tracking.
  23726. * This will be done by the impostor itself.
  23727. * @param impostor the impostor to add
  23728. */
  23729. addImpostor(impostor: PhysicsImpostor): void;
  23730. /**
  23731. * Remove an impostor from the engine.
  23732. * This impostor and its mesh will not longer be updated by the physics engine.
  23733. * @param impostor the impostor to remove
  23734. */
  23735. removeImpostor(impostor: PhysicsImpostor): void;
  23736. /**
  23737. * Add a joint to the physics engine
  23738. * @param mainImpostor defines the main impostor to which the joint is added.
  23739. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23740. * @param joint defines the joint that will connect both impostors.
  23741. */
  23742. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23743. /**
  23744. * Removes a joint from the simulation
  23745. * @param mainImpostor defines the impostor used with the joint
  23746. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23747. * @param joint defines the joint to remove
  23748. */
  23749. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23750. /**
  23751. * Gets the current plugin used to run the simulation
  23752. * @returns current plugin
  23753. */
  23754. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23755. /**
  23756. * Gets the list of physic impostors
  23757. * @returns an array of PhysicsImpostor
  23758. */
  23759. getImpostors(): Array<PhysicsImpostor>;
  23760. /**
  23761. * Gets the impostor for a physics enabled object
  23762. * @param object defines the object impersonated by the impostor
  23763. * @returns the PhysicsImpostor or null if not found
  23764. */
  23765. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23766. /**
  23767. * Gets the impostor for a physics body object
  23768. * @param body defines physics body used by the impostor
  23769. * @returns the PhysicsImpostor or null if not found
  23770. */
  23771. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23772. /**
  23773. * Does a raycast in the physics world
  23774. * @param from when should the ray start?
  23775. * @param to when should the ray end?
  23776. * @returns PhysicsRaycastResult
  23777. */
  23778. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23779. /**
  23780. * Called by the scene. No need to call it.
  23781. * @param delta defines the timespam between frames
  23782. */
  23783. _step(delta: number): void;
  23784. }
  23785. }
  23786. declare module BABYLON {
  23787. /**
  23788. * The interface for the physics imposter parameters
  23789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23790. */
  23791. export interface PhysicsImpostorParameters {
  23792. /**
  23793. * The mass of the physics imposter
  23794. */
  23795. mass: number;
  23796. /**
  23797. * The friction of the physics imposter
  23798. */
  23799. friction?: number;
  23800. /**
  23801. * The coefficient of restitution of the physics imposter
  23802. */
  23803. restitution?: number;
  23804. /**
  23805. * The native options of the physics imposter
  23806. */
  23807. nativeOptions?: any;
  23808. /**
  23809. * Specifies if the parent should be ignored
  23810. */
  23811. ignoreParent?: boolean;
  23812. /**
  23813. * Specifies if bi-directional transformations should be disabled
  23814. */
  23815. disableBidirectionalTransformation?: boolean;
  23816. /**
  23817. * The pressure inside the physics imposter, soft object only
  23818. */
  23819. pressure?: number;
  23820. /**
  23821. * The stiffness the physics imposter, soft object only
  23822. */
  23823. stiffness?: number;
  23824. /**
  23825. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23826. */
  23827. velocityIterations?: number;
  23828. /**
  23829. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23830. */
  23831. positionIterations?: number;
  23832. /**
  23833. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23834. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23835. * Add to fix multiple points
  23836. */
  23837. fixedPoints?: number;
  23838. /**
  23839. * The collision margin around a soft object
  23840. */
  23841. margin?: number;
  23842. /**
  23843. * The collision margin around a soft object
  23844. */
  23845. damping?: number;
  23846. /**
  23847. * The path for a rope based on an extrusion
  23848. */
  23849. path?: any;
  23850. /**
  23851. * The shape of an extrusion used for a rope based on an extrusion
  23852. */
  23853. shape?: any;
  23854. }
  23855. /**
  23856. * Interface for a physics-enabled object
  23857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23858. */
  23859. export interface IPhysicsEnabledObject {
  23860. /**
  23861. * The position of the physics-enabled object
  23862. */
  23863. position: Vector3;
  23864. /**
  23865. * The rotation of the physics-enabled object
  23866. */
  23867. rotationQuaternion: Nullable<Quaternion>;
  23868. /**
  23869. * The scale of the physics-enabled object
  23870. */
  23871. scaling: Vector3;
  23872. /**
  23873. * The rotation of the physics-enabled object
  23874. */
  23875. rotation?: Vector3;
  23876. /**
  23877. * The parent of the physics-enabled object
  23878. */
  23879. parent?: any;
  23880. /**
  23881. * The bounding info of the physics-enabled object
  23882. * @returns The bounding info of the physics-enabled object
  23883. */
  23884. getBoundingInfo(): BoundingInfo;
  23885. /**
  23886. * Computes the world matrix
  23887. * @param force Specifies if the world matrix should be computed by force
  23888. * @returns A world matrix
  23889. */
  23890. computeWorldMatrix(force: boolean): Matrix;
  23891. /**
  23892. * Gets the world matrix
  23893. * @returns A world matrix
  23894. */
  23895. getWorldMatrix?(): Matrix;
  23896. /**
  23897. * Gets the child meshes
  23898. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23899. * @returns An array of abstract meshes
  23900. */
  23901. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23902. /**
  23903. * Gets the vertex data
  23904. * @param kind The type of vertex data
  23905. * @returns A nullable array of numbers, or a float32 array
  23906. */
  23907. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23908. /**
  23909. * Gets the indices from the mesh
  23910. * @returns A nullable array of index arrays
  23911. */
  23912. getIndices?(): Nullable<IndicesArray>;
  23913. /**
  23914. * Gets the scene from the mesh
  23915. * @returns the indices array or null
  23916. */
  23917. getScene?(): Scene;
  23918. /**
  23919. * Gets the absolute position from the mesh
  23920. * @returns the absolute position
  23921. */
  23922. getAbsolutePosition(): Vector3;
  23923. /**
  23924. * Gets the absolute pivot point from the mesh
  23925. * @returns the absolute pivot point
  23926. */
  23927. getAbsolutePivotPoint(): Vector3;
  23928. /**
  23929. * Rotates the mesh
  23930. * @param axis The axis of rotation
  23931. * @param amount The amount of rotation
  23932. * @param space The space of the rotation
  23933. * @returns The rotation transform node
  23934. */
  23935. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23936. /**
  23937. * Translates the mesh
  23938. * @param axis The axis of translation
  23939. * @param distance The distance of translation
  23940. * @param space The space of the translation
  23941. * @returns The transform node
  23942. */
  23943. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23944. /**
  23945. * Sets the absolute position of the mesh
  23946. * @param absolutePosition The absolute position of the mesh
  23947. * @returns The transform node
  23948. */
  23949. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23950. /**
  23951. * Gets the class name of the mesh
  23952. * @returns The class name
  23953. */
  23954. getClassName(): string;
  23955. }
  23956. /**
  23957. * Represents a physics imposter
  23958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23959. */
  23960. export class PhysicsImpostor {
  23961. /**
  23962. * The physics-enabled object used as the physics imposter
  23963. */
  23964. object: IPhysicsEnabledObject;
  23965. /**
  23966. * The type of the physics imposter
  23967. */
  23968. type: number;
  23969. private _options;
  23970. private _scene?;
  23971. /**
  23972. * The default object size of the imposter
  23973. */
  23974. static DEFAULT_OBJECT_SIZE: Vector3;
  23975. /**
  23976. * The identity quaternion of the imposter
  23977. */
  23978. static IDENTITY_QUATERNION: Quaternion;
  23979. /** @hidden */
  23980. _pluginData: any;
  23981. private _physicsEngine;
  23982. private _physicsBody;
  23983. private _bodyUpdateRequired;
  23984. private _onBeforePhysicsStepCallbacks;
  23985. private _onAfterPhysicsStepCallbacks;
  23986. /** @hidden */
  23987. _onPhysicsCollideCallbacks: Array<{
  23988. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23989. otherImpostors: Array<PhysicsImpostor>;
  23990. }>;
  23991. private _deltaPosition;
  23992. private _deltaRotation;
  23993. private _deltaRotationConjugated;
  23994. /** @hidden */
  23995. _isFromLine: boolean;
  23996. private _parent;
  23997. private _isDisposed;
  23998. private static _tmpVecs;
  23999. private static _tmpQuat;
  24000. /**
  24001. * Specifies if the physics imposter is disposed
  24002. */
  24003. get isDisposed(): boolean;
  24004. /**
  24005. * Gets the mass of the physics imposter
  24006. */
  24007. get mass(): number;
  24008. set mass(value: number);
  24009. /**
  24010. * Gets the coefficient of friction
  24011. */
  24012. get friction(): number;
  24013. /**
  24014. * Sets the coefficient of friction
  24015. */
  24016. set friction(value: number);
  24017. /**
  24018. * Gets the coefficient of restitution
  24019. */
  24020. get restitution(): number;
  24021. /**
  24022. * Sets the coefficient of restitution
  24023. */
  24024. set restitution(value: number);
  24025. /**
  24026. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24027. */
  24028. get pressure(): number;
  24029. /**
  24030. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24031. */
  24032. set pressure(value: number);
  24033. /**
  24034. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24035. */
  24036. get stiffness(): number;
  24037. /**
  24038. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24039. */
  24040. set stiffness(value: number);
  24041. /**
  24042. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24043. */
  24044. get velocityIterations(): number;
  24045. /**
  24046. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24047. */
  24048. set velocityIterations(value: number);
  24049. /**
  24050. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24051. */
  24052. get positionIterations(): number;
  24053. /**
  24054. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24055. */
  24056. set positionIterations(value: number);
  24057. /**
  24058. * The unique id of the physics imposter
  24059. * set by the physics engine when adding this impostor to the array
  24060. */
  24061. uniqueId: number;
  24062. /**
  24063. * @hidden
  24064. */
  24065. soft: boolean;
  24066. /**
  24067. * @hidden
  24068. */
  24069. segments: number;
  24070. private _joints;
  24071. /**
  24072. * Initializes the physics imposter
  24073. * @param object The physics-enabled object used as the physics imposter
  24074. * @param type The type of the physics imposter
  24075. * @param _options The options for the physics imposter
  24076. * @param _scene The Babylon scene
  24077. */
  24078. constructor(
  24079. /**
  24080. * The physics-enabled object used as the physics imposter
  24081. */
  24082. object: IPhysicsEnabledObject,
  24083. /**
  24084. * The type of the physics imposter
  24085. */
  24086. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24087. /**
  24088. * This function will completly initialize this impostor.
  24089. * It will create a new body - but only if this mesh has no parent.
  24090. * If it has, this impostor will not be used other than to define the impostor
  24091. * of the child mesh.
  24092. * @hidden
  24093. */
  24094. _init(): void;
  24095. private _getPhysicsParent;
  24096. /**
  24097. * Should a new body be generated.
  24098. * @returns boolean specifying if body initialization is required
  24099. */
  24100. isBodyInitRequired(): boolean;
  24101. /**
  24102. * Sets the updated scaling
  24103. * @param updated Specifies if the scaling is updated
  24104. */
  24105. setScalingUpdated(): void;
  24106. /**
  24107. * Force a regeneration of this or the parent's impostor's body.
  24108. * Use under cautious - This will remove all joints already implemented.
  24109. */
  24110. forceUpdate(): void;
  24111. /**
  24112. * Gets the body that holds this impostor. Either its own, or its parent.
  24113. */
  24114. get physicsBody(): any;
  24115. /**
  24116. * Get the parent of the physics imposter
  24117. * @returns Physics imposter or null
  24118. */
  24119. get parent(): Nullable<PhysicsImpostor>;
  24120. /**
  24121. * Sets the parent of the physics imposter
  24122. */
  24123. set parent(value: Nullable<PhysicsImpostor>);
  24124. /**
  24125. * Set the physics body. Used mainly by the physics engine/plugin
  24126. */
  24127. set physicsBody(physicsBody: any);
  24128. /**
  24129. * Resets the update flags
  24130. */
  24131. resetUpdateFlags(): void;
  24132. /**
  24133. * Gets the object extend size
  24134. * @returns the object extend size
  24135. */
  24136. getObjectExtendSize(): Vector3;
  24137. /**
  24138. * Gets the object center
  24139. * @returns The object center
  24140. */
  24141. getObjectCenter(): Vector3;
  24142. /**
  24143. * Get a specific parameter from the options parameters
  24144. * @param paramName The object parameter name
  24145. * @returns The object parameter
  24146. */
  24147. getParam(paramName: string): any;
  24148. /**
  24149. * Sets a specific parameter in the options given to the physics plugin
  24150. * @param paramName The parameter name
  24151. * @param value The value of the parameter
  24152. */
  24153. setParam(paramName: string, value: number): void;
  24154. /**
  24155. * Specifically change the body's mass option. Won't recreate the physics body object
  24156. * @param mass The mass of the physics imposter
  24157. */
  24158. setMass(mass: number): void;
  24159. /**
  24160. * Gets the linear velocity
  24161. * @returns linear velocity or null
  24162. */
  24163. getLinearVelocity(): Nullable<Vector3>;
  24164. /**
  24165. * Sets the linear velocity
  24166. * @param velocity linear velocity or null
  24167. */
  24168. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24169. /**
  24170. * Gets the angular velocity
  24171. * @returns angular velocity or null
  24172. */
  24173. getAngularVelocity(): Nullable<Vector3>;
  24174. /**
  24175. * Sets the angular velocity
  24176. * @param velocity The velocity or null
  24177. */
  24178. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24179. /**
  24180. * Execute a function with the physics plugin native code
  24181. * Provide a function the will have two variables - the world object and the physics body object
  24182. * @param func The function to execute with the physics plugin native code
  24183. */
  24184. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24185. /**
  24186. * Register a function that will be executed before the physics world is stepping forward
  24187. * @param func The function to execute before the physics world is stepped forward
  24188. */
  24189. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24190. /**
  24191. * Unregister a function that will be executed before the physics world is stepping forward
  24192. * @param func The function to execute before the physics world is stepped forward
  24193. */
  24194. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24195. /**
  24196. * Register a function that will be executed after the physics step
  24197. * @param func The function to execute after physics step
  24198. */
  24199. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24200. /**
  24201. * Unregisters a function that will be executed after the physics step
  24202. * @param func The function to execute after physics step
  24203. */
  24204. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24205. /**
  24206. * register a function that will be executed when this impostor collides against a different body
  24207. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24208. * @param func Callback that is executed on collision
  24209. */
  24210. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24211. /**
  24212. * Unregisters the physics imposter on contact
  24213. * @param collideAgainst The physics object to collide against
  24214. * @param func Callback to execute on collision
  24215. */
  24216. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24217. private _tmpQuat;
  24218. private _tmpQuat2;
  24219. /**
  24220. * Get the parent rotation
  24221. * @returns The parent rotation
  24222. */
  24223. getParentsRotation(): Quaternion;
  24224. /**
  24225. * this function is executed by the physics engine.
  24226. */
  24227. beforeStep: () => void;
  24228. /**
  24229. * this function is executed by the physics engine
  24230. */
  24231. afterStep: () => void;
  24232. /**
  24233. * Legacy collision detection event support
  24234. */
  24235. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24236. /**
  24237. * event and body object due to cannon's event-based architecture.
  24238. */
  24239. onCollide: (e: {
  24240. body: any;
  24241. }) => void;
  24242. /**
  24243. * Apply a force
  24244. * @param force The force to apply
  24245. * @param contactPoint The contact point for the force
  24246. * @returns The physics imposter
  24247. */
  24248. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24249. /**
  24250. * Apply an impulse
  24251. * @param force The impulse force
  24252. * @param contactPoint The contact point for the impulse force
  24253. * @returns The physics imposter
  24254. */
  24255. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24256. /**
  24257. * A help function to create a joint
  24258. * @param otherImpostor A physics imposter used to create a joint
  24259. * @param jointType The type of joint
  24260. * @param jointData The data for the joint
  24261. * @returns The physics imposter
  24262. */
  24263. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24264. /**
  24265. * Add a joint to this impostor with a different impostor
  24266. * @param otherImpostor A physics imposter used to add a joint
  24267. * @param joint The joint to add
  24268. * @returns The physics imposter
  24269. */
  24270. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24271. /**
  24272. * Add an anchor to a cloth impostor
  24273. * @param otherImpostor rigid impostor to anchor to
  24274. * @param width ratio across width from 0 to 1
  24275. * @param height ratio up height from 0 to 1
  24276. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24277. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24278. * @returns impostor the soft imposter
  24279. */
  24280. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24281. /**
  24282. * Add a hook to a rope impostor
  24283. * @param otherImpostor rigid impostor to anchor to
  24284. * @param length ratio across rope from 0 to 1
  24285. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24286. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24287. * @returns impostor the rope imposter
  24288. */
  24289. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24290. /**
  24291. * Will keep this body still, in a sleep mode.
  24292. * @returns the physics imposter
  24293. */
  24294. sleep(): PhysicsImpostor;
  24295. /**
  24296. * Wake the body up.
  24297. * @returns The physics imposter
  24298. */
  24299. wakeUp(): PhysicsImpostor;
  24300. /**
  24301. * Clones the physics imposter
  24302. * @param newObject The physics imposter clones to this physics-enabled object
  24303. * @returns A nullable physics imposter
  24304. */
  24305. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24306. /**
  24307. * Disposes the physics imposter
  24308. */
  24309. dispose(): void;
  24310. /**
  24311. * Sets the delta position
  24312. * @param position The delta position amount
  24313. */
  24314. setDeltaPosition(position: Vector3): void;
  24315. /**
  24316. * Sets the delta rotation
  24317. * @param rotation The delta rotation amount
  24318. */
  24319. setDeltaRotation(rotation: Quaternion): void;
  24320. /**
  24321. * Gets the box size of the physics imposter and stores the result in the input parameter
  24322. * @param result Stores the box size
  24323. * @returns The physics imposter
  24324. */
  24325. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24326. /**
  24327. * Gets the radius of the physics imposter
  24328. * @returns Radius of the physics imposter
  24329. */
  24330. getRadius(): number;
  24331. /**
  24332. * Sync a bone with this impostor
  24333. * @param bone The bone to sync to the impostor.
  24334. * @param boneMesh The mesh that the bone is influencing.
  24335. * @param jointPivot The pivot of the joint / bone in local space.
  24336. * @param distToJoint Optional distance from the impostor to the joint.
  24337. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24338. */
  24339. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24340. /**
  24341. * Sync impostor to a bone
  24342. * @param bone The bone that the impostor will be synced to.
  24343. * @param boneMesh The mesh that the bone is influencing.
  24344. * @param jointPivot The pivot of the joint / bone in local space.
  24345. * @param distToJoint Optional distance from the impostor to the joint.
  24346. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24347. * @param boneAxis Optional vector3 axis the bone is aligned with
  24348. */
  24349. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24350. /**
  24351. * No-Imposter type
  24352. */
  24353. static NoImpostor: number;
  24354. /**
  24355. * Sphere-Imposter type
  24356. */
  24357. static SphereImpostor: number;
  24358. /**
  24359. * Box-Imposter type
  24360. */
  24361. static BoxImpostor: number;
  24362. /**
  24363. * Plane-Imposter type
  24364. */
  24365. static PlaneImpostor: number;
  24366. /**
  24367. * Mesh-imposter type
  24368. */
  24369. static MeshImpostor: number;
  24370. /**
  24371. * Capsule-Impostor type (Ammo.js plugin only)
  24372. */
  24373. static CapsuleImpostor: number;
  24374. /**
  24375. * Cylinder-Imposter type
  24376. */
  24377. static CylinderImpostor: number;
  24378. /**
  24379. * Particle-Imposter type
  24380. */
  24381. static ParticleImpostor: number;
  24382. /**
  24383. * Heightmap-Imposter type
  24384. */
  24385. static HeightmapImpostor: number;
  24386. /**
  24387. * ConvexHull-Impostor type (Ammo.js plugin only)
  24388. */
  24389. static ConvexHullImpostor: number;
  24390. /**
  24391. * Custom-Imposter type (Ammo.js plugin only)
  24392. */
  24393. static CustomImpostor: number;
  24394. /**
  24395. * Rope-Imposter type
  24396. */
  24397. static RopeImpostor: number;
  24398. /**
  24399. * Cloth-Imposter type
  24400. */
  24401. static ClothImpostor: number;
  24402. /**
  24403. * Softbody-Imposter type
  24404. */
  24405. static SoftbodyImpostor: number;
  24406. }
  24407. }
  24408. declare module BABYLON {
  24409. /**
  24410. * @hidden
  24411. **/
  24412. export class _CreationDataStorage {
  24413. closePath?: boolean;
  24414. closeArray?: boolean;
  24415. idx: number[];
  24416. dashSize: number;
  24417. gapSize: number;
  24418. path3D: Path3D;
  24419. pathArray: Vector3[][];
  24420. arc: number;
  24421. radius: number;
  24422. cap: number;
  24423. tessellation: number;
  24424. }
  24425. /**
  24426. * @hidden
  24427. **/
  24428. class _InstanceDataStorage {
  24429. visibleInstances: any;
  24430. batchCache: _InstancesBatch;
  24431. instancesBufferSize: number;
  24432. instancesBuffer: Nullable<Buffer>;
  24433. instancesData: Float32Array;
  24434. overridenInstanceCount: number;
  24435. isFrozen: boolean;
  24436. previousBatch: Nullable<_InstancesBatch>;
  24437. hardwareInstancedRendering: boolean;
  24438. sideOrientation: number;
  24439. manualUpdate: boolean;
  24440. }
  24441. /**
  24442. * @hidden
  24443. **/
  24444. export class _InstancesBatch {
  24445. mustReturn: boolean;
  24446. visibleInstances: Nullable<InstancedMesh[]>[];
  24447. renderSelf: boolean[];
  24448. hardwareInstancedRendering: boolean[];
  24449. }
  24450. /**
  24451. * Class used to represent renderable models
  24452. */
  24453. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24454. /**
  24455. * Mesh side orientation : usually the external or front surface
  24456. */
  24457. static readonly FRONTSIDE: number;
  24458. /**
  24459. * Mesh side orientation : usually the internal or back surface
  24460. */
  24461. static readonly BACKSIDE: number;
  24462. /**
  24463. * Mesh side orientation : both internal and external or front and back surfaces
  24464. */
  24465. static readonly DOUBLESIDE: number;
  24466. /**
  24467. * Mesh side orientation : by default, `FRONTSIDE`
  24468. */
  24469. static readonly DEFAULTSIDE: number;
  24470. /**
  24471. * Mesh cap setting : no cap
  24472. */
  24473. static readonly NO_CAP: number;
  24474. /**
  24475. * Mesh cap setting : one cap at the beginning of the mesh
  24476. */
  24477. static readonly CAP_START: number;
  24478. /**
  24479. * Mesh cap setting : one cap at the end of the mesh
  24480. */
  24481. static readonly CAP_END: number;
  24482. /**
  24483. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24484. */
  24485. static readonly CAP_ALL: number;
  24486. /**
  24487. * Mesh pattern setting : no flip or rotate
  24488. */
  24489. static readonly NO_FLIP: number;
  24490. /**
  24491. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24492. */
  24493. static readonly FLIP_TILE: number;
  24494. /**
  24495. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24496. */
  24497. static readonly ROTATE_TILE: number;
  24498. /**
  24499. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24500. */
  24501. static readonly FLIP_ROW: number;
  24502. /**
  24503. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24504. */
  24505. static readonly ROTATE_ROW: number;
  24506. /**
  24507. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24508. */
  24509. static readonly FLIP_N_ROTATE_TILE: number;
  24510. /**
  24511. * Mesh pattern setting : rotate pattern and rotate
  24512. */
  24513. static readonly FLIP_N_ROTATE_ROW: number;
  24514. /**
  24515. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24516. */
  24517. static readonly CENTER: number;
  24518. /**
  24519. * Mesh tile positioning : part tiles on left
  24520. */
  24521. static readonly LEFT: number;
  24522. /**
  24523. * Mesh tile positioning : part tiles on right
  24524. */
  24525. static readonly RIGHT: number;
  24526. /**
  24527. * Mesh tile positioning : part tiles on top
  24528. */
  24529. static readonly TOP: number;
  24530. /**
  24531. * Mesh tile positioning : part tiles on bottom
  24532. */
  24533. static readonly BOTTOM: number;
  24534. /**
  24535. * Gets the default side orientation.
  24536. * @param orientation the orientation to value to attempt to get
  24537. * @returns the default orientation
  24538. * @hidden
  24539. */
  24540. static _GetDefaultSideOrientation(orientation?: number): number;
  24541. private _internalMeshDataInfo;
  24542. /**
  24543. * An event triggered before rendering the mesh
  24544. */
  24545. get onBeforeRenderObservable(): Observable<Mesh>;
  24546. /**
  24547. * An event triggered before binding the mesh
  24548. */
  24549. get onBeforeBindObservable(): Observable<Mesh>;
  24550. /**
  24551. * An event triggered after rendering the mesh
  24552. */
  24553. get onAfterRenderObservable(): Observable<Mesh>;
  24554. /**
  24555. * An event triggered before drawing the mesh
  24556. */
  24557. get onBeforeDrawObservable(): Observable<Mesh>;
  24558. private _onBeforeDrawObserver;
  24559. /**
  24560. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24561. */
  24562. set onBeforeDraw(callback: () => void);
  24563. get hasInstances(): boolean;
  24564. /**
  24565. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24566. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24567. */
  24568. delayLoadState: number;
  24569. /**
  24570. * Gets the list of instances created from this mesh
  24571. * it is not supposed to be modified manually.
  24572. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24573. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24574. */
  24575. instances: InstancedMesh[];
  24576. /**
  24577. * Gets the file containing delay loading data for this mesh
  24578. */
  24579. delayLoadingFile: string;
  24580. /** @hidden */
  24581. _binaryInfo: any;
  24582. /**
  24583. * User defined function used to change how LOD level selection is done
  24584. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24585. */
  24586. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24587. /**
  24588. * Gets or sets the morph target manager
  24589. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24590. */
  24591. get morphTargetManager(): Nullable<MorphTargetManager>;
  24592. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24593. /** @hidden */
  24594. _creationDataStorage: Nullable<_CreationDataStorage>;
  24595. /** @hidden */
  24596. _geometry: Nullable<Geometry>;
  24597. /** @hidden */
  24598. _delayInfo: Array<string>;
  24599. /** @hidden */
  24600. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24601. /** @hidden */
  24602. _instanceDataStorage: _InstanceDataStorage;
  24603. private _effectiveMaterial;
  24604. /** @hidden */
  24605. _shouldGenerateFlatShading: boolean;
  24606. /** @hidden */
  24607. _originalBuilderSideOrientation: number;
  24608. /**
  24609. * Use this property to change the original side orientation defined at construction time
  24610. */
  24611. overrideMaterialSideOrientation: Nullable<number>;
  24612. /**
  24613. * Gets the source mesh (the one used to clone this one from)
  24614. */
  24615. get source(): Nullable<Mesh>;
  24616. /**
  24617. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24618. */
  24619. get isUnIndexed(): boolean;
  24620. set isUnIndexed(value: boolean);
  24621. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24622. get worldMatrixInstancedBuffer(): Float32Array;
  24623. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24624. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24625. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24626. /**
  24627. * @constructor
  24628. * @param name The value used by scene.getMeshByName() to do a lookup.
  24629. * @param scene The scene to add this mesh to.
  24630. * @param parent The parent of this mesh, if it has one
  24631. * @param source An optional Mesh from which geometry is shared, cloned.
  24632. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24633. * When false, achieved by calling a clone(), also passing False.
  24634. * This will make creation of children, recursive.
  24635. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24636. */
  24637. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24638. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24639. doNotInstantiate: boolean;
  24640. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24641. /**
  24642. * Gets the class name
  24643. * @returns the string "Mesh".
  24644. */
  24645. getClassName(): string;
  24646. /** @hidden */
  24647. get _isMesh(): boolean;
  24648. /**
  24649. * Returns a description of this mesh
  24650. * @param fullDetails define if full details about this mesh must be used
  24651. * @returns a descriptive string representing this mesh
  24652. */
  24653. toString(fullDetails?: boolean): string;
  24654. /** @hidden */
  24655. _unBindEffect(): void;
  24656. /**
  24657. * Gets a boolean indicating if this mesh has LOD
  24658. */
  24659. get hasLODLevels(): boolean;
  24660. /**
  24661. * Gets the list of MeshLODLevel associated with the current mesh
  24662. * @returns an array of MeshLODLevel
  24663. */
  24664. getLODLevels(): MeshLODLevel[];
  24665. private _sortLODLevels;
  24666. /**
  24667. * Add a mesh as LOD level triggered at the given distance.
  24668. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24669. * @param distance The distance from the center of the object to show this level
  24670. * @param mesh The mesh to be added as LOD level (can be null)
  24671. * @return This mesh (for chaining)
  24672. */
  24673. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24674. /**
  24675. * Returns the LOD level mesh at the passed distance or null if not found.
  24676. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24677. * @param distance The distance from the center of the object to show this level
  24678. * @returns a Mesh or `null`
  24679. */
  24680. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24681. /**
  24682. * Remove a mesh from the LOD array
  24683. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24684. * @param mesh defines the mesh to be removed
  24685. * @return This mesh (for chaining)
  24686. */
  24687. removeLODLevel(mesh: Mesh): Mesh;
  24688. /**
  24689. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24690. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24691. * @param camera defines the camera to use to compute distance
  24692. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24693. * @return This mesh (for chaining)
  24694. */
  24695. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24696. /**
  24697. * Gets the mesh internal Geometry object
  24698. */
  24699. get geometry(): Nullable<Geometry>;
  24700. /**
  24701. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24702. * @returns the total number of vertices
  24703. */
  24704. getTotalVertices(): number;
  24705. /**
  24706. * Returns the content of an associated vertex buffer
  24707. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24708. * - VertexBuffer.PositionKind
  24709. * - VertexBuffer.UVKind
  24710. * - VertexBuffer.UV2Kind
  24711. * - VertexBuffer.UV3Kind
  24712. * - VertexBuffer.UV4Kind
  24713. * - VertexBuffer.UV5Kind
  24714. * - VertexBuffer.UV6Kind
  24715. * - VertexBuffer.ColorKind
  24716. * - VertexBuffer.MatricesIndicesKind
  24717. * - VertexBuffer.MatricesIndicesExtraKind
  24718. * - VertexBuffer.MatricesWeightsKind
  24719. * - VertexBuffer.MatricesWeightsExtraKind
  24720. * @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
  24721. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24722. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24723. */
  24724. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24725. /**
  24726. * Returns the mesh VertexBuffer object from the requested `kind`
  24727. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24728. * - VertexBuffer.PositionKind
  24729. * - VertexBuffer.NormalKind
  24730. * - VertexBuffer.UVKind
  24731. * - VertexBuffer.UV2Kind
  24732. * - VertexBuffer.UV3Kind
  24733. * - VertexBuffer.UV4Kind
  24734. * - VertexBuffer.UV5Kind
  24735. * - VertexBuffer.UV6Kind
  24736. * - VertexBuffer.ColorKind
  24737. * - VertexBuffer.MatricesIndicesKind
  24738. * - VertexBuffer.MatricesIndicesExtraKind
  24739. * - VertexBuffer.MatricesWeightsKind
  24740. * - VertexBuffer.MatricesWeightsExtraKind
  24741. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24742. */
  24743. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24744. /**
  24745. * Tests if a specific vertex buffer is associated with this mesh
  24746. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24747. * - VertexBuffer.PositionKind
  24748. * - VertexBuffer.NormalKind
  24749. * - VertexBuffer.UVKind
  24750. * - VertexBuffer.UV2Kind
  24751. * - VertexBuffer.UV3Kind
  24752. * - VertexBuffer.UV4Kind
  24753. * - VertexBuffer.UV5Kind
  24754. * - VertexBuffer.UV6Kind
  24755. * - VertexBuffer.ColorKind
  24756. * - VertexBuffer.MatricesIndicesKind
  24757. * - VertexBuffer.MatricesIndicesExtraKind
  24758. * - VertexBuffer.MatricesWeightsKind
  24759. * - VertexBuffer.MatricesWeightsExtraKind
  24760. * @returns a boolean
  24761. */
  24762. isVerticesDataPresent(kind: string): boolean;
  24763. /**
  24764. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24765. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24766. * - VertexBuffer.PositionKind
  24767. * - VertexBuffer.UVKind
  24768. * - VertexBuffer.UV2Kind
  24769. * - VertexBuffer.UV3Kind
  24770. * - VertexBuffer.UV4Kind
  24771. * - VertexBuffer.UV5Kind
  24772. * - VertexBuffer.UV6Kind
  24773. * - VertexBuffer.ColorKind
  24774. * - VertexBuffer.MatricesIndicesKind
  24775. * - VertexBuffer.MatricesIndicesExtraKind
  24776. * - VertexBuffer.MatricesWeightsKind
  24777. * - VertexBuffer.MatricesWeightsExtraKind
  24778. * @returns a boolean
  24779. */
  24780. isVertexBufferUpdatable(kind: string): boolean;
  24781. /**
  24782. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24783. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24784. * - VertexBuffer.PositionKind
  24785. * - VertexBuffer.NormalKind
  24786. * - VertexBuffer.UVKind
  24787. * - VertexBuffer.UV2Kind
  24788. * - VertexBuffer.UV3Kind
  24789. * - VertexBuffer.UV4Kind
  24790. * - VertexBuffer.UV5Kind
  24791. * - VertexBuffer.UV6Kind
  24792. * - VertexBuffer.ColorKind
  24793. * - VertexBuffer.MatricesIndicesKind
  24794. * - VertexBuffer.MatricesIndicesExtraKind
  24795. * - VertexBuffer.MatricesWeightsKind
  24796. * - VertexBuffer.MatricesWeightsExtraKind
  24797. * @returns an array of strings
  24798. */
  24799. getVerticesDataKinds(): string[];
  24800. /**
  24801. * Returns a positive integer : the total number of indices in this mesh geometry.
  24802. * @returns the numner of indices or zero if the mesh has no geometry.
  24803. */
  24804. getTotalIndices(): number;
  24805. /**
  24806. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24807. * @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.
  24808. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24809. * @returns the indices array or an empty array if the mesh has no geometry
  24810. */
  24811. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24812. get isBlocked(): boolean;
  24813. /**
  24814. * Determine if the current mesh is ready to be rendered
  24815. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24816. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24817. * @returns true if all associated assets are ready (material, textures, shaders)
  24818. */
  24819. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24820. /**
  24821. * 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.
  24822. */
  24823. get areNormalsFrozen(): boolean;
  24824. /**
  24825. * 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.
  24826. * @returns the current mesh
  24827. */
  24828. freezeNormals(): Mesh;
  24829. /**
  24830. * 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
  24831. * @returns the current mesh
  24832. */
  24833. unfreezeNormals(): Mesh;
  24834. /**
  24835. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24836. */
  24837. set overridenInstanceCount(count: number);
  24838. /** @hidden */
  24839. _preActivate(): Mesh;
  24840. /** @hidden */
  24841. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24842. /** @hidden */
  24843. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24844. /**
  24845. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24846. * This means the mesh underlying bounding box and sphere are recomputed.
  24847. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24848. * @returns the current mesh
  24849. */
  24850. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24851. /** @hidden */
  24852. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24853. /**
  24854. * This function will subdivide the mesh into multiple submeshes
  24855. * @param count defines the expected number of submeshes
  24856. */
  24857. subdivide(count: number): void;
  24858. /**
  24859. * Copy a FloatArray into a specific associated vertex buffer
  24860. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24861. * - VertexBuffer.PositionKind
  24862. * - VertexBuffer.UVKind
  24863. * - VertexBuffer.UV2Kind
  24864. * - VertexBuffer.UV3Kind
  24865. * - VertexBuffer.UV4Kind
  24866. * - VertexBuffer.UV5Kind
  24867. * - VertexBuffer.UV6Kind
  24868. * - VertexBuffer.ColorKind
  24869. * - VertexBuffer.MatricesIndicesKind
  24870. * - VertexBuffer.MatricesIndicesExtraKind
  24871. * - VertexBuffer.MatricesWeightsKind
  24872. * - VertexBuffer.MatricesWeightsExtraKind
  24873. * @param data defines the data source
  24874. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24875. * @param stride defines the data stride size (can be null)
  24876. * @returns the current mesh
  24877. */
  24878. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24879. /**
  24880. * Delete a vertex buffer associated with this mesh
  24881. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24882. * - VertexBuffer.PositionKind
  24883. * - VertexBuffer.UVKind
  24884. * - VertexBuffer.UV2Kind
  24885. * - VertexBuffer.UV3Kind
  24886. * - VertexBuffer.UV4Kind
  24887. * - VertexBuffer.UV5Kind
  24888. * - VertexBuffer.UV6Kind
  24889. * - VertexBuffer.ColorKind
  24890. * - VertexBuffer.MatricesIndicesKind
  24891. * - VertexBuffer.MatricesIndicesExtraKind
  24892. * - VertexBuffer.MatricesWeightsKind
  24893. * - VertexBuffer.MatricesWeightsExtraKind
  24894. */
  24895. removeVerticesData(kind: string): void;
  24896. /**
  24897. * Flags an associated vertex buffer as updatable
  24898. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24899. * - VertexBuffer.PositionKind
  24900. * - VertexBuffer.UVKind
  24901. * - VertexBuffer.UV2Kind
  24902. * - VertexBuffer.UV3Kind
  24903. * - VertexBuffer.UV4Kind
  24904. * - VertexBuffer.UV5Kind
  24905. * - VertexBuffer.UV6Kind
  24906. * - VertexBuffer.ColorKind
  24907. * - VertexBuffer.MatricesIndicesKind
  24908. * - VertexBuffer.MatricesIndicesExtraKind
  24909. * - VertexBuffer.MatricesWeightsKind
  24910. * - VertexBuffer.MatricesWeightsExtraKind
  24911. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24912. */
  24913. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24914. /**
  24915. * Sets the mesh global Vertex Buffer
  24916. * @param buffer defines the buffer to use
  24917. * @returns the current mesh
  24918. */
  24919. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24920. /**
  24921. * Update a specific associated vertex buffer
  24922. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24923. * - VertexBuffer.PositionKind
  24924. * - VertexBuffer.UVKind
  24925. * - VertexBuffer.UV2Kind
  24926. * - VertexBuffer.UV3Kind
  24927. * - VertexBuffer.UV4Kind
  24928. * - VertexBuffer.UV5Kind
  24929. * - VertexBuffer.UV6Kind
  24930. * - VertexBuffer.ColorKind
  24931. * - VertexBuffer.MatricesIndicesKind
  24932. * - VertexBuffer.MatricesIndicesExtraKind
  24933. * - VertexBuffer.MatricesWeightsKind
  24934. * - VertexBuffer.MatricesWeightsExtraKind
  24935. * @param data defines the data source
  24936. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24937. * @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)
  24938. * @returns the current mesh
  24939. */
  24940. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24941. /**
  24942. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24943. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24944. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24945. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24946. * @returns the current mesh
  24947. */
  24948. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24949. /**
  24950. * Creates a un-shared specific occurence of the geometry for the mesh.
  24951. * @returns the current mesh
  24952. */
  24953. makeGeometryUnique(): Mesh;
  24954. /**
  24955. * Set the index buffer of this mesh
  24956. * @param indices defines the source data
  24957. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24958. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24959. * @returns the current mesh
  24960. */
  24961. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24962. /**
  24963. * Update the current index buffer
  24964. * @param indices defines the source data
  24965. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24966. * @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)
  24967. * @returns the current mesh
  24968. */
  24969. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24970. /**
  24971. * Invert the geometry to move from a right handed system to a left handed one.
  24972. * @returns the current mesh
  24973. */
  24974. toLeftHanded(): Mesh;
  24975. /** @hidden */
  24976. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24977. /** @hidden */
  24978. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24979. /**
  24980. * Registers for this mesh a javascript function called just before the rendering process
  24981. * @param func defines the function to call before rendering this mesh
  24982. * @returns the current mesh
  24983. */
  24984. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24985. /**
  24986. * Disposes a previously registered javascript function called before the rendering
  24987. * @param func defines the function to remove
  24988. * @returns the current mesh
  24989. */
  24990. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24991. /**
  24992. * Registers for this mesh a javascript function called just after the rendering is complete
  24993. * @param func defines the function to call after rendering this mesh
  24994. * @returns the current mesh
  24995. */
  24996. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24997. /**
  24998. * Disposes a previously registered javascript function called after the rendering.
  24999. * @param func defines the function to remove
  25000. * @returns the current mesh
  25001. */
  25002. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25003. /** @hidden */
  25004. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25005. /** @hidden */
  25006. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25007. /** @hidden */
  25008. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25009. /** @hidden */
  25010. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25011. /** @hidden */
  25012. _rebuild(): void;
  25013. /** @hidden */
  25014. _freeze(): void;
  25015. /** @hidden */
  25016. _unFreeze(): void;
  25017. /**
  25018. * 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
  25019. * @param subMesh defines the subMesh to render
  25020. * @param enableAlphaMode defines if alpha mode can be changed
  25021. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25022. * @returns the current mesh
  25023. */
  25024. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25025. private _onBeforeDraw;
  25026. /**
  25027. * Renormalize the mesh and patch it up if there are no weights
  25028. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25029. * However in the case of zero weights then we set just a single influence to 1.
  25030. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25031. */
  25032. cleanMatrixWeights(): void;
  25033. private normalizeSkinFourWeights;
  25034. private normalizeSkinWeightsAndExtra;
  25035. /**
  25036. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25037. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25038. * the user know there was an issue with importing the mesh
  25039. * @returns a validation object with skinned, valid and report string
  25040. */
  25041. validateSkinning(): {
  25042. skinned: boolean;
  25043. valid: boolean;
  25044. report: string;
  25045. };
  25046. /** @hidden */
  25047. _checkDelayState(): Mesh;
  25048. private _queueLoad;
  25049. /**
  25050. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25051. * A mesh is in the frustum if its bounding box intersects the frustum
  25052. * @param frustumPlanes defines the frustum to test
  25053. * @returns true if the mesh is in the frustum planes
  25054. */
  25055. isInFrustum(frustumPlanes: Plane[]): boolean;
  25056. /**
  25057. * Sets the mesh material by the material or multiMaterial `id` property
  25058. * @param id is a string identifying the material or the multiMaterial
  25059. * @returns the current mesh
  25060. */
  25061. setMaterialByID(id: string): Mesh;
  25062. /**
  25063. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25064. * @returns an array of IAnimatable
  25065. */
  25066. getAnimatables(): IAnimatable[];
  25067. /**
  25068. * Modifies the mesh geometry according to the passed transformation matrix.
  25069. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25070. * The mesh normals are modified using the same transformation.
  25071. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25072. * @param transform defines the transform matrix to use
  25073. * @see http://doc.babylonjs.com/resources/baking_transformations
  25074. * @returns the current mesh
  25075. */
  25076. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25077. /**
  25078. * Modifies the mesh geometry according to its own current World Matrix.
  25079. * The mesh World Matrix is then reset.
  25080. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25081. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25082. * @see http://doc.babylonjs.com/resources/baking_transformations
  25083. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25084. * @returns the current mesh
  25085. */
  25086. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25087. /** @hidden */
  25088. get _positions(): Nullable<Vector3[]>;
  25089. /** @hidden */
  25090. _resetPointsArrayCache(): Mesh;
  25091. /** @hidden */
  25092. _generatePointsArray(): boolean;
  25093. /**
  25094. * Returns a new Mesh object generated from the current mesh properties.
  25095. * This method must not get confused with createInstance()
  25096. * @param name is a string, the name given to the new mesh
  25097. * @param newParent can be any Node object (default `null`)
  25098. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25099. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25100. * @returns a new mesh
  25101. */
  25102. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25103. /**
  25104. * Releases resources associated with this mesh.
  25105. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25106. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25107. */
  25108. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25109. /** @hidden */
  25110. _disposeInstanceSpecificData(): void;
  25111. /**
  25112. * Modifies the mesh geometry according to a displacement map.
  25113. * 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.
  25114. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25115. * @param url is a string, the URL from the image file is to be downloaded.
  25116. * @param minHeight is the lower limit of the displacement.
  25117. * @param maxHeight is the upper limit of the displacement.
  25118. * @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.
  25119. * @param uvOffset is an optional vector2 used to offset UV.
  25120. * @param uvScale is an optional vector2 used to scale UV.
  25121. * @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.
  25122. * @returns the Mesh.
  25123. */
  25124. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25125. /**
  25126. * Modifies the mesh geometry according to a displacementMap buffer.
  25127. * 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.
  25128. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25129. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25130. * @param heightMapWidth is the width of the buffer image.
  25131. * @param heightMapHeight is the height of the buffer image.
  25132. * @param minHeight is the lower limit of the displacement.
  25133. * @param maxHeight is the upper limit of the displacement.
  25134. * @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.
  25135. * @param uvOffset is an optional vector2 used to offset UV.
  25136. * @param uvScale is an optional vector2 used to scale UV.
  25137. * @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.
  25138. * @returns the Mesh.
  25139. */
  25140. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25141. /**
  25142. * Modify the mesh to get a flat shading rendering.
  25143. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25144. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25145. * @returns current mesh
  25146. */
  25147. convertToFlatShadedMesh(): Mesh;
  25148. /**
  25149. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25150. * In other words, more vertices, no more indices and a single bigger VBO.
  25151. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25152. * @returns current mesh
  25153. */
  25154. convertToUnIndexedMesh(): Mesh;
  25155. /**
  25156. * Inverses facet orientations.
  25157. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25158. * @param flipNormals will also inverts the normals
  25159. * @returns current mesh
  25160. */
  25161. flipFaces(flipNormals?: boolean): Mesh;
  25162. /**
  25163. * Increase the number of facets and hence vertices in a mesh
  25164. * Vertex normals are interpolated from existing vertex normals
  25165. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25166. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25167. */
  25168. increaseVertices(numberPerEdge: number): void;
  25169. /**
  25170. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25171. * This will undo any application of covertToFlatShadedMesh
  25172. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25173. */
  25174. forceSharedVertices(): void;
  25175. /** @hidden */
  25176. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25177. /** @hidden */
  25178. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25179. /**
  25180. * Creates a new InstancedMesh object from the mesh model.
  25181. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25182. * @param name defines the name of the new instance
  25183. * @returns a new InstancedMesh
  25184. */
  25185. createInstance(name: string): InstancedMesh;
  25186. /**
  25187. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25188. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25189. * @returns the current mesh
  25190. */
  25191. synchronizeInstances(): Mesh;
  25192. /**
  25193. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25194. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25195. * This should be used together with the simplification to avoid disappearing triangles.
  25196. * @param successCallback an optional success callback to be called after the optimization finished.
  25197. * @returns the current mesh
  25198. */
  25199. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25200. /**
  25201. * Serialize current mesh
  25202. * @param serializationObject defines the object which will receive the serialization data
  25203. */
  25204. serialize(serializationObject: any): void;
  25205. /** @hidden */
  25206. _syncGeometryWithMorphTargetManager(): void;
  25207. /** @hidden */
  25208. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25209. /**
  25210. * Returns a new Mesh object parsed from the source provided.
  25211. * @param parsedMesh is the source
  25212. * @param scene defines the hosting scene
  25213. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25214. * @returns a new Mesh
  25215. */
  25216. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25217. /**
  25218. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25219. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25220. * @param name defines the name of the mesh to create
  25221. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25222. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25223. * @param closePath creates a seam between the first and the last points of each path of the path array
  25224. * @param offset is taken in account only if the `pathArray` is containing a single path
  25225. * @param scene defines the hosting scene
  25226. * @param updatable defines if the mesh must be flagged as updatable
  25227. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25228. * @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)
  25229. * @returns a new Mesh
  25230. */
  25231. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25232. /**
  25233. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25234. * @param name defines the name of the mesh to create
  25235. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25236. * @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
  25237. * @param scene defines the hosting scene
  25238. * @param updatable defines if the mesh must be flagged as updatable
  25239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25240. * @returns a new Mesh
  25241. */
  25242. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25243. /**
  25244. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25245. * @param name defines the name of the mesh to create
  25246. * @param size sets the size (float) of each box side (default 1)
  25247. * @param scene defines the hosting scene
  25248. * @param updatable defines if the mesh must be flagged as updatable
  25249. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25250. * @returns a new Mesh
  25251. */
  25252. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25253. /**
  25254. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25255. * @param name defines the name of the mesh to create
  25256. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25257. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25258. * @param scene defines the hosting scene
  25259. * @param updatable defines if the mesh must be flagged as updatable
  25260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25261. * @returns a new Mesh
  25262. */
  25263. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25264. /**
  25265. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25266. * @param name defines the name of the mesh to create
  25267. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25268. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25269. * @param scene defines the hosting scene
  25270. * @returns a new Mesh
  25271. */
  25272. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25273. /**
  25274. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25275. * @param name defines the name of the mesh to create
  25276. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25277. * @param diameterTop set the top cap diameter (floats, default 1)
  25278. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25279. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25280. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25281. * @param scene defines the hosting scene
  25282. * @param updatable defines if the mesh must be flagged as updatable
  25283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25284. * @returns a new Mesh
  25285. */
  25286. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25287. /**
  25288. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25289. * @param name defines the name of the mesh to create
  25290. * @param diameter sets the diameter size (float) of the torus (default 1)
  25291. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25292. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25293. * @param scene defines the hosting scene
  25294. * @param updatable defines if the mesh must be flagged as updatable
  25295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25296. * @returns a new Mesh
  25297. */
  25298. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25299. /**
  25300. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25301. * @param name defines the name of the mesh to create
  25302. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25303. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25304. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25305. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25306. * @param p the number of windings on X axis (positive integers, default 2)
  25307. * @param q the number of windings on Y axis (positive integers, default 3)
  25308. * @param scene defines the hosting scene
  25309. * @param updatable defines if the mesh must be flagged as updatable
  25310. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25311. * @returns a new Mesh
  25312. */
  25313. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25314. /**
  25315. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25316. * @param name defines the name of the mesh to create
  25317. * @param points is an array successive Vector3
  25318. * @param scene defines the hosting scene
  25319. * @param updatable defines if the mesh must be flagged as updatable
  25320. * @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).
  25321. * @returns a new Mesh
  25322. */
  25323. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25324. /**
  25325. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25326. * @param name defines the name of the mesh to create
  25327. * @param points is an array successive Vector3
  25328. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25329. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25330. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25331. * @param scene defines the hosting scene
  25332. * @param updatable defines if the mesh must be flagged as updatable
  25333. * @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)
  25334. * @returns a new Mesh
  25335. */
  25336. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25337. /**
  25338. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25339. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25340. * 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.
  25341. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25342. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25343. * Remember you can only change the shape positions, not their number when updating a polygon.
  25344. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25345. * @param name defines the name of the mesh to create
  25346. * @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
  25347. * @param scene defines the hosting scene
  25348. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25349. * @param updatable defines if the mesh must be flagged as updatable
  25350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25351. * @param earcutInjection can be used to inject your own earcut reference
  25352. * @returns a new Mesh
  25353. */
  25354. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25355. /**
  25356. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25357. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25358. * @param name defines the name of the mesh to create
  25359. * @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
  25360. * @param depth defines the height of extrusion
  25361. * @param scene defines the hosting scene
  25362. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25363. * @param updatable defines if the mesh must be flagged as updatable
  25364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25365. * @param earcutInjection can be used to inject your own earcut reference
  25366. * @returns a new Mesh
  25367. */
  25368. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25369. /**
  25370. * Creates an extruded shape mesh.
  25371. * 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
  25372. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25373. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25374. * @param name defines the name of the mesh to create
  25375. * @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
  25376. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25377. * @param scale is the value to scale the shape
  25378. * @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
  25379. * @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
  25380. * @param scene defines the hosting scene
  25381. * @param updatable defines if the mesh must be flagged as updatable
  25382. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25383. * @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)
  25384. * @returns a new Mesh
  25385. */
  25386. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25387. /**
  25388. * Creates an custom extruded shape mesh.
  25389. * The custom extrusion is a parametric shape.
  25390. * It has no predefined shape. Its final shape will depend on the input parameters.
  25391. * Please consider using the same method from the MeshBuilder class instead
  25392. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25393. * @param name defines the name of the mesh to create
  25394. * @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
  25395. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25396. * @param scaleFunction is a custom Javascript function called on each path point
  25397. * @param rotationFunction is a custom Javascript function called on each path point
  25398. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25399. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25400. * @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
  25401. * @param scene defines the hosting scene
  25402. * @param updatable defines if the mesh must be flagged as updatable
  25403. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25404. * @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)
  25405. * @returns a new Mesh
  25406. */
  25407. 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;
  25408. /**
  25409. * Creates lathe mesh.
  25410. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25411. * Please consider using the same method from the MeshBuilder class instead
  25412. * @param name defines the name of the mesh to create
  25413. * @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
  25414. * @param radius is the radius value of the lathe
  25415. * @param tessellation is the side number of the lathe.
  25416. * @param scene defines the hosting scene
  25417. * @param updatable defines if the mesh must be flagged as updatable
  25418. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25419. * @returns a new Mesh
  25420. */
  25421. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25422. /**
  25423. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25424. * @param name defines the name of the mesh to create
  25425. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25426. * @param scene defines the hosting scene
  25427. * @param updatable defines if the mesh must be flagged as updatable
  25428. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25429. * @returns a new Mesh
  25430. */
  25431. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25432. /**
  25433. * Creates a ground mesh.
  25434. * Please consider using the same method from the MeshBuilder class instead
  25435. * @param name defines the name of the mesh to create
  25436. * @param width set the width of the ground
  25437. * @param height set the height of the ground
  25438. * @param subdivisions sets the number of subdivisions per side
  25439. * @param scene defines the hosting scene
  25440. * @param updatable defines if the mesh must be flagged as updatable
  25441. * @returns a new Mesh
  25442. */
  25443. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25444. /**
  25445. * Creates a tiled ground mesh.
  25446. * Please consider using the same method from the MeshBuilder class instead
  25447. * @param name defines the name of the mesh to create
  25448. * @param xmin set the ground minimum X coordinate
  25449. * @param zmin set the ground minimum Y coordinate
  25450. * @param xmax set the ground maximum X coordinate
  25451. * @param zmax set the ground maximum Z coordinate
  25452. * @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
  25453. * @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
  25454. * @param scene defines the hosting scene
  25455. * @param updatable defines if the mesh must be flagged as updatable
  25456. * @returns a new Mesh
  25457. */
  25458. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25459. w: number;
  25460. h: number;
  25461. }, precision: {
  25462. w: number;
  25463. h: number;
  25464. }, scene: Scene, updatable?: boolean): Mesh;
  25465. /**
  25466. * Creates a ground mesh from a height map.
  25467. * Please consider using the same method from the MeshBuilder class instead
  25468. * @see http://doc.babylonjs.com/babylon101/height_map
  25469. * @param name defines the name of the mesh to create
  25470. * @param url sets the URL of the height map image resource
  25471. * @param width set the ground width size
  25472. * @param height set the ground height size
  25473. * @param subdivisions sets the number of subdivision per side
  25474. * @param minHeight is the minimum altitude on the ground
  25475. * @param maxHeight is the maximum altitude on the ground
  25476. * @param scene defines the hosting scene
  25477. * @param updatable defines if the mesh must be flagged as updatable
  25478. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25479. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25480. * @returns a new Mesh
  25481. */
  25482. 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;
  25483. /**
  25484. * Creates a tube mesh.
  25485. * The tube is a parametric shape.
  25486. * It has no predefined shape. Its final shape will depend on the input parameters.
  25487. * Please consider using the same method from the MeshBuilder class instead
  25488. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25489. * @param name defines the name of the mesh to create
  25490. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25491. * @param radius sets the tube radius size
  25492. * @param tessellation is the number of sides on the tubular surface
  25493. * @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
  25494. * @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
  25495. * @param scene defines the hosting scene
  25496. * @param updatable defines if the mesh must be flagged as updatable
  25497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25498. * @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)
  25499. * @returns a new Mesh
  25500. */
  25501. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25502. (i: number, distance: number): number;
  25503. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25504. /**
  25505. * Creates a polyhedron mesh.
  25506. * Please consider using the same method from the MeshBuilder class instead.
  25507. * * 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
  25508. * * The parameter `size` (positive float, default 1) sets the polygon size
  25509. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25510. * * 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`
  25511. * * 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
  25512. * * 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)`)
  25513. * * 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
  25514. * * 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
  25515. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25516. * * 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
  25517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25518. * @param name defines the name of the mesh to create
  25519. * @param options defines the options used to create the mesh
  25520. * @param scene defines the hosting scene
  25521. * @returns a new Mesh
  25522. */
  25523. static CreatePolyhedron(name: string, options: {
  25524. type?: number;
  25525. size?: number;
  25526. sizeX?: number;
  25527. sizeY?: number;
  25528. sizeZ?: number;
  25529. custom?: any;
  25530. faceUV?: Vector4[];
  25531. faceColors?: Color4[];
  25532. updatable?: boolean;
  25533. sideOrientation?: number;
  25534. }, scene: Scene): Mesh;
  25535. /**
  25536. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25537. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25538. * * 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`)
  25539. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25540. * * 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
  25541. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25542. * * 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
  25543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25544. * @param name defines the name of the mesh
  25545. * @param options defines the options used to create the mesh
  25546. * @param scene defines the hosting scene
  25547. * @returns a new Mesh
  25548. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25549. */
  25550. static CreateIcoSphere(name: string, options: {
  25551. radius?: number;
  25552. flat?: boolean;
  25553. subdivisions?: number;
  25554. sideOrientation?: number;
  25555. updatable?: boolean;
  25556. }, scene: Scene): Mesh;
  25557. /**
  25558. * Creates a decal mesh.
  25559. * Please consider using the same method from the MeshBuilder class instead.
  25560. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25561. * @param name defines the name of the mesh
  25562. * @param sourceMesh defines the mesh receiving the decal
  25563. * @param position sets the position of the decal in world coordinates
  25564. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25565. * @param size sets the decal scaling
  25566. * @param angle sets the angle to rotate the decal
  25567. * @returns a new Mesh
  25568. */
  25569. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25570. /**
  25571. * Prepare internal position array for software CPU skinning
  25572. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25573. */
  25574. setPositionsForCPUSkinning(): Float32Array;
  25575. /**
  25576. * Prepare internal normal array for software CPU skinning
  25577. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25578. */
  25579. setNormalsForCPUSkinning(): Float32Array;
  25580. /**
  25581. * Updates the vertex buffer by applying transformation from the bones
  25582. * @param skeleton defines the skeleton to apply to current mesh
  25583. * @returns the current mesh
  25584. */
  25585. applySkeleton(skeleton: Skeleton): Mesh;
  25586. /**
  25587. * 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
  25588. * @param meshes defines the list of meshes to scan
  25589. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25590. */
  25591. static MinMax(meshes: AbstractMesh[]): {
  25592. min: Vector3;
  25593. max: Vector3;
  25594. };
  25595. /**
  25596. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25597. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25598. * @returns a vector3
  25599. */
  25600. static Center(meshesOrMinMaxVector: {
  25601. min: Vector3;
  25602. max: Vector3;
  25603. } | AbstractMesh[]): Vector3;
  25604. /**
  25605. * Merge the array of meshes into a single mesh for performance reasons.
  25606. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25607. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25608. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25609. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25610. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25611. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25612. * @returns a new mesh
  25613. */
  25614. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25615. /** @hidden */
  25616. addInstance(instance: InstancedMesh): void;
  25617. /** @hidden */
  25618. removeInstance(instance: InstancedMesh): void;
  25619. }
  25620. }
  25621. declare module BABYLON {
  25622. /**
  25623. * This is the base class of all the camera used in the application.
  25624. * @see http://doc.babylonjs.com/features/cameras
  25625. */
  25626. export class Camera extends Node {
  25627. /** @hidden */
  25628. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25629. /**
  25630. * This is the default projection mode used by the cameras.
  25631. * It helps recreating a feeling of perspective and better appreciate depth.
  25632. * This is the best way to simulate real life cameras.
  25633. */
  25634. static readonly PERSPECTIVE_CAMERA: number;
  25635. /**
  25636. * This helps creating camera with an orthographic mode.
  25637. * 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.
  25638. */
  25639. static readonly ORTHOGRAPHIC_CAMERA: number;
  25640. /**
  25641. * This is the default FOV mode for perspective cameras.
  25642. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25643. */
  25644. static readonly FOVMODE_VERTICAL_FIXED: number;
  25645. /**
  25646. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25647. */
  25648. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25649. /**
  25650. * This specifies ther is no need for a camera rig.
  25651. * Basically only one eye is rendered corresponding to the camera.
  25652. */
  25653. static readonly RIG_MODE_NONE: number;
  25654. /**
  25655. * Simulates a camera Rig with one blue eye and one red eye.
  25656. * This can be use with 3d blue and red glasses.
  25657. */
  25658. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25659. /**
  25660. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25661. */
  25662. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25663. /**
  25664. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25665. */
  25666. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25667. /**
  25668. * Defines that both eyes of the camera will be rendered over under each other.
  25669. */
  25670. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25671. /**
  25672. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25673. */
  25674. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25675. /**
  25676. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25677. */
  25678. static readonly RIG_MODE_VR: number;
  25679. /**
  25680. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25681. */
  25682. static readonly RIG_MODE_WEBVR: number;
  25683. /**
  25684. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25685. */
  25686. static readonly RIG_MODE_CUSTOM: number;
  25687. /**
  25688. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25689. */
  25690. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25691. /**
  25692. * Define the input manager associated with the camera.
  25693. */
  25694. inputs: CameraInputsManager<Camera>;
  25695. /** @hidden */
  25696. _position: Vector3;
  25697. /**
  25698. * Define the current local position of the camera in the scene
  25699. */
  25700. get position(): Vector3;
  25701. set position(newPosition: Vector3);
  25702. /**
  25703. * The vector the camera should consider as up.
  25704. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25705. */
  25706. upVector: Vector3;
  25707. /**
  25708. * Define the current limit on the left side for an orthographic camera
  25709. * In scene unit
  25710. */
  25711. orthoLeft: Nullable<number>;
  25712. /**
  25713. * Define the current limit on the right side for an orthographic camera
  25714. * In scene unit
  25715. */
  25716. orthoRight: Nullable<number>;
  25717. /**
  25718. * Define the current limit on the bottom side for an orthographic camera
  25719. * In scene unit
  25720. */
  25721. orthoBottom: Nullable<number>;
  25722. /**
  25723. * Define the current limit on the top side for an orthographic camera
  25724. * In scene unit
  25725. */
  25726. orthoTop: Nullable<number>;
  25727. /**
  25728. * Field Of View is set in Radians. (default is 0.8)
  25729. */
  25730. fov: number;
  25731. /**
  25732. * Define the minimum distance the camera can see from.
  25733. * This is important to note that the depth buffer are not infinite and the closer it starts
  25734. * the more your scene might encounter depth fighting issue.
  25735. */
  25736. minZ: number;
  25737. /**
  25738. * Define the maximum distance the camera can see to.
  25739. * This is important to note that the depth buffer are not infinite and the further it end
  25740. * the more your scene might encounter depth fighting issue.
  25741. */
  25742. maxZ: number;
  25743. /**
  25744. * Define the default inertia of the camera.
  25745. * This helps giving a smooth feeling to the camera movement.
  25746. */
  25747. inertia: number;
  25748. /**
  25749. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25750. */
  25751. mode: number;
  25752. /**
  25753. * Define whether the camera is intermediate.
  25754. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25755. */
  25756. isIntermediate: boolean;
  25757. /**
  25758. * Define the viewport of the camera.
  25759. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25760. */
  25761. viewport: Viewport;
  25762. /**
  25763. * Restricts the camera to viewing objects with the same layerMask.
  25764. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25765. */
  25766. layerMask: number;
  25767. /**
  25768. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25769. */
  25770. fovMode: number;
  25771. /**
  25772. * Rig mode of the camera.
  25773. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25774. * This is normally controlled byt the camera themselves as internal use.
  25775. */
  25776. cameraRigMode: number;
  25777. /**
  25778. * Defines the distance between both "eyes" in case of a RIG
  25779. */
  25780. interaxialDistance: number;
  25781. /**
  25782. * Defines if stereoscopic rendering is done side by side or over under.
  25783. */
  25784. isStereoscopicSideBySide: boolean;
  25785. /**
  25786. * 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
  25787. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25788. * else in the scene. (Eg. security camera)
  25789. *
  25790. * 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)
  25791. */
  25792. customRenderTargets: RenderTargetTexture[];
  25793. /**
  25794. * When set, the camera will render to this render target instead of the default canvas
  25795. *
  25796. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25797. */
  25798. outputRenderTarget: Nullable<RenderTargetTexture>;
  25799. /**
  25800. * Observable triggered when the camera view matrix has changed.
  25801. */
  25802. onViewMatrixChangedObservable: Observable<Camera>;
  25803. /**
  25804. * Observable triggered when the camera Projection matrix has changed.
  25805. */
  25806. onProjectionMatrixChangedObservable: Observable<Camera>;
  25807. /**
  25808. * Observable triggered when the inputs have been processed.
  25809. */
  25810. onAfterCheckInputsObservable: Observable<Camera>;
  25811. /**
  25812. * Observable triggered when reset has been called and applied to the camera.
  25813. */
  25814. onRestoreStateObservable: Observable<Camera>;
  25815. /**
  25816. * Is this camera a part of a rig system?
  25817. */
  25818. isRigCamera: boolean;
  25819. /**
  25820. * If isRigCamera set to true this will be set with the parent camera.
  25821. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25822. */
  25823. rigParent?: Camera;
  25824. /** @hidden */
  25825. _cameraRigParams: any;
  25826. /** @hidden */
  25827. _rigCameras: Camera[];
  25828. /** @hidden */
  25829. _rigPostProcess: Nullable<PostProcess>;
  25830. protected _webvrViewMatrix: Matrix;
  25831. /** @hidden */
  25832. _skipRendering: boolean;
  25833. /** @hidden */
  25834. _projectionMatrix: Matrix;
  25835. /** @hidden */
  25836. _postProcesses: Nullable<PostProcess>[];
  25837. /** @hidden */
  25838. _activeMeshes: SmartArray<AbstractMesh>;
  25839. protected _globalPosition: Vector3;
  25840. /** @hidden */
  25841. _computedViewMatrix: Matrix;
  25842. private _doNotComputeProjectionMatrix;
  25843. private _transformMatrix;
  25844. private _frustumPlanes;
  25845. private _refreshFrustumPlanes;
  25846. private _storedFov;
  25847. private _stateStored;
  25848. /**
  25849. * Instantiates a new camera object.
  25850. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25851. * @see http://doc.babylonjs.com/features/cameras
  25852. * @param name Defines the name of the camera in the scene
  25853. * @param position Defines the position of the camera
  25854. * @param scene Defines the scene the camera belongs too
  25855. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25856. */
  25857. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25858. /**
  25859. * Store current camera state (fov, position, etc..)
  25860. * @returns the camera
  25861. */
  25862. storeState(): Camera;
  25863. /**
  25864. * Restores the camera state values if it has been stored. You must call storeState() first
  25865. */
  25866. protected _restoreStateValues(): boolean;
  25867. /**
  25868. * Restored camera state. You must call storeState() first.
  25869. * @returns true if restored and false otherwise
  25870. */
  25871. restoreState(): boolean;
  25872. /**
  25873. * Gets the class name of the camera.
  25874. * @returns the class name
  25875. */
  25876. getClassName(): string;
  25877. /** @hidden */
  25878. readonly _isCamera: boolean;
  25879. /**
  25880. * Gets a string representation of the camera useful for debug purpose.
  25881. * @param fullDetails Defines that a more verboe level of logging is required
  25882. * @returns the string representation
  25883. */
  25884. toString(fullDetails?: boolean): string;
  25885. /**
  25886. * Gets the current world space position of the camera.
  25887. */
  25888. get globalPosition(): Vector3;
  25889. /**
  25890. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25891. * @returns the active meshe list
  25892. */
  25893. getActiveMeshes(): SmartArray<AbstractMesh>;
  25894. /**
  25895. * Check whether a mesh is part of the current active mesh list of the camera
  25896. * @param mesh Defines the mesh to check
  25897. * @returns true if active, false otherwise
  25898. */
  25899. isActiveMesh(mesh: Mesh): boolean;
  25900. /**
  25901. * Is this camera ready to be used/rendered
  25902. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25903. * @return true if the camera is ready
  25904. */
  25905. isReady(completeCheck?: boolean): boolean;
  25906. /** @hidden */
  25907. _initCache(): void;
  25908. /** @hidden */
  25909. _updateCache(ignoreParentClass?: boolean): void;
  25910. /** @hidden */
  25911. _isSynchronized(): boolean;
  25912. /** @hidden */
  25913. _isSynchronizedViewMatrix(): boolean;
  25914. /** @hidden */
  25915. _isSynchronizedProjectionMatrix(): boolean;
  25916. /**
  25917. * Attach the input controls to a specific dom element to get the input from.
  25918. * @param element Defines the element the controls should be listened from
  25919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25920. */
  25921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25922. /**
  25923. * Detach the current controls from the specified dom element.
  25924. * @param element Defines the element to stop listening the inputs from
  25925. */
  25926. detachControl(element: HTMLElement): void;
  25927. /**
  25928. * Update the camera state according to the different inputs gathered during the frame.
  25929. */
  25930. update(): void;
  25931. /** @hidden */
  25932. _checkInputs(): void;
  25933. /** @hidden */
  25934. get rigCameras(): Camera[];
  25935. /**
  25936. * Gets the post process used by the rig cameras
  25937. */
  25938. get rigPostProcess(): Nullable<PostProcess>;
  25939. /**
  25940. * Internal, gets the first post proces.
  25941. * @returns the first post process to be run on this camera.
  25942. */
  25943. _getFirstPostProcess(): Nullable<PostProcess>;
  25944. private _cascadePostProcessesToRigCams;
  25945. /**
  25946. * Attach a post process to the camera.
  25947. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25948. * @param postProcess The post process to attach to the camera
  25949. * @param insertAt The position of the post process in case several of them are in use in the scene
  25950. * @returns the position the post process has been inserted at
  25951. */
  25952. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25953. /**
  25954. * Detach a post process to the camera.
  25955. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25956. * @param postProcess The post process to detach from the camera
  25957. */
  25958. detachPostProcess(postProcess: PostProcess): void;
  25959. /**
  25960. * Gets the current world matrix of the camera
  25961. */
  25962. getWorldMatrix(): Matrix;
  25963. /** @hidden */
  25964. _getViewMatrix(): Matrix;
  25965. /**
  25966. * Gets the current view matrix of the camera.
  25967. * @param force forces the camera to recompute the matrix without looking at the cached state
  25968. * @returns the view matrix
  25969. */
  25970. getViewMatrix(force?: boolean): Matrix;
  25971. /**
  25972. * Freeze the projection matrix.
  25973. * It will prevent the cache check of the camera projection compute and can speed up perf
  25974. * if no parameter of the camera are meant to change
  25975. * @param projection Defines manually a projection if necessary
  25976. */
  25977. freezeProjectionMatrix(projection?: Matrix): void;
  25978. /**
  25979. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25980. */
  25981. unfreezeProjectionMatrix(): void;
  25982. /**
  25983. * Gets the current projection matrix of the camera.
  25984. * @param force forces the camera to recompute the matrix without looking at the cached state
  25985. * @returns the projection matrix
  25986. */
  25987. getProjectionMatrix(force?: boolean): Matrix;
  25988. /**
  25989. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25990. * @returns a Matrix
  25991. */
  25992. getTransformationMatrix(): Matrix;
  25993. private _updateFrustumPlanes;
  25994. /**
  25995. * Checks if a cullable object (mesh...) is in the camera frustum
  25996. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25997. * @param target The object to check
  25998. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25999. * @returns true if the object is in frustum otherwise false
  26000. */
  26001. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26002. /**
  26003. * Checks if a cullable object (mesh...) is in the camera frustum
  26004. * Unlike isInFrustum this cheks the full bounding box
  26005. * @param target The object to check
  26006. * @returns true if the object is in frustum otherwise false
  26007. */
  26008. isCompletelyInFrustum(target: ICullable): boolean;
  26009. /**
  26010. * Gets a ray in the forward direction from the camera.
  26011. * @param length Defines the length of the ray to create
  26012. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26013. * @param origin Defines the start point of the ray which defaults to the camera position
  26014. * @returns the forward ray
  26015. */
  26016. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26017. /**
  26018. * Releases resources associated with this node.
  26019. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26020. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26021. */
  26022. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26023. /** @hidden */
  26024. _isLeftCamera: boolean;
  26025. /**
  26026. * Gets the left camera of a rig setup in case of Rigged Camera
  26027. */
  26028. get isLeftCamera(): boolean;
  26029. /** @hidden */
  26030. _isRightCamera: boolean;
  26031. /**
  26032. * Gets the right camera of a rig setup in case of Rigged Camera
  26033. */
  26034. get isRightCamera(): boolean;
  26035. /**
  26036. * Gets the left camera of a rig setup in case of Rigged Camera
  26037. */
  26038. get leftCamera(): Nullable<FreeCamera>;
  26039. /**
  26040. * Gets the right camera of a rig setup in case of Rigged Camera
  26041. */
  26042. get rightCamera(): Nullable<FreeCamera>;
  26043. /**
  26044. * Gets the left camera target of a rig setup in case of Rigged Camera
  26045. * @returns the target position
  26046. */
  26047. getLeftTarget(): Nullable<Vector3>;
  26048. /**
  26049. * Gets the right camera target of a rig setup in case of Rigged Camera
  26050. * @returns the target position
  26051. */
  26052. getRightTarget(): Nullable<Vector3>;
  26053. /**
  26054. * @hidden
  26055. */
  26056. setCameraRigMode(mode: number, rigParams: any): void;
  26057. /** @hidden */
  26058. static _setStereoscopicRigMode(camera: Camera): void;
  26059. /** @hidden */
  26060. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26061. /** @hidden */
  26062. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26063. /** @hidden */
  26064. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26065. /** @hidden */
  26066. _getVRProjectionMatrix(): Matrix;
  26067. protected _updateCameraRotationMatrix(): void;
  26068. protected _updateWebVRCameraRotationMatrix(): void;
  26069. /**
  26070. * This function MUST be overwritten by the different WebVR cameras available.
  26071. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26072. * @hidden
  26073. */
  26074. _getWebVRProjectionMatrix(): Matrix;
  26075. /**
  26076. * This function MUST be overwritten by the different WebVR cameras available.
  26077. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26078. * @hidden
  26079. */
  26080. _getWebVRViewMatrix(): Matrix;
  26081. /** @hidden */
  26082. setCameraRigParameter(name: string, value: any): void;
  26083. /**
  26084. * needs to be overridden by children so sub has required properties to be copied
  26085. * @hidden
  26086. */
  26087. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26088. /**
  26089. * May need to be overridden by children
  26090. * @hidden
  26091. */
  26092. _updateRigCameras(): void;
  26093. /** @hidden */
  26094. _setupInputs(): void;
  26095. /**
  26096. * Serialiaze the camera setup to a json represention
  26097. * @returns the JSON representation
  26098. */
  26099. serialize(): any;
  26100. /**
  26101. * Clones the current camera.
  26102. * @param name The cloned camera name
  26103. * @returns the cloned camera
  26104. */
  26105. clone(name: string): Camera;
  26106. /**
  26107. * Gets the direction of the camera relative to a given local axis.
  26108. * @param localAxis Defines the reference axis to provide a relative direction.
  26109. * @return the direction
  26110. */
  26111. getDirection(localAxis: Vector3): Vector3;
  26112. /**
  26113. * Returns the current camera absolute rotation
  26114. */
  26115. get absoluteRotation(): Quaternion;
  26116. /**
  26117. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26118. * @param localAxis Defines the reference axis to provide a relative direction.
  26119. * @param result Defines the vector to store the result in
  26120. */
  26121. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26122. /**
  26123. * Gets a camera constructor for a given camera type
  26124. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26125. * @param name The name of the camera the result will be able to instantiate
  26126. * @param scene The scene the result will construct the camera in
  26127. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26128. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26129. * @returns a factory method to construc the camera
  26130. */
  26131. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26132. /**
  26133. * Compute the world matrix of the camera.
  26134. * @returns the camera world matrix
  26135. */
  26136. computeWorldMatrix(): Matrix;
  26137. /**
  26138. * Parse a JSON and creates the camera from the parsed information
  26139. * @param parsedCamera The JSON to parse
  26140. * @param scene The scene to instantiate the camera in
  26141. * @returns the newly constructed camera
  26142. */
  26143. static Parse(parsedCamera: any, scene: Scene): Camera;
  26144. }
  26145. }
  26146. declare module BABYLON {
  26147. /**
  26148. * Class containing static functions to help procedurally build meshes
  26149. */
  26150. export class DiscBuilder {
  26151. /**
  26152. * Creates a plane polygonal mesh. By default, this is a disc
  26153. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26154. * * 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
  26155. * * 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
  26156. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26157. * * 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
  26158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26159. * @param name defines the name of the mesh
  26160. * @param options defines the options used to create the mesh
  26161. * @param scene defines the hosting scene
  26162. * @returns the plane polygonal mesh
  26163. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26164. */
  26165. static CreateDisc(name: string, options: {
  26166. radius?: number;
  26167. tessellation?: number;
  26168. arc?: number;
  26169. updatable?: boolean;
  26170. sideOrientation?: number;
  26171. frontUVs?: Vector4;
  26172. backUVs?: Vector4;
  26173. }, scene?: Nullable<Scene>): Mesh;
  26174. }
  26175. }
  26176. declare module BABYLON {
  26177. /**
  26178. * Options to be used when creating a FresnelParameters.
  26179. */
  26180. export type IFresnelParametersCreationOptions = {
  26181. /**
  26182. * Define the color used on edges (grazing angle)
  26183. */
  26184. leftColor?: Color3;
  26185. /**
  26186. * Define the color used on center
  26187. */
  26188. rightColor?: Color3;
  26189. /**
  26190. * Define bias applied to computed fresnel term
  26191. */
  26192. bias?: number;
  26193. /**
  26194. * Defined the power exponent applied to fresnel term
  26195. */
  26196. power?: number;
  26197. /**
  26198. * Define if the fresnel effect is enable or not.
  26199. */
  26200. isEnabled?: boolean;
  26201. };
  26202. /**
  26203. * Serialized format for FresnelParameters.
  26204. */
  26205. export type IFresnelParametersSerialized = {
  26206. /**
  26207. * Define the color used on edges (grazing angle) [as an array]
  26208. */
  26209. leftColor: number[];
  26210. /**
  26211. * Define the color used on center [as an array]
  26212. */
  26213. rightColor: number[];
  26214. /**
  26215. * Define bias applied to computed fresnel term
  26216. */
  26217. bias: number;
  26218. /**
  26219. * Defined the power exponent applied to fresnel term
  26220. */
  26221. power?: number;
  26222. /**
  26223. * Define if the fresnel effect is enable or not.
  26224. */
  26225. isEnabled: boolean;
  26226. };
  26227. /**
  26228. * This represents all the required information to add a fresnel effect on a material:
  26229. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26230. */
  26231. export class FresnelParameters {
  26232. private _isEnabled;
  26233. /**
  26234. * Define if the fresnel effect is enable or not.
  26235. */
  26236. get isEnabled(): boolean;
  26237. set isEnabled(value: boolean);
  26238. /**
  26239. * Define the color used on edges (grazing angle)
  26240. */
  26241. leftColor: Color3;
  26242. /**
  26243. * Define the color used on center
  26244. */
  26245. rightColor: Color3;
  26246. /**
  26247. * Define bias applied to computed fresnel term
  26248. */
  26249. bias: number;
  26250. /**
  26251. * Defined the power exponent applied to fresnel term
  26252. */
  26253. power: number;
  26254. /**
  26255. * Creates a new FresnelParameters object.
  26256. *
  26257. * @param options provide your own settings to optionally to override defaults
  26258. */
  26259. constructor(options?: IFresnelParametersCreationOptions);
  26260. /**
  26261. * Clones the current fresnel and its valuues
  26262. * @returns a clone fresnel configuration
  26263. */
  26264. clone(): FresnelParameters;
  26265. /**
  26266. * Determines equality between FresnelParameters objects
  26267. * @param otherFresnelParameters defines the second operand
  26268. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  26269. */
  26270. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  26271. /**
  26272. * Serializes the current fresnel parameters to a JSON representation.
  26273. * @return the JSON serialization
  26274. */
  26275. serialize(): IFresnelParametersSerialized;
  26276. /**
  26277. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26278. * @param parsedFresnelParameters Define the JSON representation
  26279. * @returns the parsed parameters
  26280. */
  26281. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  26282. }
  26283. }
  26284. declare module BABYLON {
  26285. /**
  26286. * Base class of materials working in push mode in babylon JS
  26287. * @hidden
  26288. */
  26289. export class PushMaterial extends Material {
  26290. protected _activeEffect: Effect;
  26291. protected _normalMatrix: Matrix;
  26292. /**
  26293. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26294. * This means that the material can keep using a previous shader while a new one is being compiled.
  26295. * This is mostly used when shader parallel compilation is supported (true by default)
  26296. */
  26297. allowShaderHotSwapping: boolean;
  26298. constructor(name: string, scene: Scene);
  26299. getEffect(): Effect;
  26300. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26301. /**
  26302. * Binds the given world matrix to the active effect
  26303. *
  26304. * @param world the matrix to bind
  26305. */
  26306. bindOnlyWorldMatrix(world: Matrix): void;
  26307. /**
  26308. * Binds the given normal matrix to the active effect
  26309. *
  26310. * @param normalMatrix the matrix to bind
  26311. */
  26312. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26313. bind(world: Matrix, mesh?: Mesh): void;
  26314. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26315. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26316. }
  26317. }
  26318. declare module BABYLON {
  26319. /**
  26320. * This groups all the flags used to control the materials channel.
  26321. */
  26322. export class MaterialFlags {
  26323. private static _DiffuseTextureEnabled;
  26324. /**
  26325. * Are diffuse textures enabled in the application.
  26326. */
  26327. static get DiffuseTextureEnabled(): boolean;
  26328. static set DiffuseTextureEnabled(value: boolean);
  26329. private static _AmbientTextureEnabled;
  26330. /**
  26331. * Are ambient textures enabled in the application.
  26332. */
  26333. static get AmbientTextureEnabled(): boolean;
  26334. static set AmbientTextureEnabled(value: boolean);
  26335. private static _OpacityTextureEnabled;
  26336. /**
  26337. * Are opacity textures enabled in the application.
  26338. */
  26339. static get OpacityTextureEnabled(): boolean;
  26340. static set OpacityTextureEnabled(value: boolean);
  26341. private static _ReflectionTextureEnabled;
  26342. /**
  26343. * Are reflection textures enabled in the application.
  26344. */
  26345. static get ReflectionTextureEnabled(): boolean;
  26346. static set ReflectionTextureEnabled(value: boolean);
  26347. private static _EmissiveTextureEnabled;
  26348. /**
  26349. * Are emissive textures enabled in the application.
  26350. */
  26351. static get EmissiveTextureEnabled(): boolean;
  26352. static set EmissiveTextureEnabled(value: boolean);
  26353. private static _SpecularTextureEnabled;
  26354. /**
  26355. * Are specular textures enabled in the application.
  26356. */
  26357. static get SpecularTextureEnabled(): boolean;
  26358. static set SpecularTextureEnabled(value: boolean);
  26359. private static _BumpTextureEnabled;
  26360. /**
  26361. * Are bump textures enabled in the application.
  26362. */
  26363. static get BumpTextureEnabled(): boolean;
  26364. static set BumpTextureEnabled(value: boolean);
  26365. private static _LightmapTextureEnabled;
  26366. /**
  26367. * Are lightmap textures enabled in the application.
  26368. */
  26369. static get LightmapTextureEnabled(): boolean;
  26370. static set LightmapTextureEnabled(value: boolean);
  26371. private static _RefractionTextureEnabled;
  26372. /**
  26373. * Are refraction textures enabled in the application.
  26374. */
  26375. static get RefractionTextureEnabled(): boolean;
  26376. static set RefractionTextureEnabled(value: boolean);
  26377. private static _ColorGradingTextureEnabled;
  26378. /**
  26379. * Are color grading textures enabled in the application.
  26380. */
  26381. static get ColorGradingTextureEnabled(): boolean;
  26382. static set ColorGradingTextureEnabled(value: boolean);
  26383. private static _FresnelEnabled;
  26384. /**
  26385. * Are fresnels enabled in the application.
  26386. */
  26387. static get FresnelEnabled(): boolean;
  26388. static set FresnelEnabled(value: boolean);
  26389. private static _ClearCoatTextureEnabled;
  26390. /**
  26391. * Are clear coat textures enabled in the application.
  26392. */
  26393. static get ClearCoatTextureEnabled(): boolean;
  26394. static set ClearCoatTextureEnabled(value: boolean);
  26395. private static _ClearCoatBumpTextureEnabled;
  26396. /**
  26397. * Are clear coat bump textures enabled in the application.
  26398. */
  26399. static get ClearCoatBumpTextureEnabled(): boolean;
  26400. static set ClearCoatBumpTextureEnabled(value: boolean);
  26401. private static _ClearCoatTintTextureEnabled;
  26402. /**
  26403. * Are clear coat tint textures enabled in the application.
  26404. */
  26405. static get ClearCoatTintTextureEnabled(): boolean;
  26406. static set ClearCoatTintTextureEnabled(value: boolean);
  26407. private static _SheenTextureEnabled;
  26408. /**
  26409. * Are sheen textures enabled in the application.
  26410. */
  26411. static get SheenTextureEnabled(): boolean;
  26412. static set SheenTextureEnabled(value: boolean);
  26413. private static _AnisotropicTextureEnabled;
  26414. /**
  26415. * Are anisotropic textures enabled in the application.
  26416. */
  26417. static get AnisotropicTextureEnabled(): boolean;
  26418. static set AnisotropicTextureEnabled(value: boolean);
  26419. private static _ThicknessTextureEnabled;
  26420. /**
  26421. * Are thickness textures enabled in the application.
  26422. */
  26423. static get ThicknessTextureEnabled(): boolean;
  26424. static set ThicknessTextureEnabled(value: boolean);
  26425. }
  26426. }
  26427. declare module BABYLON {
  26428. /** @hidden */
  26429. export var defaultFragmentDeclaration: {
  26430. name: string;
  26431. shader: string;
  26432. };
  26433. }
  26434. declare module BABYLON {
  26435. /** @hidden */
  26436. export var defaultUboDeclaration: {
  26437. name: string;
  26438. shader: string;
  26439. };
  26440. }
  26441. declare module BABYLON {
  26442. /** @hidden */
  26443. export var lightFragmentDeclaration: {
  26444. name: string;
  26445. shader: string;
  26446. };
  26447. }
  26448. declare module BABYLON {
  26449. /** @hidden */
  26450. export var lightUboDeclaration: {
  26451. name: string;
  26452. shader: string;
  26453. };
  26454. }
  26455. declare module BABYLON {
  26456. /** @hidden */
  26457. export var lightsFragmentFunctions: {
  26458. name: string;
  26459. shader: string;
  26460. };
  26461. }
  26462. declare module BABYLON {
  26463. /** @hidden */
  26464. export var shadowsFragmentFunctions: {
  26465. name: string;
  26466. shader: string;
  26467. };
  26468. }
  26469. declare module BABYLON {
  26470. /** @hidden */
  26471. export var fresnelFunction: {
  26472. name: string;
  26473. shader: string;
  26474. };
  26475. }
  26476. declare module BABYLON {
  26477. /** @hidden */
  26478. export var reflectionFunction: {
  26479. name: string;
  26480. shader: string;
  26481. };
  26482. }
  26483. declare module BABYLON {
  26484. /** @hidden */
  26485. export var bumpFragmentFunctions: {
  26486. name: string;
  26487. shader: string;
  26488. };
  26489. }
  26490. declare module BABYLON {
  26491. /** @hidden */
  26492. export var logDepthDeclaration: {
  26493. name: string;
  26494. shader: string;
  26495. };
  26496. }
  26497. declare module BABYLON {
  26498. /** @hidden */
  26499. export var bumpFragment: {
  26500. name: string;
  26501. shader: string;
  26502. };
  26503. }
  26504. declare module BABYLON {
  26505. /** @hidden */
  26506. export var depthPrePass: {
  26507. name: string;
  26508. shader: string;
  26509. };
  26510. }
  26511. declare module BABYLON {
  26512. /** @hidden */
  26513. export var lightFragment: {
  26514. name: string;
  26515. shader: string;
  26516. };
  26517. }
  26518. declare module BABYLON {
  26519. /** @hidden */
  26520. export var logDepthFragment: {
  26521. name: string;
  26522. shader: string;
  26523. };
  26524. }
  26525. declare module BABYLON {
  26526. /** @hidden */
  26527. export var defaultPixelShader: {
  26528. name: string;
  26529. shader: string;
  26530. };
  26531. }
  26532. declare module BABYLON {
  26533. /** @hidden */
  26534. export var defaultVertexDeclaration: {
  26535. name: string;
  26536. shader: string;
  26537. };
  26538. }
  26539. declare module BABYLON {
  26540. /** @hidden */
  26541. export var bumpVertexDeclaration: {
  26542. name: string;
  26543. shader: string;
  26544. };
  26545. }
  26546. declare module BABYLON {
  26547. /** @hidden */
  26548. export var bumpVertex: {
  26549. name: string;
  26550. shader: string;
  26551. };
  26552. }
  26553. declare module BABYLON {
  26554. /** @hidden */
  26555. export var fogVertex: {
  26556. name: string;
  26557. shader: string;
  26558. };
  26559. }
  26560. declare module BABYLON {
  26561. /** @hidden */
  26562. export var shadowsVertex: {
  26563. name: string;
  26564. shader: string;
  26565. };
  26566. }
  26567. declare module BABYLON {
  26568. /** @hidden */
  26569. export var pointCloudVertex: {
  26570. name: string;
  26571. shader: string;
  26572. };
  26573. }
  26574. declare module BABYLON {
  26575. /** @hidden */
  26576. export var logDepthVertex: {
  26577. name: string;
  26578. shader: string;
  26579. };
  26580. }
  26581. declare module BABYLON {
  26582. /** @hidden */
  26583. export var defaultVertexShader: {
  26584. name: string;
  26585. shader: string;
  26586. };
  26587. }
  26588. declare module BABYLON {
  26589. /** @hidden */
  26590. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26591. MAINUV1: boolean;
  26592. MAINUV2: boolean;
  26593. DIFFUSE: boolean;
  26594. DIFFUSEDIRECTUV: number;
  26595. AMBIENT: boolean;
  26596. AMBIENTDIRECTUV: number;
  26597. OPACITY: boolean;
  26598. OPACITYDIRECTUV: number;
  26599. OPACITYRGB: boolean;
  26600. REFLECTION: boolean;
  26601. EMISSIVE: boolean;
  26602. EMISSIVEDIRECTUV: number;
  26603. SPECULAR: boolean;
  26604. SPECULARDIRECTUV: number;
  26605. BUMP: boolean;
  26606. BUMPDIRECTUV: number;
  26607. PARALLAX: boolean;
  26608. PARALLAXOCCLUSION: boolean;
  26609. SPECULAROVERALPHA: boolean;
  26610. CLIPPLANE: boolean;
  26611. CLIPPLANE2: boolean;
  26612. CLIPPLANE3: boolean;
  26613. CLIPPLANE4: boolean;
  26614. CLIPPLANE5: boolean;
  26615. CLIPPLANE6: boolean;
  26616. ALPHATEST: boolean;
  26617. DEPTHPREPASS: boolean;
  26618. ALPHAFROMDIFFUSE: boolean;
  26619. POINTSIZE: boolean;
  26620. FOG: boolean;
  26621. SPECULARTERM: boolean;
  26622. DIFFUSEFRESNEL: boolean;
  26623. OPACITYFRESNEL: boolean;
  26624. REFLECTIONFRESNEL: boolean;
  26625. REFRACTIONFRESNEL: boolean;
  26626. EMISSIVEFRESNEL: boolean;
  26627. FRESNEL: boolean;
  26628. NORMAL: boolean;
  26629. UV1: boolean;
  26630. UV2: boolean;
  26631. VERTEXCOLOR: boolean;
  26632. VERTEXALPHA: boolean;
  26633. NUM_BONE_INFLUENCERS: number;
  26634. BonesPerMesh: number;
  26635. BONETEXTURE: boolean;
  26636. INSTANCES: boolean;
  26637. GLOSSINESS: boolean;
  26638. ROUGHNESS: boolean;
  26639. EMISSIVEASILLUMINATION: boolean;
  26640. LINKEMISSIVEWITHDIFFUSE: boolean;
  26641. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26642. LIGHTMAP: boolean;
  26643. LIGHTMAPDIRECTUV: number;
  26644. OBJECTSPACE_NORMALMAP: boolean;
  26645. USELIGHTMAPASSHADOWMAP: boolean;
  26646. REFLECTIONMAP_3D: boolean;
  26647. REFLECTIONMAP_SPHERICAL: boolean;
  26648. REFLECTIONMAP_PLANAR: boolean;
  26649. REFLECTIONMAP_CUBIC: boolean;
  26650. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26651. REFLECTIONMAP_PROJECTION: boolean;
  26652. REFLECTIONMAP_SKYBOX: boolean;
  26653. REFLECTIONMAP_EXPLICIT: boolean;
  26654. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26655. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26656. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26657. INVERTCUBICMAP: boolean;
  26658. LOGARITHMICDEPTH: boolean;
  26659. REFRACTION: boolean;
  26660. REFRACTIONMAP_3D: boolean;
  26661. REFLECTIONOVERALPHA: boolean;
  26662. TWOSIDEDLIGHTING: boolean;
  26663. SHADOWFLOAT: boolean;
  26664. MORPHTARGETS: boolean;
  26665. MORPHTARGETS_NORMAL: boolean;
  26666. MORPHTARGETS_TANGENT: boolean;
  26667. MORPHTARGETS_UV: boolean;
  26668. NUM_MORPH_INFLUENCERS: number;
  26669. NONUNIFORMSCALING: boolean;
  26670. PREMULTIPLYALPHA: boolean;
  26671. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  26672. ALPHABLEND: boolean;
  26673. IMAGEPROCESSING: boolean;
  26674. VIGNETTE: boolean;
  26675. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26676. VIGNETTEBLENDMODEOPAQUE: boolean;
  26677. TONEMAPPING: boolean;
  26678. TONEMAPPING_ACES: boolean;
  26679. CONTRAST: boolean;
  26680. COLORCURVES: boolean;
  26681. COLORGRADING: boolean;
  26682. COLORGRADING3D: boolean;
  26683. SAMPLER3DGREENDEPTH: boolean;
  26684. SAMPLER3DBGRMAP: boolean;
  26685. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26686. MULTIVIEW: boolean;
  26687. /**
  26688. * If the reflection texture on this material is in linear color space
  26689. * @hidden
  26690. */
  26691. IS_REFLECTION_LINEAR: boolean;
  26692. /**
  26693. * If the refraction texture on this material is in linear color space
  26694. * @hidden
  26695. */
  26696. IS_REFRACTION_LINEAR: boolean;
  26697. EXPOSURE: boolean;
  26698. constructor();
  26699. setReflectionMode(modeToEnable: string): void;
  26700. }
  26701. /**
  26702. * This is the default material used in Babylon. It is the best trade off between quality
  26703. * and performances.
  26704. * @see http://doc.babylonjs.com/babylon101/materials
  26705. */
  26706. export class StandardMaterial extends PushMaterial {
  26707. private _diffuseTexture;
  26708. /**
  26709. * The basic texture of the material as viewed under a light.
  26710. */
  26711. diffuseTexture: Nullable<BaseTexture>;
  26712. private _ambientTexture;
  26713. /**
  26714. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26715. */
  26716. ambientTexture: Nullable<BaseTexture>;
  26717. private _opacityTexture;
  26718. /**
  26719. * Define the transparency of the material from a texture.
  26720. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26721. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26722. */
  26723. opacityTexture: Nullable<BaseTexture>;
  26724. private _reflectionTexture;
  26725. /**
  26726. * Define the texture used to display the reflection.
  26727. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26728. */
  26729. reflectionTexture: Nullable<BaseTexture>;
  26730. private _emissiveTexture;
  26731. /**
  26732. * Define texture of the material as if self lit.
  26733. * This will be mixed in the final result even in the absence of light.
  26734. */
  26735. emissiveTexture: Nullable<BaseTexture>;
  26736. private _specularTexture;
  26737. /**
  26738. * Define how the color and intensity of the highlight given by the light in the material.
  26739. */
  26740. specularTexture: Nullable<BaseTexture>;
  26741. private _bumpTexture;
  26742. /**
  26743. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26744. * 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.
  26745. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26746. */
  26747. bumpTexture: Nullable<BaseTexture>;
  26748. private _lightmapTexture;
  26749. /**
  26750. * Complex lighting can be computationally expensive to compute at runtime.
  26751. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26752. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26753. */
  26754. lightmapTexture: Nullable<BaseTexture>;
  26755. private _refractionTexture;
  26756. /**
  26757. * Define the texture used to display the refraction.
  26758. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26759. */
  26760. refractionTexture: Nullable<BaseTexture>;
  26761. /**
  26762. * The color of the material lit by the environmental background lighting.
  26763. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26764. */
  26765. ambientColor: Color3;
  26766. /**
  26767. * The basic color of the material as viewed under a light.
  26768. */
  26769. diffuseColor: Color3;
  26770. /**
  26771. * Define how the color and intensity of the highlight given by the light in the material.
  26772. */
  26773. specularColor: Color3;
  26774. /**
  26775. * Define the color of the material as if self lit.
  26776. * This will be mixed in the final result even in the absence of light.
  26777. */
  26778. emissiveColor: Color3;
  26779. /**
  26780. * Defines how sharp are the highlights in the material.
  26781. * The bigger the value the sharper giving a more glossy feeling to the result.
  26782. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26783. */
  26784. specularPower: number;
  26785. private _useAlphaFromDiffuseTexture;
  26786. /**
  26787. * Does the transparency come from the diffuse texture alpha channel.
  26788. */
  26789. useAlphaFromDiffuseTexture: boolean;
  26790. private _useEmissiveAsIllumination;
  26791. /**
  26792. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26793. */
  26794. useEmissiveAsIllumination: boolean;
  26795. private _linkEmissiveWithDiffuse;
  26796. /**
  26797. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26798. * the emissive level when the final color is close to one.
  26799. */
  26800. linkEmissiveWithDiffuse: boolean;
  26801. private _useSpecularOverAlpha;
  26802. /**
  26803. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26804. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26805. */
  26806. useSpecularOverAlpha: boolean;
  26807. private _useReflectionOverAlpha;
  26808. /**
  26809. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26810. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26811. */
  26812. useReflectionOverAlpha: boolean;
  26813. private _disableLighting;
  26814. /**
  26815. * Does lights from the scene impacts this material.
  26816. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26817. */
  26818. disableLighting: boolean;
  26819. private _useObjectSpaceNormalMap;
  26820. /**
  26821. * Allows using an object space normal map (instead of tangent space).
  26822. */
  26823. useObjectSpaceNormalMap: boolean;
  26824. private _useParallax;
  26825. /**
  26826. * Is parallax enabled or not.
  26827. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26828. */
  26829. useParallax: boolean;
  26830. private _useParallaxOcclusion;
  26831. /**
  26832. * Is parallax occlusion enabled or not.
  26833. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26834. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26835. */
  26836. useParallaxOcclusion: boolean;
  26837. /**
  26838. * 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.
  26839. */
  26840. parallaxScaleBias: number;
  26841. private _roughness;
  26842. /**
  26843. * Helps to define how blurry the reflections should appears in the material.
  26844. */
  26845. roughness: number;
  26846. /**
  26847. * In case of refraction, define the value of the index of refraction.
  26848. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26849. */
  26850. indexOfRefraction: number;
  26851. /**
  26852. * Invert the refraction texture alongside the y axis.
  26853. * It can be useful with procedural textures or probe for instance.
  26854. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26855. */
  26856. invertRefractionY: boolean;
  26857. /**
  26858. * Defines the alpha limits in alpha test mode.
  26859. */
  26860. alphaCutOff: number;
  26861. private _useLightmapAsShadowmap;
  26862. /**
  26863. * In case of light mapping, define whether the map contains light or shadow informations.
  26864. */
  26865. useLightmapAsShadowmap: boolean;
  26866. private _diffuseFresnelParameters;
  26867. /**
  26868. * Define the diffuse fresnel parameters of the material.
  26869. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26870. */
  26871. diffuseFresnelParameters: FresnelParameters;
  26872. private _opacityFresnelParameters;
  26873. /**
  26874. * Define the opacity fresnel parameters of the material.
  26875. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26876. */
  26877. opacityFresnelParameters: FresnelParameters;
  26878. private _reflectionFresnelParameters;
  26879. /**
  26880. * Define the reflection fresnel parameters of the material.
  26881. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26882. */
  26883. reflectionFresnelParameters: FresnelParameters;
  26884. private _refractionFresnelParameters;
  26885. /**
  26886. * Define the refraction fresnel parameters of the material.
  26887. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26888. */
  26889. refractionFresnelParameters: FresnelParameters;
  26890. private _emissiveFresnelParameters;
  26891. /**
  26892. * Define the emissive fresnel parameters of the material.
  26893. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26894. */
  26895. emissiveFresnelParameters: FresnelParameters;
  26896. private _useReflectionFresnelFromSpecular;
  26897. /**
  26898. * If true automatically deducts the fresnels values from the material specularity.
  26899. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26900. */
  26901. useReflectionFresnelFromSpecular: boolean;
  26902. private _useGlossinessFromSpecularMapAlpha;
  26903. /**
  26904. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26905. */
  26906. useGlossinessFromSpecularMapAlpha: boolean;
  26907. private _maxSimultaneousLights;
  26908. /**
  26909. * Defines the maximum number of lights that can be used in the material
  26910. */
  26911. maxSimultaneousLights: number;
  26912. private _invertNormalMapX;
  26913. /**
  26914. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26915. */
  26916. invertNormalMapX: boolean;
  26917. private _invertNormalMapY;
  26918. /**
  26919. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26920. */
  26921. invertNormalMapY: boolean;
  26922. private _twoSidedLighting;
  26923. /**
  26924. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26925. */
  26926. twoSidedLighting: boolean;
  26927. /**
  26928. * Default configuration related to image processing available in the standard Material.
  26929. */
  26930. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26931. /**
  26932. * Gets the image processing configuration used either in this material.
  26933. */
  26934. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26935. /**
  26936. * Sets the Default image processing configuration used either in the this material.
  26937. *
  26938. * If sets to null, the scene one is in use.
  26939. */
  26940. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26941. /**
  26942. * Keep track of the image processing observer to allow dispose and replace.
  26943. */
  26944. private _imageProcessingObserver;
  26945. /**
  26946. * Attaches a new image processing configuration to the Standard Material.
  26947. * @param configuration
  26948. */
  26949. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26950. /**
  26951. * Gets wether the color curves effect is enabled.
  26952. */
  26953. get cameraColorCurvesEnabled(): boolean;
  26954. /**
  26955. * Sets wether the color curves effect is enabled.
  26956. */
  26957. set cameraColorCurvesEnabled(value: boolean);
  26958. /**
  26959. * Gets wether the color grading effect is enabled.
  26960. */
  26961. get cameraColorGradingEnabled(): boolean;
  26962. /**
  26963. * Gets wether the color grading effect is enabled.
  26964. */
  26965. set cameraColorGradingEnabled(value: boolean);
  26966. /**
  26967. * Gets wether tonemapping is enabled or not.
  26968. */
  26969. get cameraToneMappingEnabled(): boolean;
  26970. /**
  26971. * Sets wether tonemapping is enabled or not
  26972. */
  26973. set cameraToneMappingEnabled(value: boolean);
  26974. /**
  26975. * The camera exposure used on this material.
  26976. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26977. * This corresponds to a photographic exposure.
  26978. */
  26979. get cameraExposure(): number;
  26980. /**
  26981. * The camera exposure used on this material.
  26982. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26983. * This corresponds to a photographic exposure.
  26984. */
  26985. set cameraExposure(value: number);
  26986. /**
  26987. * Gets The camera contrast used on this material.
  26988. */
  26989. get cameraContrast(): number;
  26990. /**
  26991. * Sets The camera contrast used on this material.
  26992. */
  26993. set cameraContrast(value: number);
  26994. /**
  26995. * Gets the Color Grading 2D Lookup Texture.
  26996. */
  26997. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26998. /**
  26999. * Sets the Color Grading 2D Lookup Texture.
  27000. */
  27001. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27002. /**
  27003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27005. * 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;
  27006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27007. */
  27008. get cameraColorCurves(): Nullable<ColorCurves>;
  27009. /**
  27010. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27011. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27012. * 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;
  27013. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27014. */
  27015. set cameraColorCurves(value: Nullable<ColorCurves>);
  27016. /**
  27017. * Custom callback helping to override the default shader used in the material.
  27018. */
  27019. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27020. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27021. protected _worldViewProjectionMatrix: Matrix;
  27022. protected _globalAmbientColor: Color3;
  27023. protected _useLogarithmicDepth: boolean;
  27024. protected _rebuildInParallel: boolean;
  27025. /**
  27026. * Instantiates a new standard material.
  27027. * This is the default material used in Babylon. It is the best trade off between quality
  27028. * and performances.
  27029. * @see http://doc.babylonjs.com/babylon101/materials
  27030. * @param name Define the name of the material in the scene
  27031. * @param scene Define the scene the material belong to
  27032. */
  27033. constructor(name: string, scene: Scene);
  27034. /**
  27035. * Gets a boolean indicating that current material needs to register RTT
  27036. */
  27037. get hasRenderTargetTextures(): boolean;
  27038. /**
  27039. * Gets the current class name of the material e.g. "StandardMaterial"
  27040. * Mainly use in serialization.
  27041. * @returns the class name
  27042. */
  27043. getClassName(): string;
  27044. /**
  27045. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27046. * You can try switching to logarithmic depth.
  27047. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27048. */
  27049. get useLogarithmicDepth(): boolean;
  27050. set useLogarithmicDepth(value: boolean);
  27051. /**
  27052. * Specifies if the material will require alpha blending
  27053. * @returns a boolean specifying if alpha blending is needed
  27054. */
  27055. needAlphaBlending(): boolean;
  27056. /**
  27057. * Specifies if this material should be rendered in alpha test mode
  27058. * @returns a boolean specifying if an alpha test is needed.
  27059. */
  27060. needAlphaTesting(): boolean;
  27061. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27062. /**
  27063. * Get the texture used for alpha test purpose.
  27064. * @returns the diffuse texture in case of the standard material.
  27065. */
  27066. getAlphaTestTexture(): Nullable<BaseTexture>;
  27067. /**
  27068. * Get if the submesh is ready to be used and all its information available.
  27069. * Child classes can use it to update shaders
  27070. * @param mesh defines the mesh to check
  27071. * @param subMesh defines which submesh to check
  27072. * @param useInstances specifies that instances should be used
  27073. * @returns a boolean indicating that the submesh is ready or not
  27074. */
  27075. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27076. /**
  27077. * Builds the material UBO layouts.
  27078. * Used internally during the effect preparation.
  27079. */
  27080. buildUniformLayout(): void;
  27081. /**
  27082. * Unbinds the material from the mesh
  27083. */
  27084. unbind(): void;
  27085. /**
  27086. * Binds the submesh to this material by preparing the effect and shader to draw
  27087. * @param world defines the world transformation matrix
  27088. * @param mesh defines the mesh containing the submesh
  27089. * @param subMesh defines the submesh to bind the material to
  27090. */
  27091. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27092. /**
  27093. * Get the list of animatables in the material.
  27094. * @returns the list of animatables object used in the material
  27095. */
  27096. getAnimatables(): IAnimatable[];
  27097. /**
  27098. * Gets the active textures from the material
  27099. * @returns an array of textures
  27100. */
  27101. getActiveTextures(): BaseTexture[];
  27102. /**
  27103. * Specifies if the material uses a texture
  27104. * @param texture defines the texture to check against the material
  27105. * @returns a boolean specifying if the material uses the texture
  27106. */
  27107. hasTexture(texture: BaseTexture): boolean;
  27108. /**
  27109. * Disposes the material
  27110. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27111. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27112. */
  27113. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27114. /**
  27115. * Makes a duplicate of the material, and gives it a new name
  27116. * @param name defines the new name for the duplicated material
  27117. * @returns the cloned material
  27118. */
  27119. clone(name: string): StandardMaterial;
  27120. /**
  27121. * Serializes this material in a JSON representation
  27122. * @returns the serialized material object
  27123. */
  27124. serialize(): any;
  27125. /**
  27126. * Creates a standard material from parsed material data
  27127. * @param source defines the JSON representation of the material
  27128. * @param scene defines the hosting scene
  27129. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27130. * @returns a new standard material
  27131. */
  27132. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27133. /**
  27134. * Are diffuse textures enabled in the application.
  27135. */
  27136. static get DiffuseTextureEnabled(): boolean;
  27137. static set DiffuseTextureEnabled(value: boolean);
  27138. /**
  27139. * Are ambient textures enabled in the application.
  27140. */
  27141. static get AmbientTextureEnabled(): boolean;
  27142. static set AmbientTextureEnabled(value: boolean);
  27143. /**
  27144. * Are opacity textures enabled in the application.
  27145. */
  27146. static get OpacityTextureEnabled(): boolean;
  27147. static set OpacityTextureEnabled(value: boolean);
  27148. /**
  27149. * Are reflection textures enabled in the application.
  27150. */
  27151. static get ReflectionTextureEnabled(): boolean;
  27152. static set ReflectionTextureEnabled(value: boolean);
  27153. /**
  27154. * Are emissive textures enabled in the application.
  27155. */
  27156. static get EmissiveTextureEnabled(): boolean;
  27157. static set EmissiveTextureEnabled(value: boolean);
  27158. /**
  27159. * Are specular textures enabled in the application.
  27160. */
  27161. static get SpecularTextureEnabled(): boolean;
  27162. static set SpecularTextureEnabled(value: boolean);
  27163. /**
  27164. * Are bump textures enabled in the application.
  27165. */
  27166. static get BumpTextureEnabled(): boolean;
  27167. static set BumpTextureEnabled(value: boolean);
  27168. /**
  27169. * Are lightmap textures enabled in the application.
  27170. */
  27171. static get LightmapTextureEnabled(): boolean;
  27172. static set LightmapTextureEnabled(value: boolean);
  27173. /**
  27174. * Are refraction textures enabled in the application.
  27175. */
  27176. static get RefractionTextureEnabled(): boolean;
  27177. static set RefractionTextureEnabled(value: boolean);
  27178. /**
  27179. * Are color grading textures enabled in the application.
  27180. */
  27181. static get ColorGradingTextureEnabled(): boolean;
  27182. static set ColorGradingTextureEnabled(value: boolean);
  27183. /**
  27184. * Are fresnels enabled in the application.
  27185. */
  27186. static get FresnelEnabled(): boolean;
  27187. static set FresnelEnabled(value: boolean);
  27188. }
  27189. }
  27190. declare module BABYLON {
  27191. /**
  27192. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27193. *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.
  27194. * The SPS is also a particle system. It provides some methods to manage the particles.
  27195. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27196. *
  27197. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27198. */
  27199. export class SolidParticleSystem implements IDisposable {
  27200. /**
  27201. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27202. * Example : var p = SPS.particles[i];
  27203. */
  27204. particles: SolidParticle[];
  27205. /**
  27206. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27207. */
  27208. nbParticles: number;
  27209. /**
  27210. * If the particles must ever face the camera (default false). Useful for planar particles.
  27211. */
  27212. billboard: boolean;
  27213. /**
  27214. * Recompute normals when adding a shape
  27215. */
  27216. recomputeNormals: boolean;
  27217. /**
  27218. * This a counter ofr your own usage. It's not set by any SPS functions.
  27219. */
  27220. counter: number;
  27221. /**
  27222. * The SPS name. This name is also given to the underlying mesh.
  27223. */
  27224. name: string;
  27225. /**
  27226. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27227. */
  27228. mesh: Mesh;
  27229. /**
  27230. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27231. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27232. */
  27233. vars: any;
  27234. /**
  27235. * This array is populated when the SPS is set as 'pickable'.
  27236. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27237. * Each element of this array is an object `{idx: int, faceId: int}`.
  27238. * `idx` is the picked particle index in the `SPS.particles` array
  27239. * `faceId` is the picked face index counted within this particle.
  27240. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  27241. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  27242. * Use the method SPS.pickedParticle(pickingInfo) instead.
  27243. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27244. */
  27245. pickedParticles: {
  27246. idx: number;
  27247. faceId: number;
  27248. }[];
  27249. /**
  27250. * This array is populated when the SPS is set as 'pickable'
  27251. * Each key of this array is a submesh index.
  27252. * Each element of this array is a second array defined like this :
  27253. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  27254. * Each element of this second array is an object `{idx: int, faceId: int}`.
  27255. * `idx` is the picked particle index in the `SPS.particles` array
  27256. * `faceId` is the picked face index counted within this particle.
  27257. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  27258. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27259. */
  27260. pickedBySubMesh: {
  27261. idx: number;
  27262. faceId: number;
  27263. }[][];
  27264. /**
  27265. * This array is populated when `enableDepthSort` is set to true.
  27266. * Each element of this array is an instance of the class DepthSortedParticle.
  27267. */
  27268. depthSortedParticles: DepthSortedParticle[];
  27269. /**
  27270. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27271. * @hidden
  27272. */
  27273. _bSphereOnly: boolean;
  27274. /**
  27275. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27276. * @hidden
  27277. */
  27278. _bSphereRadiusFactor: number;
  27279. private _scene;
  27280. private _positions;
  27281. private _indices;
  27282. private _normals;
  27283. private _colors;
  27284. private _uvs;
  27285. private _indices32;
  27286. private _positions32;
  27287. private _normals32;
  27288. private _fixedNormal32;
  27289. private _colors32;
  27290. private _uvs32;
  27291. private _index;
  27292. private _updatable;
  27293. private _pickable;
  27294. private _isVisibilityBoxLocked;
  27295. private _alwaysVisible;
  27296. private _depthSort;
  27297. private _expandable;
  27298. private _shapeCounter;
  27299. private _copy;
  27300. private _color;
  27301. private _computeParticleColor;
  27302. private _computeParticleTexture;
  27303. private _computeParticleRotation;
  27304. private _computeParticleVertex;
  27305. private _computeBoundingBox;
  27306. private _depthSortParticles;
  27307. private _camera;
  27308. private _mustUnrotateFixedNormals;
  27309. private _particlesIntersect;
  27310. private _needs32Bits;
  27311. private _isNotBuilt;
  27312. private _lastParticleId;
  27313. private _idxOfId;
  27314. private _multimaterialEnabled;
  27315. private _useModelMaterial;
  27316. private _indicesByMaterial;
  27317. private _materialIndexes;
  27318. private _depthSortFunction;
  27319. private _materialSortFunction;
  27320. private _materials;
  27321. private _multimaterial;
  27322. private _materialIndexesById;
  27323. private _defaultMaterial;
  27324. private _autoUpdateSubMeshes;
  27325. /**
  27326. * Creates a SPS (Solid Particle System) object.
  27327. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27328. * @param scene (Scene) is the scene in which the SPS is added.
  27329. * @param options defines the options of the sps e.g.
  27330. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27331. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27332. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27333. * * 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.
  27334. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27335. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27336. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27337. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27338. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27339. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27340. */
  27341. constructor(name: string, scene: Scene, options?: {
  27342. updatable?: boolean;
  27343. isPickable?: boolean;
  27344. enableDepthSort?: boolean;
  27345. particleIntersection?: boolean;
  27346. boundingSphereOnly?: boolean;
  27347. bSphereRadiusFactor?: number;
  27348. expandable?: boolean;
  27349. useModelMaterial?: boolean;
  27350. enableMultiMaterial?: boolean;
  27351. });
  27352. /**
  27353. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27354. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27355. * @returns the created mesh
  27356. */
  27357. buildMesh(): Mesh;
  27358. /**
  27359. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27360. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27361. * Thus the particles generated from `digest()` have their property `position` set yet.
  27362. * @param mesh ( Mesh ) is the mesh to be digested
  27363. * @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
  27364. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27365. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27366. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27367. * @returns the current SPS
  27368. */
  27369. digest(mesh: Mesh, options?: {
  27370. facetNb?: number;
  27371. number?: number;
  27372. delta?: number;
  27373. storage?: [];
  27374. }): SolidParticleSystem;
  27375. /**
  27376. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27377. * @hidden
  27378. */
  27379. private _unrotateFixedNormals;
  27380. /**
  27381. * Resets the temporary working copy particle
  27382. * @hidden
  27383. */
  27384. private _resetCopy;
  27385. /**
  27386. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27387. * @param p the current index in the positions array to be updated
  27388. * @param ind the current index in the indices array
  27389. * @param shape a Vector3 array, the shape geometry
  27390. * @param positions the positions array to be updated
  27391. * @param meshInd the shape indices array
  27392. * @param indices the indices array to be updated
  27393. * @param meshUV the shape uv array
  27394. * @param uvs the uv array to be updated
  27395. * @param meshCol the shape color array
  27396. * @param colors the color array to be updated
  27397. * @param meshNor the shape normals array
  27398. * @param normals the normals array to be updated
  27399. * @param idx the particle index
  27400. * @param idxInShape the particle index in its shape
  27401. * @param options the addShape() method passed options
  27402. * @model the particle model
  27403. * @hidden
  27404. */
  27405. private _meshBuilder;
  27406. /**
  27407. * Returns a shape Vector3 array from positions float array
  27408. * @param positions float array
  27409. * @returns a vector3 array
  27410. * @hidden
  27411. */
  27412. private _posToShape;
  27413. /**
  27414. * Returns a shapeUV array from a float uvs (array deep copy)
  27415. * @param uvs as a float array
  27416. * @returns a shapeUV array
  27417. * @hidden
  27418. */
  27419. private _uvsToShapeUV;
  27420. /**
  27421. * Adds a new particle object in the particles array
  27422. * @param idx particle index in particles array
  27423. * @param id particle id
  27424. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27425. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27426. * @param model particle ModelShape object
  27427. * @param shapeId model shape identifier
  27428. * @param idxInShape index of the particle in the current model
  27429. * @param bInfo model bounding info object
  27430. * @param storage target storage array, if any
  27431. * @hidden
  27432. */
  27433. private _addParticle;
  27434. /**
  27435. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27436. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27437. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27438. * @param nb (positive integer) the number of particles to be created from this model
  27439. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27440. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27441. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27442. * @returns the number of shapes in the system
  27443. */
  27444. addShape(mesh: Mesh, nb: number, options?: {
  27445. positionFunction?: any;
  27446. vertexFunction?: any;
  27447. storage?: [];
  27448. }): number;
  27449. /**
  27450. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27451. * @hidden
  27452. */
  27453. private _rebuildParticle;
  27454. /**
  27455. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27456. * @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.
  27457. * @returns the SPS.
  27458. */
  27459. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27460. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27461. * Returns an array with the removed particles.
  27462. * 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.
  27463. * The SPS can't be empty so at least one particle needs to remain in place.
  27464. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27465. * @param start index of the first particle to remove
  27466. * @param end index of the last particle to remove (included)
  27467. * @returns an array populated with the removed particles
  27468. */
  27469. removeParticles(start: number, end: number): SolidParticle[];
  27470. /**
  27471. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27472. * @param solidParticleArray an array populated with Solid Particles objects
  27473. * @returns the SPS
  27474. */
  27475. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27476. /**
  27477. * Creates a new particle and modifies the SPS mesh geometry :
  27478. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27479. * - calls _addParticle() to populate the particle array
  27480. * factorized code from addShape() and insertParticlesFromArray()
  27481. * @param idx particle index in the particles array
  27482. * @param i particle index in its shape
  27483. * @param modelShape particle ModelShape object
  27484. * @param shape shape vertex array
  27485. * @param meshInd shape indices array
  27486. * @param meshUV shape uv array
  27487. * @param meshCol shape color array
  27488. * @param meshNor shape normals array
  27489. * @param bbInfo shape bounding info
  27490. * @param storage target particle storage
  27491. * @options addShape() passed options
  27492. * @hidden
  27493. */
  27494. private _insertNewParticle;
  27495. /**
  27496. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27497. * This method calls `updateParticle()` for each particle of the SPS.
  27498. * For an animated SPS, it is usually called within the render loop.
  27499. * 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.
  27500. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27501. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27502. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27503. * @returns the SPS.
  27504. */
  27505. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27506. /**
  27507. * Disposes the SPS.
  27508. */
  27509. dispose(): void;
  27510. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  27511. * idx is the particle index in the SPS
  27512. * faceId is the picked face index counted within this particle.
  27513. * Returns null if the pickInfo can't identify a picked particle.
  27514. * @param pickingInfo (PickingInfo object)
  27515. * @returns {idx: number, faceId: number} or null
  27516. */
  27517. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  27518. idx: number;
  27519. faceId: number;
  27520. }>;
  27521. /**
  27522. * Returns a SolidParticle object from its identifier : particle.id
  27523. * @param id (integer) the particle Id
  27524. * @returns the searched particle or null if not found in the SPS.
  27525. */
  27526. getParticleById(id: number): Nullable<SolidParticle>;
  27527. /**
  27528. * Returns a new array populated with the particles having the passed shapeId.
  27529. * @param shapeId (integer) the shape identifier
  27530. * @returns a new solid particle array
  27531. */
  27532. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27533. /**
  27534. * Populates the passed array "ref" with the particles having the passed shapeId.
  27535. * @param shapeId the shape identifier
  27536. * @returns the SPS
  27537. * @param ref
  27538. */
  27539. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27540. /**
  27541. * Computes the required SubMeshes according the materials assigned to the particles.
  27542. * @returns the solid particle system.
  27543. * Does nothing if called before the SPS mesh is built.
  27544. */
  27545. computeSubMeshes(): SolidParticleSystem;
  27546. /**
  27547. * Sorts the solid particles by material when MultiMaterial is enabled.
  27548. * Updates the indices32 array.
  27549. * Updates the indicesByMaterial array.
  27550. * Updates the mesh indices array.
  27551. * @returns the SPS
  27552. * @hidden
  27553. */
  27554. private _sortParticlesByMaterial;
  27555. /**
  27556. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27557. * @hidden
  27558. */
  27559. private _setMaterialIndexesById;
  27560. /**
  27561. * Returns an array with unique values of Materials from the passed array
  27562. * @param array the material array to be checked and filtered
  27563. * @hidden
  27564. */
  27565. private _filterUniqueMaterialId;
  27566. /**
  27567. * Sets a new Standard Material as _defaultMaterial if not already set.
  27568. * @hidden
  27569. */
  27570. private _setDefaultMaterial;
  27571. /**
  27572. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27573. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27574. * @returns the SPS.
  27575. */
  27576. refreshVisibleSize(): SolidParticleSystem;
  27577. /**
  27578. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27579. * @param size the size (float) of the visibility box
  27580. * note : this doesn't lock the SPS mesh bounding box.
  27581. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27582. */
  27583. setVisibilityBox(size: number): void;
  27584. /**
  27585. * Gets whether the SPS as always visible or not
  27586. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27587. */
  27588. get isAlwaysVisible(): boolean;
  27589. /**
  27590. * Sets the SPS as always visible or not
  27591. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27592. */
  27593. set isAlwaysVisible(val: boolean);
  27594. /**
  27595. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27596. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27597. */
  27598. set isVisibilityBoxLocked(val: boolean);
  27599. /**
  27600. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27601. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27602. */
  27603. get isVisibilityBoxLocked(): boolean;
  27604. /**
  27605. * Tells to `setParticles()` to compute the particle rotations or not.
  27606. * Default value : true. The SPS is faster when it's set to false.
  27607. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27608. */
  27609. set computeParticleRotation(val: boolean);
  27610. /**
  27611. * Tells to `setParticles()` to compute the particle colors or not.
  27612. * Default value : true. The SPS is faster when it's set to false.
  27613. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27614. */
  27615. set computeParticleColor(val: boolean);
  27616. set computeParticleTexture(val: boolean);
  27617. /**
  27618. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27619. * Default value : false. The SPS is faster when it's set to false.
  27620. * Note : the particle custom vertex positions aren't stored values.
  27621. */
  27622. set computeParticleVertex(val: boolean);
  27623. /**
  27624. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27625. */
  27626. set computeBoundingBox(val: boolean);
  27627. /**
  27628. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27629. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27630. * Default : `true`
  27631. */
  27632. set depthSortParticles(val: boolean);
  27633. /**
  27634. * Gets if `setParticles()` computes the particle rotations or not.
  27635. * Default value : true. The SPS is faster when it's set to false.
  27636. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27637. */
  27638. get computeParticleRotation(): boolean;
  27639. /**
  27640. * Gets if `setParticles()` computes the particle colors or not.
  27641. * Default value : true. The SPS is faster when it's set to false.
  27642. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27643. */
  27644. get computeParticleColor(): boolean;
  27645. /**
  27646. * Gets if `setParticles()` computes the particle textures or not.
  27647. * Default value : true. The SPS is faster when it's set to false.
  27648. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27649. */
  27650. get computeParticleTexture(): boolean;
  27651. /**
  27652. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27653. * Default value : false. The SPS is faster when it's set to false.
  27654. * Note : the particle custom vertex positions aren't stored values.
  27655. */
  27656. get computeParticleVertex(): boolean;
  27657. /**
  27658. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27659. */
  27660. get computeBoundingBox(): boolean;
  27661. /**
  27662. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27663. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27664. * Default : `true`
  27665. */
  27666. get depthSortParticles(): boolean;
  27667. /**
  27668. * Gets if the SPS is created as expandable at construction time.
  27669. * Default : `false`
  27670. */
  27671. get expandable(): boolean;
  27672. /**
  27673. * Gets if the SPS supports the Multi Materials
  27674. */
  27675. get multimaterialEnabled(): boolean;
  27676. /**
  27677. * Gets if the SPS uses the model materials for its own multimaterial.
  27678. */
  27679. get useModelMaterial(): boolean;
  27680. /**
  27681. * The SPS used material array.
  27682. */
  27683. get materials(): Material[];
  27684. /**
  27685. * Sets the SPS MultiMaterial from the passed materials.
  27686. * Note : the passed array is internally copied and not used then by reference.
  27687. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27688. */
  27689. setMultiMaterial(materials: Material[]): void;
  27690. /**
  27691. * The SPS computed multimaterial object
  27692. */
  27693. get multimaterial(): MultiMaterial;
  27694. set multimaterial(mm: MultiMaterial);
  27695. /**
  27696. * If the subMeshes must be updated on the next call to setParticles()
  27697. */
  27698. get autoUpdateSubMeshes(): boolean;
  27699. set autoUpdateSubMeshes(val: boolean);
  27700. /**
  27701. * This function does nothing. It may be overwritten to set all the particle first values.
  27702. * The SPS doesn't call this function, you may have to call it by your own.
  27703. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27704. */
  27705. initParticles(): void;
  27706. /**
  27707. * This function does nothing. It may be overwritten to recycle a particle.
  27708. * The SPS doesn't call this function, you may have to call it by your own.
  27709. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27710. * @param particle The particle to recycle
  27711. * @returns the recycled particle
  27712. */
  27713. recycleParticle(particle: SolidParticle): SolidParticle;
  27714. /**
  27715. * Updates a particle : this function should be overwritten by the user.
  27716. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27717. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27718. * @example : just set a particle position or velocity and recycle conditions
  27719. * @param particle The particle to update
  27720. * @returns the updated particle
  27721. */
  27722. updateParticle(particle: SolidParticle): SolidParticle;
  27723. /**
  27724. * Updates a vertex of a particle : it can be overwritten by the user.
  27725. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27726. * @param particle the current particle
  27727. * @param vertex the current index of the current particle
  27728. * @param pt the index of the current vertex in the particle shape
  27729. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27730. * @example : just set a vertex particle position
  27731. * @returns the updated vertex
  27732. */
  27733. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27734. /**
  27735. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27736. * This does nothing and may be overwritten by the user.
  27737. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27738. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27739. * @param update the boolean update value actually passed to setParticles()
  27740. */
  27741. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27742. /**
  27743. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27744. * This will be passed three parameters.
  27745. * This does nothing and may be overwritten by the user.
  27746. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27747. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27748. * @param update the boolean update value actually passed to setParticles()
  27749. */
  27750. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27751. }
  27752. }
  27753. declare module BABYLON {
  27754. /**
  27755. * Represents one particle of a solid particle system.
  27756. */
  27757. export class SolidParticle {
  27758. /**
  27759. * particle global index
  27760. */
  27761. idx: number;
  27762. /**
  27763. * particle identifier
  27764. */
  27765. id: number;
  27766. /**
  27767. * The color of the particle
  27768. */
  27769. color: Nullable<Color4>;
  27770. /**
  27771. * The world space position of the particle.
  27772. */
  27773. position: Vector3;
  27774. /**
  27775. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27776. */
  27777. rotation: Vector3;
  27778. /**
  27779. * The world space rotation quaternion of the particle.
  27780. */
  27781. rotationQuaternion: Nullable<Quaternion>;
  27782. /**
  27783. * The scaling of the particle.
  27784. */
  27785. scaling: Vector3;
  27786. /**
  27787. * The uvs of the particle.
  27788. */
  27789. uvs: Vector4;
  27790. /**
  27791. * The current speed of the particle.
  27792. */
  27793. velocity: Vector3;
  27794. /**
  27795. * The pivot point in the particle local space.
  27796. */
  27797. pivot: Vector3;
  27798. /**
  27799. * Must the particle be translated from its pivot point in its local space ?
  27800. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27801. * Default : false
  27802. */
  27803. translateFromPivot: boolean;
  27804. /**
  27805. * Is the particle active or not ?
  27806. */
  27807. alive: boolean;
  27808. /**
  27809. * Is the particle visible or not ?
  27810. */
  27811. isVisible: boolean;
  27812. /**
  27813. * Index of this particle in the global "positions" array (Internal use)
  27814. * @hidden
  27815. */
  27816. _pos: number;
  27817. /**
  27818. * @hidden Index of this particle in the global "indices" array (Internal use)
  27819. */
  27820. _ind: number;
  27821. /**
  27822. * @hidden ModelShape of this particle (Internal use)
  27823. */
  27824. _model: ModelShape;
  27825. /**
  27826. * ModelShape id of this particle
  27827. */
  27828. shapeId: number;
  27829. /**
  27830. * Index of the particle in its shape id
  27831. */
  27832. idxInShape: number;
  27833. /**
  27834. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27835. */
  27836. _modelBoundingInfo: BoundingInfo;
  27837. /**
  27838. * @hidden Particle BoundingInfo object (Internal use)
  27839. */
  27840. _boundingInfo: BoundingInfo;
  27841. /**
  27842. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27843. */
  27844. _sps: SolidParticleSystem;
  27845. /**
  27846. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27847. */
  27848. _stillInvisible: boolean;
  27849. /**
  27850. * @hidden Last computed particle rotation matrix
  27851. */
  27852. _rotationMatrix: number[];
  27853. /**
  27854. * Parent particle Id, if any.
  27855. * Default null.
  27856. */
  27857. parentId: Nullable<number>;
  27858. /**
  27859. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27860. */
  27861. materialIndex: Nullable<number>;
  27862. /**
  27863. * Custom object or properties.
  27864. */
  27865. props: Nullable<any>;
  27866. /**
  27867. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27868. * The possible values are :
  27869. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27870. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27871. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27872. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27873. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27874. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27875. * */
  27876. cullingStrategy: number;
  27877. /**
  27878. * @hidden Internal global position in the SPS.
  27879. */
  27880. _globalPosition: Vector3;
  27881. /**
  27882. * Creates a Solid Particle object.
  27883. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27884. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27885. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27886. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27887. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27888. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27889. * @param shapeId (integer) is the model shape identifier in the SPS.
  27890. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27891. * @param sps defines the sps it is associated to
  27892. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27893. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27894. */
  27895. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27896. /**
  27897. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27898. * @param target the particle target
  27899. * @returns the current particle
  27900. */
  27901. copyToRef(target: SolidParticle): SolidParticle;
  27902. /**
  27903. * Legacy support, changed scale to scaling
  27904. */
  27905. get scale(): Vector3;
  27906. /**
  27907. * Legacy support, changed scale to scaling
  27908. */
  27909. set scale(scale: Vector3);
  27910. /**
  27911. * Legacy support, changed quaternion to rotationQuaternion
  27912. */
  27913. get quaternion(): Nullable<Quaternion>;
  27914. /**
  27915. * Legacy support, changed quaternion to rotationQuaternion
  27916. */
  27917. set quaternion(q: Nullable<Quaternion>);
  27918. /**
  27919. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27920. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27921. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27922. * @returns true if it intersects
  27923. */
  27924. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27925. /**
  27926. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27927. * A particle is in the frustum if its bounding box intersects the frustum
  27928. * @param frustumPlanes defines the frustum to test
  27929. * @returns true if the particle is in the frustum planes
  27930. */
  27931. isInFrustum(frustumPlanes: Plane[]): boolean;
  27932. /**
  27933. * get the rotation matrix of the particle
  27934. * @hidden
  27935. */
  27936. getRotationMatrix(m: Matrix): void;
  27937. }
  27938. /**
  27939. * Represents the shape of the model used by one particle of a solid particle system.
  27940. * SPS internal tool, don't use it manually.
  27941. */
  27942. export class ModelShape {
  27943. /**
  27944. * The shape id
  27945. * @hidden
  27946. */
  27947. shapeID: number;
  27948. /**
  27949. * flat array of model positions (internal use)
  27950. * @hidden
  27951. */
  27952. _shape: Vector3[];
  27953. /**
  27954. * flat array of model UVs (internal use)
  27955. * @hidden
  27956. */
  27957. _shapeUV: number[];
  27958. /**
  27959. * color array of the model
  27960. * @hidden
  27961. */
  27962. _shapeColors: number[];
  27963. /**
  27964. * indices array of the model
  27965. * @hidden
  27966. */
  27967. _indices: number[];
  27968. /**
  27969. * normals array of the model
  27970. * @hidden
  27971. */
  27972. _normals: number[];
  27973. /**
  27974. * length of the shape in the model indices array (internal use)
  27975. * @hidden
  27976. */
  27977. _indicesLength: number;
  27978. /**
  27979. * Custom position function (internal use)
  27980. * @hidden
  27981. */
  27982. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27983. /**
  27984. * Custom vertex function (internal use)
  27985. * @hidden
  27986. */
  27987. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27988. /**
  27989. * Model material (internal use)
  27990. * @hidden
  27991. */
  27992. _material: Nullable<Material>;
  27993. /**
  27994. * 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.
  27995. * SPS internal tool, don't use it manually.
  27996. * @hidden
  27997. */
  27998. 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>);
  27999. }
  28000. /**
  28001. * Represents a Depth Sorted Particle in the solid particle system.
  28002. * @hidden
  28003. */
  28004. export class DepthSortedParticle {
  28005. /**
  28006. * Particle index
  28007. */
  28008. idx: number;
  28009. /**
  28010. * Index of the particle in the "indices" array
  28011. */
  28012. ind: number;
  28013. /**
  28014. * Length of the particle shape in the "indices" array
  28015. */
  28016. indicesLength: number;
  28017. /**
  28018. * Squared distance from the particle to the camera
  28019. */
  28020. sqDistance: number;
  28021. /**
  28022. * Material index when used with MultiMaterials
  28023. */
  28024. materialIndex: number;
  28025. /**
  28026. * Creates a new sorted particle
  28027. * @param materialIndex
  28028. */
  28029. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28030. }
  28031. }
  28032. declare module BABYLON {
  28033. /**
  28034. * @hidden
  28035. */
  28036. export class _MeshCollisionData {
  28037. _checkCollisions: boolean;
  28038. _collisionMask: number;
  28039. _collisionGroup: number;
  28040. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28041. _collider: Nullable<Collider>;
  28042. _oldPositionForCollisions: Vector3;
  28043. _diffPositionForCollisions: Vector3;
  28044. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28045. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28046. }
  28047. }
  28048. declare module BABYLON {
  28049. /** @hidden */
  28050. class _FacetDataStorage {
  28051. facetPositions: Vector3[];
  28052. facetNormals: Vector3[];
  28053. facetPartitioning: number[][];
  28054. facetNb: number;
  28055. partitioningSubdivisions: number;
  28056. partitioningBBoxRatio: number;
  28057. facetDataEnabled: boolean;
  28058. facetParameters: any;
  28059. bbSize: Vector3;
  28060. subDiv: {
  28061. max: number;
  28062. X: number;
  28063. Y: number;
  28064. Z: number;
  28065. };
  28066. facetDepthSort: boolean;
  28067. facetDepthSortEnabled: boolean;
  28068. depthSortedIndices: IndicesArray;
  28069. depthSortedFacets: {
  28070. ind: number;
  28071. sqDistance: number;
  28072. }[];
  28073. facetDepthSortFunction: (f1: {
  28074. ind: number;
  28075. sqDistance: number;
  28076. }, f2: {
  28077. ind: number;
  28078. sqDistance: number;
  28079. }) => number;
  28080. facetDepthSortFrom: Vector3;
  28081. facetDepthSortOrigin: Vector3;
  28082. invertedMatrix: Matrix;
  28083. }
  28084. /**
  28085. * @hidden
  28086. **/
  28087. class _InternalAbstractMeshDataInfo {
  28088. _hasVertexAlpha: boolean;
  28089. _useVertexColors: boolean;
  28090. _numBoneInfluencers: number;
  28091. _applyFog: boolean;
  28092. _receiveShadows: boolean;
  28093. _facetData: _FacetDataStorage;
  28094. _visibility: number;
  28095. _skeleton: Nullable<Skeleton>;
  28096. _layerMask: number;
  28097. _computeBonesUsingShaders: boolean;
  28098. _isActive: boolean;
  28099. _onlyForInstances: boolean;
  28100. _isActiveIntermediate: boolean;
  28101. _onlyForInstancesIntermediate: boolean;
  28102. _actAsRegularMesh: boolean;
  28103. }
  28104. /**
  28105. * Class used to store all common mesh properties
  28106. */
  28107. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28108. /** No occlusion */
  28109. static OCCLUSION_TYPE_NONE: number;
  28110. /** Occlusion set to optimisitic */
  28111. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28112. /** Occlusion set to strict */
  28113. static OCCLUSION_TYPE_STRICT: number;
  28114. /** Use an accurante occlusion algorithm */
  28115. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28116. /** Use a conservative occlusion algorithm */
  28117. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28118. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28119. * Test order :
  28120. * Is the bounding sphere outside the frustum ?
  28121. * If not, are the bounding box vertices outside the frustum ?
  28122. * It not, then the cullable object is in the frustum.
  28123. */
  28124. static readonly CULLINGSTRATEGY_STANDARD: number;
  28125. /** Culling strategy : Bounding Sphere Only.
  28126. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28127. * It's also less accurate than the standard because some not visible objects can still be selected.
  28128. * Test : is the bounding sphere outside the frustum ?
  28129. * If not, then the cullable object is in the frustum.
  28130. */
  28131. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28132. /** Culling strategy : Optimistic Inclusion.
  28133. * This in an inclusion test first, then the standard exclusion test.
  28134. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28135. * 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.
  28136. * Anyway, it's as accurate as the standard strategy.
  28137. * Test :
  28138. * Is the cullable object bounding sphere center in the frustum ?
  28139. * If not, apply the default culling strategy.
  28140. */
  28141. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28142. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28143. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28144. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28145. * 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.
  28146. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28147. * Test :
  28148. * Is the cullable object bounding sphere center in the frustum ?
  28149. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28150. */
  28151. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28152. /**
  28153. * No billboard
  28154. */
  28155. static get BILLBOARDMODE_NONE(): number;
  28156. /** Billboard on X axis */
  28157. static get BILLBOARDMODE_X(): number;
  28158. /** Billboard on Y axis */
  28159. static get BILLBOARDMODE_Y(): number;
  28160. /** Billboard on Z axis */
  28161. static get BILLBOARDMODE_Z(): number;
  28162. /** Billboard on all axes */
  28163. static get BILLBOARDMODE_ALL(): number;
  28164. /** Billboard on using position instead of orientation */
  28165. static get BILLBOARDMODE_USE_POSITION(): number;
  28166. /** @hidden */
  28167. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28168. /**
  28169. * The culling strategy to use to check whether the mesh must be rendered or not.
  28170. * This value can be changed at any time and will be used on the next render mesh selection.
  28171. * The possible values are :
  28172. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28173. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28174. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28175. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28176. * Please read each static variable documentation to get details about the culling process.
  28177. * */
  28178. cullingStrategy: number;
  28179. /**
  28180. * Gets the number of facets in the mesh
  28181. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28182. */
  28183. get facetNb(): number;
  28184. /**
  28185. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28187. */
  28188. get partitioningSubdivisions(): number;
  28189. set partitioningSubdivisions(nb: number);
  28190. /**
  28191. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28192. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28193. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28194. */
  28195. get partitioningBBoxRatio(): number;
  28196. set partitioningBBoxRatio(ratio: number);
  28197. /**
  28198. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28199. * Works only for updatable meshes.
  28200. * Doesn't work with multi-materials
  28201. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28202. */
  28203. get mustDepthSortFacets(): boolean;
  28204. set mustDepthSortFacets(sort: boolean);
  28205. /**
  28206. * The location (Vector3) where the facet depth sort must be computed from.
  28207. * By default, the active camera position.
  28208. * Used only when facet depth sort is enabled
  28209. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28210. */
  28211. get facetDepthSortFrom(): Vector3;
  28212. set facetDepthSortFrom(location: Vector3);
  28213. /**
  28214. * gets a boolean indicating if facetData is enabled
  28215. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28216. */
  28217. get isFacetDataEnabled(): boolean;
  28218. /** @hidden */
  28219. _updateNonUniformScalingState(value: boolean): boolean;
  28220. /**
  28221. * An event triggered when this mesh collides with another one
  28222. */
  28223. onCollideObservable: Observable<AbstractMesh>;
  28224. /** Set a function to call when this mesh collides with another one */
  28225. set onCollide(callback: () => void);
  28226. /**
  28227. * An event triggered when the collision's position changes
  28228. */
  28229. onCollisionPositionChangeObservable: Observable<Vector3>;
  28230. /** Set a function to call when the collision's position changes */
  28231. set onCollisionPositionChange(callback: () => void);
  28232. /**
  28233. * An event triggered when material is changed
  28234. */
  28235. onMaterialChangedObservable: Observable<AbstractMesh>;
  28236. /**
  28237. * Gets or sets the orientation for POV movement & rotation
  28238. */
  28239. definedFacingForward: boolean;
  28240. /** @hidden */
  28241. _occlusionQuery: Nullable<WebGLQuery>;
  28242. /** @hidden */
  28243. _renderingGroup: Nullable<RenderingGroup>;
  28244. /**
  28245. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28246. */
  28247. get visibility(): number;
  28248. /**
  28249. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28250. */
  28251. set visibility(value: number);
  28252. /** Gets or sets the alpha index used to sort transparent meshes
  28253. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28254. */
  28255. alphaIndex: number;
  28256. /**
  28257. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28258. */
  28259. isVisible: boolean;
  28260. /**
  28261. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28262. */
  28263. isPickable: boolean;
  28264. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28265. showSubMeshesBoundingBox: boolean;
  28266. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28267. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28268. */
  28269. isBlocker: boolean;
  28270. /**
  28271. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28272. */
  28273. enablePointerMoveEvents: boolean;
  28274. /**
  28275. * Specifies the rendering group id for this mesh (0 by default)
  28276. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28277. */
  28278. renderingGroupId: number;
  28279. private _material;
  28280. /** Gets or sets current material */
  28281. get material(): Nullable<Material>;
  28282. set material(value: Nullable<Material>);
  28283. /**
  28284. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28285. * @see http://doc.babylonjs.com/babylon101/shadows
  28286. */
  28287. get receiveShadows(): boolean;
  28288. set receiveShadows(value: boolean);
  28289. /** Defines color to use when rendering outline */
  28290. outlineColor: Color3;
  28291. /** Define width to use when rendering outline */
  28292. outlineWidth: number;
  28293. /** Defines color to use when rendering overlay */
  28294. overlayColor: Color3;
  28295. /** Defines alpha to use when rendering overlay */
  28296. overlayAlpha: number;
  28297. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28298. get hasVertexAlpha(): boolean;
  28299. set hasVertexAlpha(value: boolean);
  28300. /** 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) */
  28301. get useVertexColors(): boolean;
  28302. set useVertexColors(value: boolean);
  28303. /**
  28304. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28305. */
  28306. get computeBonesUsingShaders(): boolean;
  28307. set computeBonesUsingShaders(value: boolean);
  28308. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28309. get numBoneInfluencers(): number;
  28310. set numBoneInfluencers(value: number);
  28311. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28312. get applyFog(): boolean;
  28313. set applyFog(value: boolean);
  28314. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28315. useOctreeForRenderingSelection: boolean;
  28316. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28317. useOctreeForPicking: boolean;
  28318. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28319. useOctreeForCollisions: boolean;
  28320. /**
  28321. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28322. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28323. */
  28324. get layerMask(): number;
  28325. set layerMask(value: number);
  28326. /**
  28327. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28328. */
  28329. alwaysSelectAsActiveMesh: boolean;
  28330. /**
  28331. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28332. */
  28333. doNotSyncBoundingInfo: boolean;
  28334. /**
  28335. * Gets or sets the current action manager
  28336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28337. */
  28338. actionManager: Nullable<AbstractActionManager>;
  28339. private _meshCollisionData;
  28340. /**
  28341. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28343. */
  28344. ellipsoid: Vector3;
  28345. /**
  28346. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28347. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28348. */
  28349. ellipsoidOffset: Vector3;
  28350. /**
  28351. * Gets or sets a collision mask used to mask collisions (default is -1).
  28352. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28353. */
  28354. get collisionMask(): number;
  28355. set collisionMask(mask: number);
  28356. /**
  28357. * Gets or sets the current collision group mask (-1 by default).
  28358. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28359. */
  28360. get collisionGroup(): number;
  28361. set collisionGroup(mask: number);
  28362. /**
  28363. * Gets or sets current surrounding meshes (null by default).
  28364. *
  28365. * By default collision detection is tested against every mesh in the scene.
  28366. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  28367. * meshes will be tested for the collision.
  28368. *
  28369. * Note: if set to an empty array no collision will happen when this mesh is moved.
  28370. */
  28371. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  28372. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  28373. /**
  28374. * Defines edge width used when edgesRenderer is enabled
  28375. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28376. */
  28377. edgesWidth: number;
  28378. /**
  28379. * Defines edge color used when edgesRenderer is enabled
  28380. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28381. */
  28382. edgesColor: Color4;
  28383. /** @hidden */
  28384. _edgesRenderer: Nullable<IEdgesRenderer>;
  28385. /** @hidden */
  28386. _masterMesh: Nullable<AbstractMesh>;
  28387. /** @hidden */
  28388. _boundingInfo: Nullable<BoundingInfo>;
  28389. /** @hidden */
  28390. _renderId: number;
  28391. /**
  28392. * Gets or sets the list of subMeshes
  28393. * @see http://doc.babylonjs.com/how_to/multi_materials
  28394. */
  28395. subMeshes: SubMesh[];
  28396. /** @hidden */
  28397. _intersectionsInProgress: AbstractMesh[];
  28398. /** @hidden */
  28399. _unIndexed: boolean;
  28400. /** @hidden */
  28401. _lightSources: Light[];
  28402. /** Gets the list of lights affecting that mesh */
  28403. get lightSources(): Light[];
  28404. /** @hidden */
  28405. get _positions(): Nullable<Vector3[]>;
  28406. /** @hidden */
  28407. _waitingData: {
  28408. lods: Nullable<any>;
  28409. actions: Nullable<any>;
  28410. freezeWorldMatrix: Nullable<boolean>;
  28411. };
  28412. /** @hidden */
  28413. _bonesTransformMatrices: Nullable<Float32Array>;
  28414. /** @hidden */
  28415. _transformMatrixTexture: Nullable<RawTexture>;
  28416. /**
  28417. * Gets or sets a skeleton to apply skining transformations
  28418. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28419. */
  28420. set skeleton(value: Nullable<Skeleton>);
  28421. get skeleton(): Nullable<Skeleton>;
  28422. /**
  28423. * An event triggered when the mesh is rebuilt.
  28424. */
  28425. onRebuildObservable: Observable<AbstractMesh>;
  28426. /**
  28427. * Creates a new AbstractMesh
  28428. * @param name defines the name of the mesh
  28429. * @param scene defines the hosting scene
  28430. */
  28431. constructor(name: string, scene?: Nullable<Scene>);
  28432. /**
  28433. * Returns the string "AbstractMesh"
  28434. * @returns "AbstractMesh"
  28435. */
  28436. getClassName(): string;
  28437. /**
  28438. * Gets a string representation of the current mesh
  28439. * @param fullDetails defines a boolean indicating if full details must be included
  28440. * @returns a string representation of the current mesh
  28441. */
  28442. toString(fullDetails?: boolean): string;
  28443. /**
  28444. * @hidden
  28445. */
  28446. protected _getEffectiveParent(): Nullable<Node>;
  28447. /** @hidden */
  28448. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28449. /** @hidden */
  28450. _rebuild(): void;
  28451. /** @hidden */
  28452. _resyncLightSources(): void;
  28453. /** @hidden */
  28454. _resyncLightSource(light: Light): void;
  28455. /** @hidden */
  28456. _unBindEffect(): void;
  28457. /** @hidden */
  28458. _removeLightSource(light: Light, dispose: boolean): void;
  28459. private _markSubMeshesAsDirty;
  28460. /** @hidden */
  28461. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28462. /** @hidden */
  28463. _markSubMeshesAsAttributesDirty(): void;
  28464. /** @hidden */
  28465. _markSubMeshesAsMiscDirty(): void;
  28466. /**
  28467. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28468. */
  28469. get scaling(): Vector3;
  28470. set scaling(newScaling: Vector3);
  28471. /**
  28472. * Returns true if the mesh is blocked. Implemented by child classes
  28473. */
  28474. get isBlocked(): boolean;
  28475. /**
  28476. * Returns the mesh itself by default. Implemented by child classes
  28477. * @param camera defines the camera to use to pick the right LOD level
  28478. * @returns the currentAbstractMesh
  28479. */
  28480. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28481. /**
  28482. * Returns 0 by default. Implemented by child classes
  28483. * @returns an integer
  28484. */
  28485. getTotalVertices(): number;
  28486. /**
  28487. * Returns a positive integer : the total number of indices in this mesh geometry.
  28488. * @returns the numner of indices or zero if the mesh has no geometry.
  28489. */
  28490. getTotalIndices(): number;
  28491. /**
  28492. * Returns null by default. Implemented by child classes
  28493. * @returns null
  28494. */
  28495. getIndices(): Nullable<IndicesArray>;
  28496. /**
  28497. * Returns the array of the requested vertex data kind. Implemented by child classes
  28498. * @param kind defines the vertex data kind to use
  28499. * @returns null
  28500. */
  28501. getVerticesData(kind: string): Nullable<FloatArray>;
  28502. /**
  28503. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28504. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28505. * Note that a new underlying VertexBuffer object is created each call.
  28506. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28507. * @param kind defines vertex data kind:
  28508. * * VertexBuffer.PositionKind
  28509. * * VertexBuffer.UVKind
  28510. * * VertexBuffer.UV2Kind
  28511. * * VertexBuffer.UV3Kind
  28512. * * VertexBuffer.UV4Kind
  28513. * * VertexBuffer.UV5Kind
  28514. * * VertexBuffer.UV6Kind
  28515. * * VertexBuffer.ColorKind
  28516. * * VertexBuffer.MatricesIndicesKind
  28517. * * VertexBuffer.MatricesIndicesExtraKind
  28518. * * VertexBuffer.MatricesWeightsKind
  28519. * * VertexBuffer.MatricesWeightsExtraKind
  28520. * @param data defines the data source
  28521. * @param updatable defines if the data must be flagged as updatable (or static)
  28522. * @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
  28523. * @returns the current mesh
  28524. */
  28525. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28526. /**
  28527. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28528. * If the mesh has no geometry, it is simply returned as it is.
  28529. * @param kind defines vertex data kind:
  28530. * * VertexBuffer.PositionKind
  28531. * * VertexBuffer.UVKind
  28532. * * VertexBuffer.UV2Kind
  28533. * * VertexBuffer.UV3Kind
  28534. * * VertexBuffer.UV4Kind
  28535. * * VertexBuffer.UV5Kind
  28536. * * VertexBuffer.UV6Kind
  28537. * * VertexBuffer.ColorKind
  28538. * * VertexBuffer.MatricesIndicesKind
  28539. * * VertexBuffer.MatricesIndicesExtraKind
  28540. * * VertexBuffer.MatricesWeightsKind
  28541. * * VertexBuffer.MatricesWeightsExtraKind
  28542. * @param data defines the data source
  28543. * @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
  28544. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28545. * @returns the current mesh
  28546. */
  28547. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28548. /**
  28549. * Sets the mesh indices,
  28550. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28551. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28552. * @param totalVertices Defines the total number of vertices
  28553. * @returns the current mesh
  28554. */
  28555. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28556. /**
  28557. * Gets a boolean indicating if specific vertex data is present
  28558. * @param kind defines the vertex data kind to use
  28559. * @returns true is data kind is present
  28560. */
  28561. isVerticesDataPresent(kind: string): boolean;
  28562. /**
  28563. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28564. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28565. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28566. * @returns a BoundingInfo
  28567. */
  28568. getBoundingInfo(): BoundingInfo;
  28569. /**
  28570. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28571. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28572. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28573. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28574. * @returns the current mesh
  28575. */
  28576. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28577. /**
  28578. * Overwrite the current bounding info
  28579. * @param boundingInfo defines the new bounding info
  28580. * @returns the current mesh
  28581. */
  28582. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28583. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28584. get useBones(): boolean;
  28585. /** @hidden */
  28586. _preActivate(): void;
  28587. /** @hidden */
  28588. _preActivateForIntermediateRendering(renderId: number): void;
  28589. /** @hidden */
  28590. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28591. /** @hidden */
  28592. _postActivate(): void;
  28593. /** @hidden */
  28594. _freeze(): void;
  28595. /** @hidden */
  28596. _unFreeze(): void;
  28597. /**
  28598. * Gets the current world matrix
  28599. * @returns a Matrix
  28600. */
  28601. getWorldMatrix(): Matrix;
  28602. /** @hidden */
  28603. _getWorldMatrixDeterminant(): number;
  28604. /**
  28605. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28606. */
  28607. get isAnInstance(): boolean;
  28608. /**
  28609. * Gets a boolean indicating if this mesh has instances
  28610. */
  28611. get hasInstances(): boolean;
  28612. /**
  28613. * Perform relative position change from the point of view of behind the front of the mesh.
  28614. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28615. * Supports definition of mesh facing forward or backward
  28616. * @param amountRight defines the distance on the right axis
  28617. * @param amountUp defines the distance on the up axis
  28618. * @param amountForward defines the distance on the forward axis
  28619. * @returns the current mesh
  28620. */
  28621. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28622. /**
  28623. * Calculate relative position change from the point of view of behind the front of the mesh.
  28624. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28625. * Supports definition of mesh facing forward or backward
  28626. * @param amountRight defines the distance on the right axis
  28627. * @param amountUp defines the distance on the up axis
  28628. * @param amountForward defines the distance on the forward axis
  28629. * @returns the new displacement vector
  28630. */
  28631. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28632. /**
  28633. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28634. * Supports definition of mesh facing forward or backward
  28635. * @param flipBack defines the flip
  28636. * @param twirlClockwise defines the twirl
  28637. * @param tiltRight defines the tilt
  28638. * @returns the current mesh
  28639. */
  28640. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28641. /**
  28642. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28643. * Supports definition of mesh facing forward or backward.
  28644. * @param flipBack defines the flip
  28645. * @param twirlClockwise defines the twirl
  28646. * @param tiltRight defines the tilt
  28647. * @returns the new rotation vector
  28648. */
  28649. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28650. /**
  28651. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28652. * This means the mesh underlying bounding box and sphere are recomputed.
  28653. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28654. * @returns the current mesh
  28655. */
  28656. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28657. /** @hidden */
  28658. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28659. /** @hidden */
  28660. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28661. /** @hidden */
  28662. _updateBoundingInfo(): AbstractMesh;
  28663. /** @hidden */
  28664. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28665. /** @hidden */
  28666. protected _afterComputeWorldMatrix(): void;
  28667. /** @hidden */
  28668. get _effectiveMesh(): AbstractMesh;
  28669. /**
  28670. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28671. * A mesh is in the frustum if its bounding box intersects the frustum
  28672. * @param frustumPlanes defines the frustum to test
  28673. * @returns true if the mesh is in the frustum planes
  28674. */
  28675. isInFrustum(frustumPlanes: Plane[]): boolean;
  28676. /**
  28677. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28678. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28679. * @param frustumPlanes defines the frustum to test
  28680. * @returns true if the mesh is completely in the frustum planes
  28681. */
  28682. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28683. /**
  28684. * True if the mesh intersects another mesh or a SolidParticle object
  28685. * @param mesh defines a target mesh or SolidParticle to test
  28686. * @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)
  28687. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28688. * @returns true if there is an intersection
  28689. */
  28690. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28691. /**
  28692. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28693. * @param point defines the point to test
  28694. * @returns true if there is an intersection
  28695. */
  28696. intersectsPoint(point: Vector3): boolean;
  28697. /**
  28698. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28699. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28700. */
  28701. get checkCollisions(): boolean;
  28702. set checkCollisions(collisionEnabled: boolean);
  28703. /**
  28704. * Gets Collider object used to compute collisions (not physics)
  28705. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28706. */
  28707. get collider(): Nullable<Collider>;
  28708. /**
  28709. * Move the mesh using collision engine
  28710. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28711. * @param displacement defines the requested displacement vector
  28712. * @returns the current mesh
  28713. */
  28714. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28715. private _onCollisionPositionChange;
  28716. /** @hidden */
  28717. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28718. /** @hidden */
  28719. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28720. /** @hidden */
  28721. _checkCollision(collider: Collider): AbstractMesh;
  28722. /** @hidden */
  28723. _generatePointsArray(): boolean;
  28724. /**
  28725. * Checks if the passed Ray intersects with the mesh
  28726. * @param ray defines the ray to use
  28727. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28728. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28729. * @returns the picking info
  28730. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28731. */
  28732. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28733. /**
  28734. * Clones the current mesh
  28735. * @param name defines the mesh name
  28736. * @param newParent defines the new mesh parent
  28737. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28738. * @returns the new mesh
  28739. */
  28740. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28741. /**
  28742. * Disposes all the submeshes of the current meshnp
  28743. * @returns the current mesh
  28744. */
  28745. releaseSubMeshes(): AbstractMesh;
  28746. /**
  28747. * Releases resources associated with this abstract mesh.
  28748. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28749. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28750. */
  28751. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28752. /**
  28753. * Adds the passed mesh as a child to the current mesh
  28754. * @param mesh defines the child mesh
  28755. * @returns the current mesh
  28756. */
  28757. addChild(mesh: AbstractMesh): AbstractMesh;
  28758. /**
  28759. * Removes the passed mesh from the current mesh children list
  28760. * @param mesh defines the child mesh
  28761. * @returns the current mesh
  28762. */
  28763. removeChild(mesh: AbstractMesh): AbstractMesh;
  28764. /** @hidden */
  28765. private _initFacetData;
  28766. /**
  28767. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28768. * This method can be called within the render loop.
  28769. * 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
  28770. * @returns the current mesh
  28771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28772. */
  28773. updateFacetData(): AbstractMesh;
  28774. /**
  28775. * Returns the facetLocalNormals array.
  28776. * The normals are expressed in the mesh local spac
  28777. * @returns an array of Vector3
  28778. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28779. */
  28780. getFacetLocalNormals(): Vector3[];
  28781. /**
  28782. * Returns the facetLocalPositions array.
  28783. * The facet positions are expressed in the mesh local space
  28784. * @returns an array of Vector3
  28785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28786. */
  28787. getFacetLocalPositions(): Vector3[];
  28788. /**
  28789. * Returns the facetLocalPartioning array
  28790. * @returns an array of array of numbers
  28791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28792. */
  28793. getFacetLocalPartitioning(): number[][];
  28794. /**
  28795. * Returns the i-th facet position in the world system.
  28796. * This method allocates a new Vector3 per call
  28797. * @param i defines the facet index
  28798. * @returns a new Vector3
  28799. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28800. */
  28801. getFacetPosition(i: number): Vector3;
  28802. /**
  28803. * Sets the reference Vector3 with the i-th facet position in the world system
  28804. * @param i defines the facet index
  28805. * @param ref defines the target vector
  28806. * @returns the current mesh
  28807. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28808. */
  28809. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28810. /**
  28811. * Returns the i-th facet normal in the world system.
  28812. * This method allocates a new Vector3 per call
  28813. * @param i defines the facet index
  28814. * @returns a new Vector3
  28815. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28816. */
  28817. getFacetNormal(i: number): Vector3;
  28818. /**
  28819. * Sets the reference Vector3 with the i-th facet normal in the world system
  28820. * @param i defines the facet index
  28821. * @param ref defines the target vector
  28822. * @returns the current mesh
  28823. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28824. */
  28825. getFacetNormalToRef(i: number, ref: Vector3): this;
  28826. /**
  28827. * 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)
  28828. * @param x defines x coordinate
  28829. * @param y defines y coordinate
  28830. * @param z defines z coordinate
  28831. * @returns the array of facet indexes
  28832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28833. */
  28834. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28835. /**
  28836. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28837. * @param projected sets as the (x,y,z) world projection on the facet
  28838. * @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
  28839. * @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
  28840. * @param x defines x coordinate
  28841. * @param y defines y coordinate
  28842. * @param z defines z coordinate
  28843. * @returns the face index if found (or null instead)
  28844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28845. */
  28846. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28847. /**
  28848. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28849. * @param projected sets as the (x,y,z) local projection on the facet
  28850. * @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
  28851. * @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
  28852. * @param x defines x coordinate
  28853. * @param y defines y coordinate
  28854. * @param z defines z coordinate
  28855. * @returns the face index if found (or null instead)
  28856. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28857. */
  28858. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28859. /**
  28860. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28861. * @returns the parameters
  28862. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28863. */
  28864. getFacetDataParameters(): any;
  28865. /**
  28866. * Disables the feature FacetData and frees the related memory
  28867. * @returns the current mesh
  28868. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28869. */
  28870. disableFacetData(): AbstractMesh;
  28871. /**
  28872. * Updates the AbstractMesh indices array
  28873. * @param indices defines the data source
  28874. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28875. * @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)
  28876. * @returns the current mesh
  28877. */
  28878. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28879. /**
  28880. * Creates new normals data for the mesh
  28881. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28882. * @returns the current mesh
  28883. */
  28884. createNormals(updatable: boolean): AbstractMesh;
  28885. /**
  28886. * Align the mesh with a normal
  28887. * @param normal defines the normal to use
  28888. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28889. * @returns the current mesh
  28890. */
  28891. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28892. /** @hidden */
  28893. _checkOcclusionQuery(): boolean;
  28894. /**
  28895. * Disables the mesh edge rendering mode
  28896. * @returns the currentAbstractMesh
  28897. */
  28898. disableEdgesRendering(): AbstractMesh;
  28899. /**
  28900. * Enables the edge rendering mode on the mesh.
  28901. * This mode makes the mesh edges visible
  28902. * @param epsilon defines the maximal distance between two angles to detect a face
  28903. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28904. * @returns the currentAbstractMesh
  28905. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28906. */
  28907. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28908. }
  28909. }
  28910. declare module BABYLON {
  28911. /**
  28912. * Interface used to define ActionEvent
  28913. */
  28914. export interface IActionEvent {
  28915. /** The mesh or sprite that triggered the action */
  28916. source: any;
  28917. /** The X mouse cursor position at the time of the event */
  28918. pointerX: number;
  28919. /** The Y mouse cursor position at the time of the event */
  28920. pointerY: number;
  28921. /** The mesh that is currently pointed at (can be null) */
  28922. meshUnderPointer: Nullable<AbstractMesh>;
  28923. /** the original (browser) event that triggered the ActionEvent */
  28924. sourceEvent?: any;
  28925. /** additional data for the event */
  28926. additionalData?: any;
  28927. }
  28928. /**
  28929. * ActionEvent is the event being sent when an action is triggered.
  28930. */
  28931. export class ActionEvent implements IActionEvent {
  28932. /** The mesh or sprite that triggered the action */
  28933. source: any;
  28934. /** The X mouse cursor position at the time of the event */
  28935. pointerX: number;
  28936. /** The Y mouse cursor position at the time of the event */
  28937. pointerY: number;
  28938. /** The mesh that is currently pointed at (can be null) */
  28939. meshUnderPointer: Nullable<AbstractMesh>;
  28940. /** the original (browser) event that triggered the ActionEvent */
  28941. sourceEvent?: any;
  28942. /** additional data for the event */
  28943. additionalData?: any;
  28944. /**
  28945. * Creates a new ActionEvent
  28946. * @param source The mesh or sprite that triggered the action
  28947. * @param pointerX The X mouse cursor position at the time of the event
  28948. * @param pointerY The Y mouse cursor position at the time of the event
  28949. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28950. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28951. * @param additionalData additional data for the event
  28952. */
  28953. constructor(
  28954. /** The mesh or sprite that triggered the action */
  28955. source: any,
  28956. /** The X mouse cursor position at the time of the event */
  28957. pointerX: number,
  28958. /** The Y mouse cursor position at the time of the event */
  28959. pointerY: number,
  28960. /** The mesh that is currently pointed at (can be null) */
  28961. meshUnderPointer: Nullable<AbstractMesh>,
  28962. /** the original (browser) event that triggered the ActionEvent */
  28963. sourceEvent?: any,
  28964. /** additional data for the event */
  28965. additionalData?: any);
  28966. /**
  28967. * Helper function to auto-create an ActionEvent from a source mesh.
  28968. * @param source The source mesh that triggered the event
  28969. * @param evt The original (browser) event
  28970. * @param additionalData additional data for the event
  28971. * @returns the new ActionEvent
  28972. */
  28973. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28974. /**
  28975. * Helper function to auto-create an ActionEvent from a source sprite
  28976. * @param source The source sprite that triggered the event
  28977. * @param scene Scene associated with the sprite
  28978. * @param evt The original (browser) event
  28979. * @param additionalData additional data for the event
  28980. * @returns the new ActionEvent
  28981. */
  28982. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28983. /**
  28984. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28985. * @param scene the scene where the event occurred
  28986. * @param evt The original (browser) event
  28987. * @returns the new ActionEvent
  28988. */
  28989. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28990. /**
  28991. * Helper function to auto-create an ActionEvent from a primitive
  28992. * @param prim defines the target primitive
  28993. * @param pointerPos defines the pointer position
  28994. * @param evt The original (browser) event
  28995. * @param additionalData additional data for the event
  28996. * @returns the new ActionEvent
  28997. */
  28998. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28999. }
  29000. }
  29001. declare module BABYLON {
  29002. /**
  29003. * Abstract class used to decouple action Manager from scene and meshes.
  29004. * Do not instantiate.
  29005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29006. */
  29007. export abstract class AbstractActionManager implements IDisposable {
  29008. /** Gets the list of active triggers */
  29009. static Triggers: {
  29010. [key: string]: number;
  29011. };
  29012. /** Gets the cursor to use when hovering items */
  29013. hoverCursor: string;
  29014. /** Gets the list of actions */
  29015. actions: IAction[];
  29016. /**
  29017. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29018. */
  29019. isRecursive: boolean;
  29020. /**
  29021. * Releases all associated resources
  29022. */
  29023. abstract dispose(): void;
  29024. /**
  29025. * Does this action manager has pointer triggers
  29026. */
  29027. abstract get hasPointerTriggers(): boolean;
  29028. /**
  29029. * Does this action manager has pick triggers
  29030. */
  29031. abstract get hasPickTriggers(): boolean;
  29032. /**
  29033. * Process a specific trigger
  29034. * @param trigger defines the trigger to process
  29035. * @param evt defines the event details to be processed
  29036. */
  29037. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29038. /**
  29039. * Does this action manager handles actions of any of the given triggers
  29040. * @param triggers defines the triggers to be tested
  29041. * @return a boolean indicating whether one (or more) of the triggers is handled
  29042. */
  29043. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29044. /**
  29045. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29046. * speed.
  29047. * @param triggerA defines the trigger to be tested
  29048. * @param triggerB defines the trigger to be tested
  29049. * @return a boolean indicating whether one (or more) of the triggers is handled
  29050. */
  29051. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29052. /**
  29053. * Does this action manager handles actions of a given trigger
  29054. * @param trigger defines the trigger to be tested
  29055. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29056. * @return whether the trigger is handled
  29057. */
  29058. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29059. /**
  29060. * Serialize this manager to a JSON object
  29061. * @param name defines the property name to store this manager
  29062. * @returns a JSON representation of this manager
  29063. */
  29064. abstract serialize(name: string): any;
  29065. /**
  29066. * Registers an action to this action manager
  29067. * @param action defines the action to be registered
  29068. * @return the action amended (prepared) after registration
  29069. */
  29070. abstract registerAction(action: IAction): Nullable<IAction>;
  29071. /**
  29072. * Unregisters an action to this action manager
  29073. * @param action defines the action to be unregistered
  29074. * @return a boolean indicating whether the action has been unregistered
  29075. */
  29076. abstract unregisterAction(action: IAction): Boolean;
  29077. /**
  29078. * Does exist one action manager with at least one trigger
  29079. **/
  29080. static get HasTriggers(): boolean;
  29081. /**
  29082. * Does exist one action manager with at least one pick trigger
  29083. **/
  29084. static get HasPickTriggers(): boolean;
  29085. /**
  29086. * Does exist one action manager that handles actions of a given trigger
  29087. * @param trigger defines the trigger to be tested
  29088. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29089. **/
  29090. static HasSpecificTrigger(trigger: number): boolean;
  29091. }
  29092. }
  29093. declare module BABYLON {
  29094. /**
  29095. * Defines how a node can be built from a string name.
  29096. */
  29097. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29098. /**
  29099. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29100. */
  29101. export class Node implements IBehaviorAware<Node> {
  29102. /** @hidden */
  29103. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  29104. private static _NodeConstructors;
  29105. /**
  29106. * Add a new node constructor
  29107. * @param type defines the type name of the node to construct
  29108. * @param constructorFunc defines the constructor function
  29109. */
  29110. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29111. /**
  29112. * Returns a node constructor based on type name
  29113. * @param type defines the type name
  29114. * @param name defines the new node name
  29115. * @param scene defines the hosting scene
  29116. * @param options defines optional options to transmit to constructors
  29117. * @returns the new constructor or null
  29118. */
  29119. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29120. /**
  29121. * Gets or sets the name of the node
  29122. */
  29123. name: string;
  29124. /**
  29125. * Gets or sets the id of the node
  29126. */
  29127. id: string;
  29128. /**
  29129. * Gets or sets the unique id of the node
  29130. */
  29131. uniqueId: number;
  29132. /**
  29133. * Gets or sets a string used to store user defined state for the node
  29134. */
  29135. state: string;
  29136. /**
  29137. * Gets or sets an object used to store user defined information for the node
  29138. */
  29139. metadata: any;
  29140. /**
  29141. * For internal use only. Please do not use.
  29142. */
  29143. reservedDataStore: any;
  29144. /**
  29145. * List of inspectable custom properties (used by the Inspector)
  29146. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29147. */
  29148. inspectableCustomProperties: IInspectable[];
  29149. private _doNotSerialize;
  29150. /**
  29151. * Gets or sets a boolean used to define if the node must be serialized
  29152. */
  29153. get doNotSerialize(): boolean;
  29154. set doNotSerialize(value: boolean);
  29155. /** @hidden */
  29156. _isDisposed: boolean;
  29157. /**
  29158. * Gets a list of Animations associated with the node
  29159. */
  29160. animations: Animation[];
  29161. protected _ranges: {
  29162. [name: string]: Nullable<AnimationRange>;
  29163. };
  29164. /**
  29165. * Callback raised when the node is ready to be used
  29166. */
  29167. onReady: Nullable<(node: Node) => void>;
  29168. private _isEnabled;
  29169. private _isParentEnabled;
  29170. private _isReady;
  29171. /** @hidden */
  29172. _currentRenderId: number;
  29173. private _parentUpdateId;
  29174. /** @hidden */
  29175. _childUpdateId: number;
  29176. /** @hidden */
  29177. _waitingParentId: Nullable<string>;
  29178. /** @hidden */
  29179. _scene: Scene;
  29180. /** @hidden */
  29181. _cache: any;
  29182. private _parentNode;
  29183. private _children;
  29184. /** @hidden */
  29185. _worldMatrix: Matrix;
  29186. /** @hidden */
  29187. _worldMatrixDeterminant: number;
  29188. /** @hidden */
  29189. _worldMatrixDeterminantIsDirty: boolean;
  29190. /** @hidden */
  29191. private _sceneRootNodesIndex;
  29192. /**
  29193. * Gets a boolean indicating if the node has been disposed
  29194. * @returns true if the node was disposed
  29195. */
  29196. isDisposed(): boolean;
  29197. /**
  29198. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29199. * @see https://doc.babylonjs.com/how_to/parenting
  29200. */
  29201. set parent(parent: Nullable<Node>);
  29202. get parent(): Nullable<Node>;
  29203. /** @hidden */
  29204. _addToSceneRootNodes(): void;
  29205. /** @hidden */
  29206. _removeFromSceneRootNodes(): void;
  29207. private _animationPropertiesOverride;
  29208. /**
  29209. * Gets or sets the animation properties override
  29210. */
  29211. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29212. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29213. /**
  29214. * Gets a string idenfifying the name of the class
  29215. * @returns "Node" string
  29216. */
  29217. getClassName(): string;
  29218. /** @hidden */
  29219. readonly _isNode: boolean;
  29220. /**
  29221. * An event triggered when the mesh is disposed
  29222. */
  29223. onDisposeObservable: Observable<Node>;
  29224. private _onDisposeObserver;
  29225. /**
  29226. * Sets a callback that will be raised when the node will be disposed
  29227. */
  29228. set onDispose(callback: () => void);
  29229. /**
  29230. * Creates a new Node
  29231. * @param name the name and id to be given to this node
  29232. * @param scene the scene this node will be added to
  29233. */
  29234. constructor(name: string, scene?: Nullable<Scene>);
  29235. /**
  29236. * Gets the scene of the node
  29237. * @returns a scene
  29238. */
  29239. getScene(): Scene;
  29240. /**
  29241. * Gets the engine of the node
  29242. * @returns a Engine
  29243. */
  29244. getEngine(): Engine;
  29245. private _behaviors;
  29246. /**
  29247. * Attach a behavior to the node
  29248. * @see http://doc.babylonjs.com/features/behaviour
  29249. * @param behavior defines the behavior to attach
  29250. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29251. * @returns the current Node
  29252. */
  29253. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29254. /**
  29255. * Remove an attached behavior
  29256. * @see http://doc.babylonjs.com/features/behaviour
  29257. * @param behavior defines the behavior to attach
  29258. * @returns the current Node
  29259. */
  29260. removeBehavior(behavior: Behavior<Node>): Node;
  29261. /**
  29262. * Gets the list of attached behaviors
  29263. * @see http://doc.babylonjs.com/features/behaviour
  29264. */
  29265. get behaviors(): Behavior<Node>[];
  29266. /**
  29267. * Gets an attached behavior by name
  29268. * @param name defines the name of the behavior to look for
  29269. * @see http://doc.babylonjs.com/features/behaviour
  29270. * @returns null if behavior was not found else the requested behavior
  29271. */
  29272. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29273. /**
  29274. * Returns the latest update of the World matrix
  29275. * @returns a Matrix
  29276. */
  29277. getWorldMatrix(): Matrix;
  29278. /** @hidden */
  29279. _getWorldMatrixDeterminant(): number;
  29280. /**
  29281. * Returns directly the latest state of the mesh World matrix.
  29282. * A Matrix is returned.
  29283. */
  29284. get worldMatrixFromCache(): Matrix;
  29285. /** @hidden */
  29286. _initCache(): void;
  29287. /** @hidden */
  29288. updateCache(force?: boolean): void;
  29289. /** @hidden */
  29290. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29291. /** @hidden */
  29292. _updateCache(ignoreParentClass?: boolean): void;
  29293. /** @hidden */
  29294. _isSynchronized(): boolean;
  29295. /** @hidden */
  29296. _markSyncedWithParent(): void;
  29297. /** @hidden */
  29298. isSynchronizedWithParent(): boolean;
  29299. /** @hidden */
  29300. isSynchronized(): boolean;
  29301. /**
  29302. * Is this node ready to be used/rendered
  29303. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29304. * @return true if the node is ready
  29305. */
  29306. isReady(completeCheck?: boolean): boolean;
  29307. /**
  29308. * Is this node enabled?
  29309. * 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
  29310. * @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
  29311. * @return whether this node (and its parent) is enabled
  29312. */
  29313. isEnabled(checkAncestors?: boolean): boolean;
  29314. /** @hidden */
  29315. protected _syncParentEnabledState(): void;
  29316. /**
  29317. * Set the enabled state of this node
  29318. * @param value defines the new enabled state
  29319. */
  29320. setEnabled(value: boolean): void;
  29321. /**
  29322. * Is this node a descendant of the given node?
  29323. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29324. * @param ancestor defines the parent node to inspect
  29325. * @returns a boolean indicating if this node is a descendant of the given node
  29326. */
  29327. isDescendantOf(ancestor: Node): boolean;
  29328. /** @hidden */
  29329. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29330. /**
  29331. * Will return all nodes that have this node as ascendant
  29332. * @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
  29333. * @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
  29334. * @return all children nodes of all types
  29335. */
  29336. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29337. /**
  29338. * Get all child-meshes of this node
  29339. * @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)
  29340. * @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
  29341. * @returns an array of AbstractMesh
  29342. */
  29343. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29344. /**
  29345. * Get all direct children of this node
  29346. * @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
  29347. * @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)
  29348. * @returns an array of Node
  29349. */
  29350. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29351. /** @hidden */
  29352. _setReady(state: boolean): void;
  29353. /**
  29354. * Get an animation by name
  29355. * @param name defines the name of the animation to look for
  29356. * @returns null if not found else the requested animation
  29357. */
  29358. getAnimationByName(name: string): Nullable<Animation>;
  29359. /**
  29360. * Creates an animation range for this node
  29361. * @param name defines the name of the range
  29362. * @param from defines the starting key
  29363. * @param to defines the end key
  29364. */
  29365. createAnimationRange(name: string, from: number, to: number): void;
  29366. /**
  29367. * Delete a specific animation range
  29368. * @param name defines the name of the range to delete
  29369. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29370. */
  29371. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29372. /**
  29373. * Get an animation range by name
  29374. * @param name defines the name of the animation range to look for
  29375. * @returns null if not found else the requested animation range
  29376. */
  29377. getAnimationRange(name: string): Nullable<AnimationRange>;
  29378. /**
  29379. * Gets the list of all animation ranges defined on this node
  29380. * @returns an array
  29381. */
  29382. getAnimationRanges(): Nullable<AnimationRange>[];
  29383. /**
  29384. * Will start the animation sequence
  29385. * @param name defines the range frames for animation sequence
  29386. * @param loop defines if the animation should loop (false by default)
  29387. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29388. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29389. * @returns the object created for this animation. If range does not exist, it will return null
  29390. */
  29391. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29392. /**
  29393. * Serialize animation ranges into a JSON compatible object
  29394. * @returns serialization object
  29395. */
  29396. serializeAnimationRanges(): any;
  29397. /**
  29398. * Computes the world matrix of the node
  29399. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29400. * @returns the world matrix
  29401. */
  29402. computeWorldMatrix(force?: boolean): Matrix;
  29403. /**
  29404. * Releases resources associated with this node.
  29405. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29406. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29407. */
  29408. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29409. /**
  29410. * Parse animation range data from a serialization object and store them into a given node
  29411. * @param node defines where to store the animation ranges
  29412. * @param parsedNode defines the serialization object to read data from
  29413. * @param scene defines the hosting scene
  29414. */
  29415. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29416. /**
  29417. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29418. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29419. * @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
  29420. * @returns the new bounding vectors
  29421. */
  29422. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29423. min: Vector3;
  29424. max: Vector3;
  29425. };
  29426. }
  29427. }
  29428. declare module BABYLON {
  29429. /**
  29430. * @hidden
  29431. */
  29432. export class _IAnimationState {
  29433. key: number;
  29434. repeatCount: number;
  29435. workValue?: any;
  29436. loopMode?: number;
  29437. offsetValue?: any;
  29438. highLimitValue?: any;
  29439. }
  29440. /**
  29441. * Class used to store any kind of animation
  29442. */
  29443. export class Animation {
  29444. /**Name of the animation */
  29445. name: string;
  29446. /**Property to animate */
  29447. targetProperty: string;
  29448. /**The frames per second of the animation */
  29449. framePerSecond: number;
  29450. /**The data type of the animation */
  29451. dataType: number;
  29452. /**The loop mode of the animation */
  29453. loopMode?: number | undefined;
  29454. /**Specifies if blending should be enabled */
  29455. enableBlending?: boolean | undefined;
  29456. /**
  29457. * Use matrix interpolation instead of using direct key value when animating matrices
  29458. */
  29459. static AllowMatricesInterpolation: boolean;
  29460. /**
  29461. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29462. */
  29463. static AllowMatrixDecomposeForInterpolation: boolean;
  29464. /**
  29465. * Stores the key frames of the animation
  29466. */
  29467. private _keys;
  29468. /**
  29469. * Stores the easing function of the animation
  29470. */
  29471. private _easingFunction;
  29472. /**
  29473. * @hidden Internal use only
  29474. */
  29475. _runtimeAnimations: RuntimeAnimation[];
  29476. /**
  29477. * The set of event that will be linked to this animation
  29478. */
  29479. private _events;
  29480. /**
  29481. * Stores an array of target property paths
  29482. */
  29483. targetPropertyPath: string[];
  29484. /**
  29485. * Stores the blending speed of the animation
  29486. */
  29487. blendingSpeed: number;
  29488. /**
  29489. * Stores the animation ranges for the animation
  29490. */
  29491. private _ranges;
  29492. /**
  29493. * @hidden Internal use
  29494. */
  29495. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29496. /**
  29497. * Sets up an animation
  29498. * @param property The property to animate
  29499. * @param animationType The animation type to apply
  29500. * @param framePerSecond The frames per second of the animation
  29501. * @param easingFunction The easing function used in the animation
  29502. * @returns The created animation
  29503. */
  29504. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29505. /**
  29506. * Create and start an animation on a node
  29507. * @param name defines the name of the global animation that will be run on all nodes
  29508. * @param node defines the root node where the animation will take place
  29509. * @param targetProperty defines property to animate
  29510. * @param framePerSecond defines the number of frame per second yo use
  29511. * @param totalFrame defines the number of frames in total
  29512. * @param from defines the initial value
  29513. * @param to defines the final value
  29514. * @param loopMode defines which loop mode you want to use (off by default)
  29515. * @param easingFunction defines the easing function to use (linear by default)
  29516. * @param onAnimationEnd defines the callback to call when animation end
  29517. * @returns the animatable created for this animation
  29518. */
  29519. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29520. /**
  29521. * Create and start an animation on a node and its descendants
  29522. * @param name defines the name of the global animation that will be run on all nodes
  29523. * @param node defines the root node where the animation will take place
  29524. * @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
  29525. * @param targetProperty defines property to animate
  29526. * @param framePerSecond defines the number of frame per second to use
  29527. * @param totalFrame defines the number of frames in total
  29528. * @param from defines the initial value
  29529. * @param to defines the final value
  29530. * @param loopMode defines which loop mode you want to use (off by default)
  29531. * @param easingFunction defines the easing function to use (linear by default)
  29532. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29533. * @returns the list of animatables created for all nodes
  29534. * @example https://www.babylonjs-playground.com/#MH0VLI
  29535. */
  29536. 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[]>;
  29537. /**
  29538. * Creates a new animation, merges it with the existing animations and starts it
  29539. * @param name Name of the animation
  29540. * @param node Node which contains the scene that begins the animations
  29541. * @param targetProperty Specifies which property to animate
  29542. * @param framePerSecond The frames per second of the animation
  29543. * @param totalFrame The total number of frames
  29544. * @param from The frame at the beginning of the animation
  29545. * @param to The frame at the end of the animation
  29546. * @param loopMode Specifies the loop mode of the animation
  29547. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29548. * @param onAnimationEnd Callback to run once the animation is complete
  29549. * @returns Nullable animation
  29550. */
  29551. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29552. /**
  29553. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  29554. * @param sourceAnimation defines the Animation containing keyframes to convert
  29555. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  29556. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  29557. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  29558. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  29559. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  29560. */
  29561. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  29562. /**
  29563. * Transition property of an host to the target Value
  29564. * @param property The property to transition
  29565. * @param targetValue The target Value of the property
  29566. * @param host The object where the property to animate belongs
  29567. * @param scene Scene used to run the animation
  29568. * @param frameRate Framerate (in frame/s) to use
  29569. * @param transition The transition type we want to use
  29570. * @param duration The duration of the animation, in milliseconds
  29571. * @param onAnimationEnd Callback trigger at the end of the animation
  29572. * @returns Nullable animation
  29573. */
  29574. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29575. /**
  29576. * Return the array of runtime animations currently using this animation
  29577. */
  29578. get runtimeAnimations(): RuntimeAnimation[];
  29579. /**
  29580. * Specifies if any of the runtime animations are currently running
  29581. */
  29582. get hasRunningRuntimeAnimations(): boolean;
  29583. /**
  29584. * Initializes the animation
  29585. * @param name Name of the animation
  29586. * @param targetProperty Property to animate
  29587. * @param framePerSecond The frames per second of the animation
  29588. * @param dataType The data type of the animation
  29589. * @param loopMode The loop mode of the animation
  29590. * @param enableBlending Specifies if blending should be enabled
  29591. */
  29592. constructor(
  29593. /**Name of the animation */
  29594. name: string,
  29595. /**Property to animate */
  29596. targetProperty: string,
  29597. /**The frames per second of the animation */
  29598. framePerSecond: number,
  29599. /**The data type of the animation */
  29600. dataType: number,
  29601. /**The loop mode of the animation */
  29602. loopMode?: number | undefined,
  29603. /**Specifies if blending should be enabled */
  29604. enableBlending?: boolean | undefined);
  29605. /**
  29606. * Converts the animation to a string
  29607. * @param fullDetails support for multiple levels of logging within scene loading
  29608. * @returns String form of the animation
  29609. */
  29610. toString(fullDetails?: boolean): string;
  29611. /**
  29612. * Add an event to this animation
  29613. * @param event Event to add
  29614. */
  29615. addEvent(event: AnimationEvent): void;
  29616. /**
  29617. * Remove all events found at the given frame
  29618. * @param frame The frame to remove events from
  29619. */
  29620. removeEvents(frame: number): void;
  29621. /**
  29622. * Retrieves all the events from the animation
  29623. * @returns Events from the animation
  29624. */
  29625. getEvents(): AnimationEvent[];
  29626. /**
  29627. * Creates an animation range
  29628. * @param name Name of the animation range
  29629. * @param from Starting frame of the animation range
  29630. * @param to Ending frame of the animation
  29631. */
  29632. createRange(name: string, from: number, to: number): void;
  29633. /**
  29634. * Deletes an animation range by name
  29635. * @param name Name of the animation range to delete
  29636. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29637. */
  29638. deleteRange(name: string, deleteFrames?: boolean): void;
  29639. /**
  29640. * Gets the animation range by name, or null if not defined
  29641. * @param name Name of the animation range
  29642. * @returns Nullable animation range
  29643. */
  29644. getRange(name: string): Nullable<AnimationRange>;
  29645. /**
  29646. * Gets the key frames from the animation
  29647. * @returns The key frames of the animation
  29648. */
  29649. getKeys(): Array<IAnimationKey>;
  29650. /**
  29651. * Gets the highest frame rate of the animation
  29652. * @returns Highest frame rate of the animation
  29653. */
  29654. getHighestFrame(): number;
  29655. /**
  29656. * Gets the easing function of the animation
  29657. * @returns Easing function of the animation
  29658. */
  29659. getEasingFunction(): IEasingFunction;
  29660. /**
  29661. * Sets the easing function of the animation
  29662. * @param easingFunction A custom mathematical formula for animation
  29663. */
  29664. setEasingFunction(easingFunction: EasingFunction): void;
  29665. /**
  29666. * Interpolates a scalar linearly
  29667. * @param startValue Start value of the animation curve
  29668. * @param endValue End value of the animation curve
  29669. * @param gradient Scalar amount to interpolate
  29670. * @returns Interpolated scalar value
  29671. */
  29672. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29673. /**
  29674. * Interpolates a scalar cubically
  29675. * @param startValue Start value of the animation curve
  29676. * @param outTangent End tangent of the animation
  29677. * @param endValue End value of the animation curve
  29678. * @param inTangent Start tangent of the animation curve
  29679. * @param gradient Scalar amount to interpolate
  29680. * @returns Interpolated scalar value
  29681. */
  29682. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29683. /**
  29684. * Interpolates a quaternion using a spherical linear interpolation
  29685. * @param startValue Start value of the animation curve
  29686. * @param endValue End value of the animation curve
  29687. * @param gradient Scalar amount to interpolate
  29688. * @returns Interpolated quaternion value
  29689. */
  29690. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29691. /**
  29692. * Interpolates a quaternion cubically
  29693. * @param startValue Start value of the animation curve
  29694. * @param outTangent End tangent of the animation curve
  29695. * @param endValue End value of the animation curve
  29696. * @param inTangent Start tangent of the animation curve
  29697. * @param gradient Scalar amount to interpolate
  29698. * @returns Interpolated quaternion value
  29699. */
  29700. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29701. /**
  29702. * Interpolates a Vector3 linearl
  29703. * @param startValue Start value of the animation curve
  29704. * @param endValue End value of the animation curve
  29705. * @param gradient Scalar amount to interpolate
  29706. * @returns Interpolated scalar value
  29707. */
  29708. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29709. /**
  29710. * Interpolates a Vector3 cubically
  29711. * @param startValue Start value of the animation curve
  29712. * @param outTangent End tangent of the animation
  29713. * @param endValue End value of the animation curve
  29714. * @param inTangent Start tangent of the animation curve
  29715. * @param gradient Scalar amount to interpolate
  29716. * @returns InterpolatedVector3 value
  29717. */
  29718. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29719. /**
  29720. * Interpolates a Vector2 linearly
  29721. * @param startValue Start value of the animation curve
  29722. * @param endValue End value of the animation curve
  29723. * @param gradient Scalar amount to interpolate
  29724. * @returns Interpolated Vector2 value
  29725. */
  29726. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29727. /**
  29728. * Interpolates a Vector2 cubically
  29729. * @param startValue Start value of the animation curve
  29730. * @param outTangent End tangent of the animation
  29731. * @param endValue End value of the animation curve
  29732. * @param inTangent Start tangent of the animation curve
  29733. * @param gradient Scalar amount to interpolate
  29734. * @returns Interpolated Vector2 value
  29735. */
  29736. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29737. /**
  29738. * Interpolates a size linearly
  29739. * @param startValue Start value of the animation curve
  29740. * @param endValue End value of the animation curve
  29741. * @param gradient Scalar amount to interpolate
  29742. * @returns Interpolated Size value
  29743. */
  29744. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29745. /**
  29746. * Interpolates a Color3 linearly
  29747. * @param startValue Start value of the animation curve
  29748. * @param endValue End value of the animation curve
  29749. * @param gradient Scalar amount to interpolate
  29750. * @returns Interpolated Color3 value
  29751. */
  29752. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29753. /**
  29754. * Interpolates a Color4 linearly
  29755. * @param startValue Start value of the animation curve
  29756. * @param endValue End value of the animation curve
  29757. * @param gradient Scalar amount to interpolate
  29758. * @returns Interpolated Color3 value
  29759. */
  29760. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29761. /**
  29762. * @hidden Internal use only
  29763. */
  29764. _getKeyValue(value: any): any;
  29765. /**
  29766. * @hidden Internal use only
  29767. */
  29768. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29769. /**
  29770. * Defines the function to use to interpolate matrices
  29771. * @param startValue defines the start matrix
  29772. * @param endValue defines the end matrix
  29773. * @param gradient defines the gradient between both matrices
  29774. * @param result defines an optional target matrix where to store the interpolation
  29775. * @returns the interpolated matrix
  29776. */
  29777. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29778. /**
  29779. * Makes a copy of the animation
  29780. * @returns Cloned animation
  29781. */
  29782. clone(): Animation;
  29783. /**
  29784. * Sets the key frames of the animation
  29785. * @param values The animation key frames to set
  29786. */
  29787. setKeys(values: Array<IAnimationKey>): void;
  29788. /**
  29789. * Serializes the animation to an object
  29790. * @returns Serialized object
  29791. */
  29792. serialize(): any;
  29793. /**
  29794. * Float animation type
  29795. */
  29796. static readonly ANIMATIONTYPE_FLOAT: number;
  29797. /**
  29798. * Vector3 animation type
  29799. */
  29800. static readonly ANIMATIONTYPE_VECTOR3: number;
  29801. /**
  29802. * Quaternion animation type
  29803. */
  29804. static readonly ANIMATIONTYPE_QUATERNION: number;
  29805. /**
  29806. * Matrix animation type
  29807. */
  29808. static readonly ANIMATIONTYPE_MATRIX: number;
  29809. /**
  29810. * Color3 animation type
  29811. */
  29812. static readonly ANIMATIONTYPE_COLOR3: number;
  29813. /**
  29814. * Color3 animation type
  29815. */
  29816. static readonly ANIMATIONTYPE_COLOR4: number;
  29817. /**
  29818. * Vector2 animation type
  29819. */
  29820. static readonly ANIMATIONTYPE_VECTOR2: number;
  29821. /**
  29822. * Size animation type
  29823. */
  29824. static readonly ANIMATIONTYPE_SIZE: number;
  29825. /**
  29826. * Relative Loop Mode
  29827. */
  29828. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29829. /**
  29830. * Cycle Loop Mode
  29831. */
  29832. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29833. /**
  29834. * Constant Loop Mode
  29835. */
  29836. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29837. /** @hidden */
  29838. static _UniversalLerp(left: any, right: any, amount: number): any;
  29839. /**
  29840. * Parses an animation object and creates an animation
  29841. * @param parsedAnimation Parsed animation object
  29842. * @returns Animation object
  29843. */
  29844. static Parse(parsedAnimation: any): Animation;
  29845. /**
  29846. * Appends the serialized animations from the source animations
  29847. * @param source Source containing the animations
  29848. * @param destination Target to store the animations
  29849. */
  29850. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29851. }
  29852. }
  29853. declare module BABYLON {
  29854. /**
  29855. * Interface containing an array of animations
  29856. */
  29857. export interface IAnimatable {
  29858. /**
  29859. * Array of animations
  29860. */
  29861. animations: Nullable<Array<Animation>>;
  29862. }
  29863. }
  29864. declare module BABYLON {
  29865. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29866. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29867. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29868. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29869. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29870. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29871. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29872. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29873. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29874. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29875. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29876. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29877. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29878. /**
  29879. * Decorator used to define property that can be serialized as reference to a camera
  29880. * @param sourceName defines the name of the property to decorate
  29881. */
  29882. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29883. /**
  29884. * Class used to help serialization objects
  29885. */
  29886. export class SerializationHelper {
  29887. /** @hidden */
  29888. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29889. /** @hidden */
  29890. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29891. /** @hidden */
  29892. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29893. /** @hidden */
  29894. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29895. /**
  29896. * Appends the serialized animations from the source animations
  29897. * @param source Source containing the animations
  29898. * @param destination Target to store the animations
  29899. */
  29900. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29901. /**
  29902. * Static function used to serialized a specific entity
  29903. * @param entity defines the entity to serialize
  29904. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29905. * @returns a JSON compatible object representing the serialization of the entity
  29906. */
  29907. static Serialize<T>(entity: T, serializationObject?: any): any;
  29908. /**
  29909. * Creates a new entity from a serialization data object
  29910. * @param creationFunction defines a function used to instanciated the new entity
  29911. * @param source defines the source serialization data
  29912. * @param scene defines the hosting scene
  29913. * @param rootUrl defines the root url for resources
  29914. * @returns a new entity
  29915. */
  29916. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29917. /**
  29918. * Clones an object
  29919. * @param creationFunction defines the function used to instanciate the new object
  29920. * @param source defines the source object
  29921. * @returns the cloned object
  29922. */
  29923. static Clone<T>(creationFunction: () => T, source: T): T;
  29924. /**
  29925. * Instanciates a new object based on a source one (some data will be shared between both object)
  29926. * @param creationFunction defines the function used to instanciate the new object
  29927. * @param source defines the source object
  29928. * @returns the new object
  29929. */
  29930. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29931. }
  29932. }
  29933. declare module BABYLON {
  29934. /**
  29935. * Class used to manipulate GUIDs
  29936. */
  29937. export class GUID {
  29938. /**
  29939. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29940. * Be aware Math.random() could cause collisions, but:
  29941. * "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"
  29942. * @returns a pseudo random id
  29943. */
  29944. static RandomId(): string;
  29945. }
  29946. }
  29947. declare module BABYLON {
  29948. /**
  29949. * Base class of all the textures in babylon.
  29950. * It groups all the common properties the materials, post process, lights... might need
  29951. * in order to make a correct use of the texture.
  29952. */
  29953. export class BaseTexture implements IAnimatable {
  29954. /**
  29955. * Default anisotropic filtering level for the application.
  29956. * It is set to 4 as a good tradeoff between perf and quality.
  29957. */
  29958. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29959. /**
  29960. * Gets or sets the unique id of the texture
  29961. */
  29962. uniqueId: number;
  29963. /**
  29964. * Define the name of the texture.
  29965. */
  29966. name: string;
  29967. /**
  29968. * Gets or sets an object used to store user defined information.
  29969. */
  29970. metadata: any;
  29971. /**
  29972. * For internal use only. Please do not use.
  29973. */
  29974. reservedDataStore: any;
  29975. private _hasAlpha;
  29976. /**
  29977. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29978. */
  29979. set hasAlpha(value: boolean);
  29980. get hasAlpha(): boolean;
  29981. /**
  29982. * Defines if the alpha value should be determined via the rgb values.
  29983. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29984. */
  29985. getAlphaFromRGB: boolean;
  29986. /**
  29987. * Intensity or strength of the texture.
  29988. * It is commonly used by materials to fine tune the intensity of the texture
  29989. */
  29990. level: number;
  29991. /**
  29992. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29993. * This is part of the texture as textures usually maps to one uv set.
  29994. */
  29995. coordinatesIndex: number;
  29996. private _coordinatesMode;
  29997. /**
  29998. * How a texture is mapped.
  29999. *
  30000. * | Value | Type | Description |
  30001. * | ----- | ----------------------------------- | ----------- |
  30002. * | 0 | EXPLICIT_MODE | |
  30003. * | 1 | SPHERICAL_MODE | |
  30004. * | 2 | PLANAR_MODE | |
  30005. * | 3 | CUBIC_MODE | |
  30006. * | 4 | PROJECTION_MODE | |
  30007. * | 5 | SKYBOX_MODE | |
  30008. * | 6 | INVCUBIC_MODE | |
  30009. * | 7 | EQUIRECTANGULAR_MODE | |
  30010. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30011. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30012. */
  30013. set coordinatesMode(value: number);
  30014. get coordinatesMode(): number;
  30015. /**
  30016. * | Value | Type | Description |
  30017. * | ----- | ------------------ | ----------- |
  30018. * | 0 | CLAMP_ADDRESSMODE | |
  30019. * | 1 | WRAP_ADDRESSMODE | |
  30020. * | 2 | MIRROR_ADDRESSMODE | |
  30021. */
  30022. wrapU: number;
  30023. /**
  30024. * | Value | Type | Description |
  30025. * | ----- | ------------------ | ----------- |
  30026. * | 0 | CLAMP_ADDRESSMODE | |
  30027. * | 1 | WRAP_ADDRESSMODE | |
  30028. * | 2 | MIRROR_ADDRESSMODE | |
  30029. */
  30030. wrapV: number;
  30031. /**
  30032. * | Value | Type | Description |
  30033. * | ----- | ------------------ | ----------- |
  30034. * | 0 | CLAMP_ADDRESSMODE | |
  30035. * | 1 | WRAP_ADDRESSMODE | |
  30036. * | 2 | MIRROR_ADDRESSMODE | |
  30037. */
  30038. wrapR: number;
  30039. /**
  30040. * With compliant hardware and browser (supporting anisotropic filtering)
  30041. * this defines the level of anisotropic filtering in the texture.
  30042. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30043. */
  30044. anisotropicFilteringLevel: number;
  30045. /**
  30046. * Define if the texture is a cube texture or if false a 2d texture.
  30047. */
  30048. get isCube(): boolean;
  30049. set isCube(value: boolean);
  30050. /**
  30051. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30052. */
  30053. get is3D(): boolean;
  30054. set is3D(value: boolean);
  30055. /**
  30056. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30057. */
  30058. get is2DArray(): boolean;
  30059. set is2DArray(value: boolean);
  30060. /**
  30061. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30062. * HDR texture are usually stored in linear space.
  30063. * This only impacts the PBR and Background materials
  30064. */
  30065. gammaSpace: boolean;
  30066. /**
  30067. * Gets or sets whether or not the texture contains RGBD data.
  30068. */
  30069. get isRGBD(): boolean;
  30070. set isRGBD(value: boolean);
  30071. /**
  30072. * Is Z inverted in the texture (useful in a cube texture).
  30073. */
  30074. invertZ: boolean;
  30075. /**
  30076. * Are mip maps generated for this texture or not.
  30077. */
  30078. get noMipmap(): boolean;
  30079. /**
  30080. * @hidden
  30081. */
  30082. lodLevelInAlpha: boolean;
  30083. /**
  30084. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30085. */
  30086. get lodGenerationOffset(): number;
  30087. set lodGenerationOffset(value: number);
  30088. /**
  30089. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30090. */
  30091. get lodGenerationScale(): number;
  30092. set lodGenerationScale(value: number);
  30093. /**
  30094. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30095. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30096. * average roughness values.
  30097. */
  30098. get linearSpecularLOD(): boolean;
  30099. set linearSpecularLOD(value: boolean);
  30100. /**
  30101. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30102. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30103. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30104. */
  30105. get irradianceTexture(): Nullable<BaseTexture>;
  30106. set irradianceTexture(value: Nullable<BaseTexture>);
  30107. /**
  30108. * Define if the texture is a render target.
  30109. */
  30110. isRenderTarget: boolean;
  30111. /**
  30112. * Define the unique id of the texture in the scene.
  30113. */
  30114. get uid(): string;
  30115. /**
  30116. * Return a string representation of the texture.
  30117. * @returns the texture as a string
  30118. */
  30119. toString(): string;
  30120. /**
  30121. * Get the class name of the texture.
  30122. * @returns "BaseTexture"
  30123. */
  30124. getClassName(): string;
  30125. /**
  30126. * Define the list of animation attached to the texture.
  30127. */
  30128. animations: Animation[];
  30129. /**
  30130. * An event triggered when the texture is disposed.
  30131. */
  30132. onDisposeObservable: Observable<BaseTexture>;
  30133. private _onDisposeObserver;
  30134. /**
  30135. * Callback triggered when the texture has been disposed.
  30136. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30137. */
  30138. set onDispose(callback: () => void);
  30139. /**
  30140. * Define the current state of the loading sequence when in delayed load mode.
  30141. */
  30142. delayLoadState: number;
  30143. private _scene;
  30144. /** @hidden */
  30145. _texture: Nullable<InternalTexture>;
  30146. private _uid;
  30147. /**
  30148. * Define if the texture is preventinga material to render or not.
  30149. * If not and the texture is not ready, the engine will use a default black texture instead.
  30150. */
  30151. get isBlocking(): boolean;
  30152. /**
  30153. * Instantiates a new BaseTexture.
  30154. * Base class of all the textures in babylon.
  30155. * It groups all the common properties the materials, post process, lights... might need
  30156. * in order to make a correct use of the texture.
  30157. * @param scene Define the scene the texture blongs to
  30158. */
  30159. constructor(scene: Nullable<Scene>);
  30160. /**
  30161. * Get the scene the texture belongs to.
  30162. * @returns the scene or null if undefined
  30163. */
  30164. getScene(): Nullable<Scene>;
  30165. /**
  30166. * Get the texture transform matrix used to offset tile the texture for istance.
  30167. * @returns the transformation matrix
  30168. */
  30169. getTextureMatrix(): Matrix;
  30170. /**
  30171. * Get the texture reflection matrix used to rotate/transform the reflection.
  30172. * @returns the reflection matrix
  30173. */
  30174. getReflectionTextureMatrix(): Matrix;
  30175. /**
  30176. * Get the underlying lower level texture from Babylon.
  30177. * @returns the insternal texture
  30178. */
  30179. getInternalTexture(): Nullable<InternalTexture>;
  30180. /**
  30181. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30182. * @returns true if ready or not blocking
  30183. */
  30184. isReadyOrNotBlocking(): boolean;
  30185. /**
  30186. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30187. * @returns true if fully ready
  30188. */
  30189. isReady(): boolean;
  30190. private _cachedSize;
  30191. /**
  30192. * Get the size of the texture.
  30193. * @returns the texture size.
  30194. */
  30195. getSize(): ISize;
  30196. /**
  30197. * Get the base size of the texture.
  30198. * It can be different from the size if the texture has been resized for POT for instance
  30199. * @returns the base size
  30200. */
  30201. getBaseSize(): ISize;
  30202. /**
  30203. * Update the sampling mode of the texture.
  30204. * Default is Trilinear mode.
  30205. *
  30206. * | Value | Type | Description |
  30207. * | ----- | ------------------ | ----------- |
  30208. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30209. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30210. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30211. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30212. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30213. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30214. * | 7 | NEAREST_LINEAR | |
  30215. * | 8 | NEAREST_NEAREST | |
  30216. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30217. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30218. * | 11 | LINEAR_LINEAR | |
  30219. * | 12 | LINEAR_NEAREST | |
  30220. *
  30221. * > _mag_: magnification filter (close to the viewer)
  30222. * > _min_: minification filter (far from the viewer)
  30223. * > _mip_: filter used between mip map levels
  30224. *@param samplingMode Define the new sampling mode of the texture
  30225. */
  30226. updateSamplingMode(samplingMode: number): void;
  30227. /**
  30228. * Scales the texture if is `canRescale()`
  30229. * @param ratio the resize factor we want to use to rescale
  30230. */
  30231. scale(ratio: number): void;
  30232. /**
  30233. * Get if the texture can rescale.
  30234. */
  30235. get canRescale(): boolean;
  30236. /** @hidden */
  30237. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30238. /** @hidden */
  30239. _rebuild(): void;
  30240. /**
  30241. * Triggers the load sequence in delayed load mode.
  30242. */
  30243. delayLoad(): void;
  30244. /**
  30245. * Clones the texture.
  30246. * @returns the cloned texture
  30247. */
  30248. clone(): Nullable<BaseTexture>;
  30249. /**
  30250. * Get the texture underlying type (INT, FLOAT...)
  30251. */
  30252. get textureType(): number;
  30253. /**
  30254. * Get the texture underlying format (RGB, RGBA...)
  30255. */
  30256. get textureFormat(): number;
  30257. /**
  30258. * Indicates that textures need to be re-calculated for all materials
  30259. */
  30260. protected _markAllSubMeshesAsTexturesDirty(): void;
  30261. /**
  30262. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30263. * This will returns an RGBA array buffer containing either in values (0-255) or
  30264. * float values (0-1) depending of the underlying buffer type.
  30265. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30266. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30267. * @param buffer defines a user defined buffer to fill with data (can be null)
  30268. * @returns The Array buffer containing the pixels data.
  30269. */
  30270. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30271. /**
  30272. * Release and destroy the underlying lower level texture aka internalTexture.
  30273. */
  30274. releaseInternalTexture(): void;
  30275. /** @hidden */
  30276. get _lodTextureHigh(): Nullable<BaseTexture>;
  30277. /** @hidden */
  30278. get _lodTextureMid(): Nullable<BaseTexture>;
  30279. /** @hidden */
  30280. get _lodTextureLow(): Nullable<BaseTexture>;
  30281. /**
  30282. * Dispose the texture and release its associated resources.
  30283. */
  30284. dispose(): void;
  30285. /**
  30286. * Serialize the texture into a JSON representation that can be parsed later on.
  30287. * @returns the JSON representation of the texture
  30288. */
  30289. serialize(): any;
  30290. /**
  30291. * Helper function to be called back once a list of texture contains only ready textures.
  30292. * @param textures Define the list of textures to wait for
  30293. * @param callback Define the callback triggered once the entire list will be ready
  30294. */
  30295. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30296. }
  30297. }
  30298. declare module BABYLON {
  30299. /**
  30300. * Options to be used when creating an effect.
  30301. */
  30302. export interface IEffectCreationOptions {
  30303. /**
  30304. * Atrributes that will be used in the shader.
  30305. */
  30306. attributes: string[];
  30307. /**
  30308. * Uniform varible names that will be set in the shader.
  30309. */
  30310. uniformsNames: string[];
  30311. /**
  30312. * Uniform buffer variable names that will be set in the shader.
  30313. */
  30314. uniformBuffersNames: string[];
  30315. /**
  30316. * Sampler texture variable names that will be set in the shader.
  30317. */
  30318. samplers: string[];
  30319. /**
  30320. * Define statements that will be set in the shader.
  30321. */
  30322. defines: any;
  30323. /**
  30324. * Possible fallbacks for this effect to improve performance when needed.
  30325. */
  30326. fallbacks: Nullable<IEffectFallbacks>;
  30327. /**
  30328. * Callback that will be called when the shader is compiled.
  30329. */
  30330. onCompiled: Nullable<(effect: Effect) => void>;
  30331. /**
  30332. * Callback that will be called if an error occurs during shader compilation.
  30333. */
  30334. onError: Nullable<(effect: Effect, errors: string) => void>;
  30335. /**
  30336. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30337. */
  30338. indexParameters?: any;
  30339. /**
  30340. * Max number of lights that can be used in the shader.
  30341. */
  30342. maxSimultaneousLights?: number;
  30343. /**
  30344. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30345. */
  30346. transformFeedbackVaryings?: Nullable<string[]>;
  30347. }
  30348. /**
  30349. * Effect containing vertex and fragment shader that can be executed on an object.
  30350. */
  30351. export class Effect implements IDisposable {
  30352. /**
  30353. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30354. */
  30355. static ShadersRepository: string;
  30356. /**
  30357. * Enable logging of the shader code when a compilation error occurs
  30358. */
  30359. static LogShaderCodeOnCompilationError: boolean;
  30360. /**
  30361. * Name of the effect.
  30362. */
  30363. name: any;
  30364. /**
  30365. * String container all the define statements that should be set on the shader.
  30366. */
  30367. defines: string;
  30368. /**
  30369. * Callback that will be called when the shader is compiled.
  30370. */
  30371. onCompiled: Nullable<(effect: Effect) => void>;
  30372. /**
  30373. * Callback that will be called if an error occurs during shader compilation.
  30374. */
  30375. onError: Nullable<(effect: Effect, errors: string) => void>;
  30376. /**
  30377. * Callback that will be called when effect is bound.
  30378. */
  30379. onBind: Nullable<(effect: Effect) => void>;
  30380. /**
  30381. * Unique ID of the effect.
  30382. */
  30383. uniqueId: number;
  30384. /**
  30385. * Observable that will be called when the shader is compiled.
  30386. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30387. */
  30388. onCompileObservable: Observable<Effect>;
  30389. /**
  30390. * Observable that will be called if an error occurs during shader compilation.
  30391. */
  30392. onErrorObservable: Observable<Effect>;
  30393. /** @hidden */
  30394. _onBindObservable: Nullable<Observable<Effect>>;
  30395. /**
  30396. * @hidden
  30397. * Specifies if the effect was previously ready
  30398. */
  30399. _wasPreviouslyReady: boolean;
  30400. /**
  30401. * Observable that will be called when effect is bound.
  30402. */
  30403. get onBindObservable(): Observable<Effect>;
  30404. /** @hidden */
  30405. _bonesComputationForcedToCPU: boolean;
  30406. private static _uniqueIdSeed;
  30407. private _engine;
  30408. private _uniformBuffersNames;
  30409. private _uniformsNames;
  30410. private _samplerList;
  30411. private _samplers;
  30412. private _isReady;
  30413. private _compilationError;
  30414. private _allFallbacksProcessed;
  30415. private _attributesNames;
  30416. private _attributes;
  30417. private _attributeLocationByName;
  30418. private _uniforms;
  30419. /**
  30420. * Key for the effect.
  30421. * @hidden
  30422. */
  30423. _key: string;
  30424. private _indexParameters;
  30425. private _fallbacks;
  30426. private _vertexSourceCode;
  30427. private _fragmentSourceCode;
  30428. private _vertexSourceCodeOverride;
  30429. private _fragmentSourceCodeOverride;
  30430. private _transformFeedbackVaryings;
  30431. /**
  30432. * Compiled shader to webGL program.
  30433. * @hidden
  30434. */
  30435. _pipelineContext: Nullable<IPipelineContext>;
  30436. private _valueCache;
  30437. private static _baseCache;
  30438. /**
  30439. * Instantiates an effect.
  30440. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30441. * @param baseName Name of the effect.
  30442. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30443. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30444. * @param samplers List of sampler variables that will be passed to the shader.
  30445. * @param engine Engine to be used to render the effect
  30446. * @param defines Define statements to be added to the shader.
  30447. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30448. * @param onCompiled Callback that will be called when the shader is compiled.
  30449. * @param onError Callback that will be called if an error occurs during shader compilation.
  30450. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30451. */
  30452. 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);
  30453. private _useFinalCode;
  30454. /**
  30455. * Unique key for this effect
  30456. */
  30457. get key(): string;
  30458. /**
  30459. * If the effect has been compiled and prepared.
  30460. * @returns if the effect is compiled and prepared.
  30461. */
  30462. isReady(): boolean;
  30463. private _isReadyInternal;
  30464. /**
  30465. * The engine the effect was initialized with.
  30466. * @returns the engine.
  30467. */
  30468. getEngine(): Engine;
  30469. /**
  30470. * The pipeline context for this effect
  30471. * @returns the associated pipeline context
  30472. */
  30473. getPipelineContext(): Nullable<IPipelineContext>;
  30474. /**
  30475. * The set of names of attribute variables for the shader.
  30476. * @returns An array of attribute names.
  30477. */
  30478. getAttributesNames(): string[];
  30479. /**
  30480. * Returns the attribute at the given index.
  30481. * @param index The index of the attribute.
  30482. * @returns The location of the attribute.
  30483. */
  30484. getAttributeLocation(index: number): number;
  30485. /**
  30486. * Returns the attribute based on the name of the variable.
  30487. * @param name of the attribute to look up.
  30488. * @returns the attribute location.
  30489. */
  30490. getAttributeLocationByName(name: string): number;
  30491. /**
  30492. * The number of attributes.
  30493. * @returns the numnber of attributes.
  30494. */
  30495. getAttributesCount(): number;
  30496. /**
  30497. * Gets the index of a uniform variable.
  30498. * @param uniformName of the uniform to look up.
  30499. * @returns the index.
  30500. */
  30501. getUniformIndex(uniformName: string): number;
  30502. /**
  30503. * Returns the attribute based on the name of the variable.
  30504. * @param uniformName of the uniform to look up.
  30505. * @returns the location of the uniform.
  30506. */
  30507. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30508. /**
  30509. * Returns an array of sampler variable names
  30510. * @returns The array of sampler variable neames.
  30511. */
  30512. getSamplers(): string[];
  30513. /**
  30514. * The error from the last compilation.
  30515. * @returns the error string.
  30516. */
  30517. getCompilationError(): string;
  30518. /**
  30519. * Gets a boolean indicating that all fallbacks were used during compilation
  30520. * @returns true if all fallbacks were used
  30521. */
  30522. allFallbacksProcessed(): boolean;
  30523. /**
  30524. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30525. * @param func The callback to be used.
  30526. */
  30527. executeWhenCompiled(func: (effect: Effect) => void): void;
  30528. private _checkIsReady;
  30529. private _loadShader;
  30530. /**
  30531. * Recompiles the webGL program
  30532. * @param vertexSourceCode The source code for the vertex shader.
  30533. * @param fragmentSourceCode The source code for the fragment shader.
  30534. * @param onCompiled Callback called when completed.
  30535. * @param onError Callback called on error.
  30536. * @hidden
  30537. */
  30538. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30539. /**
  30540. * Prepares the effect
  30541. * @hidden
  30542. */
  30543. _prepareEffect(): void;
  30544. private _getShaderCodeAndErrorLine;
  30545. private _processCompilationErrors;
  30546. /**
  30547. * Checks if the effect is supported. (Must be called after compilation)
  30548. */
  30549. get isSupported(): boolean;
  30550. /**
  30551. * Binds a texture to the engine to be used as output of the shader.
  30552. * @param channel Name of the output variable.
  30553. * @param texture Texture to bind.
  30554. * @hidden
  30555. */
  30556. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30557. /**
  30558. * Sets a texture on the engine to be used in the shader.
  30559. * @param channel Name of the sampler variable.
  30560. * @param texture Texture to set.
  30561. */
  30562. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30563. /**
  30564. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30565. * @param channel Name of the sampler variable.
  30566. * @param texture Texture to set.
  30567. */
  30568. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30569. /**
  30570. * Sets an array of textures on the engine to be used in the shader.
  30571. * @param channel Name of the variable.
  30572. * @param textures Textures to set.
  30573. */
  30574. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30575. /**
  30576. * 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)
  30577. * @param channel Name of the sampler variable.
  30578. * @param postProcess Post process to get the input texture from.
  30579. */
  30580. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30581. /**
  30582. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30583. * 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)
  30584. * @param channel Name of the sampler variable.
  30585. * @param postProcess Post process to get the output texture from.
  30586. */
  30587. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30588. /** @hidden */
  30589. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30590. /** @hidden */
  30591. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30592. /** @hidden */
  30593. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30594. /** @hidden */
  30595. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30596. /**
  30597. * Binds a buffer to a uniform.
  30598. * @param buffer Buffer to bind.
  30599. * @param name Name of the uniform variable to bind to.
  30600. */
  30601. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30602. /**
  30603. * Binds block to a uniform.
  30604. * @param blockName Name of the block to bind.
  30605. * @param index Index to bind.
  30606. */
  30607. bindUniformBlock(blockName: string, index: number): void;
  30608. /**
  30609. * Sets an interger value on a uniform variable.
  30610. * @param uniformName Name of the variable.
  30611. * @param value Value to be set.
  30612. * @returns this effect.
  30613. */
  30614. setInt(uniformName: string, value: number): Effect;
  30615. /**
  30616. * Sets an int array on a uniform variable.
  30617. * @param uniformName Name of the variable.
  30618. * @param array array to be set.
  30619. * @returns this effect.
  30620. */
  30621. setIntArray(uniformName: string, array: Int32Array): Effect;
  30622. /**
  30623. * 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)
  30624. * @param uniformName Name of the variable.
  30625. * @param array array to be set.
  30626. * @returns this effect.
  30627. */
  30628. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30629. /**
  30630. * 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)
  30631. * @param uniformName Name of the variable.
  30632. * @param array array to be set.
  30633. * @returns this effect.
  30634. */
  30635. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30636. /**
  30637. * 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)
  30638. * @param uniformName Name of the variable.
  30639. * @param array array to be set.
  30640. * @returns this effect.
  30641. */
  30642. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30643. /**
  30644. * Sets an float array on a uniform variable.
  30645. * @param uniformName Name of the variable.
  30646. * @param array array to be set.
  30647. * @returns this effect.
  30648. */
  30649. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30650. /**
  30651. * 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)
  30652. * @param uniformName Name of the variable.
  30653. * @param array array to be set.
  30654. * @returns this effect.
  30655. */
  30656. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30657. /**
  30658. * 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)
  30659. * @param uniformName Name of the variable.
  30660. * @param array array to be set.
  30661. * @returns this effect.
  30662. */
  30663. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30664. /**
  30665. * 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)
  30666. * @param uniformName Name of the variable.
  30667. * @param array array to be set.
  30668. * @returns this effect.
  30669. */
  30670. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30671. /**
  30672. * Sets an array on a uniform variable.
  30673. * @param uniformName Name of the variable.
  30674. * @param array array to be set.
  30675. * @returns this effect.
  30676. */
  30677. setArray(uniformName: string, array: number[]): Effect;
  30678. /**
  30679. * 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)
  30680. * @param uniformName Name of the variable.
  30681. * @param array array to be set.
  30682. * @returns this effect.
  30683. */
  30684. setArray2(uniformName: string, array: number[]): Effect;
  30685. /**
  30686. * 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)
  30687. * @param uniformName Name of the variable.
  30688. * @param array array to be set.
  30689. * @returns this effect.
  30690. */
  30691. setArray3(uniformName: string, array: number[]): Effect;
  30692. /**
  30693. * 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)
  30694. * @param uniformName Name of the variable.
  30695. * @param array array to be set.
  30696. * @returns this effect.
  30697. */
  30698. setArray4(uniformName: string, array: number[]): Effect;
  30699. /**
  30700. * Sets matrices on a uniform variable.
  30701. * @param uniformName Name of the variable.
  30702. * @param matrices matrices to be set.
  30703. * @returns this effect.
  30704. */
  30705. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30706. /**
  30707. * Sets matrix on a uniform variable.
  30708. * @param uniformName Name of the variable.
  30709. * @param matrix matrix to be set.
  30710. * @returns this effect.
  30711. */
  30712. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30713. /**
  30714. * 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)
  30715. * @param uniformName Name of the variable.
  30716. * @param matrix matrix to be set.
  30717. * @returns this effect.
  30718. */
  30719. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30720. /**
  30721. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30722. * @param uniformName Name of the variable.
  30723. * @param matrix matrix to be set.
  30724. * @returns this effect.
  30725. */
  30726. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30727. /**
  30728. * Sets a float on a uniform variable.
  30729. * @param uniformName Name of the variable.
  30730. * @param value value to be set.
  30731. * @returns this effect.
  30732. */
  30733. setFloat(uniformName: string, value: number): Effect;
  30734. /**
  30735. * Sets a boolean on a uniform variable.
  30736. * @param uniformName Name of the variable.
  30737. * @param bool value to be set.
  30738. * @returns this effect.
  30739. */
  30740. setBool(uniformName: string, bool: boolean): Effect;
  30741. /**
  30742. * Sets a Vector2 on a uniform variable.
  30743. * @param uniformName Name of the variable.
  30744. * @param vector2 vector2 to be set.
  30745. * @returns this effect.
  30746. */
  30747. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30748. /**
  30749. * Sets a float2 on a uniform variable.
  30750. * @param uniformName Name of the variable.
  30751. * @param x First float in float2.
  30752. * @param y Second float in float2.
  30753. * @returns this effect.
  30754. */
  30755. setFloat2(uniformName: string, x: number, y: number): Effect;
  30756. /**
  30757. * Sets a Vector3 on a uniform variable.
  30758. * @param uniformName Name of the variable.
  30759. * @param vector3 Value to be set.
  30760. * @returns this effect.
  30761. */
  30762. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30763. /**
  30764. * Sets a float3 on a uniform variable.
  30765. * @param uniformName Name of the variable.
  30766. * @param x First float in float3.
  30767. * @param y Second float in float3.
  30768. * @param z Third float in float3.
  30769. * @returns this effect.
  30770. */
  30771. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30772. /**
  30773. * Sets a Vector4 on a uniform variable.
  30774. * @param uniformName Name of the variable.
  30775. * @param vector4 Value to be set.
  30776. * @returns this effect.
  30777. */
  30778. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30779. /**
  30780. * Sets a float4 on a uniform variable.
  30781. * @param uniformName Name of the variable.
  30782. * @param x First float in float4.
  30783. * @param y Second float in float4.
  30784. * @param z Third float in float4.
  30785. * @param w Fourth float in float4.
  30786. * @returns this effect.
  30787. */
  30788. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30789. /**
  30790. * Sets a Color3 on a uniform variable.
  30791. * @param uniformName Name of the variable.
  30792. * @param color3 Value to be set.
  30793. * @returns this effect.
  30794. */
  30795. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30796. /**
  30797. * Sets a Color4 on a uniform variable.
  30798. * @param uniformName Name of the variable.
  30799. * @param color3 Value to be set.
  30800. * @param alpha Alpha value to be set.
  30801. * @returns this effect.
  30802. */
  30803. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30804. /**
  30805. * Sets a Color4 on a uniform variable
  30806. * @param uniformName defines the name of the variable
  30807. * @param color4 defines the value to be set
  30808. * @returns this effect.
  30809. */
  30810. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30811. /** Release all associated resources */
  30812. dispose(): void;
  30813. /**
  30814. * This function will add a new shader to the shader store
  30815. * @param name the name of the shader
  30816. * @param pixelShader optional pixel shader content
  30817. * @param vertexShader optional vertex shader content
  30818. */
  30819. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30820. /**
  30821. * Store of each shader (The can be looked up using effect.key)
  30822. */
  30823. static ShadersStore: {
  30824. [key: string]: string;
  30825. };
  30826. /**
  30827. * Store of each included file for a shader (The can be looked up using effect.key)
  30828. */
  30829. static IncludesShadersStore: {
  30830. [key: string]: string;
  30831. };
  30832. /**
  30833. * Resets the cache of effects.
  30834. */
  30835. static ResetCache(): void;
  30836. }
  30837. }
  30838. declare module BABYLON {
  30839. /**
  30840. * Interface used to describe the capabilities of the engine relatively to the current browser
  30841. */
  30842. export interface EngineCapabilities {
  30843. /** Maximum textures units per fragment shader */
  30844. maxTexturesImageUnits: number;
  30845. /** Maximum texture units per vertex shader */
  30846. maxVertexTextureImageUnits: number;
  30847. /** Maximum textures units in the entire pipeline */
  30848. maxCombinedTexturesImageUnits: number;
  30849. /** Maximum texture size */
  30850. maxTextureSize: number;
  30851. /** Maximum texture samples */
  30852. maxSamples?: number;
  30853. /** Maximum cube texture size */
  30854. maxCubemapTextureSize: number;
  30855. /** Maximum render texture size */
  30856. maxRenderTextureSize: number;
  30857. /** Maximum number of vertex attributes */
  30858. maxVertexAttribs: number;
  30859. /** Maximum number of varyings */
  30860. maxVaryingVectors: number;
  30861. /** Maximum number of uniforms per vertex shader */
  30862. maxVertexUniformVectors: number;
  30863. /** Maximum number of uniforms per fragment shader */
  30864. maxFragmentUniformVectors: number;
  30865. /** Defines if standard derivates (dx/dy) are supported */
  30866. standardDerivatives: boolean;
  30867. /** Defines if s3tc texture compression is supported */
  30868. s3tc?: WEBGL_compressed_texture_s3tc;
  30869. /** Defines if pvrtc texture compression is supported */
  30870. pvrtc: any;
  30871. /** Defines if etc1 texture compression is supported */
  30872. etc1: any;
  30873. /** Defines if etc2 texture compression is supported */
  30874. etc2: any;
  30875. /** Defines if astc texture compression is supported */
  30876. astc: any;
  30877. /** Defines if float textures are supported */
  30878. textureFloat: boolean;
  30879. /** Defines if vertex array objects are supported */
  30880. vertexArrayObject: boolean;
  30881. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30882. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30883. /** Gets the maximum level of anisotropy supported */
  30884. maxAnisotropy: number;
  30885. /** Defines if instancing is supported */
  30886. instancedArrays: boolean;
  30887. /** Defines if 32 bits indices are supported */
  30888. uintIndices: boolean;
  30889. /** Defines if high precision shaders are supported */
  30890. highPrecisionShaderSupported: boolean;
  30891. /** Defines if depth reading in the fragment shader is supported */
  30892. fragmentDepthSupported: boolean;
  30893. /** Defines if float texture linear filtering is supported*/
  30894. textureFloatLinearFiltering: boolean;
  30895. /** Defines if rendering to float textures is supported */
  30896. textureFloatRender: boolean;
  30897. /** Defines if half float textures are supported*/
  30898. textureHalfFloat: boolean;
  30899. /** Defines if half float texture linear filtering is supported*/
  30900. textureHalfFloatLinearFiltering: boolean;
  30901. /** Defines if rendering to half float textures is supported */
  30902. textureHalfFloatRender: boolean;
  30903. /** Defines if textureLOD shader command is supported */
  30904. textureLOD: boolean;
  30905. /** Defines if draw buffers extension is supported */
  30906. drawBuffersExtension: boolean;
  30907. /** Defines if depth textures are supported */
  30908. depthTextureExtension: boolean;
  30909. /** Defines if float color buffer are supported */
  30910. colorBufferFloat: boolean;
  30911. /** Gets disjoint timer query extension (null if not supported) */
  30912. timerQuery?: EXT_disjoint_timer_query;
  30913. /** Defines if timestamp can be used with timer query */
  30914. canUseTimestampForTimerQuery: boolean;
  30915. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30916. multiview?: any;
  30917. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30918. oculusMultiview?: any;
  30919. /** Function used to let the system compiles shaders in background */
  30920. parallelShaderCompile?: {
  30921. COMPLETION_STATUS_KHR: number;
  30922. };
  30923. /** Max number of texture samples for MSAA */
  30924. maxMSAASamples: number;
  30925. /** Defines if the blend min max extension is supported */
  30926. blendMinMax: boolean;
  30927. }
  30928. }
  30929. declare module BABYLON {
  30930. /**
  30931. * @hidden
  30932. **/
  30933. export class DepthCullingState {
  30934. private _isDepthTestDirty;
  30935. private _isDepthMaskDirty;
  30936. private _isDepthFuncDirty;
  30937. private _isCullFaceDirty;
  30938. private _isCullDirty;
  30939. private _isZOffsetDirty;
  30940. private _isFrontFaceDirty;
  30941. private _depthTest;
  30942. private _depthMask;
  30943. private _depthFunc;
  30944. private _cull;
  30945. private _cullFace;
  30946. private _zOffset;
  30947. private _frontFace;
  30948. /**
  30949. * Initializes the state.
  30950. */
  30951. constructor();
  30952. get isDirty(): boolean;
  30953. get zOffset(): number;
  30954. set zOffset(value: number);
  30955. get cullFace(): Nullable<number>;
  30956. set cullFace(value: Nullable<number>);
  30957. get cull(): Nullable<boolean>;
  30958. set cull(value: Nullable<boolean>);
  30959. get depthFunc(): Nullable<number>;
  30960. set depthFunc(value: Nullable<number>);
  30961. get depthMask(): boolean;
  30962. set depthMask(value: boolean);
  30963. get depthTest(): boolean;
  30964. set depthTest(value: boolean);
  30965. get frontFace(): Nullable<number>;
  30966. set frontFace(value: Nullable<number>);
  30967. reset(): void;
  30968. apply(gl: WebGLRenderingContext): void;
  30969. }
  30970. }
  30971. declare module BABYLON {
  30972. /**
  30973. * @hidden
  30974. **/
  30975. export class StencilState {
  30976. /** 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 */
  30977. static readonly ALWAYS: number;
  30978. /** Passed to stencilOperation to specify that stencil value must be kept */
  30979. static readonly KEEP: number;
  30980. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30981. static readonly REPLACE: number;
  30982. private _isStencilTestDirty;
  30983. private _isStencilMaskDirty;
  30984. private _isStencilFuncDirty;
  30985. private _isStencilOpDirty;
  30986. private _stencilTest;
  30987. private _stencilMask;
  30988. private _stencilFunc;
  30989. private _stencilFuncRef;
  30990. private _stencilFuncMask;
  30991. private _stencilOpStencilFail;
  30992. private _stencilOpDepthFail;
  30993. private _stencilOpStencilDepthPass;
  30994. get isDirty(): boolean;
  30995. get stencilFunc(): number;
  30996. set stencilFunc(value: number);
  30997. get stencilFuncRef(): number;
  30998. set stencilFuncRef(value: number);
  30999. get stencilFuncMask(): number;
  31000. set stencilFuncMask(value: number);
  31001. get stencilOpStencilFail(): number;
  31002. set stencilOpStencilFail(value: number);
  31003. get stencilOpDepthFail(): number;
  31004. set stencilOpDepthFail(value: number);
  31005. get stencilOpStencilDepthPass(): number;
  31006. set stencilOpStencilDepthPass(value: number);
  31007. get stencilMask(): number;
  31008. set stencilMask(value: number);
  31009. get stencilTest(): boolean;
  31010. set stencilTest(value: boolean);
  31011. constructor();
  31012. reset(): void;
  31013. apply(gl: WebGLRenderingContext): void;
  31014. }
  31015. }
  31016. declare module BABYLON {
  31017. /**
  31018. * @hidden
  31019. **/
  31020. export class AlphaState {
  31021. private _isAlphaBlendDirty;
  31022. private _isBlendFunctionParametersDirty;
  31023. private _isBlendEquationParametersDirty;
  31024. private _isBlendConstantsDirty;
  31025. private _alphaBlend;
  31026. private _blendFunctionParameters;
  31027. private _blendEquationParameters;
  31028. private _blendConstants;
  31029. /**
  31030. * Initializes the state.
  31031. */
  31032. constructor();
  31033. get isDirty(): boolean;
  31034. get alphaBlend(): boolean;
  31035. set alphaBlend(value: boolean);
  31036. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31037. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31038. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31039. reset(): void;
  31040. apply(gl: WebGLRenderingContext): void;
  31041. }
  31042. }
  31043. declare module BABYLON {
  31044. /** @hidden */
  31045. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31046. attributeProcessor(attribute: string): string;
  31047. varyingProcessor(varying: string, isFragment: boolean): string;
  31048. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31049. }
  31050. }
  31051. declare module BABYLON {
  31052. /**
  31053. * Interface for attribute information associated with buffer instanciation
  31054. */
  31055. export interface InstancingAttributeInfo {
  31056. /**
  31057. * Name of the GLSL attribute
  31058. * if attribute index is not specified, this is used to retrieve the index from the effect
  31059. */
  31060. attributeName: string;
  31061. /**
  31062. * Index/offset of the attribute in the vertex shader
  31063. * if not specified, this will be computes from the name.
  31064. */
  31065. index?: number;
  31066. /**
  31067. * size of the attribute, 1, 2, 3 or 4
  31068. */
  31069. attributeSize: number;
  31070. /**
  31071. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31072. */
  31073. offset: number;
  31074. /**
  31075. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31076. * default to 1
  31077. */
  31078. divisor?: number;
  31079. /**
  31080. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31081. * default is FLOAT
  31082. */
  31083. attributeType?: number;
  31084. /**
  31085. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31086. */
  31087. normalized?: boolean;
  31088. }
  31089. }
  31090. declare module BABYLON {
  31091. interface ThinEngine {
  31092. /**
  31093. * Update a video texture
  31094. * @param texture defines the texture to update
  31095. * @param video defines the video element to use
  31096. * @param invertY defines if data must be stored with Y axis inverted
  31097. */
  31098. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31099. }
  31100. }
  31101. declare module BABYLON {
  31102. /**
  31103. * Settings for finer control over video usage
  31104. */
  31105. export interface VideoTextureSettings {
  31106. /**
  31107. * Applies `autoplay` to video, if specified
  31108. */
  31109. autoPlay?: boolean;
  31110. /**
  31111. * Applies `loop` to video, if specified
  31112. */
  31113. loop?: boolean;
  31114. /**
  31115. * Automatically updates internal texture from video at every frame in the render loop
  31116. */
  31117. autoUpdateTexture: boolean;
  31118. /**
  31119. * Image src displayed during the video loading or until the user interacts with the video.
  31120. */
  31121. poster?: string;
  31122. }
  31123. /**
  31124. * If you want to display a video in your scene, this is the special texture for that.
  31125. * This special texture works similar to other textures, with the exception of a few parameters.
  31126. * @see https://doc.babylonjs.com/how_to/video_texture
  31127. */
  31128. export class VideoTexture extends Texture {
  31129. /**
  31130. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31131. */
  31132. readonly autoUpdateTexture: boolean;
  31133. /**
  31134. * The video instance used by the texture internally
  31135. */
  31136. readonly video: HTMLVideoElement;
  31137. private _onUserActionRequestedObservable;
  31138. /**
  31139. * Event triggerd when a dom action is required by the user to play the video.
  31140. * This happens due to recent changes in browser policies preventing video to auto start.
  31141. */
  31142. get onUserActionRequestedObservable(): Observable<Texture>;
  31143. private _generateMipMaps;
  31144. private _engine;
  31145. private _stillImageCaptured;
  31146. private _displayingPosterTexture;
  31147. private _settings;
  31148. private _createInternalTextureOnEvent;
  31149. private _frameId;
  31150. private _currentSrc;
  31151. /**
  31152. * Creates a video texture.
  31153. * If you want to display a video in your scene, this is the special texture for that.
  31154. * This special texture works similar to other textures, with the exception of a few parameters.
  31155. * @see https://doc.babylonjs.com/how_to/video_texture
  31156. * @param name optional name, will detect from video source, if not defined
  31157. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31158. * @param scene is obviously the current scene.
  31159. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31160. * @param invertY is false by default but can be used to invert video on Y axis
  31161. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31162. * @param settings allows finer control over video usage
  31163. */
  31164. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31165. private _getName;
  31166. private _getVideo;
  31167. private _createInternalTexture;
  31168. private reset;
  31169. /**
  31170. * @hidden Internal method to initiate `update`.
  31171. */
  31172. _rebuild(): void;
  31173. /**
  31174. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31175. */
  31176. update(): void;
  31177. /**
  31178. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31179. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31180. */
  31181. updateTexture(isVisible: boolean): void;
  31182. protected _updateInternalTexture: () => void;
  31183. /**
  31184. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31185. * @param url New url.
  31186. */
  31187. updateURL(url: string): void;
  31188. /**
  31189. * Clones the texture.
  31190. * @returns the cloned texture
  31191. */
  31192. clone(): VideoTexture;
  31193. /**
  31194. * Dispose the texture and release its associated resources.
  31195. */
  31196. dispose(): void;
  31197. /**
  31198. * Creates a video texture straight from a stream.
  31199. * @param scene Define the scene the texture should be created in
  31200. * @param stream Define the stream the texture should be created from
  31201. * @returns The created video texture as a promise
  31202. */
  31203. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31204. /**
  31205. * Creates a video texture straight from your WebCam video feed.
  31206. * @param scene Define the scene the texture should be created in
  31207. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31208. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31209. * @returns The created video texture as a promise
  31210. */
  31211. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31212. minWidth: number;
  31213. maxWidth: number;
  31214. minHeight: number;
  31215. maxHeight: number;
  31216. deviceId: string;
  31217. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31218. /**
  31219. * Creates a video texture straight from your WebCam video feed.
  31220. * @param scene Define the scene the texture should be created in
  31221. * @param onReady Define a callback to triggered once the texture will be ready
  31222. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31223. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31224. */
  31225. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31226. minWidth: number;
  31227. maxWidth: number;
  31228. minHeight: number;
  31229. maxHeight: number;
  31230. deviceId: string;
  31231. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31232. }
  31233. }
  31234. declare module BABYLON {
  31235. /**
  31236. * Defines the interface used by objects working like Scene
  31237. * @hidden
  31238. */
  31239. export interface ISceneLike {
  31240. _addPendingData(data: any): void;
  31241. _removePendingData(data: any): void;
  31242. offlineProvider: IOfflineProvider;
  31243. }
  31244. /** Interface defining initialization parameters for Engine class */
  31245. export interface EngineOptions extends WebGLContextAttributes {
  31246. /**
  31247. * Defines if the engine should no exceed a specified device ratio
  31248. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31249. */
  31250. limitDeviceRatio?: number;
  31251. /**
  31252. * Defines if webvr should be enabled automatically
  31253. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31254. */
  31255. autoEnableWebVR?: boolean;
  31256. /**
  31257. * Defines if webgl2 should be turned off even if supported
  31258. * @see http://doc.babylonjs.com/features/webgl2
  31259. */
  31260. disableWebGL2Support?: boolean;
  31261. /**
  31262. * Defines if webaudio should be initialized as well
  31263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31264. */
  31265. audioEngine?: boolean;
  31266. /**
  31267. * Defines if animations should run using a deterministic lock step
  31268. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31269. */
  31270. deterministicLockstep?: boolean;
  31271. /** Defines the maximum steps to use with deterministic lock step mode */
  31272. lockstepMaxSteps?: number;
  31273. /** Defines the seconds between each deterministic lock step */
  31274. timeStep?: number;
  31275. /**
  31276. * Defines that engine should ignore context lost events
  31277. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31278. */
  31279. doNotHandleContextLost?: boolean;
  31280. /**
  31281. * Defines that engine should ignore modifying touch action attribute and style
  31282. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31283. */
  31284. doNotHandleTouchAction?: boolean;
  31285. /**
  31286. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31287. */
  31288. useHighPrecisionFloats?: boolean;
  31289. }
  31290. /**
  31291. * The base engine class (root of all engines)
  31292. */
  31293. export class ThinEngine {
  31294. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31295. static ExceptionList: ({
  31296. key: string;
  31297. capture: string;
  31298. captureConstraint: number;
  31299. targets: string[];
  31300. } | {
  31301. key: string;
  31302. capture: null;
  31303. captureConstraint: null;
  31304. targets: string[];
  31305. })[];
  31306. /** @hidden */
  31307. static _TextureLoaders: IInternalTextureLoader[];
  31308. /**
  31309. * Returns the current npm package of the sdk
  31310. */
  31311. static get NpmPackage(): string;
  31312. /**
  31313. * Returns the current version of the framework
  31314. */
  31315. static get Version(): string;
  31316. /**
  31317. * Returns a string describing the current engine
  31318. */
  31319. get description(): string;
  31320. /**
  31321. * Gets or sets the epsilon value used by collision engine
  31322. */
  31323. static CollisionsEpsilon: number;
  31324. /**
  31325. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31326. */
  31327. static get ShadersRepository(): string;
  31328. static set ShadersRepository(value: string);
  31329. /** @hidden */
  31330. _shaderProcessor: IShaderProcessor;
  31331. /**
  31332. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31333. */
  31334. forcePOTTextures: boolean;
  31335. /**
  31336. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31337. */
  31338. isFullscreen: boolean;
  31339. /**
  31340. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31341. */
  31342. cullBackFaces: boolean;
  31343. /**
  31344. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31345. */
  31346. renderEvenInBackground: boolean;
  31347. /**
  31348. * Gets or sets a boolean indicating that cache can be kept between frames
  31349. */
  31350. preventCacheWipeBetweenFrames: boolean;
  31351. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31352. validateShaderPrograms: boolean;
  31353. /**
  31354. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31355. * This can provide greater z depth for distant objects.
  31356. */
  31357. useReverseDepthBuffer: boolean;
  31358. /**
  31359. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31360. */
  31361. disableUniformBuffers: boolean;
  31362. /** @hidden */
  31363. _uniformBuffers: UniformBuffer[];
  31364. /**
  31365. * Gets a boolean indicating that the engine supports uniform buffers
  31366. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31367. */
  31368. get supportsUniformBuffers(): boolean;
  31369. /** @hidden */
  31370. _gl: WebGLRenderingContext;
  31371. /** @hidden */
  31372. _webGLVersion: number;
  31373. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31374. protected _windowIsBackground: boolean;
  31375. protected _creationOptions: EngineOptions;
  31376. protected _highPrecisionShadersAllowed: boolean;
  31377. /** @hidden */
  31378. get _shouldUseHighPrecisionShader(): boolean;
  31379. /**
  31380. * Gets a boolean indicating that only power of 2 textures are supported
  31381. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31382. */
  31383. get needPOTTextures(): boolean;
  31384. /** @hidden */
  31385. _badOS: boolean;
  31386. /** @hidden */
  31387. _badDesktopOS: boolean;
  31388. private _hardwareScalingLevel;
  31389. /** @hidden */
  31390. _caps: EngineCapabilities;
  31391. private _isStencilEnable;
  31392. private _glVersion;
  31393. private _glRenderer;
  31394. private _glVendor;
  31395. /** @hidden */
  31396. _videoTextureSupported: boolean;
  31397. protected _renderingQueueLaunched: boolean;
  31398. protected _activeRenderLoops: (() => void)[];
  31399. /**
  31400. * Observable signaled when a context lost event is raised
  31401. */
  31402. onContextLostObservable: Observable<ThinEngine>;
  31403. /**
  31404. * Observable signaled when a context restored event is raised
  31405. */
  31406. onContextRestoredObservable: Observable<ThinEngine>;
  31407. private _onContextLost;
  31408. private _onContextRestored;
  31409. protected _contextWasLost: boolean;
  31410. /** @hidden */
  31411. _doNotHandleContextLost: boolean;
  31412. /**
  31413. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31415. */
  31416. get doNotHandleContextLost(): boolean;
  31417. set doNotHandleContextLost(value: boolean);
  31418. /**
  31419. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31420. */
  31421. disableVertexArrayObjects: boolean;
  31422. /** @hidden */
  31423. protected _colorWrite: boolean;
  31424. /** @hidden */
  31425. protected _colorWriteChanged: boolean;
  31426. /** @hidden */
  31427. protected _depthCullingState: DepthCullingState;
  31428. /** @hidden */
  31429. protected _stencilState: StencilState;
  31430. /** @hidden */
  31431. _alphaState: AlphaState;
  31432. /** @hidden */
  31433. _alphaMode: number;
  31434. /** @hidden */
  31435. _alphaEquation: number;
  31436. /** @hidden */
  31437. _internalTexturesCache: InternalTexture[];
  31438. /** @hidden */
  31439. protected _activeChannel: number;
  31440. private _currentTextureChannel;
  31441. /** @hidden */
  31442. protected _boundTexturesCache: {
  31443. [key: string]: Nullable<InternalTexture>;
  31444. };
  31445. /** @hidden */
  31446. protected _currentEffect: Nullable<Effect>;
  31447. /** @hidden */
  31448. protected _currentProgram: Nullable<WebGLProgram>;
  31449. private _compiledEffects;
  31450. private _vertexAttribArraysEnabled;
  31451. /** @hidden */
  31452. protected _cachedViewport: Nullable<IViewportLike>;
  31453. private _cachedVertexArrayObject;
  31454. /** @hidden */
  31455. protected _cachedVertexBuffers: any;
  31456. /** @hidden */
  31457. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31458. /** @hidden */
  31459. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31460. /** @hidden */
  31461. _currentRenderTarget: Nullable<InternalTexture>;
  31462. private _uintIndicesCurrentlySet;
  31463. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31464. /** @hidden */
  31465. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31466. private _currentBufferPointers;
  31467. private _currentInstanceLocations;
  31468. private _currentInstanceBuffers;
  31469. private _textureUnits;
  31470. /** @hidden */
  31471. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31472. /** @hidden */
  31473. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31474. /** @hidden */
  31475. _boundRenderFunction: any;
  31476. private _vaoRecordInProgress;
  31477. private _mustWipeVertexAttributes;
  31478. private _emptyTexture;
  31479. private _emptyCubeTexture;
  31480. private _emptyTexture3D;
  31481. private _emptyTexture2DArray;
  31482. /** @hidden */
  31483. _frameHandler: number;
  31484. private _nextFreeTextureSlots;
  31485. private _maxSimultaneousTextures;
  31486. private _activeRequests;
  31487. /** @hidden */
  31488. _transformTextureUrl: Nullable<(url: string) => string>;
  31489. protected get _supportsHardwareTextureRescaling(): boolean;
  31490. private _framebufferDimensionsObject;
  31491. /**
  31492. * sets the object from which width and height will be taken from when getting render width and height
  31493. * Will fallback to the gl object
  31494. * @param dimensions the framebuffer width and height that will be used.
  31495. */
  31496. set framebufferDimensionsObject(dimensions: Nullable<{
  31497. framebufferWidth: number;
  31498. framebufferHeight: number;
  31499. }>);
  31500. /**
  31501. * Gets the current viewport
  31502. */
  31503. get currentViewport(): Nullable<IViewportLike>;
  31504. /**
  31505. * Gets the default empty texture
  31506. */
  31507. get emptyTexture(): InternalTexture;
  31508. /**
  31509. * Gets the default empty 3D texture
  31510. */
  31511. get emptyTexture3D(): InternalTexture;
  31512. /**
  31513. * Gets the default empty 2D array texture
  31514. */
  31515. get emptyTexture2DArray(): InternalTexture;
  31516. /**
  31517. * Gets the default empty cube texture
  31518. */
  31519. get emptyCubeTexture(): InternalTexture;
  31520. /**
  31521. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31522. */
  31523. readonly premultipliedAlpha: boolean;
  31524. /**
  31525. * Observable event triggered before each texture is initialized
  31526. */
  31527. onBeforeTextureInitObservable: Observable<Texture>;
  31528. /**
  31529. * Creates a new engine
  31530. * @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
  31531. * @param antialias defines enable antialiasing (default: false)
  31532. * @param options defines further options to be sent to the getContext() function
  31533. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31534. */
  31535. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31536. private _rebuildInternalTextures;
  31537. private _rebuildEffects;
  31538. /**
  31539. * Gets a boolean indicating if all created effects are ready
  31540. * @returns true if all effects are ready
  31541. */
  31542. areAllEffectsReady(): boolean;
  31543. protected _rebuildBuffers(): void;
  31544. protected _initGLContext(): void;
  31545. /**
  31546. * Gets version of the current webGL context
  31547. */
  31548. get webGLVersion(): number;
  31549. /**
  31550. * Gets a string idenfifying the name of the class
  31551. * @returns "Engine" string
  31552. */
  31553. getClassName(): string;
  31554. /**
  31555. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31556. */
  31557. get isStencilEnable(): boolean;
  31558. /** @hidden */
  31559. _prepareWorkingCanvas(): void;
  31560. /**
  31561. * Reset the texture cache to empty state
  31562. */
  31563. resetTextureCache(): void;
  31564. /**
  31565. * Gets an object containing information about the current webGL context
  31566. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31567. */
  31568. getGlInfo(): {
  31569. vendor: string;
  31570. renderer: string;
  31571. version: string;
  31572. };
  31573. /**
  31574. * Defines the hardware scaling level.
  31575. * By default the hardware scaling level is computed from the window device ratio.
  31576. * 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.
  31577. * @param level defines the level to use
  31578. */
  31579. setHardwareScalingLevel(level: number): void;
  31580. /**
  31581. * Gets the current hardware scaling level.
  31582. * By default the hardware scaling level is computed from the window device ratio.
  31583. * 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.
  31584. * @returns a number indicating the current hardware scaling level
  31585. */
  31586. getHardwareScalingLevel(): number;
  31587. /**
  31588. * Gets the list of loaded textures
  31589. * @returns an array containing all loaded textures
  31590. */
  31591. getLoadedTexturesCache(): InternalTexture[];
  31592. /**
  31593. * Gets the object containing all engine capabilities
  31594. * @returns the EngineCapabilities object
  31595. */
  31596. getCaps(): EngineCapabilities;
  31597. /**
  31598. * stop executing a render loop function and remove it from the execution array
  31599. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31600. */
  31601. stopRenderLoop(renderFunction?: () => void): void;
  31602. /** @hidden */
  31603. _renderLoop(): void;
  31604. /**
  31605. * Gets the HTML canvas attached with the current webGL context
  31606. * @returns a HTML canvas
  31607. */
  31608. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31609. /**
  31610. * Gets host window
  31611. * @returns the host window object
  31612. */
  31613. getHostWindow(): Nullable<Window>;
  31614. /**
  31615. * Gets the current render width
  31616. * @param useScreen defines if screen size must be used (or the current render target if any)
  31617. * @returns a number defining the current render width
  31618. */
  31619. getRenderWidth(useScreen?: boolean): number;
  31620. /**
  31621. * Gets the current render height
  31622. * @param useScreen defines if screen size must be used (or the current render target if any)
  31623. * @returns a number defining the current render height
  31624. */
  31625. getRenderHeight(useScreen?: boolean): number;
  31626. /**
  31627. * Can be used to override the current requestAnimationFrame requester.
  31628. * @hidden
  31629. */
  31630. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31631. /**
  31632. * Register and execute a render loop. The engine can have more than one render function
  31633. * @param renderFunction defines the function to continuously execute
  31634. */
  31635. runRenderLoop(renderFunction: () => void): void;
  31636. /**
  31637. * Clear the current render buffer or the current render target (if any is set up)
  31638. * @param color defines the color to use
  31639. * @param backBuffer defines if the back buffer must be cleared
  31640. * @param depth defines if the depth buffer must be cleared
  31641. * @param stencil defines if the stencil buffer must be cleared
  31642. */
  31643. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31644. private _viewportCached;
  31645. /** @hidden */
  31646. _viewport(x: number, y: number, width: number, height: number): void;
  31647. /**
  31648. * Set the WebGL's viewport
  31649. * @param viewport defines the viewport element to be used
  31650. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31651. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31652. */
  31653. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31654. /**
  31655. * Begin a new frame
  31656. */
  31657. beginFrame(): void;
  31658. /**
  31659. * Enf the current frame
  31660. */
  31661. endFrame(): void;
  31662. /**
  31663. * Resize the view according to the canvas' size
  31664. */
  31665. resize(): void;
  31666. /**
  31667. * Force a specific size of the canvas
  31668. * @param width defines the new canvas' width
  31669. * @param height defines the new canvas' height
  31670. */
  31671. setSize(width: number, height: number): void;
  31672. /**
  31673. * Binds the frame buffer to the specified texture.
  31674. * @param texture The texture to render to or null for the default canvas
  31675. * @param faceIndex The face of the texture to render to in case of cube texture
  31676. * @param requiredWidth The width of the target to render to
  31677. * @param requiredHeight The height of the target to render to
  31678. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31679. * @param lodLevel defines the lod level to bind to the frame buffer
  31680. * @param layer defines the 2d array index to bind to frame buffer to
  31681. */
  31682. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31683. /** @hidden */
  31684. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31685. /**
  31686. * Unbind the current render target texture from the webGL context
  31687. * @param texture defines the render target texture to unbind
  31688. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31689. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31690. */
  31691. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31692. /**
  31693. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31694. */
  31695. flushFramebuffer(): void;
  31696. /**
  31697. * Unbind the current render target and bind the default framebuffer
  31698. */
  31699. restoreDefaultFramebuffer(): void;
  31700. /** @hidden */
  31701. protected _resetVertexBufferBinding(): void;
  31702. /**
  31703. * Creates a vertex buffer
  31704. * @param data the data for the vertex buffer
  31705. * @returns the new WebGL static buffer
  31706. */
  31707. createVertexBuffer(data: DataArray): DataBuffer;
  31708. private _createVertexBuffer;
  31709. /**
  31710. * Creates a dynamic vertex buffer
  31711. * @param data the data for the dynamic vertex buffer
  31712. * @returns the new WebGL dynamic buffer
  31713. */
  31714. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31715. protected _resetIndexBufferBinding(): void;
  31716. /**
  31717. * Creates a new index buffer
  31718. * @param indices defines the content of the index buffer
  31719. * @param updatable defines if the index buffer must be updatable
  31720. * @returns a new webGL buffer
  31721. */
  31722. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31723. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31724. /**
  31725. * Bind a webGL buffer to the webGL context
  31726. * @param buffer defines the buffer to bind
  31727. */
  31728. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31729. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31730. private bindBuffer;
  31731. /**
  31732. * update the bound buffer with the given data
  31733. * @param data defines the data to update
  31734. */
  31735. updateArrayBuffer(data: Float32Array): void;
  31736. private _vertexAttribPointer;
  31737. /** @hidden */
  31738. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31739. private _bindVertexBuffersAttributes;
  31740. /**
  31741. * Records a vertex array object
  31742. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31743. * @param vertexBuffers defines the list of vertex buffers to store
  31744. * @param indexBuffer defines the index buffer to store
  31745. * @param effect defines the effect to store
  31746. * @returns the new vertex array object
  31747. */
  31748. recordVertexArrayObject(vertexBuffers: {
  31749. [key: string]: VertexBuffer;
  31750. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31751. /**
  31752. * Bind a specific vertex array object
  31753. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31754. * @param vertexArrayObject defines the vertex array object to bind
  31755. * @param indexBuffer defines the index buffer to bind
  31756. */
  31757. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31758. /**
  31759. * Bind webGl buffers directly to the webGL context
  31760. * @param vertexBuffer defines the vertex buffer to bind
  31761. * @param indexBuffer defines the index buffer to bind
  31762. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31763. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31764. * @param effect defines the effect associated with the vertex buffer
  31765. */
  31766. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31767. private _unbindVertexArrayObject;
  31768. /**
  31769. * Bind a list of vertex buffers to the webGL context
  31770. * @param vertexBuffers defines the list of vertex buffers to bind
  31771. * @param indexBuffer defines the index buffer to bind
  31772. * @param effect defines the effect associated with the vertex buffers
  31773. */
  31774. bindBuffers(vertexBuffers: {
  31775. [key: string]: Nullable<VertexBuffer>;
  31776. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31777. /**
  31778. * Unbind all instance attributes
  31779. */
  31780. unbindInstanceAttributes(): void;
  31781. /**
  31782. * Release and free the memory of a vertex array object
  31783. * @param vao defines the vertex array object to delete
  31784. */
  31785. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31786. /** @hidden */
  31787. _releaseBuffer(buffer: DataBuffer): boolean;
  31788. protected _deleteBuffer(buffer: DataBuffer): void;
  31789. /**
  31790. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31791. * @param instancesBuffer defines the webGL buffer to update and bind
  31792. * @param data defines the data to store in the buffer
  31793. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31794. */
  31795. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31796. /**
  31797. * Bind the content of a webGL buffer used with instantiation
  31798. * @param instancesBuffer defines the webGL buffer to bind
  31799. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31800. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31801. */
  31802. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31803. /**
  31804. * Disable the instance attribute corresponding to the name in parameter
  31805. * @param name defines the name of the attribute to disable
  31806. */
  31807. disableInstanceAttributeByName(name: string): void;
  31808. /**
  31809. * Disable the instance attribute corresponding to the location in parameter
  31810. * @param attributeLocation defines the attribute location of the attribute to disable
  31811. */
  31812. disableInstanceAttribute(attributeLocation: number): void;
  31813. /**
  31814. * Disable the attribute corresponding to the location in parameter
  31815. * @param attributeLocation defines the attribute location of the attribute to disable
  31816. */
  31817. disableAttributeByIndex(attributeLocation: number): void;
  31818. /**
  31819. * Send a draw order
  31820. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31821. * @param indexStart defines the starting index
  31822. * @param indexCount defines the number of index to draw
  31823. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31824. */
  31825. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31826. /**
  31827. * Draw a list of points
  31828. * @param verticesStart defines the index of first vertex to draw
  31829. * @param verticesCount defines the count of vertices to draw
  31830. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31831. */
  31832. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31833. /**
  31834. * Draw a list of unindexed primitives
  31835. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31836. * @param verticesStart defines the index of first vertex to draw
  31837. * @param verticesCount defines the count of vertices to draw
  31838. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31839. */
  31840. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31841. /**
  31842. * Draw a list of indexed primitives
  31843. * @param fillMode defines the primitive to use
  31844. * @param indexStart defines the starting index
  31845. * @param indexCount defines the number of index to draw
  31846. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31847. */
  31848. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31849. /**
  31850. * Draw a list of unindexed primitives
  31851. * @param fillMode defines the primitive to use
  31852. * @param verticesStart defines the index of first vertex to draw
  31853. * @param verticesCount defines the count of vertices to draw
  31854. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31855. */
  31856. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31857. private _drawMode;
  31858. /** @hidden */
  31859. protected _reportDrawCall(): void;
  31860. /** @hidden */
  31861. _releaseEffect(effect: Effect): void;
  31862. /** @hidden */
  31863. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31864. /**
  31865. * Create a new effect (used to store vertex/fragment shaders)
  31866. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31867. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31868. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31869. * @param samplers defines an array of string used to represent textures
  31870. * @param defines defines the string containing the defines to use to compile the shaders
  31871. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31872. * @param onCompiled defines a function to call when the effect creation is successful
  31873. * @param onError defines a function to call when the effect creation has failed
  31874. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31875. * @returns the new Effect
  31876. */
  31877. 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;
  31878. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31879. private _compileShader;
  31880. private _compileRawShader;
  31881. /** @hidden */
  31882. _getShaderSource(shader: WebGLShader): Nullable<string>;
  31883. /**
  31884. * Directly creates a webGL program
  31885. * @param pipelineContext defines the pipeline context to attach to
  31886. * @param vertexCode defines the vertex shader code to use
  31887. * @param fragmentCode defines the fragment shader code to use
  31888. * @param context defines the webGL context to use (if not set, the current one will be used)
  31889. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31890. * @returns the new webGL program
  31891. */
  31892. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31893. /**
  31894. * Creates a webGL program
  31895. * @param pipelineContext defines the pipeline context to attach to
  31896. * @param vertexCode defines the vertex shader code to use
  31897. * @param fragmentCode defines the fragment shader code to use
  31898. * @param defines defines the string containing the defines to use to compile the shaders
  31899. * @param context defines the webGL context to use (if not set, the current one will be used)
  31900. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31901. * @returns the new webGL program
  31902. */
  31903. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31904. /**
  31905. * Creates a new pipeline context
  31906. * @returns the new pipeline
  31907. */
  31908. createPipelineContext(): IPipelineContext;
  31909. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31910. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31911. /** @hidden */
  31912. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31913. /** @hidden */
  31914. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31915. /** @hidden */
  31916. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31917. /**
  31918. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31919. * @param pipelineContext defines the pipeline context to use
  31920. * @param uniformsNames defines the list of uniform names
  31921. * @returns an array of webGL uniform locations
  31922. */
  31923. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31924. /**
  31925. * Gets the lsit of active attributes for a given webGL program
  31926. * @param pipelineContext defines the pipeline context to use
  31927. * @param attributesNames defines the list of attribute names to get
  31928. * @returns an array of indices indicating the offset of each attribute
  31929. */
  31930. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31931. /**
  31932. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31933. * @param effect defines the effect to activate
  31934. */
  31935. enableEffect(effect: Nullable<Effect>): void;
  31936. /**
  31937. * Set the value of an uniform to a number (int)
  31938. * @param uniform defines the webGL uniform location where to store the value
  31939. * @param value defines the int number to store
  31940. */
  31941. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31942. /**
  31943. * Set the value of an uniform to an array of int32
  31944. * @param uniform defines the webGL uniform location where to store the value
  31945. * @param array defines the array of int32 to store
  31946. */
  31947. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31948. /**
  31949. * Set the value of an uniform to an array of int32 (stored as vec2)
  31950. * @param uniform defines the webGL uniform location where to store the value
  31951. * @param array defines the array of int32 to store
  31952. */
  31953. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31954. /**
  31955. * Set the value of an uniform to an array of int32 (stored as vec3)
  31956. * @param uniform defines the webGL uniform location where to store the value
  31957. * @param array defines the array of int32 to store
  31958. */
  31959. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31960. /**
  31961. * Set the value of an uniform to an array of int32 (stored as vec4)
  31962. * @param uniform defines the webGL uniform location where to store the value
  31963. * @param array defines the array of int32 to store
  31964. */
  31965. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31966. /**
  31967. * Set the value of an uniform to an array of number
  31968. * @param uniform defines the webGL uniform location where to store the value
  31969. * @param array defines the array of number to store
  31970. */
  31971. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31972. /**
  31973. * Set the value of an uniform to an array of number (stored as vec2)
  31974. * @param uniform defines the webGL uniform location where to store the value
  31975. * @param array defines the array of number to store
  31976. */
  31977. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31978. /**
  31979. * Set the value of an uniform to an array of number (stored as vec3)
  31980. * @param uniform defines the webGL uniform location where to store the value
  31981. * @param array defines the array of number to store
  31982. */
  31983. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31984. /**
  31985. * Set the value of an uniform to an array of number (stored as vec4)
  31986. * @param uniform defines the webGL uniform location where to store the value
  31987. * @param array defines the array of number to store
  31988. */
  31989. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31990. /**
  31991. * Set the value of an uniform to an array of float32 (stored as matrices)
  31992. * @param uniform defines the webGL uniform location where to store the value
  31993. * @param matrices defines the array of float32 to store
  31994. */
  31995. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31996. /**
  31997. * Set the value of an uniform to a matrix (3x3)
  31998. * @param uniform defines the webGL uniform location where to store the value
  31999. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32000. */
  32001. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32002. /**
  32003. * Set the value of an uniform to a matrix (2x2)
  32004. * @param uniform defines the webGL uniform location where to store the value
  32005. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32006. */
  32007. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32008. /**
  32009. * Set the value of an uniform to a number (float)
  32010. * @param uniform defines the webGL uniform location where to store the value
  32011. * @param value defines the float number to store
  32012. */
  32013. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32014. /**
  32015. * Set the value of an uniform to a vec2
  32016. * @param uniform defines the webGL uniform location where to store the value
  32017. * @param x defines the 1st component of the value
  32018. * @param y defines the 2nd component of the value
  32019. */
  32020. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32021. /**
  32022. * Set the value of an uniform to a vec3
  32023. * @param uniform defines the webGL uniform location where to store the value
  32024. * @param x defines the 1st component of the value
  32025. * @param y defines the 2nd component of the value
  32026. * @param z defines the 3rd component of the value
  32027. */
  32028. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32029. /**
  32030. * Set the value of an uniform to a vec4
  32031. * @param uniform defines the webGL uniform location where to store the value
  32032. * @param x defines the 1st component of the value
  32033. * @param y defines the 2nd component of the value
  32034. * @param z defines the 3rd component of the value
  32035. * @param w defines the 4th component of the value
  32036. */
  32037. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32038. /**
  32039. * Apply all cached states (depth, culling, stencil and alpha)
  32040. */
  32041. applyStates(): void;
  32042. /**
  32043. * Enable or disable color writing
  32044. * @param enable defines the state to set
  32045. */
  32046. setColorWrite(enable: boolean): void;
  32047. /**
  32048. * Gets a boolean indicating if color writing is enabled
  32049. * @returns the current color writing state
  32050. */
  32051. getColorWrite(): boolean;
  32052. /**
  32053. * Gets the depth culling state manager
  32054. */
  32055. get depthCullingState(): DepthCullingState;
  32056. /**
  32057. * Gets the alpha state manager
  32058. */
  32059. get alphaState(): AlphaState;
  32060. /**
  32061. * Gets the stencil state manager
  32062. */
  32063. get stencilState(): StencilState;
  32064. /**
  32065. * Clears the list of texture accessible through engine.
  32066. * This can help preventing texture load conflict due to name collision.
  32067. */
  32068. clearInternalTexturesCache(): void;
  32069. /**
  32070. * Force the entire cache to be cleared
  32071. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32072. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32073. */
  32074. wipeCaches(bruteForce?: boolean): void;
  32075. /** @hidden */
  32076. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32077. min: number;
  32078. mag: number;
  32079. };
  32080. /** @hidden */
  32081. _createTexture(): WebGLTexture;
  32082. /**
  32083. * Usually called from Texture.ts.
  32084. * Passed information to create a WebGLTexture
  32085. * @param url defines a value which contains one of the following:
  32086. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32087. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32088. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32089. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32090. * @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)
  32091. * @param scene needed for loading to the correct scene
  32092. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32093. * @param onLoad optional callback to be called upon successful completion
  32094. * @param onError optional callback to be called upon failure
  32095. * @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
  32096. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32097. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32098. * @param forcedExtension defines the extension to use to pick the right loader
  32099. * @param mimeType defines an optional mime type
  32100. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32101. */
  32102. 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;
  32103. /**
  32104. * Loads an image as an HTMLImageElement.
  32105. * @param input url string, ArrayBuffer, or Blob to load
  32106. * @param onLoad callback called when the image successfully loads
  32107. * @param onError callback called when the image fails to load
  32108. * @param offlineProvider offline provider for caching
  32109. * @param mimeType optional mime type
  32110. * @returns the HTMLImageElement of the loaded image
  32111. * @hidden
  32112. */
  32113. 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>;
  32114. /**
  32115. * @hidden
  32116. */
  32117. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32118. /**
  32119. * Creates a raw texture
  32120. * @param data defines the data to store in the texture
  32121. * @param width defines the width of the texture
  32122. * @param height defines the height of the texture
  32123. * @param format defines the format of the data
  32124. * @param generateMipMaps defines if the engine should generate the mip levels
  32125. * @param invertY defines if data must be stored with Y axis inverted
  32126. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32127. * @param compression defines the compression used (null by default)
  32128. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32129. * @returns the raw texture inside an InternalTexture
  32130. */
  32131. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32132. /**
  32133. * Creates a new raw cube texture
  32134. * @param data defines the array of data to use to create each face
  32135. * @param size defines the size of the textures
  32136. * @param format defines the format of the data
  32137. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32138. * @param generateMipMaps defines if the engine should generate the mip levels
  32139. * @param invertY defines if data must be stored with Y axis inverted
  32140. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32141. * @param compression defines the compression used (null by default)
  32142. * @returns the cube texture as an InternalTexture
  32143. */
  32144. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32145. /**
  32146. * Creates a new raw 3D texture
  32147. * @param data defines the data used to create the texture
  32148. * @param width defines the width of the texture
  32149. * @param height defines the height of the texture
  32150. * @param depth defines the depth of the texture
  32151. * @param format defines the format of the texture
  32152. * @param generateMipMaps defines if the engine must generate mip levels
  32153. * @param invertY defines if data must be stored with Y axis inverted
  32154. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32155. * @param compression defines the compressed used (can be null)
  32156. * @param textureType defines the compressed used (can be null)
  32157. * @returns a new raw 3D texture (stored in an InternalTexture)
  32158. */
  32159. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32160. /**
  32161. * Creates a new raw 2D array texture
  32162. * @param data defines the data used to create the texture
  32163. * @param width defines the width of the texture
  32164. * @param height defines the height of the texture
  32165. * @param depth defines the number of layers of the texture
  32166. * @param format defines the format of the texture
  32167. * @param generateMipMaps defines if the engine must generate mip levels
  32168. * @param invertY defines if data must be stored with Y axis inverted
  32169. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32170. * @param compression defines the compressed used (can be null)
  32171. * @param textureType defines the compressed used (can be null)
  32172. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32173. */
  32174. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32175. private _unpackFlipYCached;
  32176. /**
  32177. * In case you are sharing the context with other applications, it might
  32178. * be interested to not cache the unpack flip y state to ensure a consistent
  32179. * value would be set.
  32180. */
  32181. enableUnpackFlipYCached: boolean;
  32182. /** @hidden */
  32183. _unpackFlipY(value: boolean): void;
  32184. /** @hidden */
  32185. _getUnpackAlignement(): number;
  32186. private _getTextureTarget;
  32187. /**
  32188. * Update the sampling mode of a given texture
  32189. * @param samplingMode defines the required sampling mode
  32190. * @param texture defines the texture to update
  32191. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32192. */
  32193. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32194. /**
  32195. * Update the sampling mode of a given texture
  32196. * @param texture defines the texture to update
  32197. * @param wrapU defines the texture wrap mode of the u coordinates
  32198. * @param wrapV defines the texture wrap mode of the v coordinates
  32199. * @param wrapR defines the texture wrap mode of the r coordinates
  32200. */
  32201. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32202. /** @hidden */
  32203. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32204. width: number;
  32205. height: number;
  32206. layers?: number;
  32207. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32208. /** @hidden */
  32209. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32210. /** @hidden */
  32211. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32212. /**
  32213. * Update a portion of an internal texture
  32214. * @param texture defines the texture to update
  32215. * @param imageData defines the data to store into the texture
  32216. * @param xOffset defines the x coordinates of the update rectangle
  32217. * @param yOffset defines the y coordinates of the update rectangle
  32218. * @param width defines the width of the update rectangle
  32219. * @param height defines the height of the update rectangle
  32220. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32221. * @param lod defines the lod level to update (0 by default)
  32222. */
  32223. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32224. /** @hidden */
  32225. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32226. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32227. private _prepareWebGLTexture;
  32228. /** @hidden */
  32229. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32230. private _getDepthStencilBuffer;
  32231. /** @hidden */
  32232. _releaseFramebufferObjects(texture: InternalTexture): void;
  32233. /** @hidden */
  32234. _releaseTexture(texture: InternalTexture): void;
  32235. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32236. protected _setProgram(program: WebGLProgram): void;
  32237. protected _boundUniforms: {
  32238. [key: number]: WebGLUniformLocation;
  32239. };
  32240. /**
  32241. * Binds an effect to the webGL context
  32242. * @param effect defines the effect to bind
  32243. */
  32244. bindSamplers(effect: Effect): void;
  32245. private _activateCurrentTexture;
  32246. /** @hidden */
  32247. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32248. /** @hidden */
  32249. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32250. /**
  32251. * Unbind all textures from the webGL context
  32252. */
  32253. unbindAllTextures(): void;
  32254. /**
  32255. * Sets a texture to the according uniform.
  32256. * @param channel The texture channel
  32257. * @param uniform The uniform to set
  32258. * @param texture The texture to apply
  32259. */
  32260. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32261. private _bindSamplerUniformToChannel;
  32262. private _getTextureWrapMode;
  32263. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32264. /**
  32265. * Sets an array of texture to the webGL context
  32266. * @param channel defines the channel where the texture array must be set
  32267. * @param uniform defines the associated uniform location
  32268. * @param textures defines the array of textures to bind
  32269. */
  32270. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32271. /** @hidden */
  32272. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32273. private _setTextureParameterFloat;
  32274. private _setTextureParameterInteger;
  32275. /**
  32276. * Unbind all vertex attributes from the webGL context
  32277. */
  32278. unbindAllAttributes(): void;
  32279. /**
  32280. * 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
  32281. */
  32282. releaseEffects(): void;
  32283. /**
  32284. * Dispose and release all associated resources
  32285. */
  32286. dispose(): void;
  32287. /**
  32288. * Attach a new callback raised when context lost event is fired
  32289. * @param callback defines the callback to call
  32290. */
  32291. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32292. /**
  32293. * Attach a new callback raised when context restored event is fired
  32294. * @param callback defines the callback to call
  32295. */
  32296. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32297. /**
  32298. * Get the current error code of the webGL context
  32299. * @returns the error code
  32300. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32301. */
  32302. getError(): number;
  32303. private _canRenderToFloatFramebuffer;
  32304. private _canRenderToHalfFloatFramebuffer;
  32305. private _canRenderToFramebuffer;
  32306. /** @hidden */
  32307. _getWebGLTextureType(type: number): number;
  32308. /** @hidden */
  32309. _getInternalFormat(format: number): number;
  32310. /** @hidden */
  32311. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32312. /** @hidden */
  32313. _getRGBAMultiSampleBufferFormat(type: number): number;
  32314. /** @hidden */
  32315. _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;
  32316. /**
  32317. * Loads a file from a url
  32318. * @param url url to load
  32319. * @param onSuccess callback called when the file successfully loads
  32320. * @param onProgress callback called while file is loading (if the server supports this mode)
  32321. * @param offlineProvider defines the offline provider for caching
  32322. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32323. * @param onError callback called when the file fails to load
  32324. * @returns a file request object
  32325. * @hidden
  32326. */
  32327. 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;
  32328. /**
  32329. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32330. * @param x defines the x coordinate of the rectangle where pixels must be read
  32331. * @param y defines the y coordinate of the rectangle where pixels must be read
  32332. * @param width defines the width of the rectangle where pixels must be read
  32333. * @param height defines the height of the rectangle where pixels must be read
  32334. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32335. * @returns a Uint8Array containing RGBA colors
  32336. */
  32337. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32338. private static _isSupported;
  32339. /**
  32340. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32341. * @returns true if the engine can be created
  32342. * @ignorenaming
  32343. */
  32344. static isSupported(): boolean;
  32345. /**
  32346. * Find the next highest power of two.
  32347. * @param x Number to start search from.
  32348. * @return Next highest power of two.
  32349. */
  32350. static CeilingPOT(x: number): number;
  32351. /**
  32352. * Find the next lowest power of two.
  32353. * @param x Number to start search from.
  32354. * @return Next lowest power of two.
  32355. */
  32356. static FloorPOT(x: number): number;
  32357. /**
  32358. * Find the nearest power of two.
  32359. * @param x Number to start search from.
  32360. * @return Next nearest power of two.
  32361. */
  32362. static NearestPOT(x: number): number;
  32363. /**
  32364. * Get the closest exponent of two
  32365. * @param value defines the value to approximate
  32366. * @param max defines the maximum value to return
  32367. * @param mode defines how to define the closest value
  32368. * @returns closest exponent of two of the given value
  32369. */
  32370. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32371. /**
  32372. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32373. * @param func - the function to be called
  32374. * @param requester - the object that will request the next frame. Falls back to window.
  32375. * @returns frame number
  32376. */
  32377. static QueueNewFrame(func: () => void, requester?: any): number;
  32378. /**
  32379. * Gets host document
  32380. * @returns the host document object
  32381. */
  32382. getHostDocument(): Nullable<Document>;
  32383. }
  32384. }
  32385. declare module BABYLON {
  32386. /**
  32387. * Class representing spherical harmonics coefficients to the 3rd degree
  32388. */
  32389. export class SphericalHarmonics {
  32390. /**
  32391. * Defines whether or not the harmonics have been prescaled for rendering.
  32392. */
  32393. preScaled: boolean;
  32394. /**
  32395. * The l0,0 coefficients of the spherical harmonics
  32396. */
  32397. l00: Vector3;
  32398. /**
  32399. * The l1,-1 coefficients of the spherical harmonics
  32400. */
  32401. l1_1: Vector3;
  32402. /**
  32403. * The l1,0 coefficients of the spherical harmonics
  32404. */
  32405. l10: Vector3;
  32406. /**
  32407. * The l1,1 coefficients of the spherical harmonics
  32408. */
  32409. l11: Vector3;
  32410. /**
  32411. * The l2,-2 coefficients of the spherical harmonics
  32412. */
  32413. l2_2: Vector3;
  32414. /**
  32415. * The l2,-1 coefficients of the spherical harmonics
  32416. */
  32417. l2_1: Vector3;
  32418. /**
  32419. * The l2,0 coefficients of the spherical harmonics
  32420. */
  32421. l20: Vector3;
  32422. /**
  32423. * The l2,1 coefficients of the spherical harmonics
  32424. */
  32425. l21: Vector3;
  32426. /**
  32427. * The l2,2 coefficients of the spherical harmonics
  32428. */
  32429. l22: Vector3;
  32430. /**
  32431. * Adds a light to the spherical harmonics
  32432. * @param direction the direction of the light
  32433. * @param color the color of the light
  32434. * @param deltaSolidAngle the delta solid angle of the light
  32435. */
  32436. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32437. /**
  32438. * Scales the spherical harmonics by the given amount
  32439. * @param scale the amount to scale
  32440. */
  32441. scaleInPlace(scale: number): void;
  32442. /**
  32443. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32444. *
  32445. * ```
  32446. * E_lm = A_l * L_lm
  32447. * ```
  32448. *
  32449. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32450. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32451. * the scaling factors are given in equation 9.
  32452. */
  32453. convertIncidentRadianceToIrradiance(): void;
  32454. /**
  32455. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32456. *
  32457. * ```
  32458. * L = (1/pi) * E * rho
  32459. * ```
  32460. *
  32461. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32462. */
  32463. convertIrradianceToLambertianRadiance(): void;
  32464. /**
  32465. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32466. * required operations at run time.
  32467. *
  32468. * This is simply done by scaling back the SH with Ylm constants parameter.
  32469. * The trigonometric part being applied by the shader at run time.
  32470. */
  32471. preScaleForRendering(): void;
  32472. /**
  32473. * Constructs a spherical harmonics from an array.
  32474. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32475. * @returns the spherical harmonics
  32476. */
  32477. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32478. /**
  32479. * Gets the spherical harmonics from polynomial
  32480. * @param polynomial the spherical polynomial
  32481. * @returns the spherical harmonics
  32482. */
  32483. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32484. }
  32485. /**
  32486. * Class representing spherical polynomial coefficients to the 3rd degree
  32487. */
  32488. export class SphericalPolynomial {
  32489. private _harmonics;
  32490. /**
  32491. * The spherical harmonics used to create the polynomials.
  32492. */
  32493. get preScaledHarmonics(): SphericalHarmonics;
  32494. /**
  32495. * The x coefficients of the spherical polynomial
  32496. */
  32497. x: Vector3;
  32498. /**
  32499. * The y coefficients of the spherical polynomial
  32500. */
  32501. y: Vector3;
  32502. /**
  32503. * The z coefficients of the spherical polynomial
  32504. */
  32505. z: Vector3;
  32506. /**
  32507. * The xx coefficients of the spherical polynomial
  32508. */
  32509. xx: Vector3;
  32510. /**
  32511. * The yy coefficients of the spherical polynomial
  32512. */
  32513. yy: Vector3;
  32514. /**
  32515. * The zz coefficients of the spherical polynomial
  32516. */
  32517. zz: Vector3;
  32518. /**
  32519. * The xy coefficients of the spherical polynomial
  32520. */
  32521. xy: Vector3;
  32522. /**
  32523. * The yz coefficients of the spherical polynomial
  32524. */
  32525. yz: Vector3;
  32526. /**
  32527. * The zx coefficients of the spherical polynomial
  32528. */
  32529. zx: Vector3;
  32530. /**
  32531. * Adds an ambient color to the spherical polynomial
  32532. * @param color the color to add
  32533. */
  32534. addAmbient(color: Color3): void;
  32535. /**
  32536. * Scales the spherical polynomial by the given amount
  32537. * @param scale the amount to scale
  32538. */
  32539. scaleInPlace(scale: number): void;
  32540. /**
  32541. * Gets the spherical polynomial from harmonics
  32542. * @param harmonics the spherical harmonics
  32543. * @returns the spherical polynomial
  32544. */
  32545. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32546. /**
  32547. * Constructs a spherical polynomial from an array.
  32548. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32549. * @returns the spherical polynomial
  32550. */
  32551. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32552. }
  32553. }
  32554. declare module BABYLON {
  32555. /**
  32556. * Defines the source of the internal texture
  32557. */
  32558. export enum InternalTextureSource {
  32559. /**
  32560. * The source of the texture data is unknown
  32561. */
  32562. Unknown = 0,
  32563. /**
  32564. * Texture data comes from an URL
  32565. */
  32566. Url = 1,
  32567. /**
  32568. * Texture data is only used for temporary storage
  32569. */
  32570. Temp = 2,
  32571. /**
  32572. * Texture data comes from raw data (ArrayBuffer)
  32573. */
  32574. Raw = 3,
  32575. /**
  32576. * Texture content is dynamic (video or dynamic texture)
  32577. */
  32578. Dynamic = 4,
  32579. /**
  32580. * Texture content is generated by rendering to it
  32581. */
  32582. RenderTarget = 5,
  32583. /**
  32584. * Texture content is part of a multi render target process
  32585. */
  32586. MultiRenderTarget = 6,
  32587. /**
  32588. * Texture data comes from a cube data file
  32589. */
  32590. Cube = 7,
  32591. /**
  32592. * Texture data comes from a raw cube data
  32593. */
  32594. CubeRaw = 8,
  32595. /**
  32596. * Texture data come from a prefiltered cube data file
  32597. */
  32598. CubePrefiltered = 9,
  32599. /**
  32600. * Texture content is raw 3D data
  32601. */
  32602. Raw3D = 10,
  32603. /**
  32604. * Texture content is raw 2D array data
  32605. */
  32606. Raw2DArray = 11,
  32607. /**
  32608. * Texture content is a depth texture
  32609. */
  32610. Depth = 12,
  32611. /**
  32612. * Texture data comes from a raw cube data encoded with RGBD
  32613. */
  32614. CubeRawRGBD = 13
  32615. }
  32616. /**
  32617. * Class used to store data associated with WebGL texture data for the engine
  32618. * This class should not be used directly
  32619. */
  32620. export class InternalTexture {
  32621. /** @hidden */
  32622. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32623. /**
  32624. * Defines if the texture is ready
  32625. */
  32626. isReady: boolean;
  32627. /**
  32628. * Defines if the texture is a cube texture
  32629. */
  32630. isCube: boolean;
  32631. /**
  32632. * Defines if the texture contains 3D data
  32633. */
  32634. is3D: boolean;
  32635. /**
  32636. * Defines if the texture contains 2D array data
  32637. */
  32638. is2DArray: boolean;
  32639. /**
  32640. * Defines if the texture contains multiview data
  32641. */
  32642. isMultiview: boolean;
  32643. /**
  32644. * Gets the URL used to load this texture
  32645. */
  32646. url: string;
  32647. /**
  32648. * Gets the sampling mode of the texture
  32649. */
  32650. samplingMode: number;
  32651. /**
  32652. * Gets a boolean indicating if the texture needs mipmaps generation
  32653. */
  32654. generateMipMaps: boolean;
  32655. /**
  32656. * Gets the number of samples used by the texture (WebGL2+ only)
  32657. */
  32658. samples: number;
  32659. /**
  32660. * Gets the type of the texture (int, float...)
  32661. */
  32662. type: number;
  32663. /**
  32664. * Gets the format of the texture (RGB, RGBA...)
  32665. */
  32666. format: number;
  32667. /**
  32668. * Observable called when the texture is loaded
  32669. */
  32670. onLoadedObservable: Observable<InternalTexture>;
  32671. /**
  32672. * Gets the width of the texture
  32673. */
  32674. width: number;
  32675. /**
  32676. * Gets the height of the texture
  32677. */
  32678. height: number;
  32679. /**
  32680. * Gets the depth of the texture
  32681. */
  32682. depth: number;
  32683. /**
  32684. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32685. */
  32686. baseWidth: number;
  32687. /**
  32688. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32689. */
  32690. baseHeight: number;
  32691. /**
  32692. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32693. */
  32694. baseDepth: number;
  32695. /**
  32696. * Gets a boolean indicating if the texture is inverted on Y axis
  32697. */
  32698. invertY: boolean;
  32699. /** @hidden */
  32700. _invertVScale: boolean;
  32701. /** @hidden */
  32702. _associatedChannel: number;
  32703. /** @hidden */
  32704. _source: InternalTextureSource;
  32705. /** @hidden */
  32706. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32707. /** @hidden */
  32708. _bufferView: Nullable<ArrayBufferView>;
  32709. /** @hidden */
  32710. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32711. /** @hidden */
  32712. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32713. /** @hidden */
  32714. _size: number;
  32715. /** @hidden */
  32716. _extension: string;
  32717. /** @hidden */
  32718. _files: Nullable<string[]>;
  32719. /** @hidden */
  32720. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32721. /** @hidden */
  32722. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32723. /** @hidden */
  32724. _framebuffer: Nullable<WebGLFramebuffer>;
  32725. /** @hidden */
  32726. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32727. /** @hidden */
  32728. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32729. /** @hidden */
  32730. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32731. /** @hidden */
  32732. _attachments: Nullable<number[]>;
  32733. /** @hidden */
  32734. _cachedCoordinatesMode: Nullable<number>;
  32735. /** @hidden */
  32736. _cachedWrapU: Nullable<number>;
  32737. /** @hidden */
  32738. _cachedWrapV: Nullable<number>;
  32739. /** @hidden */
  32740. _cachedWrapR: Nullable<number>;
  32741. /** @hidden */
  32742. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32743. /** @hidden */
  32744. _isDisabled: boolean;
  32745. /** @hidden */
  32746. _compression: Nullable<string>;
  32747. /** @hidden */
  32748. _generateStencilBuffer: boolean;
  32749. /** @hidden */
  32750. _generateDepthBuffer: boolean;
  32751. /** @hidden */
  32752. _comparisonFunction: number;
  32753. /** @hidden */
  32754. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32755. /** @hidden */
  32756. _lodGenerationScale: number;
  32757. /** @hidden */
  32758. _lodGenerationOffset: number;
  32759. /** @hidden */
  32760. _depthStencilTexture: Nullable<InternalTexture>;
  32761. /** @hidden */
  32762. _colorTextureArray: Nullable<WebGLTexture>;
  32763. /** @hidden */
  32764. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32765. /** @hidden */
  32766. _lodTextureHigh: Nullable<BaseTexture>;
  32767. /** @hidden */
  32768. _lodTextureMid: Nullable<BaseTexture>;
  32769. /** @hidden */
  32770. _lodTextureLow: Nullable<BaseTexture>;
  32771. /** @hidden */
  32772. _isRGBD: boolean;
  32773. /** @hidden */
  32774. _linearSpecularLOD: boolean;
  32775. /** @hidden */
  32776. _irradianceTexture: Nullable<BaseTexture>;
  32777. /** @hidden */
  32778. _webGLTexture: Nullable<WebGLTexture>;
  32779. /** @hidden */
  32780. _references: number;
  32781. private _engine;
  32782. /**
  32783. * Gets the Engine the texture belongs to.
  32784. * @returns The babylon engine
  32785. */
  32786. getEngine(): ThinEngine;
  32787. /**
  32788. * Gets the data source type of the texture
  32789. */
  32790. get source(): InternalTextureSource;
  32791. /**
  32792. * Creates a new InternalTexture
  32793. * @param engine defines the engine to use
  32794. * @param source defines the type of data that will be used
  32795. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32796. */
  32797. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32798. /**
  32799. * Increments the number of references (ie. the number of Texture that point to it)
  32800. */
  32801. incrementReferences(): void;
  32802. /**
  32803. * Change the size of the texture (not the size of the content)
  32804. * @param width defines the new width
  32805. * @param height defines the new height
  32806. * @param depth defines the new depth (1 by default)
  32807. */
  32808. updateSize(width: int, height: int, depth?: int): void;
  32809. /** @hidden */
  32810. _rebuild(): void;
  32811. /** @hidden */
  32812. _swapAndDie(target: InternalTexture): void;
  32813. /**
  32814. * Dispose the current allocated resources
  32815. */
  32816. dispose(): void;
  32817. }
  32818. }
  32819. declare module BABYLON {
  32820. /**
  32821. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32822. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32823. */
  32824. export class Analyser {
  32825. /**
  32826. * Gets or sets the smoothing
  32827. * @ignorenaming
  32828. */
  32829. SMOOTHING: number;
  32830. /**
  32831. * Gets or sets the FFT table size
  32832. * @ignorenaming
  32833. */
  32834. FFT_SIZE: number;
  32835. /**
  32836. * Gets or sets the bar graph amplitude
  32837. * @ignorenaming
  32838. */
  32839. BARGRAPHAMPLITUDE: number;
  32840. /**
  32841. * Gets or sets the position of the debug canvas
  32842. * @ignorenaming
  32843. */
  32844. DEBUGCANVASPOS: {
  32845. x: number;
  32846. y: number;
  32847. };
  32848. /**
  32849. * Gets or sets the debug canvas size
  32850. * @ignorenaming
  32851. */
  32852. DEBUGCANVASSIZE: {
  32853. width: number;
  32854. height: number;
  32855. };
  32856. private _byteFreqs;
  32857. private _byteTime;
  32858. private _floatFreqs;
  32859. private _webAudioAnalyser;
  32860. private _debugCanvas;
  32861. private _debugCanvasContext;
  32862. private _scene;
  32863. private _registerFunc;
  32864. private _audioEngine;
  32865. /**
  32866. * Creates a new analyser
  32867. * @param scene defines hosting scene
  32868. */
  32869. constructor(scene: Scene);
  32870. /**
  32871. * Get the number of data values you will have to play with for the visualization
  32872. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32873. * @returns a number
  32874. */
  32875. getFrequencyBinCount(): number;
  32876. /**
  32877. * Gets the current frequency data as a byte array
  32878. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32879. * @returns a Uint8Array
  32880. */
  32881. getByteFrequencyData(): Uint8Array;
  32882. /**
  32883. * Gets the current waveform as a byte array
  32884. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32885. * @returns a Uint8Array
  32886. */
  32887. getByteTimeDomainData(): Uint8Array;
  32888. /**
  32889. * Gets the current frequency data as a float array
  32890. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32891. * @returns a Float32Array
  32892. */
  32893. getFloatFrequencyData(): Float32Array;
  32894. /**
  32895. * Renders the debug canvas
  32896. */
  32897. drawDebugCanvas(): void;
  32898. /**
  32899. * Stops rendering the debug canvas and removes it
  32900. */
  32901. stopDebugCanvas(): void;
  32902. /**
  32903. * Connects two audio nodes
  32904. * @param inputAudioNode defines first node to connect
  32905. * @param outputAudioNode defines second node to connect
  32906. */
  32907. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32908. /**
  32909. * Releases all associated resources
  32910. */
  32911. dispose(): void;
  32912. }
  32913. }
  32914. declare module BABYLON {
  32915. /**
  32916. * This represents an audio engine and it is responsible
  32917. * to play, synchronize and analyse sounds throughout the application.
  32918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32919. */
  32920. export interface IAudioEngine extends IDisposable {
  32921. /**
  32922. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32923. */
  32924. readonly canUseWebAudio: boolean;
  32925. /**
  32926. * Gets the current AudioContext if available.
  32927. */
  32928. readonly audioContext: Nullable<AudioContext>;
  32929. /**
  32930. * The master gain node defines the global audio volume of your audio engine.
  32931. */
  32932. readonly masterGain: GainNode;
  32933. /**
  32934. * Gets whether or not mp3 are supported by your browser.
  32935. */
  32936. readonly isMP3supported: boolean;
  32937. /**
  32938. * Gets whether or not ogg are supported by your browser.
  32939. */
  32940. readonly isOGGsupported: boolean;
  32941. /**
  32942. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32943. * @ignoreNaming
  32944. */
  32945. WarnedWebAudioUnsupported: boolean;
  32946. /**
  32947. * Defines if the audio engine relies on a custom unlocked button.
  32948. * In this case, the embedded button will not be displayed.
  32949. */
  32950. useCustomUnlockedButton: boolean;
  32951. /**
  32952. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32953. */
  32954. readonly unlocked: boolean;
  32955. /**
  32956. * Event raised when audio has been unlocked on the browser.
  32957. */
  32958. onAudioUnlockedObservable: Observable<AudioEngine>;
  32959. /**
  32960. * Event raised when audio has been locked on the browser.
  32961. */
  32962. onAudioLockedObservable: Observable<AudioEngine>;
  32963. /**
  32964. * Flags the audio engine in Locked state.
  32965. * This happens due to new browser policies preventing audio to autoplay.
  32966. */
  32967. lock(): void;
  32968. /**
  32969. * Unlocks the audio engine once a user action has been done on the dom.
  32970. * This is helpful to resume play once browser policies have been satisfied.
  32971. */
  32972. unlock(): void;
  32973. /**
  32974. * Gets the global volume sets on the master gain.
  32975. * @returns the global volume if set or -1 otherwise
  32976. */
  32977. getGlobalVolume(): number;
  32978. /**
  32979. * Sets the global volume of your experience (sets on the master gain).
  32980. * @param newVolume Defines the new global volume of the application
  32981. */
  32982. setGlobalVolume(newVolume: number): void;
  32983. /**
  32984. * Connect the audio engine to an audio analyser allowing some amazing
  32985. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32987. * @param analyser The analyser to connect to the engine
  32988. */
  32989. connectToAnalyser(analyser: Analyser): void;
  32990. }
  32991. /**
  32992. * This represents the default audio engine used in babylon.
  32993. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32994. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32995. */
  32996. export class AudioEngine implements IAudioEngine {
  32997. private _audioContext;
  32998. private _audioContextInitialized;
  32999. private _muteButton;
  33000. private _hostElement;
  33001. /**
  33002. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33003. */
  33004. canUseWebAudio: boolean;
  33005. /**
  33006. * The master gain node defines the global audio volume of your audio engine.
  33007. */
  33008. masterGain: GainNode;
  33009. /**
  33010. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33011. * @ignoreNaming
  33012. */
  33013. WarnedWebAudioUnsupported: boolean;
  33014. /**
  33015. * Gets whether or not mp3 are supported by your browser.
  33016. */
  33017. isMP3supported: boolean;
  33018. /**
  33019. * Gets whether or not ogg are supported by your browser.
  33020. */
  33021. isOGGsupported: boolean;
  33022. /**
  33023. * Gets whether audio has been unlocked on the device.
  33024. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33025. * a user interaction has happened.
  33026. */
  33027. unlocked: boolean;
  33028. /**
  33029. * Defines if the audio engine relies on a custom unlocked button.
  33030. * In this case, the embedded button will not be displayed.
  33031. */
  33032. useCustomUnlockedButton: boolean;
  33033. /**
  33034. * Event raised when audio has been unlocked on the browser.
  33035. */
  33036. onAudioUnlockedObservable: Observable<AudioEngine>;
  33037. /**
  33038. * Event raised when audio has been locked on the browser.
  33039. */
  33040. onAudioLockedObservable: Observable<AudioEngine>;
  33041. /**
  33042. * Gets the current AudioContext if available.
  33043. */
  33044. get audioContext(): Nullable<AudioContext>;
  33045. private _connectedAnalyser;
  33046. /**
  33047. * Instantiates a new audio engine.
  33048. *
  33049. * There should be only one per page as some browsers restrict the number
  33050. * of audio contexts you can create.
  33051. * @param hostElement defines the host element where to display the mute icon if necessary
  33052. */
  33053. constructor(hostElement?: Nullable<HTMLElement>);
  33054. /**
  33055. * Flags the audio engine in Locked state.
  33056. * This happens due to new browser policies preventing audio to autoplay.
  33057. */
  33058. lock(): void;
  33059. /**
  33060. * Unlocks the audio engine once a user action has been done on the dom.
  33061. * This is helpful to resume play once browser policies have been satisfied.
  33062. */
  33063. unlock(): void;
  33064. private _resumeAudioContext;
  33065. private _initializeAudioContext;
  33066. private _tryToRun;
  33067. private _triggerRunningState;
  33068. private _triggerSuspendedState;
  33069. private _displayMuteButton;
  33070. private _moveButtonToTopLeft;
  33071. private _onResize;
  33072. private _hideMuteButton;
  33073. /**
  33074. * Destroy and release the resources associated with the audio ccontext.
  33075. */
  33076. dispose(): void;
  33077. /**
  33078. * Gets the global volume sets on the master gain.
  33079. * @returns the global volume if set or -1 otherwise
  33080. */
  33081. getGlobalVolume(): number;
  33082. /**
  33083. * Sets the global volume of your experience (sets on the master gain).
  33084. * @param newVolume Defines the new global volume of the application
  33085. */
  33086. setGlobalVolume(newVolume: number): void;
  33087. /**
  33088. * Connect the audio engine to an audio analyser allowing some amazing
  33089. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33091. * @param analyser The analyser to connect to the engine
  33092. */
  33093. connectToAnalyser(analyser: Analyser): void;
  33094. }
  33095. }
  33096. declare module BABYLON {
  33097. /**
  33098. * Interface used to present a loading screen while loading a scene
  33099. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33100. */
  33101. export interface ILoadingScreen {
  33102. /**
  33103. * Function called to display the loading screen
  33104. */
  33105. displayLoadingUI: () => void;
  33106. /**
  33107. * Function called to hide the loading screen
  33108. */
  33109. hideLoadingUI: () => void;
  33110. /**
  33111. * Gets or sets the color to use for the background
  33112. */
  33113. loadingUIBackgroundColor: string;
  33114. /**
  33115. * Gets or sets the text to display while loading
  33116. */
  33117. loadingUIText: string;
  33118. }
  33119. /**
  33120. * Class used for the default loading screen
  33121. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33122. */
  33123. export class DefaultLoadingScreen implements ILoadingScreen {
  33124. private _renderingCanvas;
  33125. private _loadingText;
  33126. private _loadingDivBackgroundColor;
  33127. private _loadingDiv;
  33128. private _loadingTextDiv;
  33129. /** Gets or sets the logo url to use for the default loading screen */
  33130. static DefaultLogoUrl: string;
  33131. /** Gets or sets the spinner url to use for the default loading screen */
  33132. static DefaultSpinnerUrl: string;
  33133. /**
  33134. * Creates a new default loading screen
  33135. * @param _renderingCanvas defines the canvas used to render the scene
  33136. * @param _loadingText defines the default text to display
  33137. * @param _loadingDivBackgroundColor defines the default background color
  33138. */
  33139. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33140. /**
  33141. * Function called to display the loading screen
  33142. */
  33143. displayLoadingUI(): void;
  33144. /**
  33145. * Function called to hide the loading screen
  33146. */
  33147. hideLoadingUI(): void;
  33148. /**
  33149. * Gets or sets the text to display while loading
  33150. */
  33151. set loadingUIText(text: string);
  33152. get loadingUIText(): string;
  33153. /**
  33154. * Gets or sets the color to use for the background
  33155. */
  33156. get loadingUIBackgroundColor(): string;
  33157. set loadingUIBackgroundColor(color: string);
  33158. private _resizeLoadingUI;
  33159. }
  33160. }
  33161. declare module BABYLON {
  33162. /**
  33163. * Interface for any object that can request an animation frame
  33164. */
  33165. export interface ICustomAnimationFrameRequester {
  33166. /**
  33167. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33168. */
  33169. renderFunction?: Function;
  33170. /**
  33171. * Called to request the next frame to render to
  33172. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33173. */
  33174. requestAnimationFrame: Function;
  33175. /**
  33176. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33177. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33178. */
  33179. requestID?: number;
  33180. }
  33181. }
  33182. declare module BABYLON {
  33183. /**
  33184. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33185. */
  33186. export class PerformanceMonitor {
  33187. private _enabled;
  33188. private _rollingFrameTime;
  33189. private _lastFrameTimeMs;
  33190. /**
  33191. * constructor
  33192. * @param frameSampleSize The number of samples required to saturate the sliding window
  33193. */
  33194. constructor(frameSampleSize?: number);
  33195. /**
  33196. * Samples current frame
  33197. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33198. */
  33199. sampleFrame(timeMs?: number): void;
  33200. /**
  33201. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33202. */
  33203. get averageFrameTime(): number;
  33204. /**
  33205. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33206. */
  33207. get averageFrameTimeVariance(): number;
  33208. /**
  33209. * Returns the frame time of the most recent frame
  33210. */
  33211. get instantaneousFrameTime(): number;
  33212. /**
  33213. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33214. */
  33215. get averageFPS(): number;
  33216. /**
  33217. * Returns the average framerate in frames per second using the most recent frame time
  33218. */
  33219. get instantaneousFPS(): number;
  33220. /**
  33221. * Returns true if enough samples have been taken to completely fill the sliding window
  33222. */
  33223. get isSaturated(): boolean;
  33224. /**
  33225. * Enables contributions to the sliding window sample set
  33226. */
  33227. enable(): void;
  33228. /**
  33229. * Disables contributions to the sliding window sample set
  33230. * Samples will not be interpolated over the disabled period
  33231. */
  33232. disable(): void;
  33233. /**
  33234. * Returns true if sampling is enabled
  33235. */
  33236. get isEnabled(): boolean;
  33237. /**
  33238. * Resets performance monitor
  33239. */
  33240. reset(): void;
  33241. }
  33242. /**
  33243. * RollingAverage
  33244. *
  33245. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33246. */
  33247. export class RollingAverage {
  33248. /**
  33249. * Current average
  33250. */
  33251. average: number;
  33252. /**
  33253. * Current variance
  33254. */
  33255. variance: number;
  33256. protected _samples: Array<number>;
  33257. protected _sampleCount: number;
  33258. protected _pos: number;
  33259. protected _m2: number;
  33260. /**
  33261. * constructor
  33262. * @param length The number of samples required to saturate the sliding window
  33263. */
  33264. constructor(length: number);
  33265. /**
  33266. * Adds a sample to the sample set
  33267. * @param v The sample value
  33268. */
  33269. add(v: number): void;
  33270. /**
  33271. * Returns previously added values or null if outside of history or outside the sliding window domain
  33272. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33273. * @return Value previously recorded with add() or null if outside of range
  33274. */
  33275. history(i: number): number;
  33276. /**
  33277. * Returns true if enough samples have been taken to completely fill the sliding window
  33278. * @return true if sample-set saturated
  33279. */
  33280. isSaturated(): boolean;
  33281. /**
  33282. * Resets the rolling average (equivalent to 0 samples taken so far)
  33283. */
  33284. reset(): void;
  33285. /**
  33286. * Wraps a value around the sample range boundaries
  33287. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33288. * @return Wrapped position in sample range
  33289. */
  33290. protected _wrapPosition(i: number): number;
  33291. }
  33292. }
  33293. declare module BABYLON {
  33294. /**
  33295. * This class is used to track a performance counter which is number based.
  33296. * The user has access to many properties which give statistics of different nature.
  33297. *
  33298. * The implementer can track two kinds of Performance Counter: time and count.
  33299. * 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.
  33300. * 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.
  33301. */
  33302. export class PerfCounter {
  33303. /**
  33304. * Gets or sets a global boolean to turn on and off all the counters
  33305. */
  33306. static Enabled: boolean;
  33307. /**
  33308. * Returns the smallest value ever
  33309. */
  33310. get min(): number;
  33311. /**
  33312. * Returns the biggest value ever
  33313. */
  33314. get max(): number;
  33315. /**
  33316. * Returns the average value since the performance counter is running
  33317. */
  33318. get average(): number;
  33319. /**
  33320. * Returns the average value of the last second the counter was monitored
  33321. */
  33322. get lastSecAverage(): number;
  33323. /**
  33324. * Returns the current value
  33325. */
  33326. get current(): number;
  33327. /**
  33328. * Gets the accumulated total
  33329. */
  33330. get total(): number;
  33331. /**
  33332. * Gets the total value count
  33333. */
  33334. get count(): number;
  33335. /**
  33336. * Creates a new counter
  33337. */
  33338. constructor();
  33339. /**
  33340. * Call this method to start monitoring a new frame.
  33341. * 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.
  33342. */
  33343. fetchNewFrame(): void;
  33344. /**
  33345. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33346. * @param newCount the count value to add to the monitored count
  33347. * @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.
  33348. */
  33349. addCount(newCount: number, fetchResult: boolean): void;
  33350. /**
  33351. * Start monitoring this performance counter
  33352. */
  33353. beginMonitoring(): void;
  33354. /**
  33355. * Compute the time lapsed since the previous beginMonitoring() call.
  33356. * @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
  33357. */
  33358. endMonitoring(newFrame?: boolean): void;
  33359. private _fetchResult;
  33360. private _startMonitoringTime;
  33361. private _min;
  33362. private _max;
  33363. private _average;
  33364. private _current;
  33365. private _totalValueCount;
  33366. private _totalAccumulated;
  33367. private _lastSecAverage;
  33368. private _lastSecAccumulated;
  33369. private _lastSecTime;
  33370. private _lastSecValueCount;
  33371. }
  33372. }
  33373. declare module BABYLON {
  33374. interface ThinEngine {
  33375. /**
  33376. * Sets alpha constants used by some alpha blending modes
  33377. * @param r defines the red component
  33378. * @param g defines the green component
  33379. * @param b defines the blue component
  33380. * @param a defines the alpha component
  33381. */
  33382. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33383. /**
  33384. * Sets the current alpha mode
  33385. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33386. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33387. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33388. */
  33389. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33390. /**
  33391. * Gets the current alpha mode
  33392. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33393. * @returns the current alpha mode
  33394. */
  33395. getAlphaMode(): number;
  33396. /**
  33397. * Sets the current alpha equation
  33398. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33399. */
  33400. setAlphaEquation(equation: number): void;
  33401. /**
  33402. * Gets the current alpha equation.
  33403. * @returns the current alpha equation
  33404. */
  33405. getAlphaEquation(): number;
  33406. }
  33407. }
  33408. declare module BABYLON {
  33409. /**
  33410. * Defines the interface used by display changed events
  33411. */
  33412. export interface IDisplayChangedEventArgs {
  33413. /** Gets the vrDisplay object (if any) */
  33414. vrDisplay: Nullable<any>;
  33415. /** Gets a boolean indicating if webVR is supported */
  33416. vrSupported: boolean;
  33417. }
  33418. /**
  33419. * Defines the interface used by objects containing a viewport (like a camera)
  33420. */
  33421. interface IViewportOwnerLike {
  33422. /**
  33423. * Gets or sets the viewport
  33424. */
  33425. viewport: IViewportLike;
  33426. }
  33427. /**
  33428. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33429. */
  33430. export class Engine extends ThinEngine {
  33431. /** Defines that alpha blending is disabled */
  33432. static readonly ALPHA_DISABLE: number;
  33433. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33434. static readonly ALPHA_ADD: number;
  33435. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33436. static readonly ALPHA_COMBINE: number;
  33437. /** Defines that alpha blending to DEST - SRC * DEST */
  33438. static readonly ALPHA_SUBTRACT: number;
  33439. /** Defines that alpha blending to SRC * DEST */
  33440. static readonly ALPHA_MULTIPLY: number;
  33441. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33442. static readonly ALPHA_MAXIMIZED: number;
  33443. /** Defines that alpha blending to SRC + DEST */
  33444. static readonly ALPHA_ONEONE: number;
  33445. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33446. static readonly ALPHA_PREMULTIPLIED: number;
  33447. /**
  33448. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33449. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33450. */
  33451. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33452. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33453. static readonly ALPHA_INTERPOLATE: number;
  33454. /**
  33455. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33456. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33457. */
  33458. static readonly ALPHA_SCREENMODE: number;
  33459. /** Defines that the ressource is not delayed*/
  33460. static readonly DELAYLOADSTATE_NONE: number;
  33461. /** Defines that the ressource was successfully delay loaded */
  33462. static readonly DELAYLOADSTATE_LOADED: number;
  33463. /** Defines that the ressource is currently delay loading */
  33464. static readonly DELAYLOADSTATE_LOADING: number;
  33465. /** Defines that the ressource is delayed and has not started loading */
  33466. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33467. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33468. static readonly NEVER: number;
  33469. /** 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 */
  33470. static readonly ALWAYS: number;
  33471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33472. static readonly LESS: number;
  33473. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33474. static readonly EQUAL: number;
  33475. /** 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 */
  33476. static readonly LEQUAL: number;
  33477. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33478. static readonly GREATER: number;
  33479. /** 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 */
  33480. static readonly GEQUAL: number;
  33481. /** 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 */
  33482. static readonly NOTEQUAL: number;
  33483. /** Passed to stencilOperation to specify that stencil value must be kept */
  33484. static readonly KEEP: number;
  33485. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33486. static readonly REPLACE: number;
  33487. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33488. static readonly INCR: number;
  33489. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33490. static readonly DECR: number;
  33491. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33492. static readonly INVERT: number;
  33493. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33494. static readonly INCR_WRAP: number;
  33495. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33496. static readonly DECR_WRAP: number;
  33497. /** Texture is not repeating outside of 0..1 UVs */
  33498. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33499. /** Texture is repeating outside of 0..1 UVs */
  33500. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33501. /** Texture is repeating and mirrored */
  33502. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33503. /** ALPHA */
  33504. static readonly TEXTUREFORMAT_ALPHA: number;
  33505. /** LUMINANCE */
  33506. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33507. /** LUMINANCE_ALPHA */
  33508. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33509. /** RGB */
  33510. static readonly TEXTUREFORMAT_RGB: number;
  33511. /** RGBA */
  33512. static readonly TEXTUREFORMAT_RGBA: number;
  33513. /** RED */
  33514. static readonly TEXTUREFORMAT_RED: number;
  33515. /** RED (2nd reference) */
  33516. static readonly TEXTUREFORMAT_R: number;
  33517. /** RG */
  33518. static readonly TEXTUREFORMAT_RG: number;
  33519. /** RED_INTEGER */
  33520. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33521. /** RED_INTEGER (2nd reference) */
  33522. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33523. /** RG_INTEGER */
  33524. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33525. /** RGB_INTEGER */
  33526. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33527. /** RGBA_INTEGER */
  33528. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33529. /** UNSIGNED_BYTE */
  33530. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33531. /** UNSIGNED_BYTE (2nd reference) */
  33532. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33533. /** FLOAT */
  33534. static readonly TEXTURETYPE_FLOAT: number;
  33535. /** HALF_FLOAT */
  33536. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33537. /** BYTE */
  33538. static readonly TEXTURETYPE_BYTE: number;
  33539. /** SHORT */
  33540. static readonly TEXTURETYPE_SHORT: number;
  33541. /** UNSIGNED_SHORT */
  33542. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33543. /** INT */
  33544. static readonly TEXTURETYPE_INT: number;
  33545. /** UNSIGNED_INT */
  33546. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33547. /** UNSIGNED_SHORT_4_4_4_4 */
  33548. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33549. /** UNSIGNED_SHORT_5_5_5_1 */
  33550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33551. /** UNSIGNED_SHORT_5_6_5 */
  33552. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33553. /** UNSIGNED_INT_2_10_10_10_REV */
  33554. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33555. /** UNSIGNED_INT_24_8 */
  33556. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33557. /** UNSIGNED_INT_10F_11F_11F_REV */
  33558. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33559. /** UNSIGNED_INT_5_9_9_9_REV */
  33560. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33561. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33562. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33563. /** nearest is mag = nearest and min = nearest and mip = linear */
  33564. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33565. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33566. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33567. /** Trilinear is mag = linear and min = linear and mip = linear */
  33568. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33569. /** nearest is mag = nearest and min = nearest and mip = linear */
  33570. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33571. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33572. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33573. /** Trilinear is mag = linear and min = linear and mip = linear */
  33574. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33575. /** mag = nearest and min = nearest and mip = nearest */
  33576. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33577. /** mag = nearest and min = linear and mip = nearest */
  33578. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33579. /** mag = nearest and min = linear and mip = linear */
  33580. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33581. /** mag = nearest and min = linear and mip = none */
  33582. static readonly TEXTURE_NEAREST_LINEAR: number;
  33583. /** mag = nearest and min = nearest and mip = none */
  33584. static readonly TEXTURE_NEAREST_NEAREST: number;
  33585. /** mag = linear and min = nearest and mip = nearest */
  33586. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33587. /** mag = linear and min = nearest and mip = linear */
  33588. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33589. /** mag = linear and min = linear and mip = none */
  33590. static readonly TEXTURE_LINEAR_LINEAR: number;
  33591. /** mag = linear and min = nearest and mip = none */
  33592. static readonly TEXTURE_LINEAR_NEAREST: number;
  33593. /** Explicit coordinates mode */
  33594. static readonly TEXTURE_EXPLICIT_MODE: number;
  33595. /** Spherical coordinates mode */
  33596. static readonly TEXTURE_SPHERICAL_MODE: number;
  33597. /** Planar coordinates mode */
  33598. static readonly TEXTURE_PLANAR_MODE: number;
  33599. /** Cubic coordinates mode */
  33600. static readonly TEXTURE_CUBIC_MODE: number;
  33601. /** Projection coordinates mode */
  33602. static readonly TEXTURE_PROJECTION_MODE: number;
  33603. /** Skybox coordinates mode */
  33604. static readonly TEXTURE_SKYBOX_MODE: number;
  33605. /** Inverse Cubic coordinates mode */
  33606. static readonly TEXTURE_INVCUBIC_MODE: number;
  33607. /** Equirectangular coordinates mode */
  33608. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33609. /** Equirectangular Fixed coordinates mode */
  33610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33611. /** Equirectangular Fixed Mirrored coordinates mode */
  33612. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33613. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33614. static readonly SCALEMODE_FLOOR: number;
  33615. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33616. static readonly SCALEMODE_NEAREST: number;
  33617. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33618. static readonly SCALEMODE_CEILING: number;
  33619. /**
  33620. * Returns the current npm package of the sdk
  33621. */
  33622. static get NpmPackage(): string;
  33623. /**
  33624. * Returns the current version of the framework
  33625. */
  33626. static get Version(): string;
  33627. /** Gets the list of created engines */
  33628. static get Instances(): Engine[];
  33629. /**
  33630. * Gets the latest created engine
  33631. */
  33632. static get LastCreatedEngine(): Nullable<Engine>;
  33633. /**
  33634. * Gets the latest created scene
  33635. */
  33636. static get LastCreatedScene(): Nullable<Scene>;
  33637. /**
  33638. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33639. * @param flag defines which part of the materials must be marked as dirty
  33640. * @param predicate defines a predicate used to filter which materials should be affected
  33641. */
  33642. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33643. /**
  33644. * Method called to create the default loading screen.
  33645. * This can be overriden in your own app.
  33646. * @param canvas The rendering canvas element
  33647. * @returns The loading screen
  33648. */
  33649. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33650. /**
  33651. * Method called to create the default rescale post process on each engine.
  33652. */
  33653. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33654. /**
  33655. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33656. **/
  33657. enableOfflineSupport: boolean;
  33658. /**
  33659. * 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)
  33660. **/
  33661. disableManifestCheck: boolean;
  33662. /**
  33663. * Gets the list of created scenes
  33664. */
  33665. scenes: Scene[];
  33666. /**
  33667. * Event raised when a new scene is created
  33668. */
  33669. onNewSceneAddedObservable: Observable<Scene>;
  33670. /**
  33671. * Gets the list of created postprocesses
  33672. */
  33673. postProcesses: PostProcess[];
  33674. /**
  33675. * Gets a boolean indicating if the pointer is currently locked
  33676. */
  33677. isPointerLock: boolean;
  33678. /**
  33679. * Observable event triggered each time the rendering canvas is resized
  33680. */
  33681. onResizeObservable: Observable<Engine>;
  33682. /**
  33683. * Observable event triggered each time the canvas loses focus
  33684. */
  33685. onCanvasBlurObservable: Observable<Engine>;
  33686. /**
  33687. * Observable event triggered each time the canvas gains focus
  33688. */
  33689. onCanvasFocusObservable: Observable<Engine>;
  33690. /**
  33691. * Observable event triggered each time the canvas receives pointerout event
  33692. */
  33693. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33694. /**
  33695. * Observable raised when the engine begins a new frame
  33696. */
  33697. onBeginFrameObservable: Observable<Engine>;
  33698. /**
  33699. * If set, will be used to request the next animation frame for the render loop
  33700. */
  33701. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33702. /**
  33703. * Observable raised when the engine ends the current frame
  33704. */
  33705. onEndFrameObservable: Observable<Engine>;
  33706. /**
  33707. * Observable raised when the engine is about to compile a shader
  33708. */
  33709. onBeforeShaderCompilationObservable: Observable<Engine>;
  33710. /**
  33711. * Observable raised when the engine has jsut compiled a shader
  33712. */
  33713. onAfterShaderCompilationObservable: Observable<Engine>;
  33714. /**
  33715. * Gets the audio engine
  33716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33717. * @ignorenaming
  33718. */
  33719. static audioEngine: IAudioEngine;
  33720. /**
  33721. * Default AudioEngine factory responsible of creating the Audio Engine.
  33722. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33723. */
  33724. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33725. /**
  33726. * Default offline support factory responsible of creating a tool used to store data locally.
  33727. * By default, this will create a Database object if the workload has been embedded.
  33728. */
  33729. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33730. private _loadingScreen;
  33731. private _pointerLockRequested;
  33732. private _dummyFramebuffer;
  33733. private _rescalePostProcess;
  33734. private _deterministicLockstep;
  33735. private _lockstepMaxSteps;
  33736. private _timeStep;
  33737. protected get _supportsHardwareTextureRescaling(): boolean;
  33738. private _fps;
  33739. private _deltaTime;
  33740. /** @hidden */
  33741. _drawCalls: PerfCounter;
  33742. /** 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 */
  33743. canvasTabIndex: number;
  33744. /**
  33745. * Turn this value on if you want to pause FPS computation when in background
  33746. */
  33747. disablePerformanceMonitorInBackground: boolean;
  33748. private _performanceMonitor;
  33749. /**
  33750. * Gets the performance monitor attached to this engine
  33751. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33752. */
  33753. get performanceMonitor(): PerformanceMonitor;
  33754. private _onFocus;
  33755. private _onBlur;
  33756. private _onCanvasPointerOut;
  33757. private _onCanvasBlur;
  33758. private _onCanvasFocus;
  33759. private _onFullscreenChange;
  33760. private _onPointerLockChange;
  33761. /**
  33762. * Gets the HTML element used to attach event listeners
  33763. * @returns a HTML element
  33764. */
  33765. getInputElement(): Nullable<HTMLElement>;
  33766. /**
  33767. * Creates a new engine
  33768. * @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
  33769. * @param antialias defines enable antialiasing (default: false)
  33770. * @param options defines further options to be sent to the getContext() function
  33771. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33772. */
  33773. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33774. /**
  33775. * Gets current aspect ratio
  33776. * @param viewportOwner defines the camera to use to get the aspect ratio
  33777. * @param useScreen defines if screen size must be used (or the current render target if any)
  33778. * @returns a number defining the aspect ratio
  33779. */
  33780. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33781. /**
  33782. * Gets current screen aspect ratio
  33783. * @returns a number defining the aspect ratio
  33784. */
  33785. getScreenAspectRatio(): number;
  33786. /**
  33787. * Gets the client rect of the HTML canvas attached with the current webGL context
  33788. * @returns a client rectanglee
  33789. */
  33790. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33791. /**
  33792. * Gets the client rect of the HTML element used for events
  33793. * @returns a client rectanglee
  33794. */
  33795. getInputElementClientRect(): Nullable<ClientRect>;
  33796. /**
  33797. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33798. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33799. * @returns true if engine is in deterministic lock step mode
  33800. */
  33801. isDeterministicLockStep(): boolean;
  33802. /**
  33803. * Gets the max steps when engine is running in deterministic lock step
  33804. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33805. * @returns the max steps
  33806. */
  33807. getLockstepMaxSteps(): number;
  33808. /**
  33809. * Returns the time in ms between steps when using deterministic lock step.
  33810. * @returns time step in (ms)
  33811. */
  33812. getTimeStep(): number;
  33813. /**
  33814. * Force the mipmap generation for the given render target texture
  33815. * @param texture defines the render target texture to use
  33816. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33817. */
  33818. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33819. /** States */
  33820. /**
  33821. * Set various states to the webGL context
  33822. * @param culling defines backface culling state
  33823. * @param zOffset defines the value to apply to zOffset (0 by default)
  33824. * @param force defines if states must be applied even if cache is up to date
  33825. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33826. */
  33827. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33828. /**
  33829. * Set the z offset to apply to current rendering
  33830. * @param value defines the offset to apply
  33831. */
  33832. setZOffset(value: number): void;
  33833. /**
  33834. * Gets the current value of the zOffset
  33835. * @returns the current zOffset state
  33836. */
  33837. getZOffset(): number;
  33838. /**
  33839. * Enable or disable depth buffering
  33840. * @param enable defines the state to set
  33841. */
  33842. setDepthBuffer(enable: boolean): void;
  33843. /**
  33844. * Gets a boolean indicating if depth writing is enabled
  33845. * @returns the current depth writing state
  33846. */
  33847. getDepthWrite(): boolean;
  33848. /**
  33849. * Enable or disable depth writing
  33850. * @param enable defines the state to set
  33851. */
  33852. setDepthWrite(enable: boolean): void;
  33853. /**
  33854. * Gets a boolean indicating if stencil buffer is enabled
  33855. * @returns the current stencil buffer state
  33856. */
  33857. getStencilBuffer(): boolean;
  33858. /**
  33859. * Enable or disable the stencil buffer
  33860. * @param enable defines if the stencil buffer must be enabled or disabled
  33861. */
  33862. setStencilBuffer(enable: boolean): void;
  33863. /**
  33864. * Gets the current stencil mask
  33865. * @returns a number defining the new stencil mask to use
  33866. */
  33867. getStencilMask(): number;
  33868. /**
  33869. * Sets the current stencil mask
  33870. * @param mask defines the new stencil mask to use
  33871. */
  33872. setStencilMask(mask: number): void;
  33873. /**
  33874. * Gets the current stencil function
  33875. * @returns a number defining the stencil function to use
  33876. */
  33877. getStencilFunction(): number;
  33878. /**
  33879. * Gets the current stencil reference value
  33880. * @returns a number defining the stencil reference value to use
  33881. */
  33882. getStencilFunctionReference(): number;
  33883. /**
  33884. * Gets the current stencil mask
  33885. * @returns a number defining the stencil mask to use
  33886. */
  33887. getStencilFunctionMask(): number;
  33888. /**
  33889. * Sets the current stencil function
  33890. * @param stencilFunc defines the new stencil function to use
  33891. */
  33892. setStencilFunction(stencilFunc: number): void;
  33893. /**
  33894. * Sets the current stencil reference
  33895. * @param reference defines the new stencil reference to use
  33896. */
  33897. setStencilFunctionReference(reference: number): void;
  33898. /**
  33899. * Sets the current stencil mask
  33900. * @param mask defines the new stencil mask to use
  33901. */
  33902. setStencilFunctionMask(mask: number): void;
  33903. /**
  33904. * Gets the current stencil operation when stencil fails
  33905. * @returns a number defining stencil operation to use when stencil fails
  33906. */
  33907. getStencilOperationFail(): number;
  33908. /**
  33909. * Gets the current stencil operation when depth fails
  33910. * @returns a number defining stencil operation to use when depth fails
  33911. */
  33912. getStencilOperationDepthFail(): number;
  33913. /**
  33914. * Gets the current stencil operation when stencil passes
  33915. * @returns a number defining stencil operation to use when stencil passes
  33916. */
  33917. getStencilOperationPass(): number;
  33918. /**
  33919. * Sets the stencil operation to use when stencil fails
  33920. * @param operation defines the stencil operation to use when stencil fails
  33921. */
  33922. setStencilOperationFail(operation: number): void;
  33923. /**
  33924. * Sets the stencil operation to use when depth fails
  33925. * @param operation defines the stencil operation to use when depth fails
  33926. */
  33927. setStencilOperationDepthFail(operation: number): void;
  33928. /**
  33929. * Sets the stencil operation to use when stencil passes
  33930. * @param operation defines the stencil operation to use when stencil passes
  33931. */
  33932. setStencilOperationPass(operation: number): void;
  33933. /**
  33934. * Sets a boolean indicating if the dithering state is enabled or disabled
  33935. * @param value defines the dithering state
  33936. */
  33937. setDitheringState(value: boolean): void;
  33938. /**
  33939. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33940. * @param value defines the rasterizer state
  33941. */
  33942. setRasterizerState(value: boolean): void;
  33943. /**
  33944. * Gets the current depth function
  33945. * @returns a number defining the depth function
  33946. */
  33947. getDepthFunction(): Nullable<number>;
  33948. /**
  33949. * Sets the current depth function
  33950. * @param depthFunc defines the function to use
  33951. */
  33952. setDepthFunction(depthFunc: number): void;
  33953. /**
  33954. * Sets the current depth function to GREATER
  33955. */
  33956. setDepthFunctionToGreater(): void;
  33957. /**
  33958. * Sets the current depth function to GEQUAL
  33959. */
  33960. setDepthFunctionToGreaterOrEqual(): void;
  33961. /**
  33962. * Sets the current depth function to LESS
  33963. */
  33964. setDepthFunctionToLess(): void;
  33965. /**
  33966. * Sets the current depth function to LEQUAL
  33967. */
  33968. setDepthFunctionToLessOrEqual(): void;
  33969. private _cachedStencilBuffer;
  33970. private _cachedStencilFunction;
  33971. private _cachedStencilMask;
  33972. private _cachedStencilOperationPass;
  33973. private _cachedStencilOperationFail;
  33974. private _cachedStencilOperationDepthFail;
  33975. private _cachedStencilReference;
  33976. /**
  33977. * Caches the the state of the stencil buffer
  33978. */
  33979. cacheStencilState(): void;
  33980. /**
  33981. * Restores the state of the stencil buffer
  33982. */
  33983. restoreStencilState(): void;
  33984. /**
  33985. * Directly set the WebGL Viewport
  33986. * @param x defines the x coordinate of the viewport (in screen space)
  33987. * @param y defines the y coordinate of the viewport (in screen space)
  33988. * @param width defines the width of the viewport (in screen space)
  33989. * @param height defines the height of the viewport (in screen space)
  33990. * @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
  33991. */
  33992. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33993. /**
  33994. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33995. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33996. * @param y defines the y-coordinate of the corner of the clear rectangle
  33997. * @param width defines the width of the clear rectangle
  33998. * @param height defines the height of the clear rectangle
  33999. * @param clearColor defines the clear color
  34000. */
  34001. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34002. /**
  34003. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34004. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34005. * @param y defines the y-coordinate of the corner of the clear rectangle
  34006. * @param width defines the width of the clear rectangle
  34007. * @param height defines the height of the clear rectangle
  34008. */
  34009. enableScissor(x: number, y: number, width: number, height: number): void;
  34010. /**
  34011. * Disable previously set scissor test rectangle
  34012. */
  34013. disableScissor(): void;
  34014. protected _reportDrawCall(): void;
  34015. /**
  34016. * Initializes a webVR display and starts listening to display change events
  34017. * The onVRDisplayChangedObservable will be notified upon these changes
  34018. * @returns The onVRDisplayChangedObservable
  34019. */
  34020. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34021. /** @hidden */
  34022. _prepareVRComponent(): void;
  34023. /** @hidden */
  34024. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34025. /** @hidden */
  34026. _submitVRFrame(): void;
  34027. /**
  34028. * Call this function to leave webVR mode
  34029. * Will do nothing if webVR is not supported or if there is no webVR device
  34030. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34031. */
  34032. disableVR(): void;
  34033. /**
  34034. * Gets a boolean indicating that the system is in VR mode and is presenting
  34035. * @returns true if VR mode is engaged
  34036. */
  34037. isVRPresenting(): boolean;
  34038. /** @hidden */
  34039. _requestVRFrame(): void;
  34040. /** @hidden */
  34041. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34042. /**
  34043. * Gets the source code of the vertex shader associated with a specific webGL program
  34044. * @param program defines the program to use
  34045. * @returns a string containing the source code of the vertex shader associated with the program
  34046. */
  34047. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34048. /**
  34049. * Gets the source code of the fragment shader associated with a specific webGL program
  34050. * @param program defines the program to use
  34051. * @returns a string containing the source code of the fragment shader associated with the program
  34052. */
  34053. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34054. /**
  34055. * Sets a depth stencil texture from a render target to the according uniform.
  34056. * @param channel The texture channel
  34057. * @param uniform The uniform to set
  34058. * @param texture The render target texture containing the depth stencil texture to apply
  34059. */
  34060. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34061. /**
  34062. * Sets a texture to the webGL context from a postprocess
  34063. * @param channel defines the channel to use
  34064. * @param postProcess defines the source postprocess
  34065. */
  34066. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34067. /**
  34068. * Binds the output of the passed in post process to the texture channel specified
  34069. * @param channel The channel the texture should be bound to
  34070. * @param postProcess The post process which's output should be bound
  34071. */
  34072. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34073. /** @hidden */
  34074. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34075. protected _rebuildBuffers(): void;
  34076. /** @hidden */
  34077. _renderFrame(): void;
  34078. _renderLoop(): void;
  34079. /** @hidden */
  34080. _renderViews(): boolean;
  34081. /**
  34082. * Toggle full screen mode
  34083. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34084. */
  34085. switchFullscreen(requestPointerLock: boolean): void;
  34086. /**
  34087. * Enters full screen mode
  34088. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34089. */
  34090. enterFullscreen(requestPointerLock: boolean): void;
  34091. /**
  34092. * Exits full screen mode
  34093. */
  34094. exitFullscreen(): void;
  34095. /**
  34096. * Enters Pointerlock mode
  34097. */
  34098. enterPointerlock(): void;
  34099. /**
  34100. * Exits Pointerlock mode
  34101. */
  34102. exitPointerlock(): void;
  34103. /**
  34104. * Begin a new frame
  34105. */
  34106. beginFrame(): void;
  34107. /**
  34108. * Enf the current frame
  34109. */
  34110. endFrame(): void;
  34111. resize(): void;
  34112. /**
  34113. * Force a specific size of the canvas
  34114. * @param width defines the new canvas' width
  34115. * @param height defines the new canvas' height
  34116. */
  34117. setSize(width: number, height: number): void;
  34118. /**
  34119. * Updates a dynamic vertex buffer.
  34120. * @param vertexBuffer the vertex buffer to update
  34121. * @param data the data used to update the vertex buffer
  34122. * @param byteOffset the byte offset of the data
  34123. * @param byteLength the byte length of the data
  34124. */
  34125. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34126. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34127. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34128. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34129. _releaseTexture(texture: InternalTexture): void;
  34130. /**
  34131. * @hidden
  34132. * Rescales a texture
  34133. * @param source input texutre
  34134. * @param destination destination texture
  34135. * @param scene scene to use to render the resize
  34136. * @param internalFormat format to use when resizing
  34137. * @param onComplete callback to be called when resize has completed
  34138. */
  34139. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34140. /**
  34141. * Gets the current framerate
  34142. * @returns a number representing the framerate
  34143. */
  34144. getFps(): number;
  34145. /**
  34146. * Gets the time spent between current and previous frame
  34147. * @returns a number representing the delta time in ms
  34148. */
  34149. getDeltaTime(): number;
  34150. private _measureFps;
  34151. /** @hidden */
  34152. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34153. /**
  34154. * Update a dynamic index buffer
  34155. * @param indexBuffer defines the target index buffer
  34156. * @param indices defines the data to update
  34157. * @param offset defines the offset in the target index buffer where update should start
  34158. */
  34159. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34160. /**
  34161. * Updates the sample count of a render target texture
  34162. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34163. * @param texture defines the texture to update
  34164. * @param samples defines the sample count to set
  34165. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34166. */
  34167. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34168. /**
  34169. * Updates a depth texture Comparison Mode and Function.
  34170. * If the comparison Function is equal to 0, the mode will be set to none.
  34171. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34172. * @param texture The texture to set the comparison function for
  34173. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34174. */
  34175. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34176. /**
  34177. * Creates a webGL buffer to use with instanciation
  34178. * @param capacity defines the size of the buffer
  34179. * @returns the webGL buffer
  34180. */
  34181. createInstancesBuffer(capacity: number): DataBuffer;
  34182. /**
  34183. * Delete a webGL buffer used with instanciation
  34184. * @param buffer defines the webGL buffer to delete
  34185. */
  34186. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34187. private _clientWaitAsync;
  34188. /** @hidden */
  34189. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34190. /** @hidden */
  34191. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34192. dispose(): void;
  34193. private _disableTouchAction;
  34194. /**
  34195. * Display the loading screen
  34196. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34197. */
  34198. displayLoadingUI(): void;
  34199. /**
  34200. * Hide the loading screen
  34201. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34202. */
  34203. hideLoadingUI(): void;
  34204. /**
  34205. * Gets the current loading screen object
  34206. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34207. */
  34208. get loadingScreen(): ILoadingScreen;
  34209. /**
  34210. * Sets the current loading screen object
  34211. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34212. */
  34213. set loadingScreen(loadingScreen: ILoadingScreen);
  34214. /**
  34215. * Sets the current loading screen text
  34216. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34217. */
  34218. set loadingUIText(text: string);
  34219. /**
  34220. * Sets the current loading screen background color
  34221. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34222. */
  34223. set loadingUIBackgroundColor(color: string);
  34224. /** Pointerlock and fullscreen */
  34225. /**
  34226. * Ask the browser to promote the current element to pointerlock mode
  34227. * @param element defines the DOM element to promote
  34228. */
  34229. static _RequestPointerlock(element: HTMLElement): void;
  34230. /**
  34231. * Asks the browser to exit pointerlock mode
  34232. */
  34233. static _ExitPointerlock(): void;
  34234. /**
  34235. * Ask the browser to promote the current element to fullscreen rendering mode
  34236. * @param element defines the DOM element to promote
  34237. */
  34238. static _RequestFullscreen(element: HTMLElement): void;
  34239. /**
  34240. * Asks the browser to exit fullscreen mode
  34241. */
  34242. static _ExitFullscreen(): void;
  34243. }
  34244. }
  34245. declare module BABYLON {
  34246. /**
  34247. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34248. * during the life time of the application.
  34249. */
  34250. export class EngineStore {
  34251. /** Gets the list of created engines */
  34252. static Instances: Engine[];
  34253. /** @hidden */
  34254. static _LastCreatedScene: Nullable<Scene>;
  34255. /**
  34256. * Gets the latest created engine
  34257. */
  34258. static get LastCreatedEngine(): Nullable<Engine>;
  34259. /**
  34260. * Gets the latest created scene
  34261. */
  34262. static get LastCreatedScene(): Nullable<Scene>;
  34263. /**
  34264. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34265. * @ignorenaming
  34266. */
  34267. static UseFallbackTexture: boolean;
  34268. /**
  34269. * Texture content used if a texture cannot loaded
  34270. * @ignorenaming
  34271. */
  34272. static FallbackTexture: string;
  34273. }
  34274. }
  34275. declare module BABYLON {
  34276. /**
  34277. * Helper class that provides a small promise polyfill
  34278. */
  34279. export class PromisePolyfill {
  34280. /**
  34281. * Static function used to check if the polyfill is required
  34282. * If this is the case then the function will inject the polyfill to window.Promise
  34283. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34284. */
  34285. static Apply(force?: boolean): void;
  34286. }
  34287. }
  34288. declare module BABYLON {
  34289. /**
  34290. * Interface for screenshot methods with describe argument called `size` as object with options
  34291. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34292. */
  34293. export interface IScreenshotSize {
  34294. /**
  34295. * number in pixels for canvas height
  34296. */
  34297. height?: number;
  34298. /**
  34299. * multiplier allowing render at a higher or lower resolution
  34300. * If value is defined then height and width will be ignored and taken from camera
  34301. */
  34302. precision?: number;
  34303. /**
  34304. * number in pixels for canvas width
  34305. */
  34306. width?: number;
  34307. }
  34308. }
  34309. declare module BABYLON {
  34310. interface IColor4Like {
  34311. r: float;
  34312. g: float;
  34313. b: float;
  34314. a: float;
  34315. }
  34316. /**
  34317. * Class containing a set of static utilities functions
  34318. */
  34319. export class Tools {
  34320. /**
  34321. * Gets or sets the base URL to use to load assets
  34322. */
  34323. static get BaseUrl(): string;
  34324. static set BaseUrl(value: string);
  34325. /**
  34326. * Enable/Disable Custom HTTP Request Headers globally.
  34327. * default = false
  34328. * @see CustomRequestHeaders
  34329. */
  34330. static UseCustomRequestHeaders: boolean;
  34331. /**
  34332. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34333. * i.e. when loading files, where the server/service expects an Authorization header
  34334. */
  34335. static CustomRequestHeaders: {
  34336. [key: string]: string;
  34337. };
  34338. /**
  34339. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34340. */
  34341. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34342. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34343. /**
  34344. * Default behaviour for cors in the application.
  34345. * It can be a string if the expected behavior is identical in the entire app.
  34346. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34347. */
  34348. static get CorsBehavior(): string | ((url: string | string[]) => string);
  34349. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  34350. /**
  34351. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34352. * @ignorenaming
  34353. */
  34354. static get UseFallbackTexture(): boolean;
  34355. static set UseFallbackTexture(value: boolean);
  34356. /**
  34357. * Use this object to register external classes like custom textures or material
  34358. * to allow the laoders to instantiate them
  34359. */
  34360. static get RegisteredExternalClasses(): {
  34361. [key: string]: Object;
  34362. };
  34363. static set RegisteredExternalClasses(classes: {
  34364. [key: string]: Object;
  34365. });
  34366. /**
  34367. * Texture content used if a texture cannot loaded
  34368. * @ignorenaming
  34369. */
  34370. static get fallbackTexture(): string;
  34371. static set fallbackTexture(value: string);
  34372. /**
  34373. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34374. * @param u defines the coordinate on X axis
  34375. * @param v defines the coordinate on Y axis
  34376. * @param width defines the width of the source data
  34377. * @param height defines the height of the source data
  34378. * @param pixels defines the source byte array
  34379. * @param color defines the output color
  34380. */
  34381. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34382. /**
  34383. * Interpolates between a and b via alpha
  34384. * @param a The lower value (returned when alpha = 0)
  34385. * @param b The upper value (returned when alpha = 1)
  34386. * @param alpha The interpolation-factor
  34387. * @return The mixed value
  34388. */
  34389. static Mix(a: number, b: number, alpha: number): number;
  34390. /**
  34391. * Tries to instantiate a new object from a given class name
  34392. * @param className defines the class name to instantiate
  34393. * @returns the new object or null if the system was not able to do the instantiation
  34394. */
  34395. static Instantiate(className: string): any;
  34396. /**
  34397. * Provides a slice function that will work even on IE
  34398. * @param data defines the array to slice
  34399. * @param start defines the start of the data (optional)
  34400. * @param end defines the end of the data (optional)
  34401. * @returns the new sliced array
  34402. */
  34403. static Slice<T>(data: T, start?: number, end?: number): T;
  34404. /**
  34405. * Polyfill for setImmediate
  34406. * @param action defines the action to execute after the current execution block
  34407. */
  34408. static SetImmediate(action: () => void): void;
  34409. /**
  34410. * Function indicating if a number is an exponent of 2
  34411. * @param value defines the value to test
  34412. * @returns true if the value is an exponent of 2
  34413. */
  34414. static IsExponentOfTwo(value: number): boolean;
  34415. private static _tmpFloatArray;
  34416. /**
  34417. * Returns the nearest 32-bit single precision float representation of a Number
  34418. * @param value A Number. If the parameter is of a different type, it will get converted
  34419. * to a number or to NaN if it cannot be converted
  34420. * @returns number
  34421. */
  34422. static FloatRound(value: number): number;
  34423. /**
  34424. * Extracts the filename from a path
  34425. * @param path defines the path to use
  34426. * @returns the filename
  34427. */
  34428. static GetFilename(path: string): string;
  34429. /**
  34430. * Extracts the "folder" part of a path (everything before the filename).
  34431. * @param uri The URI to extract the info from
  34432. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34433. * @returns The "folder" part of the path
  34434. */
  34435. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34436. /**
  34437. * Extracts text content from a DOM element hierarchy
  34438. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34439. */
  34440. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34441. /**
  34442. * Convert an angle in radians to degrees
  34443. * @param angle defines the angle to convert
  34444. * @returns the angle in degrees
  34445. */
  34446. static ToDegrees(angle: number): number;
  34447. /**
  34448. * Convert an angle in degrees to radians
  34449. * @param angle defines the angle to convert
  34450. * @returns the angle in radians
  34451. */
  34452. static ToRadians(angle: number): number;
  34453. /**
  34454. * Returns an array if obj is not an array
  34455. * @param obj defines the object to evaluate as an array
  34456. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34457. * @returns either obj directly if obj is an array or a new array containing obj
  34458. */
  34459. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34460. /**
  34461. * Gets the pointer prefix to use
  34462. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34463. */
  34464. static GetPointerPrefix(): string;
  34465. /**
  34466. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34467. * @param url define the url we are trying
  34468. * @param element define the dom element where to configure the cors policy
  34469. */
  34470. static SetCorsBehavior(url: string | string[], element: {
  34471. crossOrigin: string | null;
  34472. }): void;
  34473. /**
  34474. * Removes unwanted characters from an url
  34475. * @param url defines the url to clean
  34476. * @returns the cleaned url
  34477. */
  34478. static CleanUrl(url: string): string;
  34479. /**
  34480. * Gets or sets a function used to pre-process url before using them to load assets
  34481. */
  34482. static get PreprocessUrl(): (url: string) => string;
  34483. static set PreprocessUrl(processor: (url: string) => string);
  34484. /**
  34485. * Loads an image as an HTMLImageElement.
  34486. * @param input url string, ArrayBuffer, or Blob to load
  34487. * @param onLoad callback called when the image successfully loads
  34488. * @param onError callback called when the image fails to load
  34489. * @param offlineProvider offline provider for caching
  34490. * @param mimeType optional mime type
  34491. * @returns the HTMLImageElement of the loaded image
  34492. */
  34493. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34494. /**
  34495. * Loads a file from a url
  34496. * @param url url string, ArrayBuffer, or Blob to load
  34497. * @param onSuccess callback called when the file successfully loads
  34498. * @param onProgress callback called while file is loading (if the server supports this mode)
  34499. * @param offlineProvider defines the offline provider for caching
  34500. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34501. * @param onError callback called when the file fails to load
  34502. * @returns a file request object
  34503. */
  34504. 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;
  34505. /**
  34506. * Loads a file from a url
  34507. * @param url the file url to load
  34508. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34509. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34510. */
  34511. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34512. /**
  34513. * Load a script (identified by an url). When the url returns, the
  34514. * content of this file is added into a new script element, attached to the DOM (body element)
  34515. * @param scriptUrl defines the url of the script to laod
  34516. * @param onSuccess defines the callback called when the script is loaded
  34517. * @param onError defines the callback to call if an error occurs
  34518. * @param scriptId defines the id of the script element
  34519. */
  34520. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34521. /**
  34522. * Load an asynchronous script (identified by an url). When the url returns, the
  34523. * content of this file is added into a new script element, attached to the DOM (body element)
  34524. * @param scriptUrl defines the url of the script to laod
  34525. * @param scriptId defines the id of the script element
  34526. * @returns a promise request object
  34527. */
  34528. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34529. /**
  34530. * Loads a file from a blob
  34531. * @param fileToLoad defines the blob to use
  34532. * @param callback defines the callback to call when data is loaded
  34533. * @param progressCallback defines the callback to call during loading process
  34534. * @returns a file request object
  34535. */
  34536. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34537. /**
  34538. * Reads a file from a File object
  34539. * @param file defines the file to load
  34540. * @param onSuccess defines the callback to call when data is loaded
  34541. * @param onProgress defines the callback to call during loading process
  34542. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34543. * @param onError defines the callback to call when an error occurs
  34544. * @returns a file request object
  34545. */
  34546. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34547. /**
  34548. * Creates a data url from a given string content
  34549. * @param content defines the content to convert
  34550. * @returns the new data url link
  34551. */
  34552. static FileAsURL(content: string): string;
  34553. /**
  34554. * Format the given number to a specific decimal format
  34555. * @param value defines the number to format
  34556. * @param decimals defines the number of decimals to use
  34557. * @returns the formatted string
  34558. */
  34559. static Format(value: number, decimals?: number): string;
  34560. /**
  34561. * Tries to copy an object by duplicating every property
  34562. * @param source defines the source object
  34563. * @param destination defines the target object
  34564. * @param doNotCopyList defines a list of properties to avoid
  34565. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34566. */
  34567. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34568. /**
  34569. * Gets a boolean indicating if the given object has no own property
  34570. * @param obj defines the object to test
  34571. * @returns true if object has no own property
  34572. */
  34573. static IsEmpty(obj: any): boolean;
  34574. /**
  34575. * Function used to register events at window level
  34576. * @param windowElement defines the Window object to use
  34577. * @param events defines the events to register
  34578. */
  34579. static RegisterTopRootEvents(windowElement: Window, events: {
  34580. name: string;
  34581. handler: Nullable<(e: FocusEvent) => any>;
  34582. }[]): void;
  34583. /**
  34584. * Function used to unregister events from window level
  34585. * @param windowElement defines the Window object to use
  34586. * @param events defines the events to unregister
  34587. */
  34588. static UnregisterTopRootEvents(windowElement: Window, events: {
  34589. name: string;
  34590. handler: Nullable<(e: FocusEvent) => any>;
  34591. }[]): void;
  34592. /**
  34593. * @ignore
  34594. */
  34595. static _ScreenshotCanvas: HTMLCanvasElement;
  34596. /**
  34597. * Dumps the current bound framebuffer
  34598. * @param width defines the rendering width
  34599. * @param height defines the rendering height
  34600. * @param engine defines the hosting engine
  34601. * @param successCallback defines the callback triggered once the data are available
  34602. * @param mimeType defines the mime type of the result
  34603. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34604. */
  34605. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34606. /**
  34607. * Converts the canvas data to blob.
  34608. * This acts as a polyfill for browsers not supporting the to blob function.
  34609. * @param canvas Defines the canvas to extract the data from
  34610. * @param successCallback Defines the callback triggered once the data are available
  34611. * @param mimeType Defines the mime type of the result
  34612. */
  34613. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34614. /**
  34615. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34616. * @param successCallback defines the callback triggered once the data are available
  34617. * @param mimeType defines the mime type of the result
  34618. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34619. */
  34620. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34621. /**
  34622. * Downloads a blob in the browser
  34623. * @param blob defines the blob to download
  34624. * @param fileName defines the name of the downloaded file
  34625. */
  34626. static Download(blob: Blob, fileName: string): void;
  34627. /**
  34628. * Captures a screenshot of the current rendering
  34629. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34630. * @param engine defines the rendering engine
  34631. * @param camera defines the source camera
  34632. * @param size This parameter can be set to a single number or to an object with the
  34633. * following (optional) properties: precision, width, height. If a single number is passed,
  34634. * it will be used for both width and height. If an object is passed, the screenshot size
  34635. * will be derived from the parameters. The precision property is a multiplier allowing
  34636. * rendering at a higher or lower resolution
  34637. * @param successCallback defines the callback receives a single parameter which contains the
  34638. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34639. * src parameter of an <img> to display it
  34640. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34641. * Check your browser for supported MIME types
  34642. */
  34643. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34644. /**
  34645. * Captures a screenshot of the current rendering
  34646. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34647. * @param engine defines the rendering engine
  34648. * @param camera defines the source camera
  34649. * @param size This parameter can be set to a single number or to an object with the
  34650. * following (optional) properties: precision, width, height. If a single number is passed,
  34651. * it will be used for both width and height. If an object is passed, the screenshot size
  34652. * will be derived from the parameters. The precision property is a multiplier allowing
  34653. * rendering at a higher or lower resolution
  34654. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34655. * Check your browser for supported MIME types
  34656. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34657. * to the src parameter of an <img> to display it
  34658. */
  34659. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34660. /**
  34661. * Generates an image screenshot from the specified camera.
  34662. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34663. * @param engine The engine to use for rendering
  34664. * @param camera The camera to use for rendering
  34665. * @param size This parameter can be set to a single number or to an object with the
  34666. * following (optional) properties: precision, width, height. If a single number is passed,
  34667. * it will be used for both width and height. If an object is passed, the screenshot size
  34668. * will be derived from the parameters. The precision property is a multiplier allowing
  34669. * rendering at a higher or lower resolution
  34670. * @param successCallback The callback receives a single parameter which contains the
  34671. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34672. * src parameter of an <img> to display it
  34673. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34674. * Check your browser for supported MIME types
  34675. * @param samples Texture samples (default: 1)
  34676. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34677. * @param fileName A name for for the downloaded file.
  34678. */
  34679. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34680. /**
  34681. * Generates an image screenshot from the specified camera.
  34682. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34683. * @param engine The engine to use for rendering
  34684. * @param camera The camera to use for rendering
  34685. * @param size This parameter can be set to a single number or to an object with the
  34686. * following (optional) properties: precision, width, height. If a single number is passed,
  34687. * it will be used for both width and height. If an object is passed, the screenshot size
  34688. * will be derived from the parameters. The precision property is a multiplier allowing
  34689. * rendering at a higher or lower resolution
  34690. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34691. * Check your browser for supported MIME types
  34692. * @param samples Texture samples (default: 1)
  34693. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34694. * @param fileName A name for for the downloaded file.
  34695. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34696. * to the src parameter of an <img> to display it
  34697. */
  34698. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34699. /**
  34700. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34701. * Be aware Math.random() could cause collisions, but:
  34702. * "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"
  34703. * @returns a pseudo random id
  34704. */
  34705. static RandomId(): string;
  34706. /**
  34707. * Test if the given uri is a base64 string
  34708. * @param uri The uri to test
  34709. * @return True if the uri is a base64 string or false otherwise
  34710. */
  34711. static IsBase64(uri: string): boolean;
  34712. /**
  34713. * Decode the given base64 uri.
  34714. * @param uri The uri to decode
  34715. * @return The decoded base64 data.
  34716. */
  34717. static DecodeBase64(uri: string): ArrayBuffer;
  34718. /**
  34719. * Gets the absolute url.
  34720. * @param url the input url
  34721. * @return the absolute url
  34722. */
  34723. static GetAbsoluteUrl(url: string): string;
  34724. /**
  34725. * No log
  34726. */
  34727. static readonly NoneLogLevel: number;
  34728. /**
  34729. * Only message logs
  34730. */
  34731. static readonly MessageLogLevel: number;
  34732. /**
  34733. * Only warning logs
  34734. */
  34735. static readonly WarningLogLevel: number;
  34736. /**
  34737. * Only error logs
  34738. */
  34739. static readonly ErrorLogLevel: number;
  34740. /**
  34741. * All logs
  34742. */
  34743. static readonly AllLogLevel: number;
  34744. /**
  34745. * Gets a value indicating the number of loading errors
  34746. * @ignorenaming
  34747. */
  34748. static get errorsCount(): number;
  34749. /**
  34750. * Callback called when a new log is added
  34751. */
  34752. static OnNewCacheEntry: (entry: string) => void;
  34753. /**
  34754. * Log a message to the console
  34755. * @param message defines the message to log
  34756. */
  34757. static Log(message: string): void;
  34758. /**
  34759. * Write a warning message to the console
  34760. * @param message defines the message to log
  34761. */
  34762. static Warn(message: string): void;
  34763. /**
  34764. * Write an error message to the console
  34765. * @param message defines the message to log
  34766. */
  34767. static Error(message: string): void;
  34768. /**
  34769. * Gets current log cache (list of logs)
  34770. */
  34771. static get LogCache(): string;
  34772. /**
  34773. * Clears the log cache
  34774. */
  34775. static ClearLogCache(): void;
  34776. /**
  34777. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34778. */
  34779. static set LogLevels(level: number);
  34780. /**
  34781. * Checks if the window object exists
  34782. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34783. */
  34784. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34785. /**
  34786. * No performance log
  34787. */
  34788. static readonly PerformanceNoneLogLevel: number;
  34789. /**
  34790. * Use user marks to log performance
  34791. */
  34792. static readonly PerformanceUserMarkLogLevel: number;
  34793. /**
  34794. * Log performance to the console
  34795. */
  34796. static readonly PerformanceConsoleLogLevel: number;
  34797. private static _performance;
  34798. /**
  34799. * Sets the current performance log level
  34800. */
  34801. static set PerformanceLogLevel(level: number);
  34802. private static _StartPerformanceCounterDisabled;
  34803. private static _EndPerformanceCounterDisabled;
  34804. private static _StartUserMark;
  34805. private static _EndUserMark;
  34806. private static _StartPerformanceConsole;
  34807. private static _EndPerformanceConsole;
  34808. /**
  34809. * Starts a performance counter
  34810. */
  34811. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34812. /**
  34813. * Ends a specific performance coutner
  34814. */
  34815. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34816. /**
  34817. * Gets either window.performance.now() if supported or Date.now() else
  34818. */
  34819. static get Now(): number;
  34820. /**
  34821. * This method will return the name of the class used to create the instance of the given object.
  34822. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34823. * @param object the object to get the class name from
  34824. * @param isType defines if the object is actually a type
  34825. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34826. */
  34827. static GetClassName(object: any, isType?: boolean): string;
  34828. /**
  34829. * Gets the first element of an array satisfying a given predicate
  34830. * @param array defines the array to browse
  34831. * @param predicate defines the predicate to use
  34832. * @returns null if not found or the element
  34833. */
  34834. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34835. /**
  34836. * This method will return the name of the full name of the class, including its owning module (if any).
  34837. * 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).
  34838. * @param object the object to get the class name from
  34839. * @param isType defines if the object is actually a type
  34840. * @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.
  34841. * @ignorenaming
  34842. */
  34843. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34844. /**
  34845. * Returns a promise that resolves after the given amount of time.
  34846. * @param delay Number of milliseconds to delay
  34847. * @returns Promise that resolves after the given amount of time
  34848. */
  34849. static DelayAsync(delay: number): Promise<void>;
  34850. /**
  34851. * Utility function to detect if the current user agent is Safari
  34852. * @returns whether or not the current user agent is safari
  34853. */
  34854. static IsSafari(): boolean;
  34855. }
  34856. /**
  34857. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34858. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34859. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34860. * @param name The name of the class, case should be preserved
  34861. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34862. */
  34863. export function className(name: string, module?: string): (target: Object) => void;
  34864. /**
  34865. * An implementation of a loop for asynchronous functions.
  34866. */
  34867. export class AsyncLoop {
  34868. /**
  34869. * Defines the number of iterations for the loop
  34870. */
  34871. iterations: number;
  34872. /**
  34873. * Defines the current index of the loop.
  34874. */
  34875. index: number;
  34876. private _done;
  34877. private _fn;
  34878. private _successCallback;
  34879. /**
  34880. * Constructor.
  34881. * @param iterations the number of iterations.
  34882. * @param func the function to run each iteration
  34883. * @param successCallback the callback that will be called upon succesful execution
  34884. * @param offset starting offset.
  34885. */
  34886. constructor(
  34887. /**
  34888. * Defines the number of iterations for the loop
  34889. */
  34890. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34891. /**
  34892. * Execute the next iteration. Must be called after the last iteration was finished.
  34893. */
  34894. executeNext(): void;
  34895. /**
  34896. * Break the loop and run the success callback.
  34897. */
  34898. breakLoop(): void;
  34899. /**
  34900. * Create and run an async loop.
  34901. * @param iterations the number of iterations.
  34902. * @param fn the function to run each iteration
  34903. * @param successCallback the callback that will be called upon succesful execution
  34904. * @param offset starting offset.
  34905. * @returns the created async loop object
  34906. */
  34907. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34908. /**
  34909. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34910. * @param iterations total number of iterations
  34911. * @param syncedIterations number of synchronous iterations in each async iteration.
  34912. * @param fn the function to call each iteration.
  34913. * @param callback a success call back that will be called when iterating stops.
  34914. * @param breakFunction a break condition (optional)
  34915. * @param timeout timeout settings for the setTimeout function. default - 0.
  34916. * @returns the created async loop object
  34917. */
  34918. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34919. }
  34920. }
  34921. declare module BABYLON {
  34922. /**
  34923. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34924. * The underlying implementation relies on an associative array to ensure the best performances.
  34925. * The value can be anything including 'null' but except 'undefined'
  34926. */
  34927. export class StringDictionary<T> {
  34928. /**
  34929. * This will clear this dictionary and copy the content from the 'source' one.
  34930. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34931. * @param source the dictionary to take the content from and copy to this dictionary
  34932. */
  34933. copyFrom(source: StringDictionary<T>): void;
  34934. /**
  34935. * Get a value based from its key
  34936. * @param key the given key to get the matching value from
  34937. * @return the value if found, otherwise undefined is returned
  34938. */
  34939. get(key: string): T | undefined;
  34940. /**
  34941. * Get a value from its key or add it if it doesn't exist.
  34942. * This method will ensure you that a given key/data will be present in the dictionary.
  34943. * @param key the given key to get the matching value from
  34944. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34945. * The factory will only be invoked if there's no data for the given key.
  34946. * @return the value corresponding to the key.
  34947. */
  34948. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34949. /**
  34950. * Get a value from its key if present in the dictionary otherwise add it
  34951. * @param key the key to get the value from
  34952. * @param val if there's no such key/value pair in the dictionary add it with this value
  34953. * @return the value corresponding to the key
  34954. */
  34955. getOrAdd(key: string, val: T): T;
  34956. /**
  34957. * Check if there's a given key in the dictionary
  34958. * @param key the key to check for
  34959. * @return true if the key is present, false otherwise
  34960. */
  34961. contains(key: string): boolean;
  34962. /**
  34963. * Add a new key and its corresponding value
  34964. * @param key the key to add
  34965. * @param value the value corresponding to the key
  34966. * @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
  34967. */
  34968. add(key: string, value: T): boolean;
  34969. /**
  34970. * Update a specific value associated to a key
  34971. * @param key defines the key to use
  34972. * @param value defines the value to store
  34973. * @returns true if the value was updated (or false if the key was not found)
  34974. */
  34975. set(key: string, value: T): boolean;
  34976. /**
  34977. * Get the element of the given key and remove it from the dictionary
  34978. * @param key defines the key to search
  34979. * @returns the value associated with the key or null if not found
  34980. */
  34981. getAndRemove(key: string): Nullable<T>;
  34982. /**
  34983. * Remove a key/value from the dictionary.
  34984. * @param key the key to remove
  34985. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34986. */
  34987. remove(key: string): boolean;
  34988. /**
  34989. * Clear the whole content of the dictionary
  34990. */
  34991. clear(): void;
  34992. /**
  34993. * Gets the current count
  34994. */
  34995. get count(): number;
  34996. /**
  34997. * Execute a callback on each key/val of the dictionary.
  34998. * Note that you can remove any element in this dictionary in the callback implementation
  34999. * @param callback the callback to execute on a given key/value pair
  35000. */
  35001. forEach(callback: (key: string, val: T) => void): void;
  35002. /**
  35003. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35004. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35005. * Note that you can remove any element in this dictionary in the callback implementation
  35006. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35007. * @returns the first item
  35008. */
  35009. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35010. private _count;
  35011. private _data;
  35012. }
  35013. }
  35014. declare module BABYLON {
  35015. /** @hidden */
  35016. export interface ICollisionCoordinator {
  35017. createCollider(): Collider;
  35018. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35019. init(scene: Scene): void;
  35020. }
  35021. /** @hidden */
  35022. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35023. private _scene;
  35024. private _scaledPosition;
  35025. private _scaledVelocity;
  35026. private _finalPosition;
  35027. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35028. createCollider(): Collider;
  35029. init(scene: Scene): void;
  35030. private _collideWithWorld;
  35031. }
  35032. }
  35033. declare module BABYLON {
  35034. /**
  35035. * Class used to manage all inputs for the scene.
  35036. */
  35037. export class InputManager {
  35038. /** The distance in pixel that you have to move to prevent some events */
  35039. static DragMovementThreshold: number;
  35040. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35041. static LongPressDelay: number;
  35042. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35043. static DoubleClickDelay: number;
  35044. /** If you need to check double click without raising a single click at first click, enable this flag */
  35045. static ExclusiveDoubleClickMode: boolean;
  35046. private _wheelEventName;
  35047. private _onPointerMove;
  35048. private _onPointerDown;
  35049. private _onPointerUp;
  35050. private _initClickEvent;
  35051. private _initActionManager;
  35052. private _delayedSimpleClick;
  35053. private _delayedSimpleClickTimeout;
  35054. private _previousDelayedSimpleClickTimeout;
  35055. private _meshPickProceed;
  35056. private _previousButtonPressed;
  35057. private _currentPickResult;
  35058. private _previousPickResult;
  35059. private _totalPointersPressed;
  35060. private _doubleClickOccured;
  35061. private _pointerOverMesh;
  35062. private _pickedDownMesh;
  35063. private _pickedUpMesh;
  35064. private _pointerX;
  35065. private _pointerY;
  35066. private _unTranslatedPointerX;
  35067. private _unTranslatedPointerY;
  35068. private _startingPointerPosition;
  35069. private _previousStartingPointerPosition;
  35070. private _startingPointerTime;
  35071. private _previousStartingPointerTime;
  35072. private _pointerCaptures;
  35073. private _onKeyDown;
  35074. private _onKeyUp;
  35075. private _onCanvasFocusObserver;
  35076. private _onCanvasBlurObserver;
  35077. private _scene;
  35078. /**
  35079. * Creates a new InputManager
  35080. * @param scene defines the hosting scene
  35081. */
  35082. constructor(scene: Scene);
  35083. /**
  35084. * Gets the mesh that is currently under the pointer
  35085. */
  35086. get meshUnderPointer(): Nullable<AbstractMesh>;
  35087. /**
  35088. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35089. */
  35090. get unTranslatedPointer(): Vector2;
  35091. /**
  35092. * Gets or sets the current on-screen X position of the pointer
  35093. */
  35094. get pointerX(): number;
  35095. set pointerX(value: number);
  35096. /**
  35097. * Gets or sets the current on-screen Y position of the pointer
  35098. */
  35099. get pointerY(): number;
  35100. set pointerY(value: number);
  35101. private _updatePointerPosition;
  35102. private _processPointerMove;
  35103. private _setRayOnPointerInfo;
  35104. private _checkPrePointerObservable;
  35105. /**
  35106. * Use this method to simulate a pointer move on a mesh
  35107. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35108. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35109. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35110. */
  35111. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35112. /**
  35113. * Use this method to simulate a pointer down on a mesh
  35114. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35115. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35116. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35117. */
  35118. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35119. private _processPointerDown;
  35120. /** @hidden */
  35121. _isPointerSwiping(): boolean;
  35122. /**
  35123. * Use this method to simulate a pointer up on a mesh
  35124. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35125. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35126. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35127. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35128. */
  35129. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35130. private _processPointerUp;
  35131. /**
  35132. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35133. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35134. * @returns true if the pointer was captured
  35135. */
  35136. isPointerCaptured(pointerId?: number): boolean;
  35137. /**
  35138. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35139. * @param attachUp defines if you want to attach events to pointerup
  35140. * @param attachDown defines if you want to attach events to pointerdown
  35141. * @param attachMove defines if you want to attach events to pointermove
  35142. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35143. */
  35144. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35145. /**
  35146. * Detaches all event handlers
  35147. */
  35148. detachControl(): void;
  35149. /**
  35150. * Force the value of meshUnderPointer
  35151. * @param mesh defines the mesh to use
  35152. */
  35153. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35154. /**
  35155. * Gets the mesh under the pointer
  35156. * @returns a Mesh or null if no mesh is under the pointer
  35157. */
  35158. getPointerOverMesh(): Nullable<AbstractMesh>;
  35159. }
  35160. }
  35161. declare module BABYLON {
  35162. /**
  35163. * Helper class used to generate session unique ID
  35164. */
  35165. export class UniqueIdGenerator {
  35166. private static _UniqueIdCounter;
  35167. /**
  35168. * Gets an unique (relatively to the current scene) Id
  35169. */
  35170. static get UniqueId(): number;
  35171. }
  35172. }
  35173. declare module BABYLON {
  35174. /**
  35175. * This class defines the direct association between an animation and a target
  35176. */
  35177. export class TargetedAnimation {
  35178. /**
  35179. * Animation to perform
  35180. */
  35181. animation: Animation;
  35182. /**
  35183. * Target to animate
  35184. */
  35185. target: any;
  35186. /**
  35187. * Serialize the object
  35188. * @returns the JSON object representing the current entity
  35189. */
  35190. serialize(): any;
  35191. }
  35192. /**
  35193. * Use this class to create coordinated animations on multiple targets
  35194. */
  35195. export class AnimationGroup implements IDisposable {
  35196. /** The name of the animation group */
  35197. name: string;
  35198. private _scene;
  35199. private _targetedAnimations;
  35200. private _animatables;
  35201. private _from;
  35202. private _to;
  35203. private _isStarted;
  35204. private _isPaused;
  35205. private _speedRatio;
  35206. private _loopAnimation;
  35207. private _isAdditive;
  35208. /**
  35209. * Gets or sets the unique id of the node
  35210. */
  35211. uniqueId: number;
  35212. /**
  35213. * This observable will notify when one animation have ended
  35214. */
  35215. onAnimationEndObservable: Observable<TargetedAnimation>;
  35216. /**
  35217. * Observer raised when one animation loops
  35218. */
  35219. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35220. /**
  35221. * Observer raised when all animations have looped
  35222. */
  35223. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35224. /**
  35225. * This observable will notify when all animations have ended.
  35226. */
  35227. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35228. /**
  35229. * This observable will notify when all animations have paused.
  35230. */
  35231. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35232. /**
  35233. * This observable will notify when all animations are playing.
  35234. */
  35235. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35236. /**
  35237. * Gets the first frame
  35238. */
  35239. get from(): number;
  35240. /**
  35241. * Gets the last frame
  35242. */
  35243. get to(): number;
  35244. /**
  35245. * Define if the animations are started
  35246. */
  35247. get isStarted(): boolean;
  35248. /**
  35249. * Gets a value indicating that the current group is playing
  35250. */
  35251. get isPlaying(): boolean;
  35252. /**
  35253. * Gets or sets the speed ratio to use for all animations
  35254. */
  35255. get speedRatio(): number;
  35256. /**
  35257. * Gets or sets the speed ratio to use for all animations
  35258. */
  35259. set speedRatio(value: number);
  35260. /**
  35261. * Gets or sets if all animations should loop or not
  35262. */
  35263. get loopAnimation(): boolean;
  35264. set loopAnimation(value: boolean);
  35265. /**
  35266. * Gets or sets if all animations should be evaluated additively
  35267. */
  35268. get isAdditive(): boolean;
  35269. set isAdditive(value: boolean);
  35270. /**
  35271. * Gets the targeted animations for this animation group
  35272. */
  35273. get targetedAnimations(): Array<TargetedAnimation>;
  35274. /**
  35275. * returning the list of animatables controlled by this animation group.
  35276. */
  35277. get animatables(): Array<Animatable>;
  35278. /**
  35279. * Instantiates a new Animation Group.
  35280. * This helps managing several animations at once.
  35281. * @see http://doc.babylonjs.com/how_to/group
  35282. * @param name Defines the name of the group
  35283. * @param scene Defines the scene the group belongs to
  35284. */
  35285. constructor(
  35286. /** The name of the animation group */
  35287. name: string, scene?: Nullable<Scene>);
  35288. /**
  35289. * Add an animation (with its target) in the group
  35290. * @param animation defines the animation we want to add
  35291. * @param target defines the target of the animation
  35292. * @returns the TargetedAnimation object
  35293. */
  35294. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35295. /**
  35296. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35297. * It can add constant keys at begin or end
  35298. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35299. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35300. * @returns the animation group
  35301. */
  35302. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35303. private _animationLoopCount;
  35304. private _animationLoopFlags;
  35305. private _processLoop;
  35306. /**
  35307. * Start all animations on given targets
  35308. * @param loop defines if animations must loop
  35309. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35310. * @param from defines the from key (optional)
  35311. * @param to defines the to key (optional)
  35312. * @param isAdditive defines the additive state for the resulting animatables (optional)
  35313. * @returns the current animation group
  35314. */
  35315. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  35316. /**
  35317. * Pause all animations
  35318. * @returns the animation group
  35319. */
  35320. pause(): AnimationGroup;
  35321. /**
  35322. * Play all animations to initial state
  35323. * This function will start() the animations if they were not started or will restart() them if they were paused
  35324. * @param loop defines if animations must loop
  35325. * @returns the animation group
  35326. */
  35327. play(loop?: boolean): AnimationGroup;
  35328. /**
  35329. * Reset all animations to initial state
  35330. * @returns the animation group
  35331. */
  35332. reset(): AnimationGroup;
  35333. /**
  35334. * Restart animations from key 0
  35335. * @returns the animation group
  35336. */
  35337. restart(): AnimationGroup;
  35338. /**
  35339. * Stop all animations
  35340. * @returns the animation group
  35341. */
  35342. stop(): AnimationGroup;
  35343. /**
  35344. * Set animation weight for all animatables
  35345. * @param weight defines the weight to use
  35346. * @return the animationGroup
  35347. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35348. */
  35349. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35350. /**
  35351. * Synchronize and normalize all animatables with a source animatable
  35352. * @param root defines the root animatable to synchronize with
  35353. * @return the animationGroup
  35354. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35355. */
  35356. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35357. /**
  35358. * Goes to a specific frame in this animation group
  35359. * @param frame the frame number to go to
  35360. * @return the animationGroup
  35361. */
  35362. goToFrame(frame: number): AnimationGroup;
  35363. /**
  35364. * Dispose all associated resources
  35365. */
  35366. dispose(): void;
  35367. private _checkAnimationGroupEnded;
  35368. /**
  35369. * Clone the current animation group and returns a copy
  35370. * @param newName defines the name of the new group
  35371. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35372. * @returns the new aniamtion group
  35373. */
  35374. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35375. /**
  35376. * Serializes the animationGroup to an object
  35377. * @returns Serialized object
  35378. */
  35379. serialize(): any;
  35380. /**
  35381. * Returns a new AnimationGroup object parsed from the source provided.
  35382. * @param parsedAnimationGroup defines the source
  35383. * @param scene defines the scene that will receive the animationGroup
  35384. * @returns a new AnimationGroup
  35385. */
  35386. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35387. /**
  35388. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  35389. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  35390. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  35391. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  35392. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  35393. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  35394. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  35395. */
  35396. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  35397. /**
  35398. * Returns the string "AnimationGroup"
  35399. * @returns "AnimationGroup"
  35400. */
  35401. getClassName(): string;
  35402. /**
  35403. * Creates a detailled string about the object
  35404. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35405. * @returns a string representing the object
  35406. */
  35407. toString(fullDetails?: boolean): string;
  35408. }
  35409. }
  35410. declare module BABYLON {
  35411. /**
  35412. * Define an interface for all classes that will hold resources
  35413. */
  35414. export interface IDisposable {
  35415. /**
  35416. * Releases all held resources
  35417. */
  35418. dispose(): void;
  35419. }
  35420. /** Interface defining initialization parameters for Scene class */
  35421. export interface SceneOptions {
  35422. /**
  35423. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35424. * It will improve performance when the number of geometries becomes important.
  35425. */
  35426. useGeometryUniqueIdsMap?: boolean;
  35427. /**
  35428. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35429. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35430. */
  35431. useMaterialMeshMap?: boolean;
  35432. /**
  35433. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35434. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35435. */
  35436. useClonedMeshMap?: boolean;
  35437. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35438. virtual?: boolean;
  35439. }
  35440. /**
  35441. * Represents a scene to be rendered by the engine.
  35442. * @see http://doc.babylonjs.com/features/scene
  35443. */
  35444. export class Scene extends AbstractScene implements IAnimatable {
  35445. /** The fog is deactivated */
  35446. static readonly FOGMODE_NONE: number;
  35447. /** The fog density is following an exponential function */
  35448. static readonly FOGMODE_EXP: number;
  35449. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35450. static readonly FOGMODE_EXP2: number;
  35451. /** The fog density is following a linear function. */
  35452. static readonly FOGMODE_LINEAR: number;
  35453. /**
  35454. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35455. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35456. */
  35457. static MinDeltaTime: number;
  35458. /**
  35459. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35460. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35461. */
  35462. static MaxDeltaTime: number;
  35463. /**
  35464. * Factory used to create the default material.
  35465. * @param name The name of the material to create
  35466. * @param scene The scene to create the material for
  35467. * @returns The default material
  35468. */
  35469. static DefaultMaterialFactory(scene: Scene): Material;
  35470. /**
  35471. * Factory used to create the a collision coordinator.
  35472. * @returns The collision coordinator
  35473. */
  35474. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35475. /** @hidden */
  35476. _inputManager: InputManager;
  35477. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35478. cameraToUseForPointers: Nullable<Camera>;
  35479. /** @hidden */
  35480. readonly _isScene: boolean;
  35481. /** @hidden */
  35482. _blockEntityCollection: boolean;
  35483. /**
  35484. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35485. */
  35486. autoClear: boolean;
  35487. /**
  35488. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35489. */
  35490. autoClearDepthAndStencil: boolean;
  35491. /**
  35492. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35493. */
  35494. clearColor: Color4;
  35495. /**
  35496. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35497. */
  35498. ambientColor: Color3;
  35499. /**
  35500. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35501. * It should only be one of the following (if not the default embedded one):
  35502. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35503. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35504. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35505. * The material properties need to be setup according to the type of texture in use.
  35506. */
  35507. environmentBRDFTexture: BaseTexture;
  35508. /** @hidden */
  35509. protected _environmentTexture: Nullable<BaseTexture>;
  35510. /**
  35511. * Texture used in all pbr material as the reflection texture.
  35512. * As in the majority of the scene they are the same (exception for multi room and so on),
  35513. * this is easier to reference from here than from all the materials.
  35514. */
  35515. get environmentTexture(): Nullable<BaseTexture>;
  35516. /**
  35517. * Texture used in all pbr material as the reflection texture.
  35518. * As in the majority of the scene they are the same (exception for multi room and so on),
  35519. * this is easier to set here than in all the materials.
  35520. */
  35521. set environmentTexture(value: Nullable<BaseTexture>);
  35522. /** @hidden */
  35523. protected _environmentIntensity: number;
  35524. /**
  35525. * Intensity of the environment in all pbr material.
  35526. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35527. * As in the majority of the scene they are the same (exception for multi room and so on),
  35528. * this is easier to reference from here than from all the materials.
  35529. */
  35530. get environmentIntensity(): number;
  35531. /**
  35532. * Intensity of the environment in all pbr material.
  35533. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35534. * As in the majority of the scene they are the same (exception for multi room and so on),
  35535. * this is easier to set here than in all the materials.
  35536. */
  35537. set environmentIntensity(value: number);
  35538. /** @hidden */
  35539. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35540. /**
  35541. * Default image processing configuration used either in the rendering
  35542. * Forward main pass or through the imageProcessingPostProcess if present.
  35543. * As in the majority of the scene they are the same (exception for multi camera),
  35544. * this is easier to reference from here than from all the materials and post process.
  35545. *
  35546. * No setter as we it is a shared configuration, you can set the values instead.
  35547. */
  35548. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35549. private _forceWireframe;
  35550. /**
  35551. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35552. */
  35553. set forceWireframe(value: boolean);
  35554. get forceWireframe(): boolean;
  35555. private _skipFrustumClipping;
  35556. /**
  35557. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35558. */
  35559. set skipFrustumClipping(value: boolean);
  35560. get skipFrustumClipping(): boolean;
  35561. private _forcePointsCloud;
  35562. /**
  35563. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35564. */
  35565. set forcePointsCloud(value: boolean);
  35566. get forcePointsCloud(): boolean;
  35567. /**
  35568. * Gets or sets the active clipplane 1
  35569. */
  35570. clipPlane: Nullable<Plane>;
  35571. /**
  35572. * Gets or sets the active clipplane 2
  35573. */
  35574. clipPlane2: Nullable<Plane>;
  35575. /**
  35576. * Gets or sets the active clipplane 3
  35577. */
  35578. clipPlane3: Nullable<Plane>;
  35579. /**
  35580. * Gets or sets the active clipplane 4
  35581. */
  35582. clipPlane4: Nullable<Plane>;
  35583. /**
  35584. * Gets or sets the active clipplane 5
  35585. */
  35586. clipPlane5: Nullable<Plane>;
  35587. /**
  35588. * Gets or sets the active clipplane 6
  35589. */
  35590. clipPlane6: Nullable<Plane>;
  35591. /**
  35592. * Gets or sets a boolean indicating if animations are enabled
  35593. */
  35594. animationsEnabled: boolean;
  35595. private _animationPropertiesOverride;
  35596. /**
  35597. * Gets or sets the animation properties override
  35598. */
  35599. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35600. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35601. /**
  35602. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35603. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35604. */
  35605. useConstantAnimationDeltaTime: boolean;
  35606. /**
  35607. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35608. * Please note that it requires to run a ray cast through the scene on every frame
  35609. */
  35610. constantlyUpdateMeshUnderPointer: boolean;
  35611. /**
  35612. * Defines the HTML cursor to use when hovering over interactive elements
  35613. */
  35614. hoverCursor: string;
  35615. /**
  35616. * Defines the HTML default cursor to use (empty by default)
  35617. */
  35618. defaultCursor: string;
  35619. /**
  35620. * Defines whether cursors are handled by the scene.
  35621. */
  35622. doNotHandleCursors: boolean;
  35623. /**
  35624. * This is used to call preventDefault() on pointer down
  35625. * in order to block unwanted artifacts like system double clicks
  35626. */
  35627. preventDefaultOnPointerDown: boolean;
  35628. /**
  35629. * This is used to call preventDefault() on pointer up
  35630. * in order to block unwanted artifacts like system double clicks
  35631. */
  35632. preventDefaultOnPointerUp: boolean;
  35633. /**
  35634. * Gets or sets user defined metadata
  35635. */
  35636. metadata: any;
  35637. /**
  35638. * For internal use only. Please do not use.
  35639. */
  35640. reservedDataStore: any;
  35641. /**
  35642. * Gets the name of the plugin used to load this scene (null by default)
  35643. */
  35644. loadingPluginName: string;
  35645. /**
  35646. * Use this array to add regular expressions used to disable offline support for specific urls
  35647. */
  35648. disableOfflineSupportExceptionRules: RegExp[];
  35649. /**
  35650. * An event triggered when the scene is disposed.
  35651. */
  35652. onDisposeObservable: Observable<Scene>;
  35653. private _onDisposeObserver;
  35654. /** Sets a function to be executed when this scene is disposed. */
  35655. set onDispose(callback: () => void);
  35656. /**
  35657. * An event triggered before rendering the scene (right after animations and physics)
  35658. */
  35659. onBeforeRenderObservable: Observable<Scene>;
  35660. private _onBeforeRenderObserver;
  35661. /** Sets a function to be executed before rendering this scene */
  35662. set beforeRender(callback: Nullable<() => void>);
  35663. /**
  35664. * An event triggered after rendering the scene
  35665. */
  35666. onAfterRenderObservable: Observable<Scene>;
  35667. /**
  35668. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35669. */
  35670. onAfterRenderCameraObservable: Observable<Camera>;
  35671. private _onAfterRenderObserver;
  35672. /** Sets a function to be executed after rendering this scene */
  35673. set afterRender(callback: Nullable<() => void>);
  35674. /**
  35675. * An event triggered before animating the scene
  35676. */
  35677. onBeforeAnimationsObservable: Observable<Scene>;
  35678. /**
  35679. * An event triggered after animations processing
  35680. */
  35681. onAfterAnimationsObservable: Observable<Scene>;
  35682. /**
  35683. * An event triggered before draw calls are ready to be sent
  35684. */
  35685. onBeforeDrawPhaseObservable: Observable<Scene>;
  35686. /**
  35687. * An event triggered after draw calls have been sent
  35688. */
  35689. onAfterDrawPhaseObservable: Observable<Scene>;
  35690. /**
  35691. * An event triggered when the scene is ready
  35692. */
  35693. onReadyObservable: Observable<Scene>;
  35694. /**
  35695. * An event triggered before rendering a camera
  35696. */
  35697. onBeforeCameraRenderObservable: Observable<Camera>;
  35698. private _onBeforeCameraRenderObserver;
  35699. /** Sets a function to be executed before rendering a camera*/
  35700. set beforeCameraRender(callback: () => void);
  35701. /**
  35702. * An event triggered after rendering a camera
  35703. */
  35704. onAfterCameraRenderObservable: Observable<Camera>;
  35705. private _onAfterCameraRenderObserver;
  35706. /** Sets a function to be executed after rendering a camera*/
  35707. set afterCameraRender(callback: () => void);
  35708. /**
  35709. * An event triggered when active meshes evaluation is about to start
  35710. */
  35711. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35712. /**
  35713. * An event triggered when active meshes evaluation is done
  35714. */
  35715. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35716. /**
  35717. * An event triggered when particles rendering is about to start
  35718. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35719. */
  35720. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35721. /**
  35722. * An event triggered when particles rendering is done
  35723. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35724. */
  35725. onAfterParticlesRenderingObservable: Observable<Scene>;
  35726. /**
  35727. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35728. */
  35729. onDataLoadedObservable: Observable<Scene>;
  35730. /**
  35731. * An event triggered when a camera is created
  35732. */
  35733. onNewCameraAddedObservable: Observable<Camera>;
  35734. /**
  35735. * An event triggered when a camera is removed
  35736. */
  35737. onCameraRemovedObservable: Observable<Camera>;
  35738. /**
  35739. * An event triggered when a light is created
  35740. */
  35741. onNewLightAddedObservable: Observable<Light>;
  35742. /**
  35743. * An event triggered when a light is removed
  35744. */
  35745. onLightRemovedObservable: Observable<Light>;
  35746. /**
  35747. * An event triggered when a geometry is created
  35748. */
  35749. onNewGeometryAddedObservable: Observable<Geometry>;
  35750. /**
  35751. * An event triggered when a geometry is removed
  35752. */
  35753. onGeometryRemovedObservable: Observable<Geometry>;
  35754. /**
  35755. * An event triggered when a transform node is created
  35756. */
  35757. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35758. /**
  35759. * An event triggered when a transform node is removed
  35760. */
  35761. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35762. /**
  35763. * An event triggered when a mesh is created
  35764. */
  35765. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35766. /**
  35767. * An event triggered when a mesh is removed
  35768. */
  35769. onMeshRemovedObservable: Observable<AbstractMesh>;
  35770. /**
  35771. * An event triggered when a skeleton is created
  35772. */
  35773. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35774. /**
  35775. * An event triggered when a skeleton is removed
  35776. */
  35777. onSkeletonRemovedObservable: Observable<Skeleton>;
  35778. /**
  35779. * An event triggered when a material is created
  35780. */
  35781. onNewMaterialAddedObservable: Observable<Material>;
  35782. /**
  35783. * An event triggered when a material is removed
  35784. */
  35785. onMaterialRemovedObservable: Observable<Material>;
  35786. /**
  35787. * An event triggered when a texture is created
  35788. */
  35789. onNewTextureAddedObservable: Observable<BaseTexture>;
  35790. /**
  35791. * An event triggered when a texture is removed
  35792. */
  35793. onTextureRemovedObservable: Observable<BaseTexture>;
  35794. /**
  35795. * An event triggered when render targets are about to be rendered
  35796. * Can happen multiple times per frame.
  35797. */
  35798. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35799. /**
  35800. * An event triggered when render targets were rendered.
  35801. * Can happen multiple times per frame.
  35802. */
  35803. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35804. /**
  35805. * An event triggered before calculating deterministic simulation step
  35806. */
  35807. onBeforeStepObservable: Observable<Scene>;
  35808. /**
  35809. * An event triggered after calculating deterministic simulation step
  35810. */
  35811. onAfterStepObservable: Observable<Scene>;
  35812. /**
  35813. * An event triggered when the activeCamera property is updated
  35814. */
  35815. onActiveCameraChanged: Observable<Scene>;
  35816. /**
  35817. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35818. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35819. * 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)
  35820. */
  35821. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35822. /**
  35823. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35824. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35825. * 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)
  35826. */
  35827. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35828. /**
  35829. * This Observable will when a mesh has been imported into the scene.
  35830. */
  35831. onMeshImportedObservable: Observable<AbstractMesh>;
  35832. /**
  35833. * This Observable will when an animation file has been imported into the scene.
  35834. */
  35835. onAnimationFileImportedObservable: Observable<Scene>;
  35836. /**
  35837. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35838. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35839. */
  35840. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35841. /** @hidden */
  35842. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35843. /**
  35844. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35845. */
  35846. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35847. /**
  35848. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35849. */
  35850. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35851. /**
  35852. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35853. */
  35854. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35855. /** Callback called when a pointer move is detected */
  35856. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35857. /** Callback called when a pointer down is detected */
  35858. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35859. /** Callback called when a pointer up is detected */
  35860. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35861. /** Callback called when a pointer pick is detected */
  35862. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35863. /**
  35864. * 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).
  35865. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35866. */
  35867. onPrePointerObservable: Observable<PointerInfoPre>;
  35868. /**
  35869. * Observable event triggered each time an input event is received from the rendering canvas
  35870. */
  35871. onPointerObservable: Observable<PointerInfo>;
  35872. /**
  35873. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35874. */
  35875. get unTranslatedPointer(): Vector2;
  35876. /**
  35877. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35878. */
  35879. static get DragMovementThreshold(): number;
  35880. static set DragMovementThreshold(value: number);
  35881. /**
  35882. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35883. */
  35884. static get LongPressDelay(): number;
  35885. static set LongPressDelay(value: number);
  35886. /**
  35887. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35888. */
  35889. static get DoubleClickDelay(): number;
  35890. static set DoubleClickDelay(value: number);
  35891. /** If you need to check double click without raising a single click at first click, enable this flag */
  35892. static get ExclusiveDoubleClickMode(): boolean;
  35893. static set ExclusiveDoubleClickMode(value: boolean);
  35894. /** @hidden */
  35895. _mirroredCameraPosition: Nullable<Vector3>;
  35896. /**
  35897. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35898. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35899. */
  35900. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35901. /**
  35902. * Observable event triggered each time an keyboard event is received from the hosting window
  35903. */
  35904. onKeyboardObservable: Observable<KeyboardInfo>;
  35905. private _useRightHandedSystem;
  35906. /**
  35907. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35908. */
  35909. set useRightHandedSystem(value: boolean);
  35910. get useRightHandedSystem(): boolean;
  35911. private _timeAccumulator;
  35912. private _currentStepId;
  35913. private _currentInternalStep;
  35914. /**
  35915. * Sets the step Id used by deterministic lock step
  35916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35917. * @param newStepId defines the step Id
  35918. */
  35919. setStepId(newStepId: number): void;
  35920. /**
  35921. * Gets the step Id used by deterministic lock step
  35922. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35923. * @returns the step Id
  35924. */
  35925. getStepId(): number;
  35926. /**
  35927. * Gets the internal step used by deterministic lock step
  35928. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35929. * @returns the internal step
  35930. */
  35931. getInternalStep(): number;
  35932. private _fogEnabled;
  35933. /**
  35934. * Gets or sets a boolean indicating if fog is enabled on this scene
  35935. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35936. * (Default is true)
  35937. */
  35938. set fogEnabled(value: boolean);
  35939. get fogEnabled(): boolean;
  35940. private _fogMode;
  35941. /**
  35942. * Gets or sets the fog mode to use
  35943. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35944. * | mode | value |
  35945. * | --- | --- |
  35946. * | FOGMODE_NONE | 0 |
  35947. * | FOGMODE_EXP | 1 |
  35948. * | FOGMODE_EXP2 | 2 |
  35949. * | FOGMODE_LINEAR | 3 |
  35950. */
  35951. set fogMode(value: number);
  35952. get fogMode(): number;
  35953. /**
  35954. * Gets or sets the fog color to use
  35955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35956. * (Default is Color3(0.2, 0.2, 0.3))
  35957. */
  35958. fogColor: Color3;
  35959. /**
  35960. * Gets or sets the fog density to use
  35961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35962. * (Default is 0.1)
  35963. */
  35964. fogDensity: number;
  35965. /**
  35966. * Gets or sets the fog start distance to use
  35967. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35968. * (Default is 0)
  35969. */
  35970. fogStart: number;
  35971. /**
  35972. * Gets or sets the fog end distance to use
  35973. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35974. * (Default is 1000)
  35975. */
  35976. fogEnd: number;
  35977. private _shadowsEnabled;
  35978. /**
  35979. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35980. */
  35981. set shadowsEnabled(value: boolean);
  35982. get shadowsEnabled(): boolean;
  35983. private _lightsEnabled;
  35984. /**
  35985. * Gets or sets a boolean indicating if lights are enabled on this scene
  35986. */
  35987. set lightsEnabled(value: boolean);
  35988. get lightsEnabled(): boolean;
  35989. /** All of the active cameras added to this scene. */
  35990. activeCameras: Camera[];
  35991. /** @hidden */
  35992. _activeCamera: Nullable<Camera>;
  35993. /** Gets or sets the current active camera */
  35994. get activeCamera(): Nullable<Camera>;
  35995. set activeCamera(value: Nullable<Camera>);
  35996. private _defaultMaterial;
  35997. /** The default material used on meshes when no material is affected */
  35998. get defaultMaterial(): Material;
  35999. /** The default material used on meshes when no material is affected */
  36000. set defaultMaterial(value: Material);
  36001. private _texturesEnabled;
  36002. /**
  36003. * Gets or sets a boolean indicating if textures are enabled on this scene
  36004. */
  36005. set texturesEnabled(value: boolean);
  36006. get texturesEnabled(): boolean;
  36007. /**
  36008. * Gets or sets a boolean indicating if particles are enabled on this scene
  36009. */
  36010. particlesEnabled: boolean;
  36011. /**
  36012. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36013. */
  36014. spritesEnabled: boolean;
  36015. private _skeletonsEnabled;
  36016. /**
  36017. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36018. */
  36019. set skeletonsEnabled(value: boolean);
  36020. get skeletonsEnabled(): boolean;
  36021. /**
  36022. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36023. */
  36024. lensFlaresEnabled: boolean;
  36025. /**
  36026. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36027. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36028. */
  36029. collisionsEnabled: boolean;
  36030. private _collisionCoordinator;
  36031. /** @hidden */
  36032. get collisionCoordinator(): ICollisionCoordinator;
  36033. /**
  36034. * Defines the gravity applied to this scene (used only for collisions)
  36035. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36036. */
  36037. gravity: Vector3;
  36038. /**
  36039. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36040. */
  36041. postProcessesEnabled: boolean;
  36042. /**
  36043. * The list of postprocesses added to the scene
  36044. */
  36045. postProcesses: PostProcess[];
  36046. /**
  36047. * Gets the current postprocess manager
  36048. */
  36049. postProcessManager: PostProcessManager;
  36050. /**
  36051. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36052. */
  36053. renderTargetsEnabled: boolean;
  36054. /**
  36055. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36056. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36057. */
  36058. dumpNextRenderTargets: boolean;
  36059. /**
  36060. * The list of user defined render targets added to the scene
  36061. */
  36062. customRenderTargets: RenderTargetTexture[];
  36063. /**
  36064. * Defines if texture loading must be delayed
  36065. * If true, textures will only be loaded when they need to be rendered
  36066. */
  36067. useDelayedTextureLoading: boolean;
  36068. /**
  36069. * Gets the list of meshes imported to the scene through SceneLoader
  36070. */
  36071. importedMeshesFiles: String[];
  36072. /**
  36073. * Gets or sets a boolean indicating if probes are enabled on this scene
  36074. */
  36075. probesEnabled: boolean;
  36076. /**
  36077. * Gets or sets the current offline provider to use to store scene data
  36078. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36079. */
  36080. offlineProvider: IOfflineProvider;
  36081. /**
  36082. * Gets or sets the action manager associated with the scene
  36083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36084. */
  36085. actionManager: AbstractActionManager;
  36086. private _meshesForIntersections;
  36087. /**
  36088. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36089. */
  36090. proceduralTexturesEnabled: boolean;
  36091. private _engine;
  36092. private _totalVertices;
  36093. /** @hidden */
  36094. _activeIndices: PerfCounter;
  36095. /** @hidden */
  36096. _activeParticles: PerfCounter;
  36097. /** @hidden */
  36098. _activeBones: PerfCounter;
  36099. private _animationRatio;
  36100. /** @hidden */
  36101. _animationTimeLast: number;
  36102. /** @hidden */
  36103. _animationTime: number;
  36104. /**
  36105. * Gets or sets a general scale for animation speed
  36106. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36107. */
  36108. animationTimeScale: number;
  36109. /** @hidden */
  36110. _cachedMaterial: Nullable<Material>;
  36111. /** @hidden */
  36112. _cachedEffect: Nullable<Effect>;
  36113. /** @hidden */
  36114. _cachedVisibility: Nullable<number>;
  36115. private _renderId;
  36116. private _frameId;
  36117. private _executeWhenReadyTimeoutId;
  36118. private _intermediateRendering;
  36119. private _viewUpdateFlag;
  36120. private _projectionUpdateFlag;
  36121. /** @hidden */
  36122. _toBeDisposed: Nullable<IDisposable>[];
  36123. private _activeRequests;
  36124. /** @hidden */
  36125. _pendingData: any[];
  36126. private _isDisposed;
  36127. /**
  36128. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36129. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36130. */
  36131. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36132. private _activeMeshes;
  36133. private _processedMaterials;
  36134. private _renderTargets;
  36135. /** @hidden */
  36136. _activeParticleSystems: SmartArray<IParticleSystem>;
  36137. private _activeSkeletons;
  36138. private _softwareSkinnedMeshes;
  36139. private _renderingManager;
  36140. /** @hidden */
  36141. _activeAnimatables: Animatable[];
  36142. private _transformMatrix;
  36143. private _sceneUbo;
  36144. /** @hidden */
  36145. _viewMatrix: Matrix;
  36146. private _projectionMatrix;
  36147. /** @hidden */
  36148. _forcedViewPosition: Nullable<Vector3>;
  36149. /** @hidden */
  36150. _frustumPlanes: Plane[];
  36151. /**
  36152. * Gets the list of frustum planes (built from the active camera)
  36153. */
  36154. get frustumPlanes(): Plane[];
  36155. /**
  36156. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36157. * This is useful if there are more lights that the maximum simulteanous authorized
  36158. */
  36159. requireLightSorting: boolean;
  36160. /** @hidden */
  36161. readonly useMaterialMeshMap: boolean;
  36162. /** @hidden */
  36163. readonly useClonedMeshMap: boolean;
  36164. private _externalData;
  36165. private _uid;
  36166. /**
  36167. * @hidden
  36168. * Backing store of defined scene components.
  36169. */
  36170. _components: ISceneComponent[];
  36171. /**
  36172. * @hidden
  36173. * Backing store of defined scene components.
  36174. */
  36175. _serializableComponents: ISceneSerializableComponent[];
  36176. /**
  36177. * List of components to register on the next registration step.
  36178. */
  36179. private _transientComponents;
  36180. /**
  36181. * Registers the transient components if needed.
  36182. */
  36183. private _registerTransientComponents;
  36184. /**
  36185. * @hidden
  36186. * Add a component to the scene.
  36187. * Note that the ccomponent could be registered on th next frame if this is called after
  36188. * the register component stage.
  36189. * @param component Defines the component to add to the scene
  36190. */
  36191. _addComponent(component: ISceneComponent): void;
  36192. /**
  36193. * @hidden
  36194. * Gets a component from the scene.
  36195. * @param name defines the name of the component to retrieve
  36196. * @returns the component or null if not present
  36197. */
  36198. _getComponent(name: string): Nullable<ISceneComponent>;
  36199. /**
  36200. * @hidden
  36201. * Defines the actions happening before camera updates.
  36202. */
  36203. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36204. /**
  36205. * @hidden
  36206. * Defines the actions happening before clear the canvas.
  36207. */
  36208. _beforeClearStage: Stage<SimpleStageAction>;
  36209. /**
  36210. * @hidden
  36211. * Defines the actions when collecting render targets for the frame.
  36212. */
  36213. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36214. /**
  36215. * @hidden
  36216. * Defines the actions happening for one camera in the frame.
  36217. */
  36218. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36219. /**
  36220. * @hidden
  36221. * Defines the actions happening during the per mesh ready checks.
  36222. */
  36223. _isReadyForMeshStage: Stage<MeshStageAction>;
  36224. /**
  36225. * @hidden
  36226. * Defines the actions happening before evaluate active mesh checks.
  36227. */
  36228. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36229. /**
  36230. * @hidden
  36231. * Defines the actions happening during the evaluate sub mesh checks.
  36232. */
  36233. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36234. /**
  36235. * @hidden
  36236. * Defines the actions happening during the active mesh stage.
  36237. */
  36238. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36239. /**
  36240. * @hidden
  36241. * Defines the actions happening during the per camera render target step.
  36242. */
  36243. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36244. /**
  36245. * @hidden
  36246. * Defines the actions happening just before the active camera is drawing.
  36247. */
  36248. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36249. /**
  36250. * @hidden
  36251. * Defines the actions happening just before a render target is drawing.
  36252. */
  36253. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36254. /**
  36255. * @hidden
  36256. * Defines the actions happening just before a rendering group is drawing.
  36257. */
  36258. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36259. /**
  36260. * @hidden
  36261. * Defines the actions happening just before a mesh is drawing.
  36262. */
  36263. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36264. /**
  36265. * @hidden
  36266. * Defines the actions happening just after a mesh has been drawn.
  36267. */
  36268. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36269. /**
  36270. * @hidden
  36271. * Defines the actions happening just after a rendering group has been drawn.
  36272. */
  36273. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36274. /**
  36275. * @hidden
  36276. * Defines the actions happening just after the active camera has been drawn.
  36277. */
  36278. _afterCameraDrawStage: Stage<CameraStageAction>;
  36279. /**
  36280. * @hidden
  36281. * Defines the actions happening just after a render target has been drawn.
  36282. */
  36283. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36284. /**
  36285. * @hidden
  36286. * Defines the actions happening just after rendering all cameras and computing intersections.
  36287. */
  36288. _afterRenderStage: Stage<SimpleStageAction>;
  36289. /**
  36290. * @hidden
  36291. * Defines the actions happening when a pointer move event happens.
  36292. */
  36293. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36294. /**
  36295. * @hidden
  36296. * Defines the actions happening when a pointer down event happens.
  36297. */
  36298. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36299. /**
  36300. * @hidden
  36301. * Defines the actions happening when a pointer up event happens.
  36302. */
  36303. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36304. /**
  36305. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36306. */
  36307. private geometriesByUniqueId;
  36308. /**
  36309. * Creates a new Scene
  36310. * @param engine defines the engine to use to render this scene
  36311. * @param options defines the scene options
  36312. */
  36313. constructor(engine: Engine, options?: SceneOptions);
  36314. /**
  36315. * Gets a string idenfifying the name of the class
  36316. * @returns "Scene" string
  36317. */
  36318. getClassName(): string;
  36319. private _defaultMeshCandidates;
  36320. /**
  36321. * @hidden
  36322. */
  36323. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36324. private _defaultSubMeshCandidates;
  36325. /**
  36326. * @hidden
  36327. */
  36328. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36329. /**
  36330. * Sets the default candidate providers for the scene.
  36331. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36332. * and getCollidingSubMeshCandidates to their default function
  36333. */
  36334. setDefaultCandidateProviders(): void;
  36335. /**
  36336. * Gets the mesh that is currently under the pointer
  36337. */
  36338. get meshUnderPointer(): Nullable<AbstractMesh>;
  36339. /**
  36340. * Gets or sets the current on-screen X position of the pointer
  36341. */
  36342. get pointerX(): number;
  36343. set pointerX(value: number);
  36344. /**
  36345. * Gets or sets the current on-screen Y position of the pointer
  36346. */
  36347. get pointerY(): number;
  36348. set pointerY(value: number);
  36349. /**
  36350. * Gets the cached material (ie. the latest rendered one)
  36351. * @returns the cached material
  36352. */
  36353. getCachedMaterial(): Nullable<Material>;
  36354. /**
  36355. * Gets the cached effect (ie. the latest rendered one)
  36356. * @returns the cached effect
  36357. */
  36358. getCachedEffect(): Nullable<Effect>;
  36359. /**
  36360. * Gets the cached visibility state (ie. the latest rendered one)
  36361. * @returns the cached visibility state
  36362. */
  36363. getCachedVisibility(): Nullable<number>;
  36364. /**
  36365. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36366. * @param material defines the current material
  36367. * @param effect defines the current effect
  36368. * @param visibility defines the current visibility state
  36369. * @returns true if one parameter is not cached
  36370. */
  36371. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36372. /**
  36373. * Gets the engine associated with the scene
  36374. * @returns an Engine
  36375. */
  36376. getEngine(): Engine;
  36377. /**
  36378. * Gets the total number of vertices rendered per frame
  36379. * @returns the total number of vertices rendered per frame
  36380. */
  36381. getTotalVertices(): number;
  36382. /**
  36383. * Gets the performance counter for total vertices
  36384. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36385. */
  36386. get totalVerticesPerfCounter(): PerfCounter;
  36387. /**
  36388. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36389. * @returns the total number of active indices rendered per frame
  36390. */
  36391. getActiveIndices(): number;
  36392. /**
  36393. * Gets the performance counter for active indices
  36394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36395. */
  36396. get totalActiveIndicesPerfCounter(): PerfCounter;
  36397. /**
  36398. * Gets the total number of active particles rendered per frame
  36399. * @returns the total number of active particles rendered per frame
  36400. */
  36401. getActiveParticles(): number;
  36402. /**
  36403. * Gets the performance counter for active particles
  36404. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36405. */
  36406. get activeParticlesPerfCounter(): PerfCounter;
  36407. /**
  36408. * Gets the total number of active bones rendered per frame
  36409. * @returns the total number of active bones rendered per frame
  36410. */
  36411. getActiveBones(): number;
  36412. /**
  36413. * Gets the performance counter for active bones
  36414. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36415. */
  36416. get activeBonesPerfCounter(): PerfCounter;
  36417. /**
  36418. * Gets the array of active meshes
  36419. * @returns an array of AbstractMesh
  36420. */
  36421. getActiveMeshes(): SmartArray<AbstractMesh>;
  36422. /**
  36423. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36424. * @returns a number
  36425. */
  36426. getAnimationRatio(): number;
  36427. /**
  36428. * Gets an unique Id for the current render phase
  36429. * @returns a number
  36430. */
  36431. getRenderId(): number;
  36432. /**
  36433. * Gets an unique Id for the current frame
  36434. * @returns a number
  36435. */
  36436. getFrameId(): number;
  36437. /** Call this function if you want to manually increment the render Id*/
  36438. incrementRenderId(): void;
  36439. private _createUbo;
  36440. /**
  36441. * Use this method to simulate a pointer move on a mesh
  36442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36445. * @returns the current scene
  36446. */
  36447. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36448. /**
  36449. * Use this method to simulate a pointer down on a mesh
  36450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36453. * @returns the current scene
  36454. */
  36455. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36456. /**
  36457. * Use this method to simulate a pointer up on a mesh
  36458. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36459. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36460. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36461. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36462. * @returns the current scene
  36463. */
  36464. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36465. /**
  36466. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36467. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36468. * @returns true if the pointer was captured
  36469. */
  36470. isPointerCaptured(pointerId?: number): boolean;
  36471. /**
  36472. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36473. * @param attachUp defines if you want to attach events to pointerup
  36474. * @param attachDown defines if you want to attach events to pointerdown
  36475. * @param attachMove defines if you want to attach events to pointermove
  36476. */
  36477. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36478. /** Detaches all event handlers*/
  36479. detachControl(): void;
  36480. /**
  36481. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36482. * Delay loaded resources are not taking in account
  36483. * @return true if all required resources are ready
  36484. */
  36485. isReady(): boolean;
  36486. /** Resets all cached information relative to material (including effect and visibility) */
  36487. resetCachedMaterial(): void;
  36488. /**
  36489. * Registers a function to be called before every frame render
  36490. * @param func defines the function to register
  36491. */
  36492. registerBeforeRender(func: () => void): void;
  36493. /**
  36494. * Unregisters a function called before every frame render
  36495. * @param func defines the function to unregister
  36496. */
  36497. unregisterBeforeRender(func: () => void): void;
  36498. /**
  36499. * Registers a function to be called after every frame render
  36500. * @param func defines the function to register
  36501. */
  36502. registerAfterRender(func: () => void): void;
  36503. /**
  36504. * Unregisters a function called after every frame render
  36505. * @param func defines the function to unregister
  36506. */
  36507. unregisterAfterRender(func: () => void): void;
  36508. private _executeOnceBeforeRender;
  36509. /**
  36510. * The provided function will run before render once and will be disposed afterwards.
  36511. * A timeout delay can be provided so that the function will be executed in N ms.
  36512. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36513. * @param func The function to be executed.
  36514. * @param timeout optional delay in ms
  36515. */
  36516. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36517. /** @hidden */
  36518. _addPendingData(data: any): void;
  36519. /** @hidden */
  36520. _removePendingData(data: any): void;
  36521. /**
  36522. * Returns the number of items waiting to be loaded
  36523. * @returns the number of items waiting to be loaded
  36524. */
  36525. getWaitingItemsCount(): number;
  36526. /**
  36527. * Returns a boolean indicating if the scene is still loading data
  36528. */
  36529. get isLoading(): boolean;
  36530. /**
  36531. * Registers a function to be executed when the scene is ready
  36532. * @param {Function} func - the function to be executed
  36533. */
  36534. executeWhenReady(func: () => void): void;
  36535. /**
  36536. * Returns a promise that resolves when the scene is ready
  36537. * @returns A promise that resolves when the scene is ready
  36538. */
  36539. whenReadyAsync(): Promise<void>;
  36540. /** @hidden */
  36541. _checkIsReady(): void;
  36542. /**
  36543. * Gets all animatable attached to the scene
  36544. */
  36545. get animatables(): Animatable[];
  36546. /**
  36547. * Resets the last animation time frame.
  36548. * Useful to override when animations start running when loading a scene for the first time.
  36549. */
  36550. resetLastAnimationTimeFrame(): void;
  36551. /**
  36552. * Gets the current view matrix
  36553. * @returns a Matrix
  36554. */
  36555. getViewMatrix(): Matrix;
  36556. /**
  36557. * Gets the current projection matrix
  36558. * @returns a Matrix
  36559. */
  36560. getProjectionMatrix(): Matrix;
  36561. /**
  36562. * Gets the current transform matrix
  36563. * @returns a Matrix made of View * Projection
  36564. */
  36565. getTransformMatrix(): Matrix;
  36566. /**
  36567. * Sets the current transform matrix
  36568. * @param viewL defines the View matrix to use
  36569. * @param projectionL defines the Projection matrix to use
  36570. * @param viewR defines the right View matrix to use (if provided)
  36571. * @param projectionR defines the right Projection matrix to use (if provided)
  36572. */
  36573. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36574. /**
  36575. * Gets the uniform buffer used to store scene data
  36576. * @returns a UniformBuffer
  36577. */
  36578. getSceneUniformBuffer(): UniformBuffer;
  36579. /**
  36580. * Gets an unique (relatively to the current scene) Id
  36581. * @returns an unique number for the scene
  36582. */
  36583. getUniqueId(): number;
  36584. /**
  36585. * Add a mesh to the list of scene's meshes
  36586. * @param newMesh defines the mesh to add
  36587. * @param recursive if all child meshes should also be added to the scene
  36588. */
  36589. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36590. /**
  36591. * Remove a mesh for the list of scene's meshes
  36592. * @param toRemove defines the mesh to remove
  36593. * @param recursive if all child meshes should also be removed from the scene
  36594. * @returns the index where the mesh was in the mesh list
  36595. */
  36596. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36597. /**
  36598. * Add a transform node to the list of scene's transform nodes
  36599. * @param newTransformNode defines the transform node to add
  36600. */
  36601. addTransformNode(newTransformNode: TransformNode): void;
  36602. /**
  36603. * Remove a transform node for the list of scene's transform nodes
  36604. * @param toRemove defines the transform node to remove
  36605. * @returns the index where the transform node was in the transform node list
  36606. */
  36607. removeTransformNode(toRemove: TransformNode): number;
  36608. /**
  36609. * Remove a skeleton for the list of scene's skeletons
  36610. * @param toRemove defines the skeleton to remove
  36611. * @returns the index where the skeleton was in the skeleton list
  36612. */
  36613. removeSkeleton(toRemove: Skeleton): number;
  36614. /**
  36615. * Remove a morph target for the list of scene's morph targets
  36616. * @param toRemove defines the morph target to remove
  36617. * @returns the index where the morph target was in the morph target list
  36618. */
  36619. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36620. /**
  36621. * Remove a light for the list of scene's lights
  36622. * @param toRemove defines the light to remove
  36623. * @returns the index where the light was in the light list
  36624. */
  36625. removeLight(toRemove: Light): number;
  36626. /**
  36627. * Remove a camera for the list of scene's cameras
  36628. * @param toRemove defines the camera to remove
  36629. * @returns the index where the camera was in the camera list
  36630. */
  36631. removeCamera(toRemove: Camera): number;
  36632. /**
  36633. * Remove a particle system for the list of scene's particle systems
  36634. * @param toRemove defines the particle system to remove
  36635. * @returns the index where the particle system was in the particle system list
  36636. */
  36637. removeParticleSystem(toRemove: IParticleSystem): number;
  36638. /**
  36639. * Remove a animation for the list of scene's animations
  36640. * @param toRemove defines the animation to remove
  36641. * @returns the index where the animation was in the animation list
  36642. */
  36643. removeAnimation(toRemove: Animation): number;
  36644. /**
  36645. * Will stop the animation of the given target
  36646. * @param target - the target
  36647. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36648. * @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)
  36649. */
  36650. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36651. /**
  36652. * Removes the given animation group from this scene.
  36653. * @param toRemove The animation group to remove
  36654. * @returns The index of the removed animation group
  36655. */
  36656. removeAnimationGroup(toRemove: AnimationGroup): number;
  36657. /**
  36658. * Removes the given multi-material from this scene.
  36659. * @param toRemove The multi-material to remove
  36660. * @returns The index of the removed multi-material
  36661. */
  36662. removeMultiMaterial(toRemove: MultiMaterial): number;
  36663. /**
  36664. * Removes the given material from this scene.
  36665. * @param toRemove The material to remove
  36666. * @returns The index of the removed material
  36667. */
  36668. removeMaterial(toRemove: Material): number;
  36669. /**
  36670. * Removes the given action manager from this scene.
  36671. * @param toRemove The action manager to remove
  36672. * @returns The index of the removed action manager
  36673. */
  36674. removeActionManager(toRemove: AbstractActionManager): number;
  36675. /**
  36676. * Removes the given texture from this scene.
  36677. * @param toRemove The texture to remove
  36678. * @returns The index of the removed texture
  36679. */
  36680. removeTexture(toRemove: BaseTexture): number;
  36681. /**
  36682. * Adds the given light to this scene
  36683. * @param newLight The light to add
  36684. */
  36685. addLight(newLight: Light): void;
  36686. /**
  36687. * Sorts the list list based on light priorities
  36688. */
  36689. sortLightsByPriority(): void;
  36690. /**
  36691. * Adds the given camera to this scene
  36692. * @param newCamera The camera to add
  36693. */
  36694. addCamera(newCamera: Camera): void;
  36695. /**
  36696. * Adds the given skeleton to this scene
  36697. * @param newSkeleton The skeleton to add
  36698. */
  36699. addSkeleton(newSkeleton: Skeleton): void;
  36700. /**
  36701. * Adds the given particle system to this scene
  36702. * @param newParticleSystem The particle system to add
  36703. */
  36704. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36705. /**
  36706. * Adds the given animation to this scene
  36707. * @param newAnimation The animation to add
  36708. */
  36709. addAnimation(newAnimation: Animation): void;
  36710. /**
  36711. * Adds the given animation group to this scene.
  36712. * @param newAnimationGroup The animation group to add
  36713. */
  36714. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36715. /**
  36716. * Adds the given multi-material to this scene
  36717. * @param newMultiMaterial The multi-material to add
  36718. */
  36719. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36720. /**
  36721. * Adds the given material to this scene
  36722. * @param newMaterial The material to add
  36723. */
  36724. addMaterial(newMaterial: Material): void;
  36725. /**
  36726. * Adds the given morph target to this scene
  36727. * @param newMorphTargetManager The morph target to add
  36728. */
  36729. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36730. /**
  36731. * Adds the given geometry to this scene
  36732. * @param newGeometry The geometry to add
  36733. */
  36734. addGeometry(newGeometry: Geometry): void;
  36735. /**
  36736. * Adds the given action manager to this scene
  36737. * @param newActionManager The action manager to add
  36738. */
  36739. addActionManager(newActionManager: AbstractActionManager): void;
  36740. /**
  36741. * Adds the given texture to this scene.
  36742. * @param newTexture The texture to add
  36743. */
  36744. addTexture(newTexture: BaseTexture): void;
  36745. /**
  36746. * Switch active camera
  36747. * @param newCamera defines the new active camera
  36748. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36749. */
  36750. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36751. /**
  36752. * sets the active camera of the scene using its ID
  36753. * @param id defines the camera's ID
  36754. * @return the new active camera or null if none found.
  36755. */
  36756. setActiveCameraByID(id: string): Nullable<Camera>;
  36757. /**
  36758. * sets the active camera of the scene using its name
  36759. * @param name defines the camera's name
  36760. * @returns the new active camera or null if none found.
  36761. */
  36762. setActiveCameraByName(name: string): Nullable<Camera>;
  36763. /**
  36764. * get an animation group using its name
  36765. * @param name defines the material's name
  36766. * @return the animation group or null if none found.
  36767. */
  36768. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36769. /**
  36770. * Get a material using its unique id
  36771. * @param uniqueId defines the material's unique id
  36772. * @return the material or null if none found.
  36773. */
  36774. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36775. /**
  36776. * get a material using its id
  36777. * @param id defines the material's ID
  36778. * @return the material or null if none found.
  36779. */
  36780. getMaterialByID(id: string): Nullable<Material>;
  36781. /**
  36782. * Gets a the last added material using a given id
  36783. * @param id defines the material's ID
  36784. * @return the last material with the given id or null if none found.
  36785. */
  36786. getLastMaterialByID(id: string): Nullable<Material>;
  36787. /**
  36788. * Gets a material using its name
  36789. * @param name defines the material's name
  36790. * @return the material or null if none found.
  36791. */
  36792. getMaterialByName(name: string): Nullable<Material>;
  36793. /**
  36794. * Get a texture using its unique id
  36795. * @param uniqueId defines the texture's unique id
  36796. * @return the texture or null if none found.
  36797. */
  36798. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36799. /**
  36800. * Gets a camera using its id
  36801. * @param id defines the id to look for
  36802. * @returns the camera or null if not found
  36803. */
  36804. getCameraByID(id: string): Nullable<Camera>;
  36805. /**
  36806. * Gets a camera using its unique id
  36807. * @param uniqueId defines the unique id to look for
  36808. * @returns the camera or null if not found
  36809. */
  36810. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36811. /**
  36812. * Gets a camera using its name
  36813. * @param name defines the camera's name
  36814. * @return the camera or null if none found.
  36815. */
  36816. getCameraByName(name: string): Nullable<Camera>;
  36817. /**
  36818. * Gets a bone using its id
  36819. * @param id defines the bone's id
  36820. * @return the bone or null if not found
  36821. */
  36822. getBoneByID(id: string): Nullable<Bone>;
  36823. /**
  36824. * Gets a bone using its id
  36825. * @param name defines the bone's name
  36826. * @return the bone or null if not found
  36827. */
  36828. getBoneByName(name: string): Nullable<Bone>;
  36829. /**
  36830. * Gets a light node using its name
  36831. * @param name defines the the light's name
  36832. * @return the light or null if none found.
  36833. */
  36834. getLightByName(name: string): Nullable<Light>;
  36835. /**
  36836. * Gets a light node using its id
  36837. * @param id defines the light's id
  36838. * @return the light or null if none found.
  36839. */
  36840. getLightByID(id: string): Nullable<Light>;
  36841. /**
  36842. * Gets a light node using its scene-generated unique ID
  36843. * @param uniqueId defines the light's unique id
  36844. * @return the light or null if none found.
  36845. */
  36846. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36847. /**
  36848. * Gets a particle system by id
  36849. * @param id defines the particle system id
  36850. * @return the corresponding system or null if none found
  36851. */
  36852. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36853. /**
  36854. * Gets a geometry using its ID
  36855. * @param id defines the geometry's id
  36856. * @return the geometry or null if none found.
  36857. */
  36858. getGeometryByID(id: string): Nullable<Geometry>;
  36859. private _getGeometryByUniqueID;
  36860. /**
  36861. * Add a new geometry to this scene
  36862. * @param geometry defines the geometry to be added to the scene.
  36863. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36864. * @return a boolean defining if the geometry was added or not
  36865. */
  36866. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36867. /**
  36868. * Removes an existing geometry
  36869. * @param geometry defines the geometry to be removed from the scene
  36870. * @return a boolean defining if the geometry was removed or not
  36871. */
  36872. removeGeometry(geometry: Geometry): boolean;
  36873. /**
  36874. * Gets the list of geometries attached to the scene
  36875. * @returns an array of Geometry
  36876. */
  36877. getGeometries(): Geometry[];
  36878. /**
  36879. * Gets the first added mesh found of a given ID
  36880. * @param id defines the id to search for
  36881. * @return the mesh found or null if not found at all
  36882. */
  36883. getMeshByID(id: string): Nullable<AbstractMesh>;
  36884. /**
  36885. * Gets a list of meshes using their id
  36886. * @param id defines the id to search for
  36887. * @returns a list of meshes
  36888. */
  36889. getMeshesByID(id: string): Array<AbstractMesh>;
  36890. /**
  36891. * Gets the first added transform node found of a given ID
  36892. * @param id defines the id to search for
  36893. * @return the found transform node or null if not found at all.
  36894. */
  36895. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36896. /**
  36897. * Gets a transform node with its auto-generated unique id
  36898. * @param uniqueId efines the unique id to search for
  36899. * @return the found transform node or null if not found at all.
  36900. */
  36901. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36902. /**
  36903. * Gets a list of transform nodes using their id
  36904. * @param id defines the id to search for
  36905. * @returns a list of transform nodes
  36906. */
  36907. getTransformNodesByID(id: string): Array<TransformNode>;
  36908. /**
  36909. * Gets a mesh with its auto-generated unique id
  36910. * @param uniqueId defines the unique id to search for
  36911. * @return the found mesh or null if not found at all.
  36912. */
  36913. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36914. /**
  36915. * Gets a the last added mesh using a given id
  36916. * @param id defines the id to search for
  36917. * @return the found mesh or null if not found at all.
  36918. */
  36919. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36920. /**
  36921. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36922. * @param id defines the id to search for
  36923. * @return the found node or null if not found at all
  36924. */
  36925. getLastEntryByID(id: string): Nullable<Node>;
  36926. /**
  36927. * Gets a node (Mesh, Camera, Light) using a given id
  36928. * @param id defines the id to search for
  36929. * @return the found node or null if not found at all
  36930. */
  36931. getNodeByID(id: string): Nullable<Node>;
  36932. /**
  36933. * Gets a node (Mesh, Camera, Light) using a given name
  36934. * @param name defines the name to search for
  36935. * @return the found node or null if not found at all.
  36936. */
  36937. getNodeByName(name: string): Nullable<Node>;
  36938. /**
  36939. * Gets a mesh using a given name
  36940. * @param name defines the name to search for
  36941. * @return the found mesh or null if not found at all.
  36942. */
  36943. getMeshByName(name: string): Nullable<AbstractMesh>;
  36944. /**
  36945. * Gets a transform node using a given name
  36946. * @param name defines the name to search for
  36947. * @return the found transform node or null if not found at all.
  36948. */
  36949. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36950. /**
  36951. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36952. * @param id defines the id to search for
  36953. * @return the found skeleton or null if not found at all.
  36954. */
  36955. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36956. /**
  36957. * Gets a skeleton using a given auto generated unique id
  36958. * @param uniqueId defines the unique id to search for
  36959. * @return the found skeleton or null if not found at all.
  36960. */
  36961. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36962. /**
  36963. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36964. * @param id defines the id to search for
  36965. * @return the found skeleton or null if not found at all.
  36966. */
  36967. getSkeletonById(id: string): Nullable<Skeleton>;
  36968. /**
  36969. * Gets a skeleton using a given name
  36970. * @param name defines the name to search for
  36971. * @return the found skeleton or null if not found at all.
  36972. */
  36973. getSkeletonByName(name: string): Nullable<Skeleton>;
  36974. /**
  36975. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36976. * @param id defines the id to search for
  36977. * @return the found morph target manager or null if not found at all.
  36978. */
  36979. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36980. /**
  36981. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36982. * @param id defines the id to search for
  36983. * @return the found morph target or null if not found at all.
  36984. */
  36985. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36986. /**
  36987. * Gets a boolean indicating if the given mesh is active
  36988. * @param mesh defines the mesh to look for
  36989. * @returns true if the mesh is in the active list
  36990. */
  36991. isActiveMesh(mesh: AbstractMesh): boolean;
  36992. /**
  36993. * Return a unique id as a string which can serve as an identifier for the scene
  36994. */
  36995. get uid(): string;
  36996. /**
  36997. * Add an externaly attached data from its key.
  36998. * This method call will fail and return false, if such key already exists.
  36999. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37000. * @param key the unique key that identifies the data
  37001. * @param data the data object to associate to the key for this Engine instance
  37002. * @return true if no such key were already present and the data was added successfully, false otherwise
  37003. */
  37004. addExternalData<T>(key: string, data: T): boolean;
  37005. /**
  37006. * Get an externaly attached data from its key
  37007. * @param key the unique key that identifies the data
  37008. * @return the associated data, if present (can be null), or undefined if not present
  37009. */
  37010. getExternalData<T>(key: string): Nullable<T>;
  37011. /**
  37012. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37013. * @param key the unique key that identifies the data
  37014. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37015. * @return the associated data, can be null if the factory returned null.
  37016. */
  37017. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37018. /**
  37019. * Remove an externaly attached data from the Engine instance
  37020. * @param key the unique key that identifies the data
  37021. * @return true if the data was successfully removed, false if it doesn't exist
  37022. */
  37023. removeExternalData(key: string): boolean;
  37024. private _evaluateSubMesh;
  37025. /**
  37026. * Clear the processed materials smart array preventing retention point in material dispose.
  37027. */
  37028. freeProcessedMaterials(): void;
  37029. private _preventFreeActiveMeshesAndRenderingGroups;
  37030. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37031. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37032. * when disposing several meshes in a row or a hierarchy of meshes.
  37033. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37034. */
  37035. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37036. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37037. /**
  37038. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37039. */
  37040. freeActiveMeshes(): void;
  37041. /**
  37042. * Clear the info related to rendering groups preventing retention points during dispose.
  37043. */
  37044. freeRenderingGroups(): void;
  37045. /** @hidden */
  37046. _isInIntermediateRendering(): boolean;
  37047. /**
  37048. * Lambda returning the list of potentially active meshes.
  37049. */
  37050. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37051. /**
  37052. * Lambda returning the list of potentially active sub meshes.
  37053. */
  37054. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37055. /**
  37056. * Lambda returning the list of potentially intersecting sub meshes.
  37057. */
  37058. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37059. /**
  37060. * Lambda returning the list of potentially colliding sub meshes.
  37061. */
  37062. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37063. private _activeMeshesFrozen;
  37064. private _skipEvaluateActiveMeshesCompletely;
  37065. /**
  37066. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37067. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37068. * @returns the current scene
  37069. */
  37070. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37071. /**
  37072. * Use this function to restart evaluating active meshes on every frame
  37073. * @returns the current scene
  37074. */
  37075. unfreezeActiveMeshes(): Scene;
  37076. private _evaluateActiveMeshes;
  37077. private _activeMesh;
  37078. /**
  37079. * Update the transform matrix to update from the current active camera
  37080. * @param force defines a boolean used to force the update even if cache is up to date
  37081. */
  37082. updateTransformMatrix(force?: boolean): void;
  37083. private _bindFrameBuffer;
  37084. /** @hidden */
  37085. _allowPostProcessClearColor: boolean;
  37086. /** @hidden */
  37087. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37088. private _processSubCameras;
  37089. private _checkIntersections;
  37090. /** @hidden */
  37091. _advancePhysicsEngineStep(step: number): void;
  37092. /**
  37093. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37094. */
  37095. getDeterministicFrameTime: () => number;
  37096. /** @hidden */
  37097. _animate(): void;
  37098. /** Execute all animations (for a frame) */
  37099. animate(): void;
  37100. /**
  37101. * Render the scene
  37102. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37103. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37104. */
  37105. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37106. /**
  37107. * Freeze all materials
  37108. * A frozen material will not be updatable but should be faster to render
  37109. */
  37110. freezeMaterials(): void;
  37111. /**
  37112. * Unfreeze all materials
  37113. * A frozen material will not be updatable but should be faster to render
  37114. */
  37115. unfreezeMaterials(): void;
  37116. /**
  37117. * Releases all held ressources
  37118. */
  37119. dispose(): void;
  37120. /**
  37121. * Gets if the scene is already disposed
  37122. */
  37123. get isDisposed(): boolean;
  37124. /**
  37125. * Call this function to reduce memory footprint of the scene.
  37126. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37127. */
  37128. clearCachedVertexData(): void;
  37129. /**
  37130. * This function will remove the local cached buffer data from texture.
  37131. * It will save memory but will prevent the texture from being rebuilt
  37132. */
  37133. cleanCachedTextureBuffer(): void;
  37134. /**
  37135. * Get the world extend vectors with an optional filter
  37136. *
  37137. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37138. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37139. */
  37140. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37141. min: Vector3;
  37142. max: Vector3;
  37143. };
  37144. /**
  37145. * Creates a ray that can be used to pick in the scene
  37146. * @param x defines the x coordinate of the origin (on-screen)
  37147. * @param y defines the y coordinate of the origin (on-screen)
  37148. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37149. * @param camera defines the camera to use for the picking
  37150. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37151. * @returns a Ray
  37152. */
  37153. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37154. /**
  37155. * Creates a ray that can be used to pick in the scene
  37156. * @param x defines the x coordinate of the origin (on-screen)
  37157. * @param y defines the y coordinate of the origin (on-screen)
  37158. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37159. * @param result defines the ray where to store the picking ray
  37160. * @param camera defines the camera to use for the picking
  37161. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37162. * @returns the current scene
  37163. */
  37164. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37165. /**
  37166. * Creates a ray that can be used to pick in the scene
  37167. * @param x defines the x coordinate of the origin (on-screen)
  37168. * @param y defines the y coordinate of the origin (on-screen)
  37169. * @param camera defines the camera to use for the picking
  37170. * @returns a Ray
  37171. */
  37172. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37173. /**
  37174. * Creates a ray that can be used to pick in the scene
  37175. * @param x defines the x coordinate of the origin (on-screen)
  37176. * @param y defines the y coordinate of the origin (on-screen)
  37177. * @param result defines the ray where to store the picking ray
  37178. * @param camera defines the camera to use for the picking
  37179. * @returns the current scene
  37180. */
  37181. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37182. /** Launch a ray to try to pick a mesh in the scene
  37183. * @param x position on screen
  37184. * @param y position on screen
  37185. * @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
  37186. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37187. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37188. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37189. * @returns a PickingInfo
  37190. */
  37191. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37192. /** Use the given ray to pick a mesh in the scene
  37193. * @param ray The ray to use to pick meshes
  37194. * @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
  37195. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37196. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37197. * @returns a PickingInfo
  37198. */
  37199. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37200. /**
  37201. * Launch a ray to try to pick a mesh in the scene
  37202. * @param x X position on screen
  37203. * @param y Y position on screen
  37204. * @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
  37205. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37206. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37207. * @returns an array of PickingInfo
  37208. */
  37209. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37210. /**
  37211. * Launch a ray to try to pick a mesh in the scene
  37212. * @param ray Ray to use
  37213. * @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
  37214. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37215. * @returns an array of PickingInfo
  37216. */
  37217. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37218. /**
  37219. * Force the value of meshUnderPointer
  37220. * @param mesh defines the mesh to use
  37221. */
  37222. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37223. /**
  37224. * Gets the mesh under the pointer
  37225. * @returns a Mesh or null if no mesh is under the pointer
  37226. */
  37227. getPointerOverMesh(): Nullable<AbstractMesh>;
  37228. /** @hidden */
  37229. _rebuildGeometries(): void;
  37230. /** @hidden */
  37231. _rebuildTextures(): void;
  37232. private _getByTags;
  37233. /**
  37234. * Get a list of meshes by tags
  37235. * @param tagsQuery defines the tags query to use
  37236. * @param forEach defines a predicate used to filter results
  37237. * @returns an array of Mesh
  37238. */
  37239. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37240. /**
  37241. * Get a list of cameras by tags
  37242. * @param tagsQuery defines the tags query to use
  37243. * @param forEach defines a predicate used to filter results
  37244. * @returns an array of Camera
  37245. */
  37246. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37247. /**
  37248. * Get a list of lights by tags
  37249. * @param tagsQuery defines the tags query to use
  37250. * @param forEach defines a predicate used to filter results
  37251. * @returns an array of Light
  37252. */
  37253. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37254. /**
  37255. * Get a list of materials by tags
  37256. * @param tagsQuery defines the tags query to use
  37257. * @param forEach defines a predicate used to filter results
  37258. * @returns an array of Material
  37259. */
  37260. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37261. /**
  37262. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37263. * This allowed control for front to back rendering or reversly depending of the special needs.
  37264. *
  37265. * @param renderingGroupId The rendering group id corresponding to its index
  37266. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37267. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37268. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37269. */
  37270. 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;
  37271. /**
  37272. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37273. *
  37274. * @param renderingGroupId The rendering group id corresponding to its index
  37275. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37276. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37277. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37278. */
  37279. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37280. /**
  37281. * Gets the current auto clear configuration for one rendering group of the rendering
  37282. * manager.
  37283. * @param index the rendering group index to get the information for
  37284. * @returns The auto clear setup for the requested rendering group
  37285. */
  37286. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37287. private _blockMaterialDirtyMechanism;
  37288. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37289. get blockMaterialDirtyMechanism(): boolean;
  37290. set blockMaterialDirtyMechanism(value: boolean);
  37291. /**
  37292. * Will flag all materials as dirty to trigger new shader compilation
  37293. * @param flag defines the flag used to specify which material part must be marked as dirty
  37294. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37295. */
  37296. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37297. /** @hidden */
  37298. _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;
  37299. /** @hidden */
  37300. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37301. /** @hidden */
  37302. _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;
  37303. /** @hidden */
  37304. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37305. /** @hidden */
  37306. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37307. /** @hidden */
  37308. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37309. }
  37310. }
  37311. declare module BABYLON {
  37312. /**
  37313. * Set of assets to keep when moving a scene into an asset container.
  37314. */
  37315. export class KeepAssets extends AbstractScene {
  37316. }
  37317. /**
  37318. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37319. */
  37320. export class InstantiatedEntries {
  37321. /**
  37322. * List of new root nodes (eg. nodes with no parent)
  37323. */
  37324. rootNodes: TransformNode[];
  37325. /**
  37326. * List of new skeletons
  37327. */
  37328. skeletons: Skeleton[];
  37329. /**
  37330. * List of new animation groups
  37331. */
  37332. animationGroups: AnimationGroup[];
  37333. }
  37334. /**
  37335. * Container with a set of assets that can be added or removed from a scene.
  37336. */
  37337. export class AssetContainer extends AbstractScene {
  37338. private _wasAddedToScene;
  37339. /**
  37340. * The scene the AssetContainer belongs to.
  37341. */
  37342. scene: Scene;
  37343. /**
  37344. * Instantiates an AssetContainer.
  37345. * @param scene The scene the AssetContainer belongs to.
  37346. */
  37347. constructor(scene: Scene);
  37348. /**
  37349. * Instantiate or clone all meshes and add the new ones to the scene.
  37350. * Skeletons and animation groups will all be cloned
  37351. * @param nameFunction defines an optional function used to get new names for clones
  37352. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37353. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37354. */
  37355. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37356. /**
  37357. * Adds all the assets from the container to the scene.
  37358. */
  37359. addAllToScene(): void;
  37360. /**
  37361. * Removes all the assets in the container from the scene
  37362. */
  37363. removeAllFromScene(): void;
  37364. /**
  37365. * Disposes all the assets in the container
  37366. */
  37367. dispose(): void;
  37368. private _moveAssets;
  37369. /**
  37370. * Removes all the assets contained in the scene and adds them to the container.
  37371. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37372. */
  37373. moveAllFromScene(keepAssets?: KeepAssets): void;
  37374. /**
  37375. * 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.
  37376. * @returns the root mesh
  37377. */
  37378. createRootMesh(): Mesh;
  37379. /**
  37380. * Merge animations from this asset container into a scene
  37381. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37382. * @param animatables set of animatables to retarget to a node from the scene
  37383. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37384. */
  37385. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37386. }
  37387. }
  37388. declare module BABYLON {
  37389. /**
  37390. * Defines how the parser contract is defined.
  37391. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37392. */
  37393. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37394. /**
  37395. * Defines how the individual parser contract is defined.
  37396. * These parser can parse an individual asset
  37397. */
  37398. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37399. /**
  37400. * Base class of the scene acting as a container for the different elements composing a scene.
  37401. * This class is dynamically extended by the different components of the scene increasing
  37402. * flexibility and reducing coupling
  37403. */
  37404. export abstract class AbstractScene {
  37405. /**
  37406. * Stores the list of available parsers in the application.
  37407. */
  37408. private static _BabylonFileParsers;
  37409. /**
  37410. * Stores the list of available individual parsers in the application.
  37411. */
  37412. private static _IndividualBabylonFileParsers;
  37413. /**
  37414. * Adds a parser in the list of available ones
  37415. * @param name Defines the name of the parser
  37416. * @param parser Defines the parser to add
  37417. */
  37418. static AddParser(name: string, parser: BabylonFileParser): void;
  37419. /**
  37420. * Gets a general parser from the list of avaialble ones
  37421. * @param name Defines the name of the parser
  37422. * @returns the requested parser or null
  37423. */
  37424. static GetParser(name: string): Nullable<BabylonFileParser>;
  37425. /**
  37426. * Adds n individual parser in the list of available ones
  37427. * @param name Defines the name of the parser
  37428. * @param parser Defines the parser to add
  37429. */
  37430. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37431. /**
  37432. * Gets an individual parser from the list of avaialble ones
  37433. * @param name Defines the name of the parser
  37434. * @returns the requested parser or null
  37435. */
  37436. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37437. /**
  37438. * Parser json data and populate both a scene and its associated container object
  37439. * @param jsonData Defines the data to parse
  37440. * @param scene Defines the scene to parse the data for
  37441. * @param container Defines the container attached to the parsing sequence
  37442. * @param rootUrl Defines the root url of the data
  37443. */
  37444. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37445. /**
  37446. * Gets the list of root nodes (ie. nodes with no parent)
  37447. */
  37448. rootNodes: Node[];
  37449. /** All of the cameras added to this scene
  37450. * @see http://doc.babylonjs.com/babylon101/cameras
  37451. */
  37452. cameras: Camera[];
  37453. /**
  37454. * All of the lights added to this scene
  37455. * @see http://doc.babylonjs.com/babylon101/lights
  37456. */
  37457. lights: Light[];
  37458. /**
  37459. * All of the (abstract) meshes added to this scene
  37460. */
  37461. meshes: AbstractMesh[];
  37462. /**
  37463. * The list of skeletons added to the scene
  37464. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37465. */
  37466. skeletons: Skeleton[];
  37467. /**
  37468. * All of the particle systems added to this scene
  37469. * @see http://doc.babylonjs.com/babylon101/particles
  37470. */
  37471. particleSystems: IParticleSystem[];
  37472. /**
  37473. * Gets a list of Animations associated with the scene
  37474. */
  37475. animations: Animation[];
  37476. /**
  37477. * All of the animation groups added to this scene
  37478. * @see http://doc.babylonjs.com/how_to/group
  37479. */
  37480. animationGroups: AnimationGroup[];
  37481. /**
  37482. * All of the multi-materials added to this scene
  37483. * @see http://doc.babylonjs.com/how_to/multi_materials
  37484. */
  37485. multiMaterials: MultiMaterial[];
  37486. /**
  37487. * All of the materials added to this scene
  37488. * In the context of a Scene, it is not supposed to be modified manually.
  37489. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37490. * Note also that the order of the Material within the array is not significant and might change.
  37491. * @see http://doc.babylonjs.com/babylon101/materials
  37492. */
  37493. materials: Material[];
  37494. /**
  37495. * The list of morph target managers added to the scene
  37496. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37497. */
  37498. morphTargetManagers: MorphTargetManager[];
  37499. /**
  37500. * The list of geometries used in the scene.
  37501. */
  37502. geometries: Geometry[];
  37503. /**
  37504. * All of the tranform nodes added to this scene
  37505. * In the context of a Scene, it is not supposed to be modified manually.
  37506. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37507. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37508. * @see http://doc.babylonjs.com/how_to/transformnode
  37509. */
  37510. transformNodes: TransformNode[];
  37511. /**
  37512. * ActionManagers available on the scene.
  37513. */
  37514. actionManagers: AbstractActionManager[];
  37515. /**
  37516. * Textures to keep.
  37517. */
  37518. textures: BaseTexture[];
  37519. /**
  37520. * Environment texture for the scene
  37521. */
  37522. environmentTexture: Nullable<BaseTexture>;
  37523. /**
  37524. * @returns all meshes, lights, cameras, transformNodes and bones
  37525. */
  37526. getNodes(): Array<Node>;
  37527. }
  37528. }
  37529. declare module BABYLON {
  37530. /**
  37531. * Interface used to define options for Sound class
  37532. */
  37533. export interface ISoundOptions {
  37534. /**
  37535. * Does the sound autoplay once loaded.
  37536. */
  37537. autoplay?: boolean;
  37538. /**
  37539. * Does the sound loop after it finishes playing once.
  37540. */
  37541. loop?: boolean;
  37542. /**
  37543. * Sound's volume
  37544. */
  37545. volume?: number;
  37546. /**
  37547. * Is it a spatial sound?
  37548. */
  37549. spatialSound?: boolean;
  37550. /**
  37551. * Maximum distance to hear that sound
  37552. */
  37553. maxDistance?: number;
  37554. /**
  37555. * Uses user defined attenuation function
  37556. */
  37557. useCustomAttenuation?: boolean;
  37558. /**
  37559. * Define the roll off factor of spatial sounds.
  37560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37561. */
  37562. rolloffFactor?: number;
  37563. /**
  37564. * Define the reference distance the sound should be heard perfectly.
  37565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37566. */
  37567. refDistance?: number;
  37568. /**
  37569. * Define the distance attenuation model the sound will follow.
  37570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37571. */
  37572. distanceModel?: string;
  37573. /**
  37574. * Defines the playback speed (1 by default)
  37575. */
  37576. playbackRate?: number;
  37577. /**
  37578. * Defines if the sound is from a streaming source
  37579. */
  37580. streaming?: boolean;
  37581. /**
  37582. * Defines an optional length (in seconds) inside the sound file
  37583. */
  37584. length?: number;
  37585. /**
  37586. * Defines an optional offset (in seconds) inside the sound file
  37587. */
  37588. offset?: number;
  37589. /**
  37590. * If true, URLs will not be required to state the audio file codec to use.
  37591. */
  37592. skipCodecCheck?: boolean;
  37593. }
  37594. /**
  37595. * Defines a sound that can be played in the application.
  37596. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37597. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37598. */
  37599. export class Sound {
  37600. /**
  37601. * The name of the sound in the scene.
  37602. */
  37603. name: string;
  37604. /**
  37605. * Does the sound autoplay once loaded.
  37606. */
  37607. autoplay: boolean;
  37608. /**
  37609. * Does the sound loop after it finishes playing once.
  37610. */
  37611. loop: boolean;
  37612. /**
  37613. * Does the sound use a custom attenuation curve to simulate the falloff
  37614. * happening when the source gets further away from the camera.
  37615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37616. */
  37617. useCustomAttenuation: boolean;
  37618. /**
  37619. * The sound track id this sound belongs to.
  37620. */
  37621. soundTrackId: number;
  37622. /**
  37623. * Is this sound currently played.
  37624. */
  37625. isPlaying: boolean;
  37626. /**
  37627. * Is this sound currently paused.
  37628. */
  37629. isPaused: boolean;
  37630. /**
  37631. * Does this sound enables spatial sound.
  37632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37633. */
  37634. spatialSound: boolean;
  37635. /**
  37636. * Define the reference distance the sound should be heard perfectly.
  37637. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37638. */
  37639. refDistance: number;
  37640. /**
  37641. * Define the roll off factor of spatial sounds.
  37642. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37643. */
  37644. rolloffFactor: number;
  37645. /**
  37646. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37647. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37648. */
  37649. maxDistance: number;
  37650. /**
  37651. * Define the distance attenuation model the sound will follow.
  37652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37653. */
  37654. distanceModel: string;
  37655. /**
  37656. * @hidden
  37657. * Back Compat
  37658. **/
  37659. onended: () => any;
  37660. /**
  37661. * Observable event when the current playing sound finishes.
  37662. */
  37663. onEndedObservable: Observable<Sound>;
  37664. private _panningModel;
  37665. private _playbackRate;
  37666. private _streaming;
  37667. private _startTime;
  37668. private _startOffset;
  37669. private _position;
  37670. /** @hidden */
  37671. _positionInEmitterSpace: boolean;
  37672. private _localDirection;
  37673. private _volume;
  37674. private _isReadyToPlay;
  37675. private _isDirectional;
  37676. private _readyToPlayCallback;
  37677. private _audioBuffer;
  37678. private _soundSource;
  37679. private _streamingSource;
  37680. private _soundPanner;
  37681. private _soundGain;
  37682. private _inputAudioNode;
  37683. private _outputAudioNode;
  37684. private _coneInnerAngle;
  37685. private _coneOuterAngle;
  37686. private _coneOuterGain;
  37687. private _scene;
  37688. private _connectedTransformNode;
  37689. private _customAttenuationFunction;
  37690. private _registerFunc;
  37691. private _isOutputConnected;
  37692. private _htmlAudioElement;
  37693. private _urlType;
  37694. private _length?;
  37695. private _offset?;
  37696. /** @hidden */
  37697. static _SceneComponentInitialization: (scene: Scene) => void;
  37698. /**
  37699. * Create a sound and attach it to a scene
  37700. * @param name Name of your sound
  37701. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37702. * @param scene defines the scene the sound belongs to
  37703. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37704. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37705. */
  37706. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37707. /**
  37708. * Release the sound and its associated resources
  37709. */
  37710. dispose(): void;
  37711. /**
  37712. * Gets if the sounds is ready to be played or not.
  37713. * @returns true if ready, otherwise false
  37714. */
  37715. isReady(): boolean;
  37716. private _soundLoaded;
  37717. /**
  37718. * Sets the data of the sound from an audiobuffer
  37719. * @param audioBuffer The audioBuffer containing the data
  37720. */
  37721. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37722. /**
  37723. * Updates the current sounds options such as maxdistance, loop...
  37724. * @param options A JSON object containing values named as the object properties
  37725. */
  37726. updateOptions(options: ISoundOptions): void;
  37727. private _createSpatialParameters;
  37728. private _updateSpatialParameters;
  37729. /**
  37730. * Switch the panning model to HRTF:
  37731. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37732. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37733. */
  37734. switchPanningModelToHRTF(): void;
  37735. /**
  37736. * Switch the panning model to Equal Power:
  37737. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37739. */
  37740. switchPanningModelToEqualPower(): void;
  37741. private _switchPanningModel;
  37742. /**
  37743. * Connect this sound to a sound track audio node like gain...
  37744. * @param soundTrackAudioNode the sound track audio node to connect to
  37745. */
  37746. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37747. /**
  37748. * Transform this sound into a directional source
  37749. * @param coneInnerAngle Size of the inner cone in degree
  37750. * @param coneOuterAngle Size of the outer cone in degree
  37751. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37752. */
  37753. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37754. /**
  37755. * Gets or sets the inner angle for the directional cone.
  37756. */
  37757. get directionalConeInnerAngle(): number;
  37758. /**
  37759. * Gets or sets the inner angle for the directional cone.
  37760. */
  37761. set directionalConeInnerAngle(value: number);
  37762. /**
  37763. * Gets or sets the outer angle for the directional cone.
  37764. */
  37765. get directionalConeOuterAngle(): number;
  37766. /**
  37767. * Gets or sets the outer angle for the directional cone.
  37768. */
  37769. set directionalConeOuterAngle(value: number);
  37770. /**
  37771. * Sets the position of the emitter if spatial sound is enabled
  37772. * @param newPosition Defines the new posisiton
  37773. */
  37774. setPosition(newPosition: Vector3): void;
  37775. /**
  37776. * Sets the local direction of the emitter if spatial sound is enabled
  37777. * @param newLocalDirection Defines the new local direction
  37778. */
  37779. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37780. private _updateDirection;
  37781. /** @hidden */
  37782. updateDistanceFromListener(): void;
  37783. /**
  37784. * Sets a new custom attenuation function for the sound.
  37785. * @param callback Defines the function used for the attenuation
  37786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37787. */
  37788. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37789. /**
  37790. * Play the sound
  37791. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37792. * @param offset (optional) Start the sound at a specific time in seconds
  37793. * @param length (optional) Sound duration (in seconds)
  37794. */
  37795. play(time?: number, offset?: number, length?: number): void;
  37796. private _onended;
  37797. /**
  37798. * Stop the sound
  37799. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37800. */
  37801. stop(time?: number): void;
  37802. /**
  37803. * Put the sound in pause
  37804. */
  37805. pause(): void;
  37806. /**
  37807. * Sets a dedicated volume for this sounds
  37808. * @param newVolume Define the new volume of the sound
  37809. * @param time Define time for gradual change to new volume
  37810. */
  37811. setVolume(newVolume: number, time?: number): void;
  37812. /**
  37813. * Set the sound play back rate
  37814. * @param newPlaybackRate Define the playback rate the sound should be played at
  37815. */
  37816. setPlaybackRate(newPlaybackRate: number): void;
  37817. /**
  37818. * Gets the volume of the sound.
  37819. * @returns the volume of the sound
  37820. */
  37821. getVolume(): number;
  37822. /**
  37823. * Attach the sound to a dedicated mesh
  37824. * @param transformNode The transform node to connect the sound with
  37825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37826. */
  37827. attachToMesh(transformNode: TransformNode): void;
  37828. /**
  37829. * Detach the sound from the previously attached mesh
  37830. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37831. */
  37832. detachFromMesh(): void;
  37833. private _onRegisterAfterWorldMatrixUpdate;
  37834. /**
  37835. * Clone the current sound in the scene.
  37836. * @returns the new sound clone
  37837. */
  37838. clone(): Nullable<Sound>;
  37839. /**
  37840. * Gets the current underlying audio buffer containing the data
  37841. * @returns the audio buffer
  37842. */
  37843. getAudioBuffer(): Nullable<AudioBuffer>;
  37844. /**
  37845. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  37846. * @returns the source node
  37847. */
  37848. getSoundSource(): Nullable<AudioBufferSourceNode>;
  37849. /**
  37850. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  37851. * @returns the gain node
  37852. */
  37853. getSoundGain(): Nullable<GainNode>;
  37854. /**
  37855. * Serializes the Sound in a JSON representation
  37856. * @returns the JSON representation of the sound
  37857. */
  37858. serialize(): any;
  37859. /**
  37860. * Parse a JSON representation of a sound to innstantiate in a given scene
  37861. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37862. * @param scene Define the scene the new parsed sound should be created in
  37863. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37864. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37865. * @returns the newly parsed sound
  37866. */
  37867. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37868. }
  37869. }
  37870. declare module BABYLON {
  37871. /**
  37872. * This defines an action helpful to play a defined sound on a triggered action.
  37873. */
  37874. export class PlaySoundAction extends Action {
  37875. private _sound;
  37876. /**
  37877. * Instantiate the action
  37878. * @param triggerOptions defines the trigger options
  37879. * @param sound defines the sound to play
  37880. * @param condition defines the trigger related conditions
  37881. */
  37882. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37883. /** @hidden */
  37884. _prepare(): void;
  37885. /**
  37886. * Execute the action and play the sound.
  37887. */
  37888. execute(): void;
  37889. /**
  37890. * Serializes the actions and its related information.
  37891. * @param parent defines the object to serialize in
  37892. * @returns the serialized object
  37893. */
  37894. serialize(parent: any): any;
  37895. }
  37896. /**
  37897. * This defines an action helpful to stop a defined sound on a triggered action.
  37898. */
  37899. export class StopSoundAction extends Action {
  37900. private _sound;
  37901. /**
  37902. * Instantiate the action
  37903. * @param triggerOptions defines the trigger options
  37904. * @param sound defines the sound to stop
  37905. * @param condition defines the trigger related conditions
  37906. */
  37907. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37908. /** @hidden */
  37909. _prepare(): void;
  37910. /**
  37911. * Execute the action and stop the sound.
  37912. */
  37913. execute(): void;
  37914. /**
  37915. * Serializes the actions and its related information.
  37916. * @param parent defines the object to serialize in
  37917. * @returns the serialized object
  37918. */
  37919. serialize(parent: any): any;
  37920. }
  37921. }
  37922. declare module BABYLON {
  37923. /**
  37924. * This defines an action responsible to change the value of a property
  37925. * by interpolating between its current value and the newly set one once triggered.
  37926. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37927. */
  37928. export class InterpolateValueAction extends Action {
  37929. /**
  37930. * Defines the path of the property where the value should be interpolated
  37931. */
  37932. propertyPath: string;
  37933. /**
  37934. * Defines the target value at the end of the interpolation.
  37935. */
  37936. value: any;
  37937. /**
  37938. * Defines the time it will take for the property to interpolate to the value.
  37939. */
  37940. duration: number;
  37941. /**
  37942. * Defines if the other scene animations should be stopped when the action has been triggered
  37943. */
  37944. stopOtherAnimations?: boolean;
  37945. /**
  37946. * Defines a callback raised once the interpolation animation has been done.
  37947. */
  37948. onInterpolationDone?: () => void;
  37949. /**
  37950. * Observable triggered once the interpolation animation has been done.
  37951. */
  37952. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37953. private _target;
  37954. private _effectiveTarget;
  37955. private _property;
  37956. /**
  37957. * Instantiate the action
  37958. * @param triggerOptions defines the trigger options
  37959. * @param target defines the object containing the value to interpolate
  37960. * @param propertyPath defines the path to the property in the target object
  37961. * @param value defines the target value at the end of the interpolation
  37962. * @param duration deines the time it will take for the property to interpolate to the value.
  37963. * @param condition defines the trigger related conditions
  37964. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37965. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37966. */
  37967. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37968. /** @hidden */
  37969. _prepare(): void;
  37970. /**
  37971. * Execute the action starts the value interpolation.
  37972. */
  37973. execute(): void;
  37974. /**
  37975. * Serializes the actions and its related information.
  37976. * @param parent defines the object to serialize in
  37977. * @returns the serialized object
  37978. */
  37979. serialize(parent: any): any;
  37980. }
  37981. }
  37982. declare module BABYLON {
  37983. /**
  37984. * Options allowed during the creation of a sound track.
  37985. */
  37986. export interface ISoundTrackOptions {
  37987. /**
  37988. * The volume the sound track should take during creation
  37989. */
  37990. volume?: number;
  37991. /**
  37992. * Define if the sound track is the main sound track of the scene
  37993. */
  37994. mainTrack?: boolean;
  37995. }
  37996. /**
  37997. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37998. * It will be also used in a future release to apply effects on a specific track.
  37999. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38000. */
  38001. export class SoundTrack {
  38002. /**
  38003. * The unique identifier of the sound track in the scene.
  38004. */
  38005. id: number;
  38006. /**
  38007. * The list of sounds included in the sound track.
  38008. */
  38009. soundCollection: Array<Sound>;
  38010. private _outputAudioNode;
  38011. private _scene;
  38012. private _connectedAnalyser;
  38013. private _options;
  38014. private _isInitialized;
  38015. /**
  38016. * Creates a new sound track.
  38017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38018. * @param scene Define the scene the sound track belongs to
  38019. * @param options
  38020. */
  38021. constructor(scene: Scene, options?: ISoundTrackOptions);
  38022. private _initializeSoundTrackAudioGraph;
  38023. /**
  38024. * Release the sound track and its associated resources
  38025. */
  38026. dispose(): void;
  38027. /**
  38028. * Adds a sound to this sound track
  38029. * @param sound define the cound to add
  38030. * @ignoreNaming
  38031. */
  38032. AddSound(sound: Sound): void;
  38033. /**
  38034. * Removes a sound to this sound track
  38035. * @param sound define the cound to remove
  38036. * @ignoreNaming
  38037. */
  38038. RemoveSound(sound: Sound): void;
  38039. /**
  38040. * Set a global volume for the full sound track.
  38041. * @param newVolume Define the new volume of the sound track
  38042. */
  38043. setVolume(newVolume: number): void;
  38044. /**
  38045. * Switch the panning model to HRTF:
  38046. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38048. */
  38049. switchPanningModelToHRTF(): void;
  38050. /**
  38051. * Switch the panning model to Equal Power:
  38052. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38053. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38054. */
  38055. switchPanningModelToEqualPower(): void;
  38056. /**
  38057. * Connect the sound track to an audio analyser allowing some amazing
  38058. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38059. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38060. * @param analyser The analyser to connect to the engine
  38061. */
  38062. connectToAnalyser(analyser: Analyser): void;
  38063. }
  38064. }
  38065. declare module BABYLON {
  38066. interface AbstractScene {
  38067. /**
  38068. * The list of sounds used in the scene.
  38069. */
  38070. sounds: Nullable<Array<Sound>>;
  38071. }
  38072. interface Scene {
  38073. /**
  38074. * @hidden
  38075. * Backing field
  38076. */
  38077. _mainSoundTrack: SoundTrack;
  38078. /**
  38079. * The main sound track played by the scene.
  38080. * It cotains your primary collection of sounds.
  38081. */
  38082. mainSoundTrack: SoundTrack;
  38083. /**
  38084. * The list of sound tracks added to the scene
  38085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38086. */
  38087. soundTracks: Nullable<Array<SoundTrack>>;
  38088. /**
  38089. * Gets a sound using a given name
  38090. * @param name defines the name to search for
  38091. * @return the found sound or null if not found at all.
  38092. */
  38093. getSoundByName(name: string): Nullable<Sound>;
  38094. /**
  38095. * Gets or sets if audio support is enabled
  38096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38097. */
  38098. audioEnabled: boolean;
  38099. /**
  38100. * Gets or sets if audio will be output to headphones
  38101. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38102. */
  38103. headphone: boolean;
  38104. /**
  38105. * Gets or sets custom audio listener position provider
  38106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38107. */
  38108. audioListenerPositionProvider: Nullable<() => Vector3>;
  38109. /**
  38110. * Gets or sets a refresh rate when using 3D audio positioning
  38111. */
  38112. audioPositioningRefreshRate: number;
  38113. }
  38114. /**
  38115. * Defines the sound scene component responsible to manage any sounds
  38116. * in a given scene.
  38117. */
  38118. export class AudioSceneComponent implements ISceneSerializableComponent {
  38119. /**
  38120. * The component name helpfull to identify the component in the list of scene components.
  38121. */
  38122. readonly name: string;
  38123. /**
  38124. * The scene the component belongs to.
  38125. */
  38126. scene: Scene;
  38127. private _audioEnabled;
  38128. /**
  38129. * Gets whether audio is enabled or not.
  38130. * Please use related enable/disable method to switch state.
  38131. */
  38132. get audioEnabled(): boolean;
  38133. private _headphone;
  38134. /**
  38135. * Gets whether audio is outputing to headphone or not.
  38136. * Please use the according Switch methods to change output.
  38137. */
  38138. get headphone(): boolean;
  38139. /**
  38140. * Gets or sets a refresh rate when using 3D audio positioning
  38141. */
  38142. audioPositioningRefreshRate: number;
  38143. private _audioListenerPositionProvider;
  38144. /**
  38145. * Gets the current audio listener position provider
  38146. */
  38147. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38148. /**
  38149. * Sets a custom listener position for all sounds in the scene
  38150. * By default, this is the position of the first active camera
  38151. */
  38152. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38153. /**
  38154. * Creates a new instance of the component for the given scene
  38155. * @param scene Defines the scene to register the component in
  38156. */
  38157. constructor(scene: Scene);
  38158. /**
  38159. * Registers the component in a given scene
  38160. */
  38161. register(): void;
  38162. /**
  38163. * Rebuilds the elements related to this component in case of
  38164. * context lost for instance.
  38165. */
  38166. rebuild(): void;
  38167. /**
  38168. * Serializes the component data to the specified json object
  38169. * @param serializationObject The object to serialize to
  38170. */
  38171. serialize(serializationObject: any): void;
  38172. /**
  38173. * Adds all the elements from the container to the scene
  38174. * @param container the container holding the elements
  38175. */
  38176. addFromContainer(container: AbstractScene): void;
  38177. /**
  38178. * Removes all the elements in the container from the scene
  38179. * @param container contains the elements to remove
  38180. * @param dispose if the removed element should be disposed (default: false)
  38181. */
  38182. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38183. /**
  38184. * Disposes the component and the associated ressources.
  38185. */
  38186. dispose(): void;
  38187. /**
  38188. * Disables audio in the associated scene.
  38189. */
  38190. disableAudio(): void;
  38191. /**
  38192. * Enables audio in the associated scene.
  38193. */
  38194. enableAudio(): void;
  38195. /**
  38196. * Switch audio to headphone output.
  38197. */
  38198. switchAudioModeForHeadphones(): void;
  38199. /**
  38200. * Switch audio to normal speakers.
  38201. */
  38202. switchAudioModeForNormalSpeakers(): void;
  38203. private _cachedCameraDirection;
  38204. private _cachedCameraPosition;
  38205. private _lastCheck;
  38206. private _afterRender;
  38207. }
  38208. }
  38209. declare module BABYLON {
  38210. /**
  38211. * Wraps one or more Sound objects and selects one with random weight for playback.
  38212. */
  38213. export class WeightedSound {
  38214. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38215. loop: boolean;
  38216. private _coneInnerAngle;
  38217. private _coneOuterAngle;
  38218. private _volume;
  38219. /** A Sound is currently playing. */
  38220. isPlaying: boolean;
  38221. /** A Sound is currently paused. */
  38222. isPaused: boolean;
  38223. private _sounds;
  38224. private _weights;
  38225. private _currentIndex?;
  38226. /**
  38227. * Creates a new WeightedSound from the list of sounds given.
  38228. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38229. * @param sounds Array of Sounds that will be selected from.
  38230. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38231. */
  38232. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38233. /**
  38234. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38235. */
  38236. get directionalConeInnerAngle(): number;
  38237. /**
  38238. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38239. */
  38240. set directionalConeInnerAngle(value: number);
  38241. /**
  38242. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38243. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38244. */
  38245. get directionalConeOuterAngle(): number;
  38246. /**
  38247. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38248. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38249. */
  38250. set directionalConeOuterAngle(value: number);
  38251. /**
  38252. * Playback volume.
  38253. */
  38254. get volume(): number;
  38255. /**
  38256. * Playback volume.
  38257. */
  38258. set volume(value: number);
  38259. private _onended;
  38260. /**
  38261. * Suspend playback
  38262. */
  38263. pause(): void;
  38264. /**
  38265. * Stop playback
  38266. */
  38267. stop(): void;
  38268. /**
  38269. * Start playback.
  38270. * @param startOffset Position the clip head at a specific time in seconds.
  38271. */
  38272. play(startOffset?: number): void;
  38273. }
  38274. }
  38275. declare module BABYLON {
  38276. /**
  38277. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38279. */
  38280. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38281. /**
  38282. * Gets the name of the behavior.
  38283. */
  38284. get name(): string;
  38285. /**
  38286. * The easing function used by animations
  38287. */
  38288. static EasingFunction: BackEase;
  38289. /**
  38290. * The easing mode used by animations
  38291. */
  38292. static EasingMode: number;
  38293. /**
  38294. * The duration of the animation, in milliseconds
  38295. */
  38296. transitionDuration: number;
  38297. /**
  38298. * Length of the distance animated by the transition when lower radius is reached
  38299. */
  38300. lowerRadiusTransitionRange: number;
  38301. /**
  38302. * Length of the distance animated by the transition when upper radius is reached
  38303. */
  38304. upperRadiusTransitionRange: number;
  38305. private _autoTransitionRange;
  38306. /**
  38307. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38308. */
  38309. get autoTransitionRange(): boolean;
  38310. /**
  38311. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38312. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38313. */
  38314. set autoTransitionRange(value: boolean);
  38315. private _attachedCamera;
  38316. private _onAfterCheckInputsObserver;
  38317. private _onMeshTargetChangedObserver;
  38318. /**
  38319. * Initializes the behavior.
  38320. */
  38321. init(): void;
  38322. /**
  38323. * Attaches the behavior to its arc rotate camera.
  38324. * @param camera Defines the camera to attach the behavior to
  38325. */
  38326. attach(camera: ArcRotateCamera): void;
  38327. /**
  38328. * Detaches the behavior from its current arc rotate camera.
  38329. */
  38330. detach(): void;
  38331. private _radiusIsAnimating;
  38332. private _radiusBounceTransition;
  38333. private _animatables;
  38334. private _cachedWheelPrecision;
  38335. /**
  38336. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38337. * @param radiusLimit The limit to check against.
  38338. * @return Bool to indicate if at limit.
  38339. */
  38340. private _isRadiusAtLimit;
  38341. /**
  38342. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38343. * @param radiusDelta The delta by which to animate to. Can be negative.
  38344. */
  38345. private _applyBoundRadiusAnimation;
  38346. /**
  38347. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38348. */
  38349. protected _clearAnimationLocks(): void;
  38350. /**
  38351. * Stops and removes all animations that have been applied to the camera
  38352. */
  38353. stopAllAnimations(): void;
  38354. }
  38355. }
  38356. declare module BABYLON {
  38357. /**
  38358. * 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.
  38359. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38360. */
  38361. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38362. /**
  38363. * Gets the name of the behavior.
  38364. */
  38365. get name(): string;
  38366. private _mode;
  38367. private _radiusScale;
  38368. private _positionScale;
  38369. private _defaultElevation;
  38370. private _elevationReturnTime;
  38371. private _elevationReturnWaitTime;
  38372. private _zoomStopsAnimation;
  38373. private _framingTime;
  38374. /**
  38375. * The easing function used by animations
  38376. */
  38377. static EasingFunction: ExponentialEase;
  38378. /**
  38379. * The easing mode used by animations
  38380. */
  38381. static EasingMode: number;
  38382. /**
  38383. * Sets the current mode used by the behavior
  38384. */
  38385. set mode(mode: number);
  38386. /**
  38387. * Gets current mode used by the behavior.
  38388. */
  38389. get mode(): number;
  38390. /**
  38391. * Sets the scale applied to the radius (1 by default)
  38392. */
  38393. set radiusScale(radius: number);
  38394. /**
  38395. * Gets the scale applied to the radius
  38396. */
  38397. get radiusScale(): number;
  38398. /**
  38399. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38400. */
  38401. set positionScale(scale: number);
  38402. /**
  38403. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38404. */
  38405. get positionScale(): number;
  38406. /**
  38407. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38408. * behaviour is triggered, in radians.
  38409. */
  38410. set defaultElevation(elevation: number);
  38411. /**
  38412. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38413. * behaviour is triggered, in radians.
  38414. */
  38415. get defaultElevation(): number;
  38416. /**
  38417. * Sets the time (in milliseconds) taken to return to the default beta position.
  38418. * Negative value indicates camera should not return to default.
  38419. */
  38420. set elevationReturnTime(speed: number);
  38421. /**
  38422. * Gets the time (in milliseconds) taken to return to the default beta position.
  38423. * Negative value indicates camera should not return to default.
  38424. */
  38425. get elevationReturnTime(): number;
  38426. /**
  38427. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38428. */
  38429. set elevationReturnWaitTime(time: number);
  38430. /**
  38431. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38432. */
  38433. get elevationReturnWaitTime(): number;
  38434. /**
  38435. * Sets the flag that indicates if user zooming should stop animation.
  38436. */
  38437. set zoomStopsAnimation(flag: boolean);
  38438. /**
  38439. * Gets the flag that indicates if user zooming should stop animation.
  38440. */
  38441. get zoomStopsAnimation(): boolean;
  38442. /**
  38443. * Sets the transition time when framing the mesh, in milliseconds
  38444. */
  38445. set framingTime(time: number);
  38446. /**
  38447. * Gets the transition time when framing the mesh, in milliseconds
  38448. */
  38449. get framingTime(): number;
  38450. /**
  38451. * Define if the behavior should automatically change the configured
  38452. * camera limits and sensibilities.
  38453. */
  38454. autoCorrectCameraLimitsAndSensibility: boolean;
  38455. private _onPrePointerObservableObserver;
  38456. private _onAfterCheckInputsObserver;
  38457. private _onMeshTargetChangedObserver;
  38458. private _attachedCamera;
  38459. private _isPointerDown;
  38460. private _lastInteractionTime;
  38461. /**
  38462. * Initializes the behavior.
  38463. */
  38464. init(): void;
  38465. /**
  38466. * Attaches the behavior to its arc rotate camera.
  38467. * @param camera Defines the camera to attach the behavior to
  38468. */
  38469. attach(camera: ArcRotateCamera): void;
  38470. /**
  38471. * Detaches the behavior from its current arc rotate camera.
  38472. */
  38473. detach(): void;
  38474. private _animatables;
  38475. private _betaIsAnimating;
  38476. private _betaTransition;
  38477. private _radiusTransition;
  38478. private _vectorTransition;
  38479. /**
  38480. * Targets the given mesh and updates zoom level accordingly.
  38481. * @param mesh The mesh to target.
  38482. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38483. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38484. */
  38485. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38486. /**
  38487. * Targets the given mesh with its children and updates zoom level accordingly.
  38488. * @param mesh The mesh to target.
  38489. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38490. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38491. */
  38492. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38493. /**
  38494. * Targets the given meshes with their children and updates zoom level accordingly.
  38495. * @param meshes The mesh to target.
  38496. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38497. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38498. */
  38499. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38500. /**
  38501. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38502. * @param minimumWorld Determines the smaller position of the bounding box extend
  38503. * @param maximumWorld Determines the bigger position of the bounding box extend
  38504. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38505. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38506. */
  38507. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38508. /**
  38509. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38510. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38511. * frustum width.
  38512. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38513. * to fully enclose the mesh in the viewing frustum.
  38514. */
  38515. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38516. /**
  38517. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38518. * is automatically returned to its default position (expected to be above ground plane).
  38519. */
  38520. private _maintainCameraAboveGround;
  38521. /**
  38522. * Returns the frustum slope based on the canvas ratio and camera FOV
  38523. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38524. */
  38525. private _getFrustumSlope;
  38526. /**
  38527. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38528. */
  38529. private _clearAnimationLocks;
  38530. /**
  38531. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38532. */
  38533. private _applyUserInteraction;
  38534. /**
  38535. * Stops and removes all animations that have been applied to the camera
  38536. */
  38537. stopAllAnimations(): void;
  38538. /**
  38539. * Gets a value indicating if the user is moving the camera
  38540. */
  38541. get isUserIsMoving(): boolean;
  38542. /**
  38543. * The camera can move all the way towards the mesh.
  38544. */
  38545. static IgnoreBoundsSizeMode: number;
  38546. /**
  38547. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38548. */
  38549. static FitFrustumSidesMode: number;
  38550. }
  38551. }
  38552. declare module BABYLON {
  38553. /**
  38554. * Base class for Camera Pointer Inputs.
  38555. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38556. * for example usage.
  38557. */
  38558. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38559. /**
  38560. * Defines the camera the input is attached to.
  38561. */
  38562. abstract camera: Camera;
  38563. /**
  38564. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38565. */
  38566. protected _altKey: boolean;
  38567. protected _ctrlKey: boolean;
  38568. protected _metaKey: boolean;
  38569. protected _shiftKey: boolean;
  38570. /**
  38571. * Which mouse buttons were pressed at time of last mouse event.
  38572. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38573. */
  38574. protected _buttonsPressed: number;
  38575. /**
  38576. * Defines the buttons associated with the input to handle camera move.
  38577. */
  38578. buttons: number[];
  38579. /**
  38580. * Attach the input controls to a specific dom element to get the input from.
  38581. * @param element Defines the element the controls should be listened from
  38582. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38583. */
  38584. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38585. /**
  38586. * Detach the current controls from the specified dom element.
  38587. * @param element Defines the element to stop listening the inputs from
  38588. */
  38589. detachControl(element: Nullable<HTMLElement>): void;
  38590. /**
  38591. * Gets the class name of the current input.
  38592. * @returns the class name
  38593. */
  38594. getClassName(): string;
  38595. /**
  38596. * Get the friendly name associated with the input class.
  38597. * @returns the input friendly name
  38598. */
  38599. getSimpleName(): string;
  38600. /**
  38601. * Called on pointer POINTERDOUBLETAP event.
  38602. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38603. */
  38604. protected onDoubleTap(type: string): void;
  38605. /**
  38606. * Called on pointer POINTERMOVE event if only a single touch is active.
  38607. * Override this method to provide functionality.
  38608. */
  38609. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38610. /**
  38611. * Called on pointer POINTERMOVE event if multiple touches are active.
  38612. * Override this method to provide functionality.
  38613. */
  38614. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38615. /**
  38616. * Called on JS contextmenu event.
  38617. * Override this method to provide functionality.
  38618. */
  38619. protected onContextMenu(evt: PointerEvent): void;
  38620. /**
  38621. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38622. * press.
  38623. * Override this method to provide functionality.
  38624. */
  38625. protected onButtonDown(evt: PointerEvent): void;
  38626. /**
  38627. * Called each time a new POINTERUP event occurs. Ie, for each button
  38628. * release.
  38629. * Override this method to provide functionality.
  38630. */
  38631. protected onButtonUp(evt: PointerEvent): void;
  38632. /**
  38633. * Called when window becomes inactive.
  38634. * Override this method to provide functionality.
  38635. */
  38636. protected onLostFocus(): void;
  38637. private _pointerInput;
  38638. private _observer;
  38639. private _onLostFocus;
  38640. private pointA;
  38641. private pointB;
  38642. }
  38643. }
  38644. declare module BABYLON {
  38645. /**
  38646. * Manage the pointers inputs to control an arc rotate camera.
  38647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38648. */
  38649. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38650. /**
  38651. * Defines the camera the input is attached to.
  38652. */
  38653. camera: ArcRotateCamera;
  38654. /**
  38655. * Gets the class name of the current input.
  38656. * @returns the class name
  38657. */
  38658. getClassName(): string;
  38659. /**
  38660. * Defines the buttons associated with the input to handle camera move.
  38661. */
  38662. buttons: number[];
  38663. /**
  38664. * Defines the pointer angular sensibility along the X axis or how fast is
  38665. * the camera rotating.
  38666. */
  38667. angularSensibilityX: number;
  38668. /**
  38669. * Defines the pointer angular sensibility along the Y axis or how fast is
  38670. * the camera rotating.
  38671. */
  38672. angularSensibilityY: number;
  38673. /**
  38674. * Defines the pointer pinch precision or how fast is the camera zooming.
  38675. */
  38676. pinchPrecision: number;
  38677. /**
  38678. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38679. * from 0.
  38680. * It defines the percentage of current camera.radius to use as delta when
  38681. * pinch zoom is used.
  38682. */
  38683. pinchDeltaPercentage: number;
  38684. /**
  38685. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38686. * that any object in the plane at the camera's target point will scale
  38687. * perfectly with finger motion.
  38688. * Overrides pinchDeltaPercentage and pinchPrecision.
  38689. */
  38690. useNaturalPinchZoom: boolean;
  38691. /**
  38692. * Defines the pointer panning sensibility or how fast is the camera moving.
  38693. */
  38694. panningSensibility: number;
  38695. /**
  38696. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38697. */
  38698. multiTouchPanning: boolean;
  38699. /**
  38700. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38701. * zoom (pinch) through multitouch.
  38702. */
  38703. multiTouchPanAndZoom: boolean;
  38704. /**
  38705. * Revers pinch action direction.
  38706. */
  38707. pinchInwards: boolean;
  38708. private _isPanClick;
  38709. private _twoFingerActivityCount;
  38710. private _isPinching;
  38711. /**
  38712. * Called on pointer POINTERMOVE event if only a single touch is active.
  38713. */
  38714. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38715. /**
  38716. * Called on pointer POINTERDOUBLETAP event.
  38717. */
  38718. protected onDoubleTap(type: string): void;
  38719. /**
  38720. * Called on pointer POINTERMOVE event if multiple touches are active.
  38721. */
  38722. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38723. /**
  38724. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38725. * press.
  38726. */
  38727. protected onButtonDown(evt: PointerEvent): void;
  38728. /**
  38729. * Called each time a new POINTERUP event occurs. Ie, for each button
  38730. * release.
  38731. */
  38732. protected onButtonUp(evt: PointerEvent): void;
  38733. /**
  38734. * Called when window becomes inactive.
  38735. */
  38736. protected onLostFocus(): void;
  38737. }
  38738. }
  38739. declare module BABYLON {
  38740. /**
  38741. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38742. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38743. */
  38744. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38745. /**
  38746. * Defines the camera the input is attached to.
  38747. */
  38748. camera: ArcRotateCamera;
  38749. /**
  38750. * Defines the list of key codes associated with the up action (increase alpha)
  38751. */
  38752. keysUp: number[];
  38753. /**
  38754. * Defines the list of key codes associated with the down action (decrease alpha)
  38755. */
  38756. keysDown: number[];
  38757. /**
  38758. * Defines the list of key codes associated with the left action (increase beta)
  38759. */
  38760. keysLeft: number[];
  38761. /**
  38762. * Defines the list of key codes associated with the right action (decrease beta)
  38763. */
  38764. keysRight: number[];
  38765. /**
  38766. * Defines the list of key codes associated with the reset action.
  38767. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38768. */
  38769. keysReset: number[];
  38770. /**
  38771. * Defines the panning sensibility of the inputs.
  38772. * (How fast is the camera panning)
  38773. */
  38774. panningSensibility: number;
  38775. /**
  38776. * Defines the zooming sensibility of the inputs.
  38777. * (How fast is the camera zooming)
  38778. */
  38779. zoomingSensibility: number;
  38780. /**
  38781. * Defines whether maintaining the alt key down switch the movement mode from
  38782. * orientation to zoom.
  38783. */
  38784. useAltToZoom: boolean;
  38785. /**
  38786. * Rotation speed of the camera
  38787. */
  38788. angularSpeed: number;
  38789. private _keys;
  38790. private _ctrlPressed;
  38791. private _altPressed;
  38792. private _onCanvasBlurObserver;
  38793. private _onKeyboardObserver;
  38794. private _engine;
  38795. private _scene;
  38796. /**
  38797. * Attach the input controls to a specific dom element to get the input from.
  38798. * @param element Defines the element the controls should be listened from
  38799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38800. */
  38801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38802. /**
  38803. * Detach the current controls from the specified dom element.
  38804. * @param element Defines the element to stop listening the inputs from
  38805. */
  38806. detachControl(element: Nullable<HTMLElement>): void;
  38807. /**
  38808. * Update the current camera state depending on the inputs that have been used this frame.
  38809. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38810. */
  38811. checkInputs(): void;
  38812. /**
  38813. * Gets the class name of the current intput.
  38814. * @returns the class name
  38815. */
  38816. getClassName(): string;
  38817. /**
  38818. * Get the friendly name associated with the input class.
  38819. * @returns the input friendly name
  38820. */
  38821. getSimpleName(): string;
  38822. }
  38823. }
  38824. declare module BABYLON {
  38825. /**
  38826. * Manage the mouse wheel inputs to control an arc rotate camera.
  38827. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38828. */
  38829. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38830. /**
  38831. * Defines the camera the input is attached to.
  38832. */
  38833. camera: ArcRotateCamera;
  38834. /**
  38835. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38836. */
  38837. wheelPrecision: number;
  38838. /**
  38839. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38840. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38841. */
  38842. wheelDeltaPercentage: number;
  38843. private _wheel;
  38844. private _observer;
  38845. private computeDeltaFromMouseWheelLegacyEvent;
  38846. /**
  38847. * Attach the input controls to a specific dom element to get the input from.
  38848. * @param element Defines the element the controls should be listened from
  38849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38850. */
  38851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38852. /**
  38853. * Detach the current controls from the specified dom element.
  38854. * @param element Defines the element to stop listening the inputs from
  38855. */
  38856. detachControl(element: Nullable<HTMLElement>): void;
  38857. /**
  38858. * Gets the class name of the current intput.
  38859. * @returns the class name
  38860. */
  38861. getClassName(): string;
  38862. /**
  38863. * Get the friendly name associated with the input class.
  38864. * @returns the input friendly name
  38865. */
  38866. getSimpleName(): string;
  38867. }
  38868. }
  38869. declare module BABYLON {
  38870. /**
  38871. * Default Inputs manager for the ArcRotateCamera.
  38872. * It groups all the default supported inputs for ease of use.
  38873. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38874. */
  38875. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38876. /**
  38877. * Instantiates a new ArcRotateCameraInputsManager.
  38878. * @param camera Defines the camera the inputs belong to
  38879. */
  38880. constructor(camera: ArcRotateCamera);
  38881. /**
  38882. * Add mouse wheel input support to the input manager.
  38883. * @returns the current input manager
  38884. */
  38885. addMouseWheel(): ArcRotateCameraInputsManager;
  38886. /**
  38887. * Add pointers input support to the input manager.
  38888. * @returns the current input manager
  38889. */
  38890. addPointers(): ArcRotateCameraInputsManager;
  38891. /**
  38892. * Add keyboard input support to the input manager.
  38893. * @returns the current input manager
  38894. */
  38895. addKeyboard(): ArcRotateCameraInputsManager;
  38896. }
  38897. }
  38898. declare module BABYLON {
  38899. /**
  38900. * This represents an orbital type of camera.
  38901. *
  38902. * 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.
  38903. * 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.
  38904. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38905. */
  38906. export class ArcRotateCamera extends TargetCamera {
  38907. /**
  38908. * Defines the rotation angle of the camera along the longitudinal axis.
  38909. */
  38910. alpha: number;
  38911. /**
  38912. * Defines the rotation angle of the camera along the latitudinal axis.
  38913. */
  38914. beta: number;
  38915. /**
  38916. * Defines the radius of the camera from it s target point.
  38917. */
  38918. radius: number;
  38919. protected _target: Vector3;
  38920. protected _targetHost: Nullable<AbstractMesh>;
  38921. /**
  38922. * Defines the target point of the camera.
  38923. * The camera looks towards it form the radius distance.
  38924. */
  38925. get target(): Vector3;
  38926. set target(value: Vector3);
  38927. /**
  38928. * Define the current local position of the camera in the scene
  38929. */
  38930. get position(): Vector3;
  38931. set position(newPosition: Vector3);
  38932. protected _upVector: Vector3;
  38933. protected _upToYMatrix: Matrix;
  38934. protected _YToUpMatrix: Matrix;
  38935. /**
  38936. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38937. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38938. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38939. */
  38940. set upVector(vec: Vector3);
  38941. get upVector(): Vector3;
  38942. /**
  38943. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38944. */
  38945. setMatUp(): void;
  38946. /**
  38947. * Current inertia value on the longitudinal axis.
  38948. * The bigger this number the longer it will take for the camera to stop.
  38949. */
  38950. inertialAlphaOffset: number;
  38951. /**
  38952. * Current inertia value on the latitudinal axis.
  38953. * The bigger this number the longer it will take for the camera to stop.
  38954. */
  38955. inertialBetaOffset: number;
  38956. /**
  38957. * Current inertia value on the radius axis.
  38958. * The bigger this number the longer it will take for the camera to stop.
  38959. */
  38960. inertialRadiusOffset: number;
  38961. /**
  38962. * Minimum allowed angle on the longitudinal axis.
  38963. * This can help limiting how the Camera is able to move in the scene.
  38964. */
  38965. lowerAlphaLimit: Nullable<number>;
  38966. /**
  38967. * Maximum allowed angle on the longitudinal axis.
  38968. * This can help limiting how the Camera is able to move in the scene.
  38969. */
  38970. upperAlphaLimit: Nullable<number>;
  38971. /**
  38972. * Minimum allowed angle on the latitudinal axis.
  38973. * This can help limiting how the Camera is able to move in the scene.
  38974. */
  38975. lowerBetaLimit: number;
  38976. /**
  38977. * Maximum allowed angle on the latitudinal axis.
  38978. * This can help limiting how the Camera is able to move in the scene.
  38979. */
  38980. upperBetaLimit: number;
  38981. /**
  38982. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38983. * This can help limiting how the Camera is able to move in the scene.
  38984. */
  38985. lowerRadiusLimit: Nullable<number>;
  38986. /**
  38987. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38988. * This can help limiting how the Camera is able to move in the scene.
  38989. */
  38990. upperRadiusLimit: Nullable<number>;
  38991. /**
  38992. * Defines the current inertia value used during panning of the camera along the X axis.
  38993. */
  38994. inertialPanningX: number;
  38995. /**
  38996. * Defines the current inertia value used during panning of the camera along the Y axis.
  38997. */
  38998. inertialPanningY: number;
  38999. /**
  39000. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39001. * Basically if your fingers moves away from more than this distance you will be considered
  39002. * in pinch mode.
  39003. */
  39004. pinchToPanMaxDistance: number;
  39005. /**
  39006. * Defines the maximum distance the camera can pan.
  39007. * This could help keeping the cammera always in your scene.
  39008. */
  39009. panningDistanceLimit: Nullable<number>;
  39010. /**
  39011. * Defines the target of the camera before paning.
  39012. */
  39013. panningOriginTarget: Vector3;
  39014. /**
  39015. * Defines the value of the inertia used during panning.
  39016. * 0 would mean stop inertia and one would mean no decelleration at all.
  39017. */
  39018. panningInertia: number;
  39019. /**
  39020. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39021. */
  39022. get angularSensibilityX(): number;
  39023. set angularSensibilityX(value: number);
  39024. /**
  39025. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39026. */
  39027. get angularSensibilityY(): number;
  39028. set angularSensibilityY(value: number);
  39029. /**
  39030. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39031. */
  39032. get pinchPrecision(): number;
  39033. set pinchPrecision(value: number);
  39034. /**
  39035. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39036. * It will be used instead of pinchDeltaPrecision if different from 0.
  39037. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39038. */
  39039. get pinchDeltaPercentage(): number;
  39040. set pinchDeltaPercentage(value: number);
  39041. /**
  39042. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39043. * and pinch delta percentage.
  39044. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39045. * that any object in the plane at the camera's target point will scale
  39046. * perfectly with finger motion.
  39047. */
  39048. get useNaturalPinchZoom(): boolean;
  39049. set useNaturalPinchZoom(value: boolean);
  39050. /**
  39051. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39052. */
  39053. get panningSensibility(): number;
  39054. set panningSensibility(value: number);
  39055. /**
  39056. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39057. */
  39058. get keysUp(): number[];
  39059. set keysUp(value: number[]);
  39060. /**
  39061. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39062. */
  39063. get keysDown(): number[];
  39064. set keysDown(value: number[]);
  39065. /**
  39066. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39067. */
  39068. get keysLeft(): number[];
  39069. set keysLeft(value: number[]);
  39070. /**
  39071. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39072. */
  39073. get keysRight(): number[];
  39074. set keysRight(value: number[]);
  39075. /**
  39076. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39077. */
  39078. get wheelPrecision(): number;
  39079. set wheelPrecision(value: number);
  39080. /**
  39081. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39082. * It will be used instead of pinchDeltaPrecision if different from 0.
  39083. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39084. */
  39085. get wheelDeltaPercentage(): number;
  39086. set wheelDeltaPercentage(value: number);
  39087. /**
  39088. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39089. */
  39090. zoomOnFactor: number;
  39091. /**
  39092. * Defines a screen offset for the camera position.
  39093. */
  39094. targetScreenOffset: Vector2;
  39095. /**
  39096. * Allows the camera to be completely reversed.
  39097. * If false the camera can not arrive upside down.
  39098. */
  39099. allowUpsideDown: boolean;
  39100. /**
  39101. * Define if double tap/click is used to restore the previously saved state of the camera.
  39102. */
  39103. useInputToRestoreState: boolean;
  39104. /** @hidden */
  39105. _viewMatrix: Matrix;
  39106. /** @hidden */
  39107. _useCtrlForPanning: boolean;
  39108. /** @hidden */
  39109. _panningMouseButton: number;
  39110. /**
  39111. * Defines the input associated to the camera.
  39112. */
  39113. inputs: ArcRotateCameraInputsManager;
  39114. /** @hidden */
  39115. _reset: () => void;
  39116. /**
  39117. * Defines the allowed panning axis.
  39118. */
  39119. panningAxis: Vector3;
  39120. protected _localDirection: Vector3;
  39121. protected _transformedDirection: Vector3;
  39122. private _bouncingBehavior;
  39123. /**
  39124. * Gets the bouncing behavior of the camera if it has been enabled.
  39125. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39126. */
  39127. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39128. /**
  39129. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39130. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39131. */
  39132. get useBouncingBehavior(): boolean;
  39133. set useBouncingBehavior(value: boolean);
  39134. private _framingBehavior;
  39135. /**
  39136. * Gets the framing behavior of the camera if it has been enabled.
  39137. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39138. */
  39139. get framingBehavior(): Nullable<FramingBehavior>;
  39140. /**
  39141. * Defines if the framing behavior of the camera is enabled on the camera.
  39142. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39143. */
  39144. get useFramingBehavior(): boolean;
  39145. set useFramingBehavior(value: boolean);
  39146. private _autoRotationBehavior;
  39147. /**
  39148. * Gets the auto rotation behavior of the camera if it has been enabled.
  39149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39150. */
  39151. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39152. /**
  39153. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39154. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39155. */
  39156. get useAutoRotationBehavior(): boolean;
  39157. set useAutoRotationBehavior(value: boolean);
  39158. /**
  39159. * Observable triggered when the mesh target has been changed on the camera.
  39160. */
  39161. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39162. /**
  39163. * Event raised when the camera is colliding with a mesh.
  39164. */
  39165. onCollide: (collidedMesh: AbstractMesh) => void;
  39166. /**
  39167. * Defines whether the camera should check collision with the objects oh the scene.
  39168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39169. */
  39170. checkCollisions: boolean;
  39171. /**
  39172. * Defines the collision radius of the camera.
  39173. * This simulates a sphere around the camera.
  39174. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39175. */
  39176. collisionRadius: Vector3;
  39177. protected _collider: Collider;
  39178. protected _previousPosition: Vector3;
  39179. protected _collisionVelocity: Vector3;
  39180. protected _newPosition: Vector3;
  39181. protected _previousAlpha: number;
  39182. protected _previousBeta: number;
  39183. protected _previousRadius: number;
  39184. protected _collisionTriggered: boolean;
  39185. protected _targetBoundingCenter: Nullable<Vector3>;
  39186. private _computationVector;
  39187. /**
  39188. * Instantiates a new ArcRotateCamera in a given scene
  39189. * @param name Defines the name of the camera
  39190. * @param alpha Defines the camera rotation along the logitudinal axis
  39191. * @param beta Defines the camera rotation along the latitudinal axis
  39192. * @param radius Defines the camera distance from its target
  39193. * @param target Defines the camera target
  39194. * @param scene Defines the scene the camera belongs to
  39195. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39196. */
  39197. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39198. /** @hidden */
  39199. _initCache(): void;
  39200. /** @hidden */
  39201. _updateCache(ignoreParentClass?: boolean): void;
  39202. protected _getTargetPosition(): Vector3;
  39203. private _storedAlpha;
  39204. private _storedBeta;
  39205. private _storedRadius;
  39206. private _storedTarget;
  39207. private _storedTargetScreenOffset;
  39208. /**
  39209. * Stores the current state of the camera (alpha, beta, radius and target)
  39210. * @returns the camera itself
  39211. */
  39212. storeState(): Camera;
  39213. /**
  39214. * @hidden
  39215. * Restored camera state. You must call storeState() first
  39216. */
  39217. _restoreStateValues(): boolean;
  39218. /** @hidden */
  39219. _isSynchronizedViewMatrix(): boolean;
  39220. /**
  39221. * Attached controls to the current camera.
  39222. * @param element Defines the element the controls should be listened from
  39223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39224. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39225. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39226. */
  39227. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39228. /**
  39229. * Detach the current controls from the camera.
  39230. * The camera will stop reacting to inputs.
  39231. * @param element Defines the element to stop listening the inputs from
  39232. */
  39233. detachControl(element: HTMLElement): void;
  39234. /** @hidden */
  39235. _checkInputs(): void;
  39236. protected _checkLimits(): void;
  39237. /**
  39238. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39239. */
  39240. rebuildAnglesAndRadius(): void;
  39241. /**
  39242. * Use a position to define the current camera related information like alpha, beta and radius
  39243. * @param position Defines the position to set the camera at
  39244. */
  39245. setPosition(position: Vector3): void;
  39246. /**
  39247. * Defines the target the camera should look at.
  39248. * This will automatically adapt alpha beta and radius to fit within the new target.
  39249. * @param target Defines the new target as a Vector or a mesh
  39250. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  39251. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39252. */
  39253. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39254. /** @hidden */
  39255. _getViewMatrix(): Matrix;
  39256. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39257. /**
  39258. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39259. * @param meshes Defines the mesh to zoom on
  39260. * @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)
  39261. */
  39262. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39263. /**
  39264. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39265. * The target will be changed but the radius
  39266. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39267. * @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)
  39268. */
  39269. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39270. min: Vector3;
  39271. max: Vector3;
  39272. distance: number;
  39273. }, doNotUpdateMaxZ?: boolean): void;
  39274. /**
  39275. * @override
  39276. * Override Camera.createRigCamera
  39277. */
  39278. createRigCamera(name: string, cameraIndex: number): Camera;
  39279. /**
  39280. * @hidden
  39281. * @override
  39282. * Override Camera._updateRigCameras
  39283. */
  39284. _updateRigCameras(): void;
  39285. /**
  39286. * Destroy the camera and release the current resources hold by it.
  39287. */
  39288. dispose(): void;
  39289. /**
  39290. * Gets the current object class name.
  39291. * @return the class name
  39292. */
  39293. getClassName(): string;
  39294. }
  39295. }
  39296. declare module BABYLON {
  39297. /**
  39298. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39299. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39300. */
  39301. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39302. /**
  39303. * Gets the name of the behavior.
  39304. */
  39305. get name(): string;
  39306. private _zoomStopsAnimation;
  39307. private _idleRotationSpeed;
  39308. private _idleRotationWaitTime;
  39309. private _idleRotationSpinupTime;
  39310. /**
  39311. * Sets the flag that indicates if user zooming should stop animation.
  39312. */
  39313. set zoomStopsAnimation(flag: boolean);
  39314. /**
  39315. * Gets the flag that indicates if user zooming should stop animation.
  39316. */
  39317. get zoomStopsAnimation(): boolean;
  39318. /**
  39319. * Sets the default speed at which the camera rotates around the model.
  39320. */
  39321. set idleRotationSpeed(speed: number);
  39322. /**
  39323. * Gets the default speed at which the camera rotates around the model.
  39324. */
  39325. get idleRotationSpeed(): number;
  39326. /**
  39327. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39328. */
  39329. set idleRotationWaitTime(time: number);
  39330. /**
  39331. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39332. */
  39333. get idleRotationWaitTime(): number;
  39334. /**
  39335. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39336. */
  39337. set idleRotationSpinupTime(time: number);
  39338. /**
  39339. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39340. */
  39341. get idleRotationSpinupTime(): number;
  39342. /**
  39343. * Gets a value indicating if the camera is currently rotating because of this behavior
  39344. */
  39345. get rotationInProgress(): boolean;
  39346. private _onPrePointerObservableObserver;
  39347. private _onAfterCheckInputsObserver;
  39348. private _attachedCamera;
  39349. private _isPointerDown;
  39350. private _lastFrameTime;
  39351. private _lastInteractionTime;
  39352. private _cameraRotationSpeed;
  39353. /**
  39354. * Initializes the behavior.
  39355. */
  39356. init(): void;
  39357. /**
  39358. * Attaches the behavior to its arc rotate camera.
  39359. * @param camera Defines the camera to attach the behavior to
  39360. */
  39361. attach(camera: ArcRotateCamera): void;
  39362. /**
  39363. * Detaches the behavior from its current arc rotate camera.
  39364. */
  39365. detach(): void;
  39366. /**
  39367. * Returns true if user is scrolling.
  39368. * @return true if user is scrolling.
  39369. */
  39370. private _userIsZooming;
  39371. private _lastFrameRadius;
  39372. private _shouldAnimationStopForInteraction;
  39373. /**
  39374. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39375. */
  39376. private _applyUserInteraction;
  39377. private _userIsMoving;
  39378. }
  39379. }
  39380. declare module BABYLON {
  39381. /**
  39382. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39383. */
  39384. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39385. private ui;
  39386. /**
  39387. * The name of the behavior
  39388. */
  39389. name: string;
  39390. /**
  39391. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39392. */
  39393. distanceAwayFromFace: number;
  39394. /**
  39395. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39396. */
  39397. distanceAwayFromBottomOfFace: number;
  39398. private _faceVectors;
  39399. private _target;
  39400. private _scene;
  39401. private _onRenderObserver;
  39402. private _tmpMatrix;
  39403. private _tmpVector;
  39404. /**
  39405. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39406. * @param ui The transform node that should be attched to the mesh
  39407. */
  39408. constructor(ui: TransformNode);
  39409. /**
  39410. * Initializes the behavior
  39411. */
  39412. init(): void;
  39413. private _closestFace;
  39414. private _zeroVector;
  39415. private _lookAtTmpMatrix;
  39416. private _lookAtToRef;
  39417. /**
  39418. * Attaches the AttachToBoxBehavior to the passed in mesh
  39419. * @param target The mesh that the specified node will be attached to
  39420. */
  39421. attach(target: Mesh): void;
  39422. /**
  39423. * Detaches the behavior from the mesh
  39424. */
  39425. detach(): void;
  39426. }
  39427. }
  39428. declare module BABYLON {
  39429. /**
  39430. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39431. */
  39432. export class FadeInOutBehavior implements Behavior<Mesh> {
  39433. /**
  39434. * Time in milliseconds to delay before fading in (Default: 0)
  39435. */
  39436. delay: number;
  39437. /**
  39438. * Time in milliseconds for the mesh to fade in (Default: 300)
  39439. */
  39440. fadeInTime: number;
  39441. private _millisecondsPerFrame;
  39442. private _hovered;
  39443. private _hoverValue;
  39444. private _ownerNode;
  39445. /**
  39446. * Instatiates the FadeInOutBehavior
  39447. */
  39448. constructor();
  39449. /**
  39450. * The name of the behavior
  39451. */
  39452. get name(): string;
  39453. /**
  39454. * Initializes the behavior
  39455. */
  39456. init(): void;
  39457. /**
  39458. * Attaches the fade behavior on the passed in mesh
  39459. * @param ownerNode The mesh that will be faded in/out once attached
  39460. */
  39461. attach(ownerNode: Mesh): void;
  39462. /**
  39463. * Detaches the behavior from the mesh
  39464. */
  39465. detach(): void;
  39466. /**
  39467. * Triggers the mesh to begin fading in or out
  39468. * @param value if the object should fade in or out (true to fade in)
  39469. */
  39470. fadeIn(value: boolean): void;
  39471. private _update;
  39472. private _setAllVisibility;
  39473. }
  39474. }
  39475. declare module BABYLON {
  39476. /**
  39477. * Class containing a set of static utilities functions for managing Pivots
  39478. * @hidden
  39479. */
  39480. export class PivotTools {
  39481. private static _PivotCached;
  39482. private static _OldPivotPoint;
  39483. private static _PivotTranslation;
  39484. private static _PivotTmpVector;
  39485. /** @hidden */
  39486. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39487. /** @hidden */
  39488. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39489. }
  39490. }
  39491. declare module BABYLON {
  39492. /**
  39493. * Class containing static functions to help procedurally build meshes
  39494. */
  39495. export class PlaneBuilder {
  39496. /**
  39497. * Creates a plane mesh
  39498. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39499. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39500. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39502. * * 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
  39503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39504. * @param name defines the name of the mesh
  39505. * @param options defines the options used to create the mesh
  39506. * @param scene defines the hosting scene
  39507. * @returns the plane mesh
  39508. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39509. */
  39510. static CreatePlane(name: string, options: {
  39511. size?: number;
  39512. width?: number;
  39513. height?: number;
  39514. sideOrientation?: number;
  39515. frontUVs?: Vector4;
  39516. backUVs?: Vector4;
  39517. updatable?: boolean;
  39518. sourcePlane?: Plane;
  39519. }, scene?: Nullable<Scene>): Mesh;
  39520. }
  39521. }
  39522. declare module BABYLON {
  39523. /**
  39524. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39525. */
  39526. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39527. private static _AnyMouseID;
  39528. /**
  39529. * Abstract mesh the behavior is set on
  39530. */
  39531. attachedNode: AbstractMesh;
  39532. private _dragPlane;
  39533. private _scene;
  39534. private _pointerObserver;
  39535. private _beforeRenderObserver;
  39536. private static _planeScene;
  39537. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39538. /**
  39539. * 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)
  39540. */
  39541. maxDragAngle: number;
  39542. /**
  39543. * @hidden
  39544. */
  39545. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39546. /**
  39547. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39548. */
  39549. currentDraggingPointerID: number;
  39550. /**
  39551. * The last position where the pointer hit the drag plane in world space
  39552. */
  39553. lastDragPosition: Vector3;
  39554. /**
  39555. * If the behavior is currently in a dragging state
  39556. */
  39557. dragging: boolean;
  39558. /**
  39559. * 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)
  39560. */
  39561. dragDeltaRatio: number;
  39562. /**
  39563. * If the drag plane orientation should be updated during the dragging (Default: true)
  39564. */
  39565. updateDragPlane: boolean;
  39566. private _debugMode;
  39567. private _moving;
  39568. /**
  39569. * Fires each time the attached mesh is dragged with the pointer
  39570. * * delta between last drag position and current drag position in world space
  39571. * * dragDistance along the drag axis
  39572. * * dragPlaneNormal normal of the current drag plane used during the drag
  39573. * * dragPlanePoint in world space where the drag intersects the drag plane
  39574. */
  39575. onDragObservable: Observable<{
  39576. delta: Vector3;
  39577. dragPlanePoint: Vector3;
  39578. dragPlaneNormal: Vector3;
  39579. dragDistance: number;
  39580. pointerId: number;
  39581. }>;
  39582. /**
  39583. * Fires each time a drag begins (eg. mouse down on mesh)
  39584. */
  39585. onDragStartObservable: Observable<{
  39586. dragPlanePoint: Vector3;
  39587. pointerId: number;
  39588. }>;
  39589. /**
  39590. * Fires each time a drag ends (eg. mouse release after drag)
  39591. */
  39592. onDragEndObservable: Observable<{
  39593. dragPlanePoint: Vector3;
  39594. pointerId: number;
  39595. }>;
  39596. /**
  39597. * If the attached mesh should be moved when dragged
  39598. */
  39599. moveAttached: boolean;
  39600. /**
  39601. * If the drag behavior will react to drag events (Default: true)
  39602. */
  39603. enabled: boolean;
  39604. /**
  39605. * If pointer events should start and release the drag (Default: true)
  39606. */
  39607. startAndReleaseDragOnPointerEvents: boolean;
  39608. /**
  39609. * If camera controls should be detached during the drag
  39610. */
  39611. detachCameraControls: boolean;
  39612. /**
  39613. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39614. */
  39615. useObjectOrientationForDragging: boolean;
  39616. private _options;
  39617. /**
  39618. * Gets the options used by the behavior
  39619. */
  39620. get options(): {
  39621. dragAxis?: Vector3;
  39622. dragPlaneNormal?: Vector3;
  39623. };
  39624. /**
  39625. * Sets the options used by the behavior
  39626. */
  39627. set options(options: {
  39628. dragAxis?: Vector3;
  39629. dragPlaneNormal?: Vector3;
  39630. });
  39631. /**
  39632. * Creates a pointer drag behavior that can be attached to a mesh
  39633. * @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)
  39634. */
  39635. constructor(options?: {
  39636. dragAxis?: Vector3;
  39637. dragPlaneNormal?: Vector3;
  39638. });
  39639. /**
  39640. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39641. */
  39642. validateDrag: (targetPosition: Vector3) => boolean;
  39643. /**
  39644. * The name of the behavior
  39645. */
  39646. get name(): string;
  39647. /**
  39648. * Initializes the behavior
  39649. */
  39650. init(): void;
  39651. private _tmpVector;
  39652. private _alternatePickedPoint;
  39653. private _worldDragAxis;
  39654. private _targetPosition;
  39655. private _attachedElement;
  39656. /**
  39657. * Attaches the drag behavior the passed in mesh
  39658. * @param ownerNode The mesh that will be dragged around once attached
  39659. * @param predicate Predicate to use for pick filtering
  39660. */
  39661. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39662. /**
  39663. * Force relase the drag action by code.
  39664. */
  39665. releaseDrag(): void;
  39666. private _startDragRay;
  39667. private _lastPointerRay;
  39668. /**
  39669. * Simulates the start of a pointer drag event on the behavior
  39670. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39671. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39672. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39673. */
  39674. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39675. private _startDrag;
  39676. private _dragDelta;
  39677. private _moveDrag;
  39678. private _pickWithRayOnDragPlane;
  39679. private _pointA;
  39680. private _pointB;
  39681. private _pointC;
  39682. private _lineA;
  39683. private _lineB;
  39684. private _localAxis;
  39685. private _lookAt;
  39686. private _updateDragPlanePosition;
  39687. /**
  39688. * Detaches the behavior from the mesh
  39689. */
  39690. detach(): void;
  39691. }
  39692. }
  39693. declare module BABYLON {
  39694. /**
  39695. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39696. */
  39697. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39698. private _dragBehaviorA;
  39699. private _dragBehaviorB;
  39700. private _startDistance;
  39701. private _initialScale;
  39702. private _targetScale;
  39703. private _ownerNode;
  39704. private _sceneRenderObserver;
  39705. /**
  39706. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39707. */
  39708. constructor();
  39709. /**
  39710. * The name of the behavior
  39711. */
  39712. get name(): string;
  39713. /**
  39714. * Initializes the behavior
  39715. */
  39716. init(): void;
  39717. private _getCurrentDistance;
  39718. /**
  39719. * Attaches the scale behavior the passed in mesh
  39720. * @param ownerNode The mesh that will be scaled around once attached
  39721. */
  39722. attach(ownerNode: Mesh): void;
  39723. /**
  39724. * Detaches the behavior from the mesh
  39725. */
  39726. detach(): void;
  39727. }
  39728. }
  39729. declare module BABYLON {
  39730. /**
  39731. * 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
  39732. */
  39733. export class SixDofDragBehavior implements Behavior<Mesh> {
  39734. private static _virtualScene;
  39735. private _ownerNode;
  39736. private _sceneRenderObserver;
  39737. private _scene;
  39738. private _targetPosition;
  39739. private _virtualOriginMesh;
  39740. private _virtualDragMesh;
  39741. private _pointerObserver;
  39742. private _moving;
  39743. private _startingOrientation;
  39744. private _attachedElement;
  39745. /**
  39746. * 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)
  39747. */
  39748. private zDragFactor;
  39749. /**
  39750. * If the object should rotate to face the drag origin
  39751. */
  39752. rotateDraggedObject: boolean;
  39753. /**
  39754. * If the behavior is currently in a dragging state
  39755. */
  39756. dragging: boolean;
  39757. /**
  39758. * 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)
  39759. */
  39760. dragDeltaRatio: number;
  39761. /**
  39762. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39763. */
  39764. currentDraggingPointerID: number;
  39765. /**
  39766. * If camera controls should be detached during the drag
  39767. */
  39768. detachCameraControls: boolean;
  39769. /**
  39770. * Fires each time a drag starts
  39771. */
  39772. onDragStartObservable: Observable<{}>;
  39773. /**
  39774. * Fires each time a drag ends (eg. mouse release after drag)
  39775. */
  39776. onDragEndObservable: Observable<{}>;
  39777. /**
  39778. * 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
  39779. */
  39780. constructor();
  39781. /**
  39782. * The name of the behavior
  39783. */
  39784. get name(): string;
  39785. /**
  39786. * Initializes the behavior
  39787. */
  39788. init(): void;
  39789. /**
  39790. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39791. */
  39792. private get _pointerCamera();
  39793. /**
  39794. * Attaches the scale behavior the passed in mesh
  39795. * @param ownerNode The mesh that will be scaled around once attached
  39796. */
  39797. attach(ownerNode: Mesh): void;
  39798. /**
  39799. * Detaches the behavior from the mesh
  39800. */
  39801. detach(): void;
  39802. }
  39803. }
  39804. declare module BABYLON {
  39805. /**
  39806. * Class used to apply inverse kinematics to bones
  39807. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39808. */
  39809. export class BoneIKController {
  39810. private static _tmpVecs;
  39811. private static _tmpQuat;
  39812. private static _tmpMats;
  39813. /**
  39814. * Gets or sets the target mesh
  39815. */
  39816. targetMesh: AbstractMesh;
  39817. /** Gets or sets the mesh used as pole */
  39818. poleTargetMesh: AbstractMesh;
  39819. /**
  39820. * Gets or sets the bone used as pole
  39821. */
  39822. poleTargetBone: Nullable<Bone>;
  39823. /**
  39824. * Gets or sets the target position
  39825. */
  39826. targetPosition: Vector3;
  39827. /**
  39828. * Gets or sets the pole target position
  39829. */
  39830. poleTargetPosition: Vector3;
  39831. /**
  39832. * Gets or sets the pole target local offset
  39833. */
  39834. poleTargetLocalOffset: Vector3;
  39835. /**
  39836. * Gets or sets the pole angle
  39837. */
  39838. poleAngle: number;
  39839. /**
  39840. * Gets or sets the mesh associated with the controller
  39841. */
  39842. mesh: AbstractMesh;
  39843. /**
  39844. * 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)
  39845. */
  39846. slerpAmount: number;
  39847. private _bone1Quat;
  39848. private _bone1Mat;
  39849. private _bone2Ang;
  39850. private _bone1;
  39851. private _bone2;
  39852. private _bone1Length;
  39853. private _bone2Length;
  39854. private _maxAngle;
  39855. private _maxReach;
  39856. private _rightHandedSystem;
  39857. private _bendAxis;
  39858. private _slerping;
  39859. private _adjustRoll;
  39860. /**
  39861. * Gets or sets maximum allowed angle
  39862. */
  39863. get maxAngle(): number;
  39864. set maxAngle(value: number);
  39865. /**
  39866. * Creates a new BoneIKController
  39867. * @param mesh defines the mesh to control
  39868. * @param bone defines the bone to control
  39869. * @param options defines options to set up the controller
  39870. */
  39871. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39872. targetMesh?: AbstractMesh;
  39873. poleTargetMesh?: AbstractMesh;
  39874. poleTargetBone?: Bone;
  39875. poleTargetLocalOffset?: Vector3;
  39876. poleAngle?: number;
  39877. bendAxis?: Vector3;
  39878. maxAngle?: number;
  39879. slerpAmount?: number;
  39880. });
  39881. private _setMaxAngle;
  39882. /**
  39883. * Force the controller to update the bones
  39884. */
  39885. update(): void;
  39886. }
  39887. }
  39888. declare module BABYLON {
  39889. /**
  39890. * Class used to make a bone look toward a point in space
  39891. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39892. */
  39893. export class BoneLookController {
  39894. private static _tmpVecs;
  39895. private static _tmpQuat;
  39896. private static _tmpMats;
  39897. /**
  39898. * The target Vector3 that the bone will look at
  39899. */
  39900. target: Vector3;
  39901. /**
  39902. * The mesh that the bone is attached to
  39903. */
  39904. mesh: AbstractMesh;
  39905. /**
  39906. * The bone that will be looking to the target
  39907. */
  39908. bone: Bone;
  39909. /**
  39910. * The up axis of the coordinate system that is used when the bone is rotated
  39911. */
  39912. upAxis: Vector3;
  39913. /**
  39914. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39915. */
  39916. upAxisSpace: Space;
  39917. /**
  39918. * Used to make an adjustment to the yaw of the bone
  39919. */
  39920. adjustYaw: number;
  39921. /**
  39922. * Used to make an adjustment to the pitch of the bone
  39923. */
  39924. adjustPitch: number;
  39925. /**
  39926. * Used to make an adjustment to the roll of the bone
  39927. */
  39928. adjustRoll: number;
  39929. /**
  39930. * 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)
  39931. */
  39932. slerpAmount: number;
  39933. private _minYaw;
  39934. private _maxYaw;
  39935. private _minPitch;
  39936. private _maxPitch;
  39937. private _minYawSin;
  39938. private _minYawCos;
  39939. private _maxYawSin;
  39940. private _maxYawCos;
  39941. private _midYawConstraint;
  39942. private _minPitchTan;
  39943. private _maxPitchTan;
  39944. private _boneQuat;
  39945. private _slerping;
  39946. private _transformYawPitch;
  39947. private _transformYawPitchInv;
  39948. private _firstFrameSkipped;
  39949. private _yawRange;
  39950. private _fowardAxis;
  39951. /**
  39952. * Gets or sets the minimum yaw angle that the bone can look to
  39953. */
  39954. get minYaw(): number;
  39955. set minYaw(value: number);
  39956. /**
  39957. * Gets or sets the maximum yaw angle that the bone can look to
  39958. */
  39959. get maxYaw(): number;
  39960. set maxYaw(value: number);
  39961. /**
  39962. * Gets or sets the minimum pitch angle that the bone can look to
  39963. */
  39964. get minPitch(): number;
  39965. set minPitch(value: number);
  39966. /**
  39967. * Gets or sets the maximum pitch angle that the bone can look to
  39968. */
  39969. get maxPitch(): number;
  39970. set maxPitch(value: number);
  39971. /**
  39972. * Create a BoneLookController
  39973. * @param mesh the mesh that the bone belongs to
  39974. * @param bone the bone that will be looking to the target
  39975. * @param target the target Vector3 to look at
  39976. * @param options optional settings:
  39977. * * maxYaw: the maximum angle the bone will yaw to
  39978. * * minYaw: the minimum angle the bone will yaw to
  39979. * * maxPitch: the maximum angle the bone will pitch to
  39980. * * minPitch: the minimum angle the bone will yaw to
  39981. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39982. * * upAxis: the up axis of the coordinate system
  39983. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39984. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39985. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39986. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39987. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39988. * * adjustRoll: used to make an adjustment to the roll of the bone
  39989. **/
  39990. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39991. maxYaw?: number;
  39992. minYaw?: number;
  39993. maxPitch?: number;
  39994. minPitch?: number;
  39995. slerpAmount?: number;
  39996. upAxis?: Vector3;
  39997. upAxisSpace?: Space;
  39998. yawAxis?: Vector3;
  39999. pitchAxis?: Vector3;
  40000. adjustYaw?: number;
  40001. adjustPitch?: number;
  40002. adjustRoll?: number;
  40003. });
  40004. /**
  40005. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40006. */
  40007. update(): void;
  40008. private _getAngleDiff;
  40009. private _getAngleBetween;
  40010. private _isAngleBetween;
  40011. }
  40012. }
  40013. declare module BABYLON {
  40014. /**
  40015. * Manage the gamepad inputs to control an arc rotate camera.
  40016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40017. */
  40018. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40019. /**
  40020. * Defines the camera the input is attached to.
  40021. */
  40022. camera: ArcRotateCamera;
  40023. /**
  40024. * Defines the gamepad the input is gathering event from.
  40025. */
  40026. gamepad: Nullable<Gamepad>;
  40027. /**
  40028. * Defines the gamepad rotation sensiblity.
  40029. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40030. */
  40031. gamepadRotationSensibility: number;
  40032. /**
  40033. * Defines the gamepad move sensiblity.
  40034. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40035. */
  40036. gamepadMoveSensibility: number;
  40037. private _yAxisScale;
  40038. /**
  40039. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40040. */
  40041. get invertYAxis(): boolean;
  40042. set invertYAxis(value: boolean);
  40043. private _onGamepadConnectedObserver;
  40044. private _onGamepadDisconnectedObserver;
  40045. /**
  40046. * Attach the input controls to a specific dom element to get the input from.
  40047. * @param element Defines the element the controls should be listened from
  40048. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40049. */
  40050. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40051. /**
  40052. * Detach the current controls from the specified dom element.
  40053. * @param element Defines the element to stop listening the inputs from
  40054. */
  40055. detachControl(element: Nullable<HTMLElement>): void;
  40056. /**
  40057. * Update the current camera state depending on the inputs that have been used this frame.
  40058. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40059. */
  40060. checkInputs(): void;
  40061. /**
  40062. * Gets the class name of the current intput.
  40063. * @returns the class name
  40064. */
  40065. getClassName(): string;
  40066. /**
  40067. * Get the friendly name associated with the input class.
  40068. * @returns the input friendly name
  40069. */
  40070. getSimpleName(): string;
  40071. }
  40072. }
  40073. declare module BABYLON {
  40074. interface ArcRotateCameraInputsManager {
  40075. /**
  40076. * Add orientation input support to the input manager.
  40077. * @returns the current input manager
  40078. */
  40079. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40080. }
  40081. /**
  40082. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40084. */
  40085. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40086. /**
  40087. * Defines the camera the input is attached to.
  40088. */
  40089. camera: ArcRotateCamera;
  40090. /**
  40091. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40092. */
  40093. alphaCorrection: number;
  40094. /**
  40095. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40096. */
  40097. gammaCorrection: number;
  40098. private _alpha;
  40099. private _gamma;
  40100. private _dirty;
  40101. private _deviceOrientationHandler;
  40102. /**
  40103. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40104. */
  40105. constructor();
  40106. /**
  40107. * Attach the input controls to a specific dom element to get the input from.
  40108. * @param element Defines the element the controls should be listened from
  40109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40110. */
  40111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40112. /** @hidden */
  40113. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40114. /**
  40115. * Update the current camera state depending on the inputs that have been used this frame.
  40116. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40117. */
  40118. checkInputs(): void;
  40119. /**
  40120. * Detach the current controls from the specified dom element.
  40121. * @param element Defines the element to stop listening the inputs from
  40122. */
  40123. detachControl(element: Nullable<HTMLElement>): void;
  40124. /**
  40125. * Gets the class name of the current intput.
  40126. * @returns the class name
  40127. */
  40128. getClassName(): string;
  40129. /**
  40130. * Get the friendly name associated with the input class.
  40131. * @returns the input friendly name
  40132. */
  40133. getSimpleName(): string;
  40134. }
  40135. }
  40136. declare module BABYLON {
  40137. /**
  40138. * Listen to mouse events to control the camera.
  40139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40140. */
  40141. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40142. /**
  40143. * Defines the camera the input is attached to.
  40144. */
  40145. camera: FlyCamera;
  40146. /**
  40147. * Defines if touch is enabled. (Default is true.)
  40148. */
  40149. touchEnabled: boolean;
  40150. /**
  40151. * Defines the buttons associated with the input to handle camera rotation.
  40152. */
  40153. buttons: number[];
  40154. /**
  40155. * Assign buttons for Yaw control.
  40156. */
  40157. buttonsYaw: number[];
  40158. /**
  40159. * Assign buttons for Pitch control.
  40160. */
  40161. buttonsPitch: number[];
  40162. /**
  40163. * Assign buttons for Roll control.
  40164. */
  40165. buttonsRoll: number[];
  40166. /**
  40167. * Detect if any button is being pressed while mouse is moved.
  40168. * -1 = Mouse locked.
  40169. * 0 = Left button.
  40170. * 1 = Middle Button.
  40171. * 2 = Right Button.
  40172. */
  40173. activeButton: number;
  40174. /**
  40175. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40176. * Higher values reduce its sensitivity.
  40177. */
  40178. angularSensibility: number;
  40179. private _mousemoveCallback;
  40180. private _observer;
  40181. private _rollObserver;
  40182. private previousPosition;
  40183. private noPreventDefault;
  40184. private element;
  40185. /**
  40186. * Listen to mouse events to control the camera.
  40187. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40189. */
  40190. constructor(touchEnabled?: boolean);
  40191. /**
  40192. * Attach the mouse control to the HTML DOM element.
  40193. * @param element Defines the element that listens to the input events.
  40194. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40195. */
  40196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40197. /**
  40198. * Detach the current controls from the specified dom element.
  40199. * @param element Defines the element to stop listening the inputs from
  40200. */
  40201. detachControl(element: Nullable<HTMLElement>): void;
  40202. /**
  40203. * Gets the class name of the current input.
  40204. * @returns the class name.
  40205. */
  40206. getClassName(): string;
  40207. /**
  40208. * Get the friendly name associated with the input class.
  40209. * @returns the input's friendly name.
  40210. */
  40211. getSimpleName(): string;
  40212. private _pointerInput;
  40213. private _onMouseMove;
  40214. /**
  40215. * Rotate camera by mouse offset.
  40216. */
  40217. private rotateCamera;
  40218. }
  40219. }
  40220. declare module BABYLON {
  40221. /**
  40222. * Default Inputs manager for the FlyCamera.
  40223. * It groups all the default supported inputs for ease of use.
  40224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40225. */
  40226. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40227. /**
  40228. * Instantiates a new FlyCameraInputsManager.
  40229. * @param camera Defines the camera the inputs belong to.
  40230. */
  40231. constructor(camera: FlyCamera);
  40232. /**
  40233. * Add keyboard input support to the input manager.
  40234. * @returns the new FlyCameraKeyboardMoveInput().
  40235. */
  40236. addKeyboard(): FlyCameraInputsManager;
  40237. /**
  40238. * Add mouse input support to the input manager.
  40239. * @param touchEnabled Enable touch screen support.
  40240. * @returns the new FlyCameraMouseInput().
  40241. */
  40242. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40243. }
  40244. }
  40245. declare module BABYLON {
  40246. /**
  40247. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40248. * such as in a 3D Space Shooter or a Flight Simulator.
  40249. */
  40250. export class FlyCamera extends TargetCamera {
  40251. /**
  40252. * Define the collision ellipsoid of the camera.
  40253. * This is helpful for simulating a camera body, like a player's body.
  40254. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40255. */
  40256. ellipsoid: Vector3;
  40257. /**
  40258. * Define an offset for the position of the ellipsoid around the camera.
  40259. * This can be helpful if the camera is attached away from the player's body center,
  40260. * such as at its head.
  40261. */
  40262. ellipsoidOffset: Vector3;
  40263. /**
  40264. * Enable or disable collisions of the camera with the rest of the scene objects.
  40265. */
  40266. checkCollisions: boolean;
  40267. /**
  40268. * Enable or disable gravity on the camera.
  40269. */
  40270. applyGravity: boolean;
  40271. /**
  40272. * Define the current direction the camera is moving to.
  40273. */
  40274. cameraDirection: Vector3;
  40275. /**
  40276. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40277. * This overrides and empties cameraRotation.
  40278. */
  40279. rotationQuaternion: Quaternion;
  40280. /**
  40281. * Track Roll to maintain the wanted Rolling when looking around.
  40282. */
  40283. _trackRoll: number;
  40284. /**
  40285. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40286. */
  40287. rollCorrect: number;
  40288. /**
  40289. * Mimic a banked turn, Rolling the camera when Yawing.
  40290. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40291. */
  40292. bankedTurn: boolean;
  40293. /**
  40294. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40295. */
  40296. bankedTurnLimit: number;
  40297. /**
  40298. * Value of 0 disables the banked Roll.
  40299. * Value of 1 is equal to the Yaw angle in radians.
  40300. */
  40301. bankedTurnMultiplier: number;
  40302. /**
  40303. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40304. */
  40305. inputs: FlyCameraInputsManager;
  40306. /**
  40307. * Gets the input sensibility for mouse input.
  40308. * Higher values reduce sensitivity.
  40309. */
  40310. get angularSensibility(): number;
  40311. /**
  40312. * Sets the input sensibility for a mouse input.
  40313. * Higher values reduce sensitivity.
  40314. */
  40315. set angularSensibility(value: number);
  40316. /**
  40317. * Get the keys for camera movement forward.
  40318. */
  40319. get keysForward(): number[];
  40320. /**
  40321. * Set the keys for camera movement forward.
  40322. */
  40323. set keysForward(value: number[]);
  40324. /**
  40325. * Get the keys for camera movement backward.
  40326. */
  40327. get keysBackward(): number[];
  40328. set keysBackward(value: number[]);
  40329. /**
  40330. * Get the keys for camera movement up.
  40331. */
  40332. get keysUp(): number[];
  40333. /**
  40334. * Set the keys for camera movement up.
  40335. */
  40336. set keysUp(value: number[]);
  40337. /**
  40338. * Get the keys for camera movement down.
  40339. */
  40340. get keysDown(): number[];
  40341. /**
  40342. * Set the keys for camera movement down.
  40343. */
  40344. set keysDown(value: number[]);
  40345. /**
  40346. * Get the keys for camera movement left.
  40347. */
  40348. get keysLeft(): number[];
  40349. /**
  40350. * Set the keys for camera movement left.
  40351. */
  40352. set keysLeft(value: number[]);
  40353. /**
  40354. * Set the keys for camera movement right.
  40355. */
  40356. get keysRight(): number[];
  40357. /**
  40358. * Set the keys for camera movement right.
  40359. */
  40360. set keysRight(value: number[]);
  40361. /**
  40362. * Event raised when the camera collides with a mesh in the scene.
  40363. */
  40364. onCollide: (collidedMesh: AbstractMesh) => void;
  40365. private _collider;
  40366. private _needMoveForGravity;
  40367. private _oldPosition;
  40368. private _diffPosition;
  40369. private _newPosition;
  40370. /** @hidden */
  40371. _localDirection: Vector3;
  40372. /** @hidden */
  40373. _transformedDirection: Vector3;
  40374. /**
  40375. * Instantiates a FlyCamera.
  40376. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40377. * such as in a 3D Space Shooter or a Flight Simulator.
  40378. * @param name Define the name of the camera in the scene.
  40379. * @param position Define the starting position of the camera in the scene.
  40380. * @param scene Define the scene the camera belongs to.
  40381. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  40382. */
  40383. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40384. /**
  40385. * Attach a control to the HTML DOM element.
  40386. * @param element Defines the element that listens to the input events.
  40387. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40388. */
  40389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40390. /**
  40391. * Detach a control from the HTML DOM element.
  40392. * The camera will stop reacting to that input.
  40393. * @param element Defines the element that listens to the input events.
  40394. */
  40395. detachControl(element: HTMLElement): void;
  40396. private _collisionMask;
  40397. /**
  40398. * Get the mask that the camera ignores in collision events.
  40399. */
  40400. get collisionMask(): number;
  40401. /**
  40402. * Set the mask that the camera ignores in collision events.
  40403. */
  40404. set collisionMask(mask: number);
  40405. /** @hidden */
  40406. _collideWithWorld(displacement: Vector3): void;
  40407. /** @hidden */
  40408. private _onCollisionPositionChange;
  40409. /** @hidden */
  40410. _checkInputs(): void;
  40411. /** @hidden */
  40412. _decideIfNeedsToMove(): boolean;
  40413. /** @hidden */
  40414. _updatePosition(): void;
  40415. /**
  40416. * Restore the Roll to its target value at the rate specified.
  40417. * @param rate - Higher means slower restoring.
  40418. * @hidden
  40419. */
  40420. restoreRoll(rate: number): void;
  40421. /**
  40422. * Destroy the camera and release the current resources held by it.
  40423. */
  40424. dispose(): void;
  40425. /**
  40426. * Get the current object class name.
  40427. * @returns the class name.
  40428. */
  40429. getClassName(): string;
  40430. }
  40431. }
  40432. declare module BABYLON {
  40433. /**
  40434. * Listen to keyboard events to control the camera.
  40435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40436. */
  40437. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40438. /**
  40439. * Defines the camera the input is attached to.
  40440. */
  40441. camera: FlyCamera;
  40442. /**
  40443. * The list of keyboard keys used to control the forward move of the camera.
  40444. */
  40445. keysForward: number[];
  40446. /**
  40447. * The list of keyboard keys used to control the backward move of the camera.
  40448. */
  40449. keysBackward: number[];
  40450. /**
  40451. * The list of keyboard keys used to control the forward move of the camera.
  40452. */
  40453. keysUp: number[];
  40454. /**
  40455. * The list of keyboard keys used to control the backward move of the camera.
  40456. */
  40457. keysDown: number[];
  40458. /**
  40459. * The list of keyboard keys used to control the right strafe move of the camera.
  40460. */
  40461. keysRight: number[];
  40462. /**
  40463. * The list of keyboard keys used to control the left strafe move of the camera.
  40464. */
  40465. keysLeft: number[];
  40466. private _keys;
  40467. private _onCanvasBlurObserver;
  40468. private _onKeyboardObserver;
  40469. private _engine;
  40470. private _scene;
  40471. /**
  40472. * Attach the input controls to a specific dom element to get the input from.
  40473. * @param element Defines the element the controls should be listened from
  40474. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40475. */
  40476. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40477. /**
  40478. * Detach the current controls from the specified dom element.
  40479. * @param element Defines the element to stop listening the inputs from
  40480. */
  40481. detachControl(element: Nullable<HTMLElement>): void;
  40482. /**
  40483. * Gets the class name of the current intput.
  40484. * @returns the class name
  40485. */
  40486. getClassName(): string;
  40487. /** @hidden */
  40488. _onLostFocus(e: FocusEvent): void;
  40489. /**
  40490. * Get the friendly name associated with the input class.
  40491. * @returns the input friendly name
  40492. */
  40493. getSimpleName(): string;
  40494. /**
  40495. * Update the current camera state depending on the inputs that have been used this frame.
  40496. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40497. */
  40498. checkInputs(): void;
  40499. }
  40500. }
  40501. declare module BABYLON {
  40502. /**
  40503. * Manage the mouse wheel inputs to control a follow camera.
  40504. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40505. */
  40506. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40507. /**
  40508. * Defines the camera the input is attached to.
  40509. */
  40510. camera: FollowCamera;
  40511. /**
  40512. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40513. */
  40514. axisControlRadius: boolean;
  40515. /**
  40516. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40517. */
  40518. axisControlHeight: boolean;
  40519. /**
  40520. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40521. */
  40522. axisControlRotation: boolean;
  40523. /**
  40524. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40525. * relation to mouseWheel events.
  40526. */
  40527. wheelPrecision: number;
  40528. /**
  40529. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40530. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40531. */
  40532. wheelDeltaPercentage: number;
  40533. private _wheel;
  40534. private _observer;
  40535. /**
  40536. * Attach the input controls to a specific dom element to get the input from.
  40537. * @param element Defines the element the controls should be listened from
  40538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40539. */
  40540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40541. /**
  40542. * Detach the current controls from the specified dom element.
  40543. * @param element Defines the element to stop listening the inputs from
  40544. */
  40545. detachControl(element: Nullable<HTMLElement>): void;
  40546. /**
  40547. * Gets the class name of the current intput.
  40548. * @returns the class name
  40549. */
  40550. getClassName(): string;
  40551. /**
  40552. * Get the friendly name associated with the input class.
  40553. * @returns the input friendly name
  40554. */
  40555. getSimpleName(): string;
  40556. }
  40557. }
  40558. declare module BABYLON {
  40559. /**
  40560. * Manage the pointers inputs to control an follow camera.
  40561. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40562. */
  40563. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40564. /**
  40565. * Defines the camera the input is attached to.
  40566. */
  40567. camera: FollowCamera;
  40568. /**
  40569. * Gets the class name of the current input.
  40570. * @returns the class name
  40571. */
  40572. getClassName(): string;
  40573. /**
  40574. * Defines the pointer angular sensibility along the X axis or how fast is
  40575. * the camera rotating.
  40576. * A negative number will reverse the axis direction.
  40577. */
  40578. angularSensibilityX: number;
  40579. /**
  40580. * Defines the pointer angular sensibility along the Y axis or how fast is
  40581. * the camera rotating.
  40582. * A negative number will reverse the axis direction.
  40583. */
  40584. angularSensibilityY: number;
  40585. /**
  40586. * Defines the pointer pinch precision or how fast is the camera zooming.
  40587. * A negative number will reverse the axis direction.
  40588. */
  40589. pinchPrecision: number;
  40590. /**
  40591. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40592. * from 0.
  40593. * It defines the percentage of current camera.radius to use as delta when
  40594. * pinch zoom is used.
  40595. */
  40596. pinchDeltaPercentage: number;
  40597. /**
  40598. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40599. */
  40600. axisXControlRadius: boolean;
  40601. /**
  40602. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40603. */
  40604. axisXControlHeight: boolean;
  40605. /**
  40606. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40607. */
  40608. axisXControlRotation: boolean;
  40609. /**
  40610. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40611. */
  40612. axisYControlRadius: boolean;
  40613. /**
  40614. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40615. */
  40616. axisYControlHeight: boolean;
  40617. /**
  40618. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40619. */
  40620. axisYControlRotation: boolean;
  40621. /**
  40622. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40623. */
  40624. axisPinchControlRadius: boolean;
  40625. /**
  40626. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40627. */
  40628. axisPinchControlHeight: boolean;
  40629. /**
  40630. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40631. */
  40632. axisPinchControlRotation: boolean;
  40633. /**
  40634. * Log error messages if basic misconfiguration has occurred.
  40635. */
  40636. warningEnable: boolean;
  40637. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40638. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40639. private _warningCounter;
  40640. private _warning;
  40641. }
  40642. }
  40643. declare module BABYLON {
  40644. /**
  40645. * Default Inputs manager for the FollowCamera.
  40646. * It groups all the default supported inputs for ease of use.
  40647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40648. */
  40649. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40650. /**
  40651. * Instantiates a new FollowCameraInputsManager.
  40652. * @param camera Defines the camera the inputs belong to
  40653. */
  40654. constructor(camera: FollowCamera);
  40655. /**
  40656. * Add keyboard input support to the input manager.
  40657. * @returns the current input manager
  40658. */
  40659. addKeyboard(): FollowCameraInputsManager;
  40660. /**
  40661. * Add mouse wheel input support to the input manager.
  40662. * @returns the current input manager
  40663. */
  40664. addMouseWheel(): FollowCameraInputsManager;
  40665. /**
  40666. * Add pointers input support to the input manager.
  40667. * @returns the current input manager
  40668. */
  40669. addPointers(): FollowCameraInputsManager;
  40670. /**
  40671. * Add orientation input support to the input manager.
  40672. * @returns the current input manager
  40673. */
  40674. addVRDeviceOrientation(): FollowCameraInputsManager;
  40675. }
  40676. }
  40677. declare module BABYLON {
  40678. /**
  40679. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40680. * an arc rotate version arcFollowCamera are available.
  40681. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40682. */
  40683. export class FollowCamera extends TargetCamera {
  40684. /**
  40685. * Distance the follow camera should follow an object at
  40686. */
  40687. radius: number;
  40688. /**
  40689. * Minimum allowed distance of the camera to the axis of rotation
  40690. * (The camera can not get closer).
  40691. * This can help limiting how the Camera is able to move in the scene.
  40692. */
  40693. lowerRadiusLimit: Nullable<number>;
  40694. /**
  40695. * Maximum allowed distance of the camera to the axis of rotation
  40696. * (The camera can not get further).
  40697. * This can help limiting how the Camera is able to move in the scene.
  40698. */
  40699. upperRadiusLimit: Nullable<number>;
  40700. /**
  40701. * Define a rotation offset between the camera and the object it follows
  40702. */
  40703. rotationOffset: number;
  40704. /**
  40705. * Minimum allowed angle to camera position relative to target object.
  40706. * This can help limiting how the Camera is able to move in the scene.
  40707. */
  40708. lowerRotationOffsetLimit: Nullable<number>;
  40709. /**
  40710. * Maximum allowed angle to camera position relative to target object.
  40711. * This can help limiting how the Camera is able to move in the scene.
  40712. */
  40713. upperRotationOffsetLimit: Nullable<number>;
  40714. /**
  40715. * Define a height offset between the camera and the object it follows.
  40716. * It can help following an object from the top (like a car chaing a plane)
  40717. */
  40718. heightOffset: number;
  40719. /**
  40720. * Minimum allowed height of camera position relative to target object.
  40721. * This can help limiting how the Camera is able to move in the scene.
  40722. */
  40723. lowerHeightOffsetLimit: Nullable<number>;
  40724. /**
  40725. * Maximum allowed height of camera position relative to target object.
  40726. * This can help limiting how the Camera is able to move in the scene.
  40727. */
  40728. upperHeightOffsetLimit: Nullable<number>;
  40729. /**
  40730. * Define how fast the camera can accelerate to follow it s target.
  40731. */
  40732. cameraAcceleration: number;
  40733. /**
  40734. * Define the speed limit of the camera following an object.
  40735. */
  40736. maxCameraSpeed: number;
  40737. /**
  40738. * Define the target of the camera.
  40739. */
  40740. lockedTarget: Nullable<AbstractMesh>;
  40741. /**
  40742. * Defines the input associated with the camera.
  40743. */
  40744. inputs: FollowCameraInputsManager;
  40745. /**
  40746. * Instantiates the follow camera.
  40747. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40748. * @param name Define the name of the camera in the scene
  40749. * @param position Define the position of the camera
  40750. * @param scene Define the scene the camera belong to
  40751. * @param lockedTarget Define the target of the camera
  40752. */
  40753. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40754. private _follow;
  40755. /**
  40756. * Attached controls to the current camera.
  40757. * @param element Defines the element the controls should be listened from
  40758. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40759. */
  40760. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40761. /**
  40762. * Detach the current controls from the camera.
  40763. * The camera will stop reacting to inputs.
  40764. * @param element Defines the element to stop listening the inputs from
  40765. */
  40766. detachControl(element: HTMLElement): void;
  40767. /** @hidden */
  40768. _checkInputs(): void;
  40769. private _checkLimits;
  40770. /**
  40771. * Gets the camera class name.
  40772. * @returns the class name
  40773. */
  40774. getClassName(): string;
  40775. }
  40776. /**
  40777. * Arc Rotate version of the follow camera.
  40778. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40779. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40780. */
  40781. export class ArcFollowCamera extends TargetCamera {
  40782. /** The longitudinal angle of the camera */
  40783. alpha: number;
  40784. /** The latitudinal angle of the camera */
  40785. beta: number;
  40786. /** The radius of the camera from its target */
  40787. radius: number;
  40788. /** Define the camera target (the messh it should follow) */
  40789. target: Nullable<AbstractMesh>;
  40790. private _cartesianCoordinates;
  40791. /**
  40792. * Instantiates a new ArcFollowCamera
  40793. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40794. * @param name Define the name of the camera
  40795. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40796. * @param beta Define the rotation angle of the camera around the elevation axis
  40797. * @param radius Define the radius of the camera from its target point
  40798. * @param target Define the target of the camera
  40799. * @param scene Define the scene the camera belongs to
  40800. */
  40801. constructor(name: string,
  40802. /** The longitudinal angle of the camera */
  40803. alpha: number,
  40804. /** The latitudinal angle of the camera */
  40805. beta: number,
  40806. /** The radius of the camera from its target */
  40807. radius: number,
  40808. /** Define the camera target (the messh it should follow) */
  40809. target: Nullable<AbstractMesh>, scene: Scene);
  40810. private _follow;
  40811. /** @hidden */
  40812. _checkInputs(): void;
  40813. /**
  40814. * Returns the class name of the object.
  40815. * It is mostly used internally for serialization purposes.
  40816. */
  40817. getClassName(): string;
  40818. }
  40819. }
  40820. declare module BABYLON {
  40821. /**
  40822. * Manage the keyboard inputs to control the movement of a follow camera.
  40823. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40824. */
  40825. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40826. /**
  40827. * Defines the camera the input is attached to.
  40828. */
  40829. camera: FollowCamera;
  40830. /**
  40831. * Defines the list of key codes associated with the up action (increase heightOffset)
  40832. */
  40833. keysHeightOffsetIncr: number[];
  40834. /**
  40835. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40836. */
  40837. keysHeightOffsetDecr: number[];
  40838. /**
  40839. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40840. */
  40841. keysHeightOffsetModifierAlt: boolean;
  40842. /**
  40843. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40844. */
  40845. keysHeightOffsetModifierCtrl: boolean;
  40846. /**
  40847. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40848. */
  40849. keysHeightOffsetModifierShift: boolean;
  40850. /**
  40851. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40852. */
  40853. keysRotationOffsetIncr: number[];
  40854. /**
  40855. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40856. */
  40857. keysRotationOffsetDecr: number[];
  40858. /**
  40859. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40860. */
  40861. keysRotationOffsetModifierAlt: boolean;
  40862. /**
  40863. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40864. */
  40865. keysRotationOffsetModifierCtrl: boolean;
  40866. /**
  40867. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40868. */
  40869. keysRotationOffsetModifierShift: boolean;
  40870. /**
  40871. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40872. */
  40873. keysRadiusIncr: number[];
  40874. /**
  40875. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40876. */
  40877. keysRadiusDecr: number[];
  40878. /**
  40879. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40880. */
  40881. keysRadiusModifierAlt: boolean;
  40882. /**
  40883. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40884. */
  40885. keysRadiusModifierCtrl: boolean;
  40886. /**
  40887. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40888. */
  40889. keysRadiusModifierShift: boolean;
  40890. /**
  40891. * Defines the rate of change of heightOffset.
  40892. */
  40893. heightSensibility: number;
  40894. /**
  40895. * Defines the rate of change of rotationOffset.
  40896. */
  40897. rotationSensibility: number;
  40898. /**
  40899. * Defines the rate of change of radius.
  40900. */
  40901. radiusSensibility: number;
  40902. private _keys;
  40903. private _ctrlPressed;
  40904. private _altPressed;
  40905. private _shiftPressed;
  40906. private _onCanvasBlurObserver;
  40907. private _onKeyboardObserver;
  40908. private _engine;
  40909. private _scene;
  40910. /**
  40911. * Attach the input controls to a specific dom element to get the input from.
  40912. * @param element Defines the element the controls should be listened from
  40913. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40914. */
  40915. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40916. /**
  40917. * Detach the current controls from the specified dom element.
  40918. * @param element Defines the element to stop listening the inputs from
  40919. */
  40920. detachControl(element: Nullable<HTMLElement>): void;
  40921. /**
  40922. * Update the current camera state depending on the inputs that have been used this frame.
  40923. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40924. */
  40925. checkInputs(): void;
  40926. /**
  40927. * Gets the class name of the current input.
  40928. * @returns the class name
  40929. */
  40930. getClassName(): string;
  40931. /**
  40932. * Get the friendly name associated with the input class.
  40933. * @returns the input friendly name
  40934. */
  40935. getSimpleName(): string;
  40936. /**
  40937. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40938. * allow modification of the heightOffset value.
  40939. */
  40940. private _modifierHeightOffset;
  40941. /**
  40942. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40943. * allow modification of the rotationOffset value.
  40944. */
  40945. private _modifierRotationOffset;
  40946. /**
  40947. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40948. * allow modification of the radius value.
  40949. */
  40950. private _modifierRadius;
  40951. }
  40952. }
  40953. declare module BABYLON {
  40954. interface FreeCameraInputsManager {
  40955. /**
  40956. * @hidden
  40957. */
  40958. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40959. /**
  40960. * Add orientation input support to the input manager.
  40961. * @returns the current input manager
  40962. */
  40963. addDeviceOrientation(): FreeCameraInputsManager;
  40964. }
  40965. /**
  40966. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40967. * Screen rotation is taken into account.
  40968. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40969. */
  40970. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40971. private _camera;
  40972. private _screenOrientationAngle;
  40973. private _constantTranform;
  40974. private _screenQuaternion;
  40975. private _alpha;
  40976. private _beta;
  40977. private _gamma;
  40978. /**
  40979. * Can be used to detect if a device orientation sensor is available on a device
  40980. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40981. * @returns a promise that will resolve on orientation change
  40982. */
  40983. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40984. /**
  40985. * @hidden
  40986. */
  40987. _onDeviceOrientationChangedObservable: Observable<void>;
  40988. /**
  40989. * Instantiates a new input
  40990. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40991. */
  40992. constructor();
  40993. /**
  40994. * Define the camera controlled by the input.
  40995. */
  40996. get camera(): FreeCamera;
  40997. set camera(camera: FreeCamera);
  40998. /**
  40999. * Attach the input controls to a specific dom element to get the input from.
  41000. * @param element Defines the element the controls should be listened from
  41001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41002. */
  41003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41004. private _orientationChanged;
  41005. private _deviceOrientation;
  41006. /**
  41007. * Detach the current controls from the specified dom element.
  41008. * @param element Defines the element to stop listening the inputs from
  41009. */
  41010. detachControl(element: Nullable<HTMLElement>): void;
  41011. /**
  41012. * Update the current camera state depending on the inputs that have been used this frame.
  41013. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41014. */
  41015. checkInputs(): void;
  41016. /**
  41017. * Gets the class name of the current intput.
  41018. * @returns the class name
  41019. */
  41020. getClassName(): string;
  41021. /**
  41022. * Get the friendly name associated with the input class.
  41023. * @returns the input friendly name
  41024. */
  41025. getSimpleName(): string;
  41026. }
  41027. }
  41028. declare module BABYLON {
  41029. /**
  41030. * Manage the gamepad inputs to control a free camera.
  41031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41032. */
  41033. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41034. /**
  41035. * Define the camera the input is attached to.
  41036. */
  41037. camera: FreeCamera;
  41038. /**
  41039. * Define the Gamepad controlling the input
  41040. */
  41041. gamepad: Nullable<Gamepad>;
  41042. /**
  41043. * Defines the gamepad rotation sensiblity.
  41044. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41045. */
  41046. gamepadAngularSensibility: number;
  41047. /**
  41048. * Defines the gamepad move sensiblity.
  41049. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41050. */
  41051. gamepadMoveSensibility: number;
  41052. private _yAxisScale;
  41053. /**
  41054. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41055. */
  41056. get invertYAxis(): boolean;
  41057. set invertYAxis(value: boolean);
  41058. private _onGamepadConnectedObserver;
  41059. private _onGamepadDisconnectedObserver;
  41060. private _cameraTransform;
  41061. private _deltaTransform;
  41062. private _vector3;
  41063. private _vector2;
  41064. /**
  41065. * Attach the input controls to a specific dom element to get the input from.
  41066. * @param element Defines the element the controls should be listened from
  41067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41068. */
  41069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41070. /**
  41071. * Detach the current controls from the specified dom element.
  41072. * @param element Defines the element to stop listening the inputs from
  41073. */
  41074. detachControl(element: Nullable<HTMLElement>): void;
  41075. /**
  41076. * Update the current camera state depending on the inputs that have been used this frame.
  41077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41078. */
  41079. checkInputs(): void;
  41080. /**
  41081. * Gets the class name of the current intput.
  41082. * @returns the class name
  41083. */
  41084. getClassName(): string;
  41085. /**
  41086. * Get the friendly name associated with the input class.
  41087. * @returns the input friendly name
  41088. */
  41089. getSimpleName(): string;
  41090. }
  41091. }
  41092. declare module BABYLON {
  41093. /**
  41094. * Defines the potential axis of a Joystick
  41095. */
  41096. export enum JoystickAxis {
  41097. /** X axis */
  41098. X = 0,
  41099. /** Y axis */
  41100. Y = 1,
  41101. /** Z axis */
  41102. Z = 2
  41103. }
  41104. /**
  41105. * Class used to define virtual joystick (used in touch mode)
  41106. */
  41107. export class VirtualJoystick {
  41108. /**
  41109. * Gets or sets a boolean indicating that left and right values must be inverted
  41110. */
  41111. reverseLeftRight: boolean;
  41112. /**
  41113. * Gets or sets a boolean indicating that up and down values must be inverted
  41114. */
  41115. reverseUpDown: boolean;
  41116. /**
  41117. * Gets the offset value for the position (ie. the change of the position value)
  41118. */
  41119. deltaPosition: Vector3;
  41120. /**
  41121. * Gets a boolean indicating if the virtual joystick was pressed
  41122. */
  41123. pressed: boolean;
  41124. /**
  41125. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41126. */
  41127. static Canvas: Nullable<HTMLCanvasElement>;
  41128. private static _globalJoystickIndex;
  41129. private static vjCanvasContext;
  41130. private static vjCanvasWidth;
  41131. private static vjCanvasHeight;
  41132. private static halfWidth;
  41133. private _action;
  41134. private _axisTargetedByLeftAndRight;
  41135. private _axisTargetedByUpAndDown;
  41136. private _joystickSensibility;
  41137. private _inversedSensibility;
  41138. private _joystickPointerID;
  41139. private _joystickColor;
  41140. private _joystickPointerPos;
  41141. private _joystickPreviousPointerPos;
  41142. private _joystickPointerStartPos;
  41143. private _deltaJoystickVector;
  41144. private _leftJoystick;
  41145. private _touches;
  41146. private _onPointerDownHandlerRef;
  41147. private _onPointerMoveHandlerRef;
  41148. private _onPointerUpHandlerRef;
  41149. private _onResize;
  41150. /**
  41151. * Creates a new virtual joystick
  41152. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41153. */
  41154. constructor(leftJoystick?: boolean);
  41155. /**
  41156. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41157. * @param newJoystickSensibility defines the new sensibility
  41158. */
  41159. setJoystickSensibility(newJoystickSensibility: number): void;
  41160. private _onPointerDown;
  41161. private _onPointerMove;
  41162. private _onPointerUp;
  41163. /**
  41164. * Change the color of the virtual joystick
  41165. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41166. */
  41167. setJoystickColor(newColor: string): void;
  41168. /**
  41169. * Defines a callback to call when the joystick is touched
  41170. * @param action defines the callback
  41171. */
  41172. setActionOnTouch(action: () => any): void;
  41173. /**
  41174. * Defines which axis you'd like to control for left & right
  41175. * @param axis defines the axis to use
  41176. */
  41177. setAxisForLeftRight(axis: JoystickAxis): void;
  41178. /**
  41179. * Defines which axis you'd like to control for up & down
  41180. * @param axis defines the axis to use
  41181. */
  41182. setAxisForUpDown(axis: JoystickAxis): void;
  41183. private _drawVirtualJoystick;
  41184. /**
  41185. * Release internal HTML canvas
  41186. */
  41187. releaseCanvas(): void;
  41188. }
  41189. }
  41190. declare module BABYLON {
  41191. interface FreeCameraInputsManager {
  41192. /**
  41193. * Add virtual joystick input support to the input manager.
  41194. * @returns the current input manager
  41195. */
  41196. addVirtualJoystick(): FreeCameraInputsManager;
  41197. }
  41198. /**
  41199. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41200. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41201. */
  41202. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41203. /**
  41204. * Defines the camera the input is attached to.
  41205. */
  41206. camera: FreeCamera;
  41207. private _leftjoystick;
  41208. private _rightjoystick;
  41209. /**
  41210. * Gets the left stick of the virtual joystick.
  41211. * @returns The virtual Joystick
  41212. */
  41213. getLeftJoystick(): VirtualJoystick;
  41214. /**
  41215. * Gets the right stick of the virtual joystick.
  41216. * @returns The virtual Joystick
  41217. */
  41218. getRightJoystick(): VirtualJoystick;
  41219. /**
  41220. * Update the current camera state depending on the inputs that have been used this frame.
  41221. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41222. */
  41223. checkInputs(): void;
  41224. /**
  41225. * Attach the input controls to a specific dom element to get the input from.
  41226. * @param element Defines the element the controls should be listened from
  41227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41228. */
  41229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41230. /**
  41231. * Detach the current controls from the specified dom element.
  41232. * @param element Defines the element to stop listening the inputs from
  41233. */
  41234. detachControl(element: Nullable<HTMLElement>): void;
  41235. /**
  41236. * Gets the class name of the current intput.
  41237. * @returns the class name
  41238. */
  41239. getClassName(): string;
  41240. /**
  41241. * Get the friendly name associated with the input class.
  41242. * @returns the input friendly name
  41243. */
  41244. getSimpleName(): string;
  41245. }
  41246. }
  41247. declare module BABYLON {
  41248. /**
  41249. * This represents a FPS type of camera controlled by touch.
  41250. * This is like a universal camera minus the Gamepad controls.
  41251. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41252. */
  41253. export class TouchCamera extends FreeCamera {
  41254. /**
  41255. * Defines the touch sensibility for rotation.
  41256. * The higher the faster.
  41257. */
  41258. get touchAngularSensibility(): number;
  41259. set touchAngularSensibility(value: number);
  41260. /**
  41261. * Defines the touch sensibility for move.
  41262. * The higher the faster.
  41263. */
  41264. get touchMoveSensibility(): number;
  41265. set touchMoveSensibility(value: number);
  41266. /**
  41267. * Instantiates a new touch camera.
  41268. * This represents a FPS type of camera controlled by touch.
  41269. * This is like a universal camera minus the Gamepad controls.
  41270. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41271. * @param name Define the name of the camera in the scene
  41272. * @param position Define the start position of the camera in the scene
  41273. * @param scene Define the scene the camera belongs to
  41274. */
  41275. constructor(name: string, position: Vector3, scene: Scene);
  41276. /**
  41277. * Gets the current object class name.
  41278. * @return the class name
  41279. */
  41280. getClassName(): string;
  41281. /** @hidden */
  41282. _setupInputs(): void;
  41283. }
  41284. }
  41285. declare module BABYLON {
  41286. /**
  41287. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41288. * being tilted forward or back and left or right.
  41289. */
  41290. export class DeviceOrientationCamera extends FreeCamera {
  41291. private _initialQuaternion;
  41292. private _quaternionCache;
  41293. private _tmpDragQuaternion;
  41294. private _disablePointerInputWhenUsingDeviceOrientation;
  41295. /**
  41296. * Creates a new device orientation camera
  41297. * @param name The name of the camera
  41298. * @param position The start position camera
  41299. * @param scene The scene the camera belongs to
  41300. */
  41301. constructor(name: string, position: Vector3, scene: Scene);
  41302. /**
  41303. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  41304. */
  41305. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  41306. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  41307. private _dragFactor;
  41308. /**
  41309. * Enabled turning on the y axis when the orientation sensor is active
  41310. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  41311. */
  41312. enableHorizontalDragging(dragFactor?: number): void;
  41313. /**
  41314. * Gets the current instance class name ("DeviceOrientationCamera").
  41315. * This helps avoiding instanceof at run time.
  41316. * @returns the class name
  41317. */
  41318. getClassName(): string;
  41319. /**
  41320. * @hidden
  41321. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  41322. */
  41323. _checkInputs(): void;
  41324. /**
  41325. * Reset the camera to its default orientation on the specified axis only.
  41326. * @param axis The axis to reset
  41327. */
  41328. resetToCurrentRotation(axis?: Axis): void;
  41329. }
  41330. }
  41331. declare module BABYLON {
  41332. /**
  41333. * Defines supported buttons for XBox360 compatible gamepads
  41334. */
  41335. export enum Xbox360Button {
  41336. /** A */
  41337. A = 0,
  41338. /** B */
  41339. B = 1,
  41340. /** X */
  41341. X = 2,
  41342. /** Y */
  41343. Y = 3,
  41344. /** Left button */
  41345. LB = 4,
  41346. /** Right button */
  41347. RB = 5,
  41348. /** Back */
  41349. Back = 8,
  41350. /** Start */
  41351. Start = 9,
  41352. /** Left stick */
  41353. LeftStick = 10,
  41354. /** Right stick */
  41355. RightStick = 11
  41356. }
  41357. /** Defines values for XBox360 DPad */
  41358. export enum Xbox360Dpad {
  41359. /** Up */
  41360. Up = 12,
  41361. /** Down */
  41362. Down = 13,
  41363. /** Left */
  41364. Left = 14,
  41365. /** Right */
  41366. Right = 15
  41367. }
  41368. /**
  41369. * Defines a XBox360 gamepad
  41370. */
  41371. export class Xbox360Pad extends Gamepad {
  41372. private _leftTrigger;
  41373. private _rightTrigger;
  41374. private _onlefttriggerchanged;
  41375. private _onrighttriggerchanged;
  41376. private _onbuttondown;
  41377. private _onbuttonup;
  41378. private _ondpaddown;
  41379. private _ondpadup;
  41380. /** Observable raised when a button is pressed */
  41381. onButtonDownObservable: Observable<Xbox360Button>;
  41382. /** Observable raised when a button is released */
  41383. onButtonUpObservable: Observable<Xbox360Button>;
  41384. /** Observable raised when a pad is pressed */
  41385. onPadDownObservable: Observable<Xbox360Dpad>;
  41386. /** Observable raised when a pad is released */
  41387. onPadUpObservable: Observable<Xbox360Dpad>;
  41388. private _buttonA;
  41389. private _buttonB;
  41390. private _buttonX;
  41391. private _buttonY;
  41392. private _buttonBack;
  41393. private _buttonStart;
  41394. private _buttonLB;
  41395. private _buttonRB;
  41396. private _buttonLeftStick;
  41397. private _buttonRightStick;
  41398. private _dPadUp;
  41399. private _dPadDown;
  41400. private _dPadLeft;
  41401. private _dPadRight;
  41402. private _isXboxOnePad;
  41403. /**
  41404. * Creates a new XBox360 gamepad object
  41405. * @param id defines the id of this gamepad
  41406. * @param index defines its index
  41407. * @param gamepad defines the internal HTML gamepad object
  41408. * @param xboxOne defines if it is a XBox One gamepad
  41409. */
  41410. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41411. /**
  41412. * Defines the callback to call when left trigger is pressed
  41413. * @param callback defines the callback to use
  41414. */
  41415. onlefttriggerchanged(callback: (value: number) => void): void;
  41416. /**
  41417. * Defines the callback to call when right trigger is pressed
  41418. * @param callback defines the callback to use
  41419. */
  41420. onrighttriggerchanged(callback: (value: number) => void): void;
  41421. /**
  41422. * Gets the left trigger value
  41423. */
  41424. get leftTrigger(): number;
  41425. /**
  41426. * Sets the left trigger value
  41427. */
  41428. set leftTrigger(newValue: number);
  41429. /**
  41430. * Gets the right trigger value
  41431. */
  41432. get rightTrigger(): number;
  41433. /**
  41434. * Sets the right trigger value
  41435. */
  41436. set rightTrigger(newValue: number);
  41437. /**
  41438. * Defines the callback to call when a button is pressed
  41439. * @param callback defines the callback to use
  41440. */
  41441. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41442. /**
  41443. * Defines the callback to call when a button is released
  41444. * @param callback defines the callback to use
  41445. */
  41446. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41447. /**
  41448. * Defines the callback to call when a pad is pressed
  41449. * @param callback defines the callback to use
  41450. */
  41451. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41452. /**
  41453. * Defines the callback to call when a pad is released
  41454. * @param callback defines the callback to use
  41455. */
  41456. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41457. private _setButtonValue;
  41458. private _setDPadValue;
  41459. /**
  41460. * Gets the value of the `A` button
  41461. */
  41462. get buttonA(): number;
  41463. /**
  41464. * Sets the value of the `A` button
  41465. */
  41466. set buttonA(value: number);
  41467. /**
  41468. * Gets the value of the `B` button
  41469. */
  41470. get buttonB(): number;
  41471. /**
  41472. * Sets the value of the `B` button
  41473. */
  41474. set buttonB(value: number);
  41475. /**
  41476. * Gets the value of the `X` button
  41477. */
  41478. get buttonX(): number;
  41479. /**
  41480. * Sets the value of the `X` button
  41481. */
  41482. set buttonX(value: number);
  41483. /**
  41484. * Gets the value of the `Y` button
  41485. */
  41486. get buttonY(): number;
  41487. /**
  41488. * Sets the value of the `Y` button
  41489. */
  41490. set buttonY(value: number);
  41491. /**
  41492. * Gets the value of the `Start` button
  41493. */
  41494. get buttonStart(): number;
  41495. /**
  41496. * Sets the value of the `Start` button
  41497. */
  41498. set buttonStart(value: number);
  41499. /**
  41500. * Gets the value of the `Back` button
  41501. */
  41502. get buttonBack(): number;
  41503. /**
  41504. * Sets the value of the `Back` button
  41505. */
  41506. set buttonBack(value: number);
  41507. /**
  41508. * Gets the value of the `Left` button
  41509. */
  41510. get buttonLB(): number;
  41511. /**
  41512. * Sets the value of the `Left` button
  41513. */
  41514. set buttonLB(value: number);
  41515. /**
  41516. * Gets the value of the `Right` button
  41517. */
  41518. get buttonRB(): number;
  41519. /**
  41520. * Sets the value of the `Right` button
  41521. */
  41522. set buttonRB(value: number);
  41523. /**
  41524. * Gets the value of the Left joystick
  41525. */
  41526. get buttonLeftStick(): number;
  41527. /**
  41528. * Sets the value of the Left joystick
  41529. */
  41530. set buttonLeftStick(value: number);
  41531. /**
  41532. * Gets the value of the Right joystick
  41533. */
  41534. get buttonRightStick(): number;
  41535. /**
  41536. * Sets the value of the Right joystick
  41537. */
  41538. set buttonRightStick(value: number);
  41539. /**
  41540. * Gets the value of D-pad up
  41541. */
  41542. get dPadUp(): number;
  41543. /**
  41544. * Sets the value of D-pad up
  41545. */
  41546. set dPadUp(value: number);
  41547. /**
  41548. * Gets the value of D-pad down
  41549. */
  41550. get dPadDown(): number;
  41551. /**
  41552. * Sets the value of D-pad down
  41553. */
  41554. set dPadDown(value: number);
  41555. /**
  41556. * Gets the value of D-pad left
  41557. */
  41558. get dPadLeft(): number;
  41559. /**
  41560. * Sets the value of D-pad left
  41561. */
  41562. set dPadLeft(value: number);
  41563. /**
  41564. * Gets the value of D-pad right
  41565. */
  41566. get dPadRight(): number;
  41567. /**
  41568. * Sets the value of D-pad right
  41569. */
  41570. set dPadRight(value: number);
  41571. /**
  41572. * Force the gamepad to synchronize with device values
  41573. */
  41574. update(): void;
  41575. /**
  41576. * Disposes the gamepad
  41577. */
  41578. dispose(): void;
  41579. }
  41580. }
  41581. declare module BABYLON {
  41582. /**
  41583. * Defines supported buttons for DualShock compatible gamepads
  41584. */
  41585. export enum DualShockButton {
  41586. /** Cross */
  41587. Cross = 0,
  41588. /** Circle */
  41589. Circle = 1,
  41590. /** Square */
  41591. Square = 2,
  41592. /** Triangle */
  41593. Triangle = 3,
  41594. /** L1 */
  41595. L1 = 4,
  41596. /** R1 */
  41597. R1 = 5,
  41598. /** Share */
  41599. Share = 8,
  41600. /** Options */
  41601. Options = 9,
  41602. /** Left stick */
  41603. LeftStick = 10,
  41604. /** Right stick */
  41605. RightStick = 11
  41606. }
  41607. /** Defines values for DualShock DPad */
  41608. export enum DualShockDpad {
  41609. /** Up */
  41610. Up = 12,
  41611. /** Down */
  41612. Down = 13,
  41613. /** Left */
  41614. Left = 14,
  41615. /** Right */
  41616. Right = 15
  41617. }
  41618. /**
  41619. * Defines a DualShock gamepad
  41620. */
  41621. export class DualShockPad extends Gamepad {
  41622. private _leftTrigger;
  41623. private _rightTrigger;
  41624. private _onlefttriggerchanged;
  41625. private _onrighttriggerchanged;
  41626. private _onbuttondown;
  41627. private _onbuttonup;
  41628. private _ondpaddown;
  41629. private _ondpadup;
  41630. /** Observable raised when a button is pressed */
  41631. onButtonDownObservable: Observable<DualShockButton>;
  41632. /** Observable raised when a button is released */
  41633. onButtonUpObservable: Observable<DualShockButton>;
  41634. /** Observable raised when a pad is pressed */
  41635. onPadDownObservable: Observable<DualShockDpad>;
  41636. /** Observable raised when a pad is released */
  41637. onPadUpObservable: Observable<DualShockDpad>;
  41638. private _buttonCross;
  41639. private _buttonCircle;
  41640. private _buttonSquare;
  41641. private _buttonTriangle;
  41642. private _buttonShare;
  41643. private _buttonOptions;
  41644. private _buttonL1;
  41645. private _buttonR1;
  41646. private _buttonLeftStick;
  41647. private _buttonRightStick;
  41648. private _dPadUp;
  41649. private _dPadDown;
  41650. private _dPadLeft;
  41651. private _dPadRight;
  41652. /**
  41653. * Creates a new DualShock gamepad object
  41654. * @param id defines the id of this gamepad
  41655. * @param index defines its index
  41656. * @param gamepad defines the internal HTML gamepad object
  41657. */
  41658. constructor(id: string, index: number, gamepad: any);
  41659. /**
  41660. * Defines the callback to call when left trigger is pressed
  41661. * @param callback defines the callback to use
  41662. */
  41663. onlefttriggerchanged(callback: (value: number) => void): void;
  41664. /**
  41665. * Defines the callback to call when right trigger is pressed
  41666. * @param callback defines the callback to use
  41667. */
  41668. onrighttriggerchanged(callback: (value: number) => void): void;
  41669. /**
  41670. * Gets the left trigger value
  41671. */
  41672. get leftTrigger(): number;
  41673. /**
  41674. * Sets the left trigger value
  41675. */
  41676. set leftTrigger(newValue: number);
  41677. /**
  41678. * Gets the right trigger value
  41679. */
  41680. get rightTrigger(): number;
  41681. /**
  41682. * Sets the right trigger value
  41683. */
  41684. set rightTrigger(newValue: number);
  41685. /**
  41686. * Defines the callback to call when a button is pressed
  41687. * @param callback defines the callback to use
  41688. */
  41689. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41690. /**
  41691. * Defines the callback to call when a button is released
  41692. * @param callback defines the callback to use
  41693. */
  41694. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41695. /**
  41696. * Defines the callback to call when a pad is pressed
  41697. * @param callback defines the callback to use
  41698. */
  41699. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41700. /**
  41701. * Defines the callback to call when a pad is released
  41702. * @param callback defines the callback to use
  41703. */
  41704. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41705. private _setButtonValue;
  41706. private _setDPadValue;
  41707. /**
  41708. * Gets the value of the `Cross` button
  41709. */
  41710. get buttonCross(): number;
  41711. /**
  41712. * Sets the value of the `Cross` button
  41713. */
  41714. set buttonCross(value: number);
  41715. /**
  41716. * Gets the value of the `Circle` button
  41717. */
  41718. get buttonCircle(): number;
  41719. /**
  41720. * Sets the value of the `Circle` button
  41721. */
  41722. set buttonCircle(value: number);
  41723. /**
  41724. * Gets the value of the `Square` button
  41725. */
  41726. get buttonSquare(): number;
  41727. /**
  41728. * Sets the value of the `Square` button
  41729. */
  41730. set buttonSquare(value: number);
  41731. /**
  41732. * Gets the value of the `Triangle` button
  41733. */
  41734. get buttonTriangle(): number;
  41735. /**
  41736. * Sets the value of the `Triangle` button
  41737. */
  41738. set buttonTriangle(value: number);
  41739. /**
  41740. * Gets the value of the `Options` button
  41741. */
  41742. get buttonOptions(): number;
  41743. /**
  41744. * Sets the value of the `Options` button
  41745. */
  41746. set buttonOptions(value: number);
  41747. /**
  41748. * Gets the value of the `Share` button
  41749. */
  41750. get buttonShare(): number;
  41751. /**
  41752. * Sets the value of the `Share` button
  41753. */
  41754. set buttonShare(value: number);
  41755. /**
  41756. * Gets the value of the `L1` button
  41757. */
  41758. get buttonL1(): number;
  41759. /**
  41760. * Sets the value of the `L1` button
  41761. */
  41762. set buttonL1(value: number);
  41763. /**
  41764. * Gets the value of the `R1` button
  41765. */
  41766. get buttonR1(): number;
  41767. /**
  41768. * Sets the value of the `R1` button
  41769. */
  41770. set buttonR1(value: number);
  41771. /**
  41772. * Gets the value of the Left joystick
  41773. */
  41774. get buttonLeftStick(): number;
  41775. /**
  41776. * Sets the value of the Left joystick
  41777. */
  41778. set buttonLeftStick(value: number);
  41779. /**
  41780. * Gets the value of the Right joystick
  41781. */
  41782. get buttonRightStick(): number;
  41783. /**
  41784. * Sets the value of the Right joystick
  41785. */
  41786. set buttonRightStick(value: number);
  41787. /**
  41788. * Gets the value of D-pad up
  41789. */
  41790. get dPadUp(): number;
  41791. /**
  41792. * Sets the value of D-pad up
  41793. */
  41794. set dPadUp(value: number);
  41795. /**
  41796. * Gets the value of D-pad down
  41797. */
  41798. get dPadDown(): number;
  41799. /**
  41800. * Sets the value of D-pad down
  41801. */
  41802. set dPadDown(value: number);
  41803. /**
  41804. * Gets the value of D-pad left
  41805. */
  41806. get dPadLeft(): number;
  41807. /**
  41808. * Sets the value of D-pad left
  41809. */
  41810. set dPadLeft(value: number);
  41811. /**
  41812. * Gets the value of D-pad right
  41813. */
  41814. get dPadRight(): number;
  41815. /**
  41816. * Sets the value of D-pad right
  41817. */
  41818. set dPadRight(value: number);
  41819. /**
  41820. * Force the gamepad to synchronize with device values
  41821. */
  41822. update(): void;
  41823. /**
  41824. * Disposes the gamepad
  41825. */
  41826. dispose(): void;
  41827. }
  41828. }
  41829. declare module BABYLON {
  41830. /**
  41831. * Manager for handling gamepads
  41832. */
  41833. export class GamepadManager {
  41834. private _scene?;
  41835. private _babylonGamepads;
  41836. private _oneGamepadConnected;
  41837. /** @hidden */
  41838. _isMonitoring: boolean;
  41839. private _gamepadEventSupported;
  41840. private _gamepadSupport?;
  41841. /**
  41842. * observable to be triggered when the gamepad controller has been connected
  41843. */
  41844. onGamepadConnectedObservable: Observable<Gamepad>;
  41845. /**
  41846. * observable to be triggered when the gamepad controller has been disconnected
  41847. */
  41848. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41849. private _onGamepadConnectedEvent;
  41850. private _onGamepadDisconnectedEvent;
  41851. /**
  41852. * Initializes the gamepad manager
  41853. * @param _scene BabylonJS scene
  41854. */
  41855. constructor(_scene?: Scene | undefined);
  41856. /**
  41857. * The gamepads in the game pad manager
  41858. */
  41859. get gamepads(): Gamepad[];
  41860. /**
  41861. * Get the gamepad controllers based on type
  41862. * @param type The type of gamepad controller
  41863. * @returns Nullable gamepad
  41864. */
  41865. getGamepadByType(type?: number): Nullable<Gamepad>;
  41866. /**
  41867. * Disposes the gamepad manager
  41868. */
  41869. dispose(): void;
  41870. private _addNewGamepad;
  41871. private _startMonitoringGamepads;
  41872. private _stopMonitoringGamepads;
  41873. /** @hidden */
  41874. _checkGamepadsStatus(): void;
  41875. private _updateGamepadObjects;
  41876. }
  41877. }
  41878. declare module BABYLON {
  41879. interface Scene {
  41880. /** @hidden */
  41881. _gamepadManager: Nullable<GamepadManager>;
  41882. /**
  41883. * Gets the gamepad manager associated with the scene
  41884. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41885. */
  41886. gamepadManager: GamepadManager;
  41887. }
  41888. /**
  41889. * Interface representing a free camera inputs manager
  41890. */
  41891. interface FreeCameraInputsManager {
  41892. /**
  41893. * Adds gamepad input support to the FreeCameraInputsManager.
  41894. * @returns the FreeCameraInputsManager
  41895. */
  41896. addGamepad(): FreeCameraInputsManager;
  41897. }
  41898. /**
  41899. * Interface representing an arc rotate camera inputs manager
  41900. */
  41901. interface ArcRotateCameraInputsManager {
  41902. /**
  41903. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41904. * @returns the camera inputs manager
  41905. */
  41906. addGamepad(): ArcRotateCameraInputsManager;
  41907. }
  41908. /**
  41909. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41910. */
  41911. export class GamepadSystemSceneComponent implements ISceneComponent {
  41912. /**
  41913. * The component name helpfull to identify the component in the list of scene components.
  41914. */
  41915. readonly name: string;
  41916. /**
  41917. * The scene the component belongs to.
  41918. */
  41919. scene: Scene;
  41920. /**
  41921. * Creates a new instance of the component for the given scene
  41922. * @param scene Defines the scene to register the component in
  41923. */
  41924. constructor(scene: Scene);
  41925. /**
  41926. * Registers the component in a given scene
  41927. */
  41928. register(): void;
  41929. /**
  41930. * Rebuilds the elements related to this component in case of
  41931. * context lost for instance.
  41932. */
  41933. rebuild(): void;
  41934. /**
  41935. * Disposes the component and the associated ressources
  41936. */
  41937. dispose(): void;
  41938. private _beforeCameraUpdate;
  41939. }
  41940. }
  41941. declare module BABYLON {
  41942. /**
  41943. * 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,
  41944. * which still works and will still be found in many Playgrounds.
  41945. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41946. */
  41947. export class UniversalCamera extends TouchCamera {
  41948. /**
  41949. * Defines the gamepad rotation sensiblity.
  41950. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41951. */
  41952. get gamepadAngularSensibility(): number;
  41953. set gamepadAngularSensibility(value: number);
  41954. /**
  41955. * Defines the gamepad move sensiblity.
  41956. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41957. */
  41958. get gamepadMoveSensibility(): number;
  41959. set gamepadMoveSensibility(value: number);
  41960. /**
  41961. * 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,
  41962. * which still works and will still be found in many Playgrounds.
  41963. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41964. * @param name Define the name of the camera in the scene
  41965. * @param position Define the start position of the camera in the scene
  41966. * @param scene Define the scene the camera belongs to
  41967. */
  41968. constructor(name: string, position: Vector3, scene: Scene);
  41969. /**
  41970. * Gets the current object class name.
  41971. * @return the class name
  41972. */
  41973. getClassName(): string;
  41974. }
  41975. }
  41976. declare module BABYLON {
  41977. /**
  41978. * This represents a FPS type of camera. This is only here for back compat purpose.
  41979. * Please use the UniversalCamera instead as both are identical.
  41980. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41981. */
  41982. export class GamepadCamera extends UniversalCamera {
  41983. /**
  41984. * Instantiates a new Gamepad Camera
  41985. * This represents a FPS type of camera. This is only here for back compat purpose.
  41986. * Please use the UniversalCamera instead as both are identical.
  41987. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41988. * @param name Define the name of the camera in the scene
  41989. * @param position Define the start position of the camera in the scene
  41990. * @param scene Define the scene the camera belongs to
  41991. */
  41992. constructor(name: string, position: Vector3, scene: Scene);
  41993. /**
  41994. * Gets the current object class name.
  41995. * @return the class name
  41996. */
  41997. getClassName(): string;
  41998. }
  41999. }
  42000. declare module BABYLON {
  42001. /** @hidden */
  42002. export var passPixelShader: {
  42003. name: string;
  42004. shader: string;
  42005. };
  42006. }
  42007. declare module BABYLON {
  42008. /** @hidden */
  42009. export var passCubePixelShader: {
  42010. name: string;
  42011. shader: string;
  42012. };
  42013. }
  42014. declare module BABYLON {
  42015. /**
  42016. * PassPostProcess which produces an output the same as it's input
  42017. */
  42018. export class PassPostProcess extends PostProcess {
  42019. /**
  42020. * Creates the PassPostProcess
  42021. * @param name The name of the effect.
  42022. * @param options The required width/height ratio to downsize to before computing the render pass.
  42023. * @param camera The camera to apply the render pass to.
  42024. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42025. * @param engine The engine which the post process will be applied. (default: current engine)
  42026. * @param reusable If the post process can be reused on the same frame. (default: false)
  42027. * @param textureType The type of texture to be used when performing the post processing.
  42028. * @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)
  42029. */
  42030. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42031. }
  42032. /**
  42033. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42034. */
  42035. export class PassCubePostProcess extends PostProcess {
  42036. private _face;
  42037. /**
  42038. * Gets or sets the cube face to display.
  42039. * * 0 is +X
  42040. * * 1 is -X
  42041. * * 2 is +Y
  42042. * * 3 is -Y
  42043. * * 4 is +Z
  42044. * * 5 is -Z
  42045. */
  42046. get face(): number;
  42047. set face(value: number);
  42048. /**
  42049. * Creates the PassCubePostProcess
  42050. * @param name The name of the effect.
  42051. * @param options The required width/height ratio to downsize to before computing the render pass.
  42052. * @param camera The camera to apply the render pass to.
  42053. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42054. * @param engine The engine which the post process will be applied. (default: current engine)
  42055. * @param reusable If the post process can be reused on the same frame. (default: false)
  42056. * @param textureType The type of texture to be used when performing the post processing.
  42057. * @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)
  42058. */
  42059. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42060. }
  42061. }
  42062. declare module BABYLON {
  42063. /** @hidden */
  42064. export var anaglyphPixelShader: {
  42065. name: string;
  42066. shader: string;
  42067. };
  42068. }
  42069. declare module BABYLON {
  42070. /**
  42071. * Postprocess used to generate anaglyphic rendering
  42072. */
  42073. export class AnaglyphPostProcess extends PostProcess {
  42074. private _passedProcess;
  42075. /**
  42076. * Creates a new AnaglyphPostProcess
  42077. * @param name defines postprocess name
  42078. * @param options defines creation options or target ratio scale
  42079. * @param rigCameras defines cameras using this postprocess
  42080. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42081. * @param engine defines hosting engine
  42082. * @param reusable defines if the postprocess will be reused multiple times per frame
  42083. */
  42084. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42085. }
  42086. }
  42087. declare module BABYLON {
  42088. /**
  42089. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42090. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42091. */
  42092. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42093. /**
  42094. * Creates a new AnaglyphArcRotateCamera
  42095. * @param name defines camera name
  42096. * @param alpha defines alpha angle (in radians)
  42097. * @param beta defines beta angle (in radians)
  42098. * @param radius defines radius
  42099. * @param target defines camera target
  42100. * @param interaxialDistance defines distance between each color axis
  42101. * @param scene defines the hosting scene
  42102. */
  42103. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42104. /**
  42105. * Gets camera class name
  42106. * @returns AnaglyphArcRotateCamera
  42107. */
  42108. getClassName(): string;
  42109. }
  42110. }
  42111. declare module BABYLON {
  42112. /**
  42113. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42114. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42115. */
  42116. export class AnaglyphFreeCamera extends FreeCamera {
  42117. /**
  42118. * Creates a new AnaglyphFreeCamera
  42119. * @param name defines camera name
  42120. * @param position defines initial position
  42121. * @param interaxialDistance defines distance between each color axis
  42122. * @param scene defines the hosting scene
  42123. */
  42124. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42125. /**
  42126. * Gets camera class name
  42127. * @returns AnaglyphFreeCamera
  42128. */
  42129. getClassName(): string;
  42130. }
  42131. }
  42132. declare module BABYLON {
  42133. /**
  42134. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42135. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42136. */
  42137. export class AnaglyphGamepadCamera extends GamepadCamera {
  42138. /**
  42139. * Creates a new AnaglyphGamepadCamera
  42140. * @param name defines camera name
  42141. * @param position defines initial position
  42142. * @param interaxialDistance defines distance between each color axis
  42143. * @param scene defines the hosting scene
  42144. */
  42145. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42146. /**
  42147. * Gets camera class name
  42148. * @returns AnaglyphGamepadCamera
  42149. */
  42150. getClassName(): string;
  42151. }
  42152. }
  42153. declare module BABYLON {
  42154. /**
  42155. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42156. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42157. */
  42158. export class AnaglyphUniversalCamera extends UniversalCamera {
  42159. /**
  42160. * Creates a new AnaglyphUniversalCamera
  42161. * @param name defines camera name
  42162. * @param position defines initial position
  42163. * @param interaxialDistance defines distance between each color axis
  42164. * @param scene defines the hosting scene
  42165. */
  42166. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42167. /**
  42168. * Gets camera class name
  42169. * @returns AnaglyphUniversalCamera
  42170. */
  42171. getClassName(): string;
  42172. }
  42173. }
  42174. declare module BABYLON {
  42175. /** @hidden */
  42176. export var stereoscopicInterlacePixelShader: {
  42177. name: string;
  42178. shader: string;
  42179. };
  42180. }
  42181. declare module BABYLON {
  42182. /**
  42183. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  42184. */
  42185. export class StereoscopicInterlacePostProcessI extends PostProcess {
  42186. private _stepSize;
  42187. private _passedProcess;
  42188. /**
  42189. * Initializes a StereoscopicInterlacePostProcessI
  42190. * @param name The name of the effect.
  42191. * @param rigCameras The rig cameras to be appled to the post process
  42192. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  42193. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  42194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42195. * @param engine The engine which the post process will be applied. (default: current engine)
  42196. * @param reusable If the post process can be reused on the same frame. (default: false)
  42197. */
  42198. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42199. }
  42200. /**
  42201. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42202. */
  42203. export class StereoscopicInterlacePostProcess extends PostProcess {
  42204. private _stepSize;
  42205. private _passedProcess;
  42206. /**
  42207. * Initializes a StereoscopicInterlacePostProcess
  42208. * @param name The name of the effect.
  42209. * @param rigCameras The rig cameras to be appled to the post process
  42210. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42211. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42212. * @param engine The engine which the post process will be applied. (default: current engine)
  42213. * @param reusable If the post process can be reused on the same frame. (default: false)
  42214. */
  42215. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42216. }
  42217. }
  42218. declare module BABYLON {
  42219. /**
  42220. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42221. * @see http://doc.babylonjs.com/features/cameras
  42222. */
  42223. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42224. /**
  42225. * Creates a new StereoscopicArcRotateCamera
  42226. * @param name defines camera name
  42227. * @param alpha defines alpha angle (in radians)
  42228. * @param beta defines beta angle (in radians)
  42229. * @param radius defines radius
  42230. * @param target defines camera target
  42231. * @param interaxialDistance defines distance between each color axis
  42232. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42233. * @param scene defines the hosting scene
  42234. */
  42235. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42236. /**
  42237. * Gets camera class name
  42238. * @returns StereoscopicArcRotateCamera
  42239. */
  42240. getClassName(): string;
  42241. }
  42242. }
  42243. declare module BABYLON {
  42244. /**
  42245. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42246. * @see http://doc.babylonjs.com/features/cameras
  42247. */
  42248. export class StereoscopicFreeCamera extends FreeCamera {
  42249. /**
  42250. * Creates a new StereoscopicFreeCamera
  42251. * @param name defines camera name
  42252. * @param position defines initial position
  42253. * @param interaxialDistance defines distance between each color axis
  42254. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42255. * @param scene defines the hosting scene
  42256. */
  42257. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42258. /**
  42259. * Gets camera class name
  42260. * @returns StereoscopicFreeCamera
  42261. */
  42262. getClassName(): string;
  42263. }
  42264. }
  42265. declare module BABYLON {
  42266. /**
  42267. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  42268. * @see http://doc.babylonjs.com/features/cameras
  42269. */
  42270. export class StereoscopicGamepadCamera extends GamepadCamera {
  42271. /**
  42272. * Creates a new StereoscopicGamepadCamera
  42273. * @param name defines camera name
  42274. * @param position defines initial position
  42275. * @param interaxialDistance defines distance between each color axis
  42276. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42277. * @param scene defines the hosting scene
  42278. */
  42279. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42280. /**
  42281. * Gets camera class name
  42282. * @returns StereoscopicGamepadCamera
  42283. */
  42284. getClassName(): string;
  42285. }
  42286. }
  42287. declare module BABYLON {
  42288. /**
  42289. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  42290. * @see http://doc.babylonjs.com/features/cameras
  42291. */
  42292. export class StereoscopicUniversalCamera extends UniversalCamera {
  42293. /**
  42294. * Creates a new StereoscopicUniversalCamera
  42295. * @param name defines camera name
  42296. * @param position defines initial position
  42297. * @param interaxialDistance defines distance between each color axis
  42298. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42299. * @param scene defines the hosting scene
  42300. */
  42301. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42302. /**
  42303. * Gets camera class name
  42304. * @returns StereoscopicUniversalCamera
  42305. */
  42306. getClassName(): string;
  42307. }
  42308. }
  42309. declare module BABYLON {
  42310. /**
  42311. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  42312. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42313. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42314. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42315. */
  42316. export class VirtualJoysticksCamera extends FreeCamera {
  42317. /**
  42318. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  42319. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  42320. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  42321. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  42322. * @param name Define the name of the camera in the scene
  42323. * @param position Define the start position of the camera in the scene
  42324. * @param scene Define the scene the camera belongs to
  42325. */
  42326. constructor(name: string, position: Vector3, scene: Scene);
  42327. /**
  42328. * Gets the current object class name.
  42329. * @return the class name
  42330. */
  42331. getClassName(): string;
  42332. }
  42333. }
  42334. declare module BABYLON {
  42335. /**
  42336. * This represents all the required metrics to create a VR camera.
  42337. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  42338. */
  42339. export class VRCameraMetrics {
  42340. /**
  42341. * Define the horizontal resolution off the screen.
  42342. */
  42343. hResolution: number;
  42344. /**
  42345. * Define the vertical resolution off the screen.
  42346. */
  42347. vResolution: number;
  42348. /**
  42349. * Define the horizontal screen size.
  42350. */
  42351. hScreenSize: number;
  42352. /**
  42353. * Define the vertical screen size.
  42354. */
  42355. vScreenSize: number;
  42356. /**
  42357. * Define the vertical screen center position.
  42358. */
  42359. vScreenCenter: number;
  42360. /**
  42361. * Define the distance of the eyes to the screen.
  42362. */
  42363. eyeToScreenDistance: number;
  42364. /**
  42365. * Define the distance between both lenses
  42366. */
  42367. lensSeparationDistance: number;
  42368. /**
  42369. * Define the distance between both viewer's eyes.
  42370. */
  42371. interpupillaryDistance: number;
  42372. /**
  42373. * Define the distortion factor of the VR postprocess.
  42374. * Please, touch with care.
  42375. */
  42376. distortionK: number[];
  42377. /**
  42378. * Define the chromatic aberration correction factors for the VR post process.
  42379. */
  42380. chromaAbCorrection: number[];
  42381. /**
  42382. * Define the scale factor of the post process.
  42383. * The smaller the better but the slower.
  42384. */
  42385. postProcessScaleFactor: number;
  42386. /**
  42387. * Define an offset for the lens center.
  42388. */
  42389. lensCenterOffset: number;
  42390. /**
  42391. * Define if the current vr camera should compensate the distortion of the lense or not.
  42392. */
  42393. compensateDistortion: boolean;
  42394. /**
  42395. * Defines if multiview should be enabled when rendering (Default: false)
  42396. */
  42397. multiviewEnabled: boolean;
  42398. /**
  42399. * Gets the rendering aspect ratio based on the provided resolutions.
  42400. */
  42401. get aspectRatio(): number;
  42402. /**
  42403. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42404. */
  42405. get aspectRatioFov(): number;
  42406. /**
  42407. * @hidden
  42408. */
  42409. get leftHMatrix(): Matrix;
  42410. /**
  42411. * @hidden
  42412. */
  42413. get rightHMatrix(): Matrix;
  42414. /**
  42415. * @hidden
  42416. */
  42417. get leftPreViewMatrix(): Matrix;
  42418. /**
  42419. * @hidden
  42420. */
  42421. get rightPreViewMatrix(): Matrix;
  42422. /**
  42423. * Get the default VRMetrics based on the most generic setup.
  42424. * @returns the default vr metrics
  42425. */
  42426. static GetDefault(): VRCameraMetrics;
  42427. }
  42428. }
  42429. declare module BABYLON {
  42430. /** @hidden */
  42431. export var vrDistortionCorrectionPixelShader: {
  42432. name: string;
  42433. shader: string;
  42434. };
  42435. }
  42436. declare module BABYLON {
  42437. /**
  42438. * VRDistortionCorrectionPostProcess used for mobile VR
  42439. */
  42440. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42441. private _isRightEye;
  42442. private _distortionFactors;
  42443. private _postProcessScaleFactor;
  42444. private _lensCenterOffset;
  42445. private _scaleIn;
  42446. private _scaleFactor;
  42447. private _lensCenter;
  42448. /**
  42449. * Initializes the VRDistortionCorrectionPostProcess
  42450. * @param name The name of the effect.
  42451. * @param camera The camera to apply the render pass to.
  42452. * @param isRightEye If this is for the right eye distortion
  42453. * @param vrMetrics All the required metrics for the VR camera
  42454. */
  42455. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42456. }
  42457. }
  42458. declare module BABYLON {
  42459. /**
  42460. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42461. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42462. */
  42463. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42464. /**
  42465. * Creates a new VRDeviceOrientationArcRotateCamera
  42466. * @param name defines camera name
  42467. * @param alpha defines the camera rotation along the logitudinal axis
  42468. * @param beta defines the camera rotation along the latitudinal axis
  42469. * @param radius defines the camera distance from its target
  42470. * @param target defines the camera target
  42471. * @param scene defines the scene the camera belongs to
  42472. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42473. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42474. */
  42475. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42476. /**
  42477. * Gets camera class name
  42478. * @returns VRDeviceOrientationArcRotateCamera
  42479. */
  42480. getClassName(): string;
  42481. }
  42482. }
  42483. declare module BABYLON {
  42484. /**
  42485. * Camera used to simulate VR rendering (based on FreeCamera)
  42486. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42487. */
  42488. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42489. /**
  42490. * Creates a new VRDeviceOrientationFreeCamera
  42491. * @param name defines camera name
  42492. * @param position defines the start position of the camera
  42493. * @param scene defines the scene the camera belongs to
  42494. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42495. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42496. */
  42497. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42498. /**
  42499. * Gets camera class name
  42500. * @returns VRDeviceOrientationFreeCamera
  42501. */
  42502. getClassName(): string;
  42503. }
  42504. }
  42505. declare module BABYLON {
  42506. /**
  42507. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42508. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42509. */
  42510. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42511. /**
  42512. * Creates a new VRDeviceOrientationGamepadCamera
  42513. * @param name defines camera name
  42514. * @param position defines the start position of the camera
  42515. * @param scene defines the scene the camera belongs to
  42516. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42517. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42518. */
  42519. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42520. /**
  42521. * Gets camera class name
  42522. * @returns VRDeviceOrientationGamepadCamera
  42523. */
  42524. getClassName(): string;
  42525. }
  42526. }
  42527. declare module BABYLON {
  42528. /** @hidden */
  42529. export var imageProcessingPixelShader: {
  42530. name: string;
  42531. shader: string;
  42532. };
  42533. }
  42534. declare module BABYLON {
  42535. /**
  42536. * ImageProcessingPostProcess
  42537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42538. */
  42539. export class ImageProcessingPostProcess extends PostProcess {
  42540. /**
  42541. * Default configuration related to image processing available in the PBR Material.
  42542. */
  42543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42544. /**
  42545. * Gets the image processing configuration used either in this material.
  42546. */
  42547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42548. /**
  42549. * Sets the Default image processing configuration used either in the this material.
  42550. *
  42551. * If sets to null, the scene one is in use.
  42552. */
  42553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42554. /**
  42555. * Keep track of the image processing observer to allow dispose and replace.
  42556. */
  42557. private _imageProcessingObserver;
  42558. /**
  42559. * Attaches a new image processing configuration to the PBR Material.
  42560. * @param configuration
  42561. */
  42562. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42563. /**
  42564. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42565. */
  42566. get colorCurves(): Nullable<ColorCurves>;
  42567. /**
  42568. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42569. */
  42570. set colorCurves(value: Nullable<ColorCurves>);
  42571. /**
  42572. * Gets wether the color curves effect is enabled.
  42573. */
  42574. get colorCurvesEnabled(): boolean;
  42575. /**
  42576. * Sets wether the color curves effect is enabled.
  42577. */
  42578. set colorCurvesEnabled(value: boolean);
  42579. /**
  42580. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42581. */
  42582. get colorGradingTexture(): Nullable<BaseTexture>;
  42583. /**
  42584. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42585. */
  42586. set colorGradingTexture(value: Nullable<BaseTexture>);
  42587. /**
  42588. * Gets wether the color grading effect is enabled.
  42589. */
  42590. get colorGradingEnabled(): boolean;
  42591. /**
  42592. * Gets wether the color grading effect is enabled.
  42593. */
  42594. set colorGradingEnabled(value: boolean);
  42595. /**
  42596. * Gets exposure used in the effect.
  42597. */
  42598. get exposure(): number;
  42599. /**
  42600. * Sets exposure used in the effect.
  42601. */
  42602. set exposure(value: number);
  42603. /**
  42604. * Gets wether tonemapping is enabled or not.
  42605. */
  42606. get toneMappingEnabled(): boolean;
  42607. /**
  42608. * Sets wether tonemapping is enabled or not
  42609. */
  42610. set toneMappingEnabled(value: boolean);
  42611. /**
  42612. * Gets the type of tone mapping effect.
  42613. */
  42614. get toneMappingType(): number;
  42615. /**
  42616. * Sets the type of tone mapping effect.
  42617. */
  42618. set toneMappingType(value: number);
  42619. /**
  42620. * Gets contrast used in the effect.
  42621. */
  42622. get contrast(): number;
  42623. /**
  42624. * Sets contrast used in the effect.
  42625. */
  42626. set contrast(value: number);
  42627. /**
  42628. * Gets Vignette stretch size.
  42629. */
  42630. get vignetteStretch(): number;
  42631. /**
  42632. * Sets Vignette stretch size.
  42633. */
  42634. set vignetteStretch(value: number);
  42635. /**
  42636. * Gets Vignette centre X Offset.
  42637. */
  42638. get vignetteCentreX(): number;
  42639. /**
  42640. * Sets Vignette centre X Offset.
  42641. */
  42642. set vignetteCentreX(value: number);
  42643. /**
  42644. * Gets Vignette centre Y Offset.
  42645. */
  42646. get vignetteCentreY(): number;
  42647. /**
  42648. * Sets Vignette centre Y Offset.
  42649. */
  42650. set vignetteCentreY(value: number);
  42651. /**
  42652. * Gets Vignette weight or intensity of the vignette effect.
  42653. */
  42654. get vignetteWeight(): number;
  42655. /**
  42656. * Sets Vignette weight or intensity of the vignette effect.
  42657. */
  42658. set vignetteWeight(value: number);
  42659. /**
  42660. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42661. * if vignetteEnabled is set to true.
  42662. */
  42663. get vignetteColor(): Color4;
  42664. /**
  42665. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42666. * if vignetteEnabled is set to true.
  42667. */
  42668. set vignetteColor(value: Color4);
  42669. /**
  42670. * Gets Camera field of view used by the Vignette effect.
  42671. */
  42672. get vignetteCameraFov(): number;
  42673. /**
  42674. * Sets Camera field of view used by the Vignette effect.
  42675. */
  42676. set vignetteCameraFov(value: number);
  42677. /**
  42678. * Gets the vignette blend mode allowing different kind of effect.
  42679. */
  42680. get vignetteBlendMode(): number;
  42681. /**
  42682. * Sets the vignette blend mode allowing different kind of effect.
  42683. */
  42684. set vignetteBlendMode(value: number);
  42685. /**
  42686. * Gets wether the vignette effect is enabled.
  42687. */
  42688. get vignetteEnabled(): boolean;
  42689. /**
  42690. * Sets wether the vignette effect is enabled.
  42691. */
  42692. set vignetteEnabled(value: boolean);
  42693. private _fromLinearSpace;
  42694. /**
  42695. * Gets wether the input of the processing is in Gamma or Linear Space.
  42696. */
  42697. get fromLinearSpace(): boolean;
  42698. /**
  42699. * Sets wether the input of the processing is in Gamma or Linear Space.
  42700. */
  42701. set fromLinearSpace(value: boolean);
  42702. /**
  42703. * Defines cache preventing GC.
  42704. */
  42705. private _defines;
  42706. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42707. /**
  42708. * "ImageProcessingPostProcess"
  42709. * @returns "ImageProcessingPostProcess"
  42710. */
  42711. getClassName(): string;
  42712. protected _updateParameters(): void;
  42713. dispose(camera?: Camera): void;
  42714. }
  42715. }
  42716. declare module BABYLON {
  42717. /**
  42718. * Class containing static functions to help procedurally build meshes
  42719. */
  42720. export class GroundBuilder {
  42721. /**
  42722. * Creates a ground mesh
  42723. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42724. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42726. * @param name defines the name of the mesh
  42727. * @param options defines the options used to create the mesh
  42728. * @param scene defines the hosting scene
  42729. * @returns the ground mesh
  42730. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42731. */
  42732. static CreateGround(name: string, options: {
  42733. width?: number;
  42734. height?: number;
  42735. subdivisions?: number;
  42736. subdivisionsX?: number;
  42737. subdivisionsY?: number;
  42738. updatable?: boolean;
  42739. }, scene: any): Mesh;
  42740. /**
  42741. * Creates a tiled ground mesh
  42742. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42743. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42744. * * 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
  42745. * * 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
  42746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42747. * @param name defines the name of the mesh
  42748. * @param options defines the options used to create the mesh
  42749. * @param scene defines the hosting scene
  42750. * @returns the tiled ground mesh
  42751. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42752. */
  42753. static CreateTiledGround(name: string, options: {
  42754. xmin: number;
  42755. zmin: number;
  42756. xmax: number;
  42757. zmax: number;
  42758. subdivisions?: {
  42759. w: number;
  42760. h: number;
  42761. };
  42762. precision?: {
  42763. w: number;
  42764. h: number;
  42765. };
  42766. updatable?: boolean;
  42767. }, scene?: Nullable<Scene>): Mesh;
  42768. /**
  42769. * Creates a ground mesh from a height map
  42770. * * The parameter `url` sets the URL of the height map image resource.
  42771. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42772. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42773. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42774. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42775. * * 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.
  42776. * * 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).
  42777. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42779. * @param name defines the name of the mesh
  42780. * @param url defines the url to the height map
  42781. * @param options defines the options used to create the mesh
  42782. * @param scene defines the hosting scene
  42783. * @returns the ground mesh
  42784. * @see https://doc.babylonjs.com/babylon101/height_map
  42785. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42786. */
  42787. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42788. width?: number;
  42789. height?: number;
  42790. subdivisions?: number;
  42791. minHeight?: number;
  42792. maxHeight?: number;
  42793. colorFilter?: Color3;
  42794. alphaFilter?: number;
  42795. updatable?: boolean;
  42796. onReady?: (mesh: GroundMesh) => void;
  42797. }, scene?: Nullable<Scene>): GroundMesh;
  42798. }
  42799. }
  42800. declare module BABYLON {
  42801. /**
  42802. * Class containing static functions to help procedurally build meshes
  42803. */
  42804. export class TorusBuilder {
  42805. /**
  42806. * Creates a torus mesh
  42807. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42808. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42809. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42811. * * 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
  42812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42813. * @param name defines the name of the mesh
  42814. * @param options defines the options used to create the mesh
  42815. * @param scene defines the hosting scene
  42816. * @returns the torus mesh
  42817. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42818. */
  42819. static CreateTorus(name: string, options: {
  42820. diameter?: number;
  42821. thickness?: number;
  42822. tessellation?: number;
  42823. updatable?: boolean;
  42824. sideOrientation?: number;
  42825. frontUVs?: Vector4;
  42826. backUVs?: Vector4;
  42827. }, scene: any): Mesh;
  42828. }
  42829. }
  42830. declare module BABYLON {
  42831. /**
  42832. * Class containing static functions to help procedurally build meshes
  42833. */
  42834. export class CylinderBuilder {
  42835. /**
  42836. * Creates a cylinder or a cone mesh
  42837. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42838. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42839. * * 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.
  42840. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42841. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42842. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42843. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42844. * * 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).
  42845. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42846. * * 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).
  42847. * * 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
  42848. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42849. * * 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
  42850. * * 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.
  42851. * * If `enclose` is false, a ring surface is one element.
  42852. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42853. * * 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
  42854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42855. * * 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
  42856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42857. * @param name defines the name of the mesh
  42858. * @param options defines the options used to create the mesh
  42859. * @param scene defines the hosting scene
  42860. * @returns the cylinder mesh
  42861. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42862. */
  42863. static CreateCylinder(name: string, options: {
  42864. height?: number;
  42865. diameterTop?: number;
  42866. diameterBottom?: number;
  42867. diameter?: number;
  42868. tessellation?: number;
  42869. subdivisions?: number;
  42870. arc?: number;
  42871. faceColors?: Color4[];
  42872. faceUV?: Vector4[];
  42873. updatable?: boolean;
  42874. hasRings?: boolean;
  42875. enclose?: boolean;
  42876. cap?: number;
  42877. sideOrientation?: number;
  42878. frontUVs?: Vector4;
  42879. backUVs?: Vector4;
  42880. }, scene: any): Mesh;
  42881. }
  42882. }
  42883. declare module BABYLON {
  42884. /**
  42885. * States of the webXR experience
  42886. */
  42887. export enum WebXRState {
  42888. /**
  42889. * Transitioning to being in XR mode
  42890. */
  42891. ENTERING_XR = 0,
  42892. /**
  42893. * Transitioning to non XR mode
  42894. */
  42895. EXITING_XR = 1,
  42896. /**
  42897. * In XR mode and presenting
  42898. */
  42899. IN_XR = 2,
  42900. /**
  42901. * Not entered XR mode
  42902. */
  42903. NOT_IN_XR = 3
  42904. }
  42905. /**
  42906. * Abstraction of the XR render target
  42907. */
  42908. export interface WebXRRenderTarget extends IDisposable {
  42909. /**
  42910. * xrpresent context of the canvas which can be used to display/mirror xr content
  42911. */
  42912. canvasContext: WebGLRenderingContext;
  42913. /**
  42914. * xr layer for the canvas
  42915. */
  42916. xrLayer: Nullable<XRWebGLLayer>;
  42917. /**
  42918. * Initializes the xr layer for the session
  42919. * @param xrSession xr session
  42920. * @returns a promise that will resolve once the XR Layer has been created
  42921. */
  42922. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42923. }
  42924. }
  42925. declare module BABYLON {
  42926. /**
  42927. * COnfiguration object for WebXR output canvas
  42928. */
  42929. export class WebXRManagedOutputCanvasOptions {
  42930. /**
  42931. * An optional canvas in case you wish to create it yourself and provide it here.
  42932. * If not provided, a new canvas will be created
  42933. */
  42934. canvasElement?: HTMLCanvasElement;
  42935. /**
  42936. * Options for this XR Layer output
  42937. */
  42938. canvasOptions?: XRWebGLLayerOptions;
  42939. /**
  42940. * CSS styling for a newly created canvas (if not provided)
  42941. */
  42942. newCanvasCssStyle?: string;
  42943. /**
  42944. * Get the default values of the configuration object
  42945. * @returns default values of this configuration object
  42946. */
  42947. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42948. }
  42949. /**
  42950. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42951. */
  42952. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42953. private _options;
  42954. private _canvas;
  42955. private _engine;
  42956. /**
  42957. * Rendering context of the canvas which can be used to display/mirror xr content
  42958. */
  42959. canvasContext: WebGLRenderingContext;
  42960. /**
  42961. * xr layer for the canvas
  42962. */
  42963. xrLayer: Nullable<XRWebGLLayer>;
  42964. /**
  42965. * Initializes the canvas to be added/removed upon entering/exiting xr
  42966. * @param _xrSessionManager The XR Session manager
  42967. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42968. */
  42969. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42970. /**
  42971. * Disposes of the object
  42972. */
  42973. dispose(): void;
  42974. /**
  42975. * Initializes the xr layer for the session
  42976. * @param xrSession xr session
  42977. * @returns a promise that will resolve once the XR Layer has been created
  42978. */
  42979. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42980. private _addCanvas;
  42981. private _removeCanvas;
  42982. private _setManagedOutputCanvas;
  42983. }
  42984. }
  42985. declare module BABYLON {
  42986. /**
  42987. * Manages an XRSession to work with Babylon's engine
  42988. * @see https://doc.babylonjs.com/how_to/webxr
  42989. */
  42990. export class WebXRSessionManager implements IDisposable {
  42991. /** The scene which the session should be created for */
  42992. scene: Scene;
  42993. private _referenceSpace;
  42994. private _rttProvider;
  42995. private _sessionEnded;
  42996. private _xrNavigator;
  42997. private baseLayer;
  42998. /**
  42999. * The base reference space from which the session started. good if you want to reset your
  43000. * reference space
  43001. */
  43002. baseReferenceSpace: XRReferenceSpace;
  43003. /**
  43004. * Current XR frame
  43005. */
  43006. currentFrame: Nullable<XRFrame>;
  43007. /** WebXR timestamp updated every frame */
  43008. currentTimestamp: number;
  43009. /**
  43010. * Used just in case of a failure to initialize an immersive session.
  43011. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43012. */
  43013. defaultHeightCompensation: number;
  43014. /**
  43015. * Fires every time a new xrFrame arrives which can be used to update the camera
  43016. */
  43017. onXRFrameObservable: Observable<XRFrame>;
  43018. /**
  43019. * Fires when the reference space changed
  43020. */
  43021. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  43022. /**
  43023. * Fires when the xr session is ended either by the device or manually done
  43024. */
  43025. onXRSessionEnded: Observable<any>;
  43026. /**
  43027. * Fires when the xr session is ended either by the device or manually done
  43028. */
  43029. onXRSessionInit: Observable<XRSession>;
  43030. /**
  43031. * Underlying xr session
  43032. */
  43033. session: XRSession;
  43034. /**
  43035. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43036. * or get the offset the player is currently at.
  43037. */
  43038. viewerReferenceSpace: XRReferenceSpace;
  43039. /**
  43040. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43041. * @param scene The scene which the session should be created for
  43042. */
  43043. constructor(
  43044. /** The scene which the session should be created for */
  43045. scene: Scene);
  43046. /**
  43047. * The current reference space used in this session. This reference space can constantly change!
  43048. * It is mainly used to offset the camera's position.
  43049. */
  43050. get referenceSpace(): XRReferenceSpace;
  43051. /**
  43052. * Set a new reference space and triggers the observable
  43053. */
  43054. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  43055. /**
  43056. * Disposes of the session manager
  43057. */
  43058. dispose(): void;
  43059. /**
  43060. * Stops the xrSession and restores the render loop
  43061. * @returns Promise which resolves after it exits XR
  43062. */
  43063. exitXRAsync(): Promise<void>;
  43064. /**
  43065. * Gets the correct render target texture to be rendered this frame for this eye
  43066. * @param eye the eye for which to get the render target
  43067. * @returns the render target for the specified eye
  43068. */
  43069. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43070. /**
  43071. * Creates a WebXRRenderTarget object for the XR session
  43072. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43073. * @param options optional options to provide when creating a new render target
  43074. * @returns a WebXR render target to which the session can render
  43075. */
  43076. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43077. /**
  43078. * Initializes the manager
  43079. * After initialization enterXR can be called to start an XR session
  43080. * @returns Promise which resolves after it is initialized
  43081. */
  43082. initializeAsync(): Promise<void>;
  43083. /**
  43084. * Initializes an xr session
  43085. * @param xrSessionMode mode to initialize
  43086. * @param xrSessionInit defines optional and required values to pass to the session builder
  43087. * @returns a promise which will resolve once the session has been initialized
  43088. */
  43089. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  43090. /**
  43091. * Checks if a session would be supported for the creation options specified
  43092. * @param sessionMode session mode to check if supported eg. immersive-vr
  43093. * @returns A Promise that resolves to true if supported and false if not
  43094. */
  43095. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43096. /**
  43097. * Resets the reference space to the one started the session
  43098. */
  43099. resetReferenceSpace(): void;
  43100. /**
  43101. * Starts rendering to the xr layer
  43102. */
  43103. runXRRenderLoop(): void;
  43104. /**
  43105. * Sets the reference space on the xr session
  43106. * @param referenceSpaceType space to set
  43107. * @returns a promise that will resolve once the reference space has been set
  43108. */
  43109. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  43110. /**
  43111. * Updates the render state of the session
  43112. * @param state state to set
  43113. * @returns a promise that resolves once the render state has been updated
  43114. */
  43115. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43116. /**
  43117. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  43118. * @param sessionMode defines the session to test
  43119. * @returns a promise with boolean as final value
  43120. */
  43121. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43122. private _createRenderTargetTexture;
  43123. }
  43124. }
  43125. declare module BABYLON {
  43126. /**
  43127. * WebXR Camera which holds the views for the xrSession
  43128. * @see https://doc.babylonjs.com/how_to/webxr_camera
  43129. */
  43130. export class WebXRCamera extends FreeCamera {
  43131. private _xrSessionManager;
  43132. private _firstFrame;
  43133. private _referenceQuaternion;
  43134. private _referencedPosition;
  43135. private _xrInvPositionCache;
  43136. private _xrInvQuaternionCache;
  43137. /**
  43138. * Should position compensation execute on first frame.
  43139. * This is used when copying the position from a native (non XR) camera
  43140. */
  43141. compensateOnFirstFrame: boolean;
  43142. /**
  43143. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43144. * @param name the name of the camera
  43145. * @param scene the scene to add the camera to
  43146. * @param _xrSessionManager a constructed xr session manager
  43147. */
  43148. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43149. /**
  43150. * Return the user's height, unrelated to the current ground.
  43151. * This will be the y position of this camera, when ground level is 0.
  43152. */
  43153. get realWorldHeight(): number;
  43154. /** @hidden */
  43155. _updateForDualEyeDebugging(): void;
  43156. /**
  43157. * Sets this camera's transformation based on a non-vr camera
  43158. * @param otherCamera the non-vr camera to copy the transformation from
  43159. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  43160. */
  43161. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  43162. /**
  43163. * Gets the current instance class name ("WebXRCamera").
  43164. * @returns the class name
  43165. */
  43166. getClassName(): string;
  43167. private _updateFromXRSession;
  43168. private _updateNumberOfRigCameras;
  43169. private _updateReferenceSpace;
  43170. private _updateReferenceSpaceOffset;
  43171. }
  43172. }
  43173. declare module BABYLON {
  43174. /**
  43175. * Defining the interface required for a (webxr) feature
  43176. */
  43177. export interface IWebXRFeature extends IDisposable {
  43178. /**
  43179. * Is this feature attached
  43180. */
  43181. attached: boolean;
  43182. /**
  43183. * Should auto-attach be disabled?
  43184. */
  43185. disableAutoAttach: boolean;
  43186. /**
  43187. * Attach the feature to the session
  43188. * Will usually be called by the features manager
  43189. *
  43190. * @param force should attachment be forced (even when already attached)
  43191. * @returns true if successful.
  43192. */
  43193. attach(force?: boolean): boolean;
  43194. /**
  43195. * Detach the feature from the session
  43196. * Will usually be called by the features manager
  43197. *
  43198. * @returns true if successful.
  43199. */
  43200. detach(): boolean;
  43201. }
  43202. /**
  43203. * A list of the currently available features without referencing them
  43204. */
  43205. export class WebXRFeatureName {
  43206. /**
  43207. * The name of the anchor system feature
  43208. */
  43209. static ANCHOR_SYSTEM: string;
  43210. /**
  43211. * The name of the background remover feature
  43212. */
  43213. static BACKGROUND_REMOVER: string;
  43214. /**
  43215. * The name of the hit test feature
  43216. */
  43217. static HIT_TEST: string;
  43218. /**
  43219. * physics impostors for xr controllers feature
  43220. */
  43221. static PHYSICS_CONTROLLERS: string;
  43222. /**
  43223. * The name of the plane detection feature
  43224. */
  43225. static PLANE_DETECTION: string;
  43226. /**
  43227. * The name of the pointer selection feature
  43228. */
  43229. static POINTER_SELECTION: string;
  43230. /**
  43231. * The name of the teleportation feature
  43232. */
  43233. static TELEPORTATION: string;
  43234. }
  43235. /**
  43236. * Defining the constructor of a feature. Used to register the modules.
  43237. */
  43238. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  43239. /**
  43240. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  43241. * It is mainly used in AR sessions.
  43242. *
  43243. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  43244. */
  43245. export class WebXRFeaturesManager implements IDisposable {
  43246. private _xrSessionManager;
  43247. private static readonly _AvailableFeatures;
  43248. private _features;
  43249. /**
  43250. * constructs a new features manages.
  43251. *
  43252. * @param _xrSessionManager an instance of WebXRSessionManager
  43253. */
  43254. constructor(_xrSessionManager: WebXRSessionManager);
  43255. /**
  43256. * Used to register a module. After calling this function a developer can use this feature in the scene.
  43257. * Mainly used internally.
  43258. *
  43259. * @param featureName the name of the feature to register
  43260. * @param constructorFunction the function used to construct the module
  43261. * @param version the (babylon) version of the module
  43262. * @param stable is that a stable version of this module
  43263. */
  43264. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  43265. /**
  43266. * Returns a constructor of a specific feature.
  43267. *
  43268. * @param featureName the name of the feature to construct
  43269. * @param version the version of the feature to load
  43270. * @param xrSessionManager the xrSessionManager. Used to construct the module
  43271. * @param options optional options provided to the module.
  43272. * @returns a function that, when called, will return a new instance of this feature
  43273. */
  43274. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  43275. /**
  43276. * Can be used to return the list of features currently registered
  43277. *
  43278. * @returns an Array of available features
  43279. */
  43280. static GetAvailableFeatures(): string[];
  43281. /**
  43282. * Gets the versions available for a specific feature
  43283. * @param featureName the name of the feature
  43284. * @returns an array with the available versions
  43285. */
  43286. static GetAvailableVersions(featureName: string): string[];
  43287. /**
  43288. * Return the latest unstable version of this feature
  43289. * @param featureName the name of the feature to search
  43290. * @returns the version number. if not found will return -1
  43291. */
  43292. static GetLatestVersionOfFeature(featureName: string): number;
  43293. /**
  43294. * Return the latest stable version of this feature
  43295. * @param featureName the name of the feature to search
  43296. * @returns the version number. if not found will return -1
  43297. */
  43298. static GetStableVersionOfFeature(featureName: string): number;
  43299. /**
  43300. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  43301. * Can be used during a session to start a feature
  43302. * @param featureName the name of feature to attach
  43303. */
  43304. attachFeature(featureName: string): void;
  43305. /**
  43306. * Can be used inside a session or when the session ends to detach a specific feature
  43307. * @param featureName the name of the feature to detach
  43308. */
  43309. detachFeature(featureName: string): void;
  43310. /**
  43311. * Used to disable an already-enabled feature
  43312. * The feature will be disposed and will be recreated once enabled.
  43313. * @param featureName the feature to disable
  43314. * @returns true if disable was successful
  43315. */
  43316. disableFeature(featureName: string | {
  43317. Name: string;
  43318. }): boolean;
  43319. /**
  43320. * dispose this features manager
  43321. */
  43322. dispose(): void;
  43323. /**
  43324. * 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.
  43325. * 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.
  43326. *
  43327. * @param featureName the name of the feature to load or the class of the feature
  43328. * @param version optional version to load. if not provided the latest version will be enabled
  43329. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  43330. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  43331. * @returns a new constructed feature or throws an error if feature not found.
  43332. */
  43333. enableFeature(featureName: string | {
  43334. Name: string;
  43335. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  43336. /**
  43337. * get the implementation of an enabled feature.
  43338. * @param featureName the name of the feature to load
  43339. * @returns the feature class, if found
  43340. */
  43341. getEnabledFeature(featureName: string): IWebXRFeature;
  43342. /**
  43343. * Get the list of enabled features
  43344. * @returns an array of enabled features
  43345. */
  43346. getEnabledFeatures(): string[];
  43347. }
  43348. }
  43349. declare module BABYLON {
  43350. /**
  43351. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  43352. * @see https://doc.babylonjs.com/how_to/webxr
  43353. */
  43354. export class WebXRExperienceHelper implements IDisposable {
  43355. private scene;
  43356. private _nonVRCamera;
  43357. private _originalSceneAutoClear;
  43358. private _supported;
  43359. /**
  43360. * Camera used to render xr content
  43361. */
  43362. camera: WebXRCamera;
  43363. /** A features manager for this xr session */
  43364. featuresManager: WebXRFeaturesManager;
  43365. /**
  43366. * Observers registered here will be triggered after the camera's initial transformation is set
  43367. * This can be used to set a different ground level or an extra rotation.
  43368. *
  43369. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  43370. * to the position set after this observable is done executing.
  43371. */
  43372. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  43373. /**
  43374. * Fires when the state of the experience helper has changed
  43375. */
  43376. onStateChangedObservable: Observable<WebXRState>;
  43377. /** Session manager used to keep track of xr session */
  43378. sessionManager: WebXRSessionManager;
  43379. /**
  43380. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43381. */
  43382. state: WebXRState;
  43383. /**
  43384. * Creates a WebXRExperienceHelper
  43385. * @param scene The scene the helper should be created in
  43386. */
  43387. private constructor();
  43388. /**
  43389. * Creates the experience helper
  43390. * @param scene the scene to attach the experience helper to
  43391. * @returns a promise for the experience helper
  43392. */
  43393. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43394. /**
  43395. * Disposes of the experience helper
  43396. */
  43397. dispose(): void;
  43398. /**
  43399. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43400. * @param sessionMode options for the XR session
  43401. * @param referenceSpaceType frame of reference of the XR session
  43402. * @param renderTarget the output canvas that will be used to enter XR mode
  43403. * @returns promise that resolves after xr mode has entered
  43404. */
  43405. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43406. /**
  43407. * Exits XR mode and returns the scene to its original state
  43408. * @returns promise that resolves after xr mode has exited
  43409. */
  43410. exitXRAsync(): Promise<void>;
  43411. private _nonXRToXRCamera;
  43412. private _setState;
  43413. }
  43414. }
  43415. declare module BABYLON {
  43416. /**
  43417. * X-Y values for axes in WebXR
  43418. */
  43419. export interface IWebXRMotionControllerAxesValue {
  43420. /**
  43421. * The value of the x axis
  43422. */
  43423. x: number;
  43424. /**
  43425. * The value of the y-axis
  43426. */
  43427. y: number;
  43428. }
  43429. /**
  43430. * changed / previous values for the values of this component
  43431. */
  43432. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43433. /**
  43434. * current (this frame) value
  43435. */
  43436. current: T;
  43437. /**
  43438. * previous (last change) value
  43439. */
  43440. previous: T;
  43441. }
  43442. /**
  43443. * Represents changes in the component between current frame and last values recorded
  43444. */
  43445. export interface IWebXRMotionControllerComponentChanges {
  43446. /**
  43447. * will be populated with previous and current values if axes changed
  43448. */
  43449. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43450. /**
  43451. * will be populated with previous and current values if pressed changed
  43452. */
  43453. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43454. /**
  43455. * will be populated with previous and current values if touched changed
  43456. */
  43457. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43458. /**
  43459. * will be populated with previous and current values if value changed
  43460. */
  43461. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43462. }
  43463. /**
  43464. * This class represents a single component (for example button or thumbstick) of a motion controller
  43465. */
  43466. export class WebXRControllerComponent implements IDisposable {
  43467. /**
  43468. * the id of this component
  43469. */
  43470. id: string;
  43471. /**
  43472. * the type of the component
  43473. */
  43474. type: MotionControllerComponentType;
  43475. private _buttonIndex;
  43476. private _axesIndices;
  43477. private _axes;
  43478. private _changes;
  43479. private _currentValue;
  43480. private _hasChanges;
  43481. private _pressed;
  43482. private _touched;
  43483. /**
  43484. * button component type
  43485. */
  43486. static BUTTON_TYPE: MotionControllerComponentType;
  43487. /**
  43488. * squeeze component type
  43489. */
  43490. static SQUEEZE_TYPE: MotionControllerComponentType;
  43491. /**
  43492. * Thumbstick component type
  43493. */
  43494. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43495. /**
  43496. * Touchpad component type
  43497. */
  43498. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43499. /**
  43500. * trigger component type
  43501. */
  43502. static TRIGGER_TYPE: MotionControllerComponentType;
  43503. /**
  43504. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43505. * the axes data changes
  43506. */
  43507. onAxisValueChangedObservable: Observable<{
  43508. x: number;
  43509. y: number;
  43510. }>;
  43511. /**
  43512. * Observers registered here will be triggered when the state of a button changes
  43513. * State change is either pressed / touched / value
  43514. */
  43515. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43516. /**
  43517. * Creates a new component for a motion controller.
  43518. * It is created by the motion controller itself
  43519. *
  43520. * @param id the id of this component
  43521. * @param type the type of the component
  43522. * @param _buttonIndex index in the buttons array of the gamepad
  43523. * @param _axesIndices indices of the values in the axes array of the gamepad
  43524. */
  43525. constructor(
  43526. /**
  43527. * the id of this component
  43528. */
  43529. id: string,
  43530. /**
  43531. * the type of the component
  43532. */
  43533. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43534. /**
  43535. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43536. */
  43537. get axes(): IWebXRMotionControllerAxesValue;
  43538. /**
  43539. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43540. */
  43541. get changes(): IWebXRMotionControllerComponentChanges;
  43542. /**
  43543. * Return whether or not the component changed the last frame
  43544. */
  43545. get hasChanges(): boolean;
  43546. /**
  43547. * is the button currently pressed
  43548. */
  43549. get pressed(): boolean;
  43550. /**
  43551. * is the button currently touched
  43552. */
  43553. get touched(): boolean;
  43554. /**
  43555. * Get the current value of this component
  43556. */
  43557. get value(): number;
  43558. /**
  43559. * Dispose this component
  43560. */
  43561. dispose(): void;
  43562. /**
  43563. * Are there axes correlating to this component
  43564. * @return true is axes data is available
  43565. */
  43566. isAxes(): boolean;
  43567. /**
  43568. * Is this component a button (hence - pressable)
  43569. * @returns true if can be pressed
  43570. */
  43571. isButton(): boolean;
  43572. /**
  43573. * update this component using the gamepad object it is in. Called on every frame
  43574. * @param nativeController the native gamepad controller object
  43575. */
  43576. update(nativeController: IMinimalMotionControllerObject): void;
  43577. }
  43578. }
  43579. declare module BABYLON {
  43580. /**
  43581. * Class used to represent data loading progression
  43582. */
  43583. export class SceneLoaderProgressEvent {
  43584. /** defines if data length to load can be evaluated */
  43585. readonly lengthComputable: boolean;
  43586. /** defines the loaded data length */
  43587. readonly loaded: number;
  43588. /** defines the data length to load */
  43589. readonly total: number;
  43590. /**
  43591. * Create a new progress event
  43592. * @param lengthComputable defines if data length to load can be evaluated
  43593. * @param loaded defines the loaded data length
  43594. * @param total defines the data length to load
  43595. */
  43596. constructor(
  43597. /** defines if data length to load can be evaluated */
  43598. lengthComputable: boolean,
  43599. /** defines the loaded data length */
  43600. loaded: number,
  43601. /** defines the data length to load */
  43602. total: number);
  43603. /**
  43604. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43605. * @param event defines the source event
  43606. * @returns a new SceneLoaderProgressEvent
  43607. */
  43608. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43609. }
  43610. /**
  43611. * Interface used by SceneLoader plugins to define supported file extensions
  43612. */
  43613. export interface ISceneLoaderPluginExtensions {
  43614. /**
  43615. * Defines the list of supported extensions
  43616. */
  43617. [extension: string]: {
  43618. isBinary: boolean;
  43619. };
  43620. }
  43621. /**
  43622. * Interface used by SceneLoader plugin factory
  43623. */
  43624. export interface ISceneLoaderPluginFactory {
  43625. /**
  43626. * Defines the name of the factory
  43627. */
  43628. name: string;
  43629. /**
  43630. * Function called to create a new plugin
  43631. * @return the new plugin
  43632. */
  43633. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43634. /**
  43635. * The callback that returns true if the data can be directly loaded.
  43636. * @param data string containing the file data
  43637. * @returns if the data can be loaded directly
  43638. */
  43639. canDirectLoad?(data: string): boolean;
  43640. }
  43641. /**
  43642. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43643. */
  43644. export interface ISceneLoaderPluginBase {
  43645. /**
  43646. * The friendly name of this plugin.
  43647. */
  43648. name: string;
  43649. /**
  43650. * The file extensions supported by this plugin.
  43651. */
  43652. extensions: string | ISceneLoaderPluginExtensions;
  43653. /**
  43654. * The callback called when loading from a url.
  43655. * @param scene scene loading this url
  43656. * @param url url to load
  43657. * @param onSuccess callback called when the file successfully loads
  43658. * @param onProgress callback called while file is loading (if the server supports this mode)
  43659. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43660. * @param onError callback called when the file fails to load
  43661. * @returns a file request object
  43662. */
  43663. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43664. /**
  43665. * The callback called when loading from a file object.
  43666. * @param scene scene loading this file
  43667. * @param file defines the file to load
  43668. * @param onSuccess defines the callback to call when data is loaded
  43669. * @param onProgress defines the callback to call during loading process
  43670. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43671. * @param onError defines the callback to call when an error occurs
  43672. * @returns a file request object
  43673. */
  43674. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43675. /**
  43676. * The callback that returns true if the data can be directly loaded.
  43677. * @param data string containing the file data
  43678. * @returns if the data can be loaded directly
  43679. */
  43680. canDirectLoad?(data: string): boolean;
  43681. /**
  43682. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43683. * @param scene scene loading this data
  43684. * @param data string containing the data
  43685. * @returns data to pass to the plugin
  43686. */
  43687. directLoad?(scene: Scene, data: string): any;
  43688. /**
  43689. * The callback that allows custom handling of the root url based on the response url.
  43690. * @param rootUrl the original root url
  43691. * @param responseURL the response url if available
  43692. * @returns the new root url
  43693. */
  43694. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43695. }
  43696. /**
  43697. * Interface used to define a SceneLoader plugin
  43698. */
  43699. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43700. /**
  43701. * Import meshes into a scene.
  43702. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43703. * @param scene The scene to import into
  43704. * @param data The data to import
  43705. * @param rootUrl The root url for scene and resources
  43706. * @param meshes The meshes array to import into
  43707. * @param particleSystems The particle systems array to import into
  43708. * @param skeletons The skeletons array to import into
  43709. * @param onError The callback when import fails
  43710. * @returns True if successful or false otherwise
  43711. */
  43712. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43713. /**
  43714. * Load into a scene.
  43715. * @param scene The scene to load into
  43716. * @param data The data to import
  43717. * @param rootUrl The root url for scene and resources
  43718. * @param onError The callback when import fails
  43719. * @returns True if successful or false otherwise
  43720. */
  43721. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43722. /**
  43723. * Load into an asset container.
  43724. * @param scene The scene to load into
  43725. * @param data The data to import
  43726. * @param rootUrl The root url for scene and resources
  43727. * @param onError The callback when import fails
  43728. * @returns The loaded asset container
  43729. */
  43730. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43731. }
  43732. /**
  43733. * Interface used to define an async SceneLoader plugin
  43734. */
  43735. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43736. /**
  43737. * Import meshes into a scene.
  43738. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43739. * @param scene The scene to import into
  43740. * @param data The data to import
  43741. * @param rootUrl The root url for scene and resources
  43742. * @param onProgress The callback when the load progresses
  43743. * @param fileName Defines the name of the file to load
  43744. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43745. */
  43746. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43747. meshes: AbstractMesh[];
  43748. particleSystems: IParticleSystem[];
  43749. skeletons: Skeleton[];
  43750. animationGroups: AnimationGroup[];
  43751. }>;
  43752. /**
  43753. * Load into a scene.
  43754. * @param scene The scene to load into
  43755. * @param data The data to import
  43756. * @param rootUrl The root url for scene and resources
  43757. * @param onProgress The callback when the load progresses
  43758. * @param fileName Defines the name of the file to load
  43759. * @returns Nothing
  43760. */
  43761. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43762. /**
  43763. * Load into an asset container.
  43764. * @param scene The scene to load into
  43765. * @param data The data to import
  43766. * @param rootUrl The root url for scene and resources
  43767. * @param onProgress The callback when the load progresses
  43768. * @param fileName Defines the name of the file to load
  43769. * @returns The loaded asset container
  43770. */
  43771. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43772. }
  43773. /**
  43774. * Mode that determines how to handle old animation groups before loading new ones.
  43775. */
  43776. export enum SceneLoaderAnimationGroupLoadingMode {
  43777. /**
  43778. * Reset all old animations to initial state then dispose them.
  43779. */
  43780. Clean = 0,
  43781. /**
  43782. * Stop all old animations.
  43783. */
  43784. Stop = 1,
  43785. /**
  43786. * Restart old animations from first frame.
  43787. */
  43788. Sync = 2,
  43789. /**
  43790. * Old animations remains untouched.
  43791. */
  43792. NoSync = 3
  43793. }
  43794. /**
  43795. * Class used to load scene from various file formats using registered plugins
  43796. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43797. */
  43798. export class SceneLoader {
  43799. /**
  43800. * No logging while loading
  43801. */
  43802. static readonly NO_LOGGING: number;
  43803. /**
  43804. * Minimal logging while loading
  43805. */
  43806. static readonly MINIMAL_LOGGING: number;
  43807. /**
  43808. * Summary logging while loading
  43809. */
  43810. static readonly SUMMARY_LOGGING: number;
  43811. /**
  43812. * Detailled logging while loading
  43813. */
  43814. static readonly DETAILED_LOGGING: number;
  43815. /**
  43816. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43817. */
  43818. static get ForceFullSceneLoadingForIncremental(): boolean;
  43819. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43820. /**
  43821. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43822. */
  43823. static get ShowLoadingScreen(): boolean;
  43824. static set ShowLoadingScreen(value: boolean);
  43825. /**
  43826. * Defines the current logging level (while loading the scene)
  43827. * @ignorenaming
  43828. */
  43829. static get loggingLevel(): number;
  43830. static set loggingLevel(value: number);
  43831. /**
  43832. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43833. */
  43834. static get CleanBoneMatrixWeights(): boolean;
  43835. static set CleanBoneMatrixWeights(value: boolean);
  43836. /**
  43837. * Event raised when a plugin is used to load a scene
  43838. */
  43839. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43840. private static _registeredPlugins;
  43841. private static _getDefaultPlugin;
  43842. private static _getPluginForExtension;
  43843. private static _getPluginForDirectLoad;
  43844. private static _getPluginForFilename;
  43845. private static _getDirectLoad;
  43846. private static _loadData;
  43847. private static _getFileInfo;
  43848. /**
  43849. * Gets a plugin that can load the given extension
  43850. * @param extension defines the extension to load
  43851. * @returns a plugin or null if none works
  43852. */
  43853. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43854. /**
  43855. * Gets a boolean indicating that the given extension can be loaded
  43856. * @param extension defines the extension to load
  43857. * @returns true if the extension is supported
  43858. */
  43859. static IsPluginForExtensionAvailable(extension: string): boolean;
  43860. /**
  43861. * Adds a new plugin to the list of registered plugins
  43862. * @param plugin defines the plugin to add
  43863. */
  43864. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43865. /**
  43866. * Import meshes into a scene
  43867. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43868. * @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)
  43869. * @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)
  43870. * @param scene the instance of BABYLON.Scene to append to
  43871. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43872. * @param onProgress a callback with a progress event for each file being loaded
  43873. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43874. * @param pluginExtension the extension used to determine the plugin
  43875. * @returns The loaded plugin
  43876. */
  43877. 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>;
  43878. /**
  43879. * Import meshes into a scene
  43880. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43881. * @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)
  43882. * @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)
  43883. * @param scene the instance of BABYLON.Scene to append to
  43884. * @param onProgress a callback with a progress event for each file being loaded
  43885. * @param pluginExtension the extension used to determine the plugin
  43886. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43887. */
  43888. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43889. meshes: AbstractMesh[];
  43890. particleSystems: IParticleSystem[];
  43891. skeletons: Skeleton[];
  43892. animationGroups: AnimationGroup[];
  43893. }>;
  43894. /**
  43895. * Load a scene
  43896. * @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)
  43897. * @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)
  43898. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43899. * @param onSuccess a callback with the scene when import succeeds
  43900. * @param onProgress a callback with a progress event for each file being loaded
  43901. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43902. * @param pluginExtension the extension used to determine the plugin
  43903. * @returns The loaded plugin
  43904. */
  43905. 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>;
  43906. /**
  43907. * Load a scene
  43908. * @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)
  43909. * @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)
  43910. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43911. * @param onProgress a callback with a progress event for each file being loaded
  43912. * @param pluginExtension the extension used to determine the plugin
  43913. * @returns The loaded scene
  43914. */
  43915. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43916. /**
  43917. * Append a scene
  43918. * @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)
  43919. * @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)
  43920. * @param scene is the instance of BABYLON.Scene to append to
  43921. * @param onSuccess a callback with the scene when import succeeds
  43922. * @param onProgress a callback with a progress event for each file being loaded
  43923. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43924. * @param pluginExtension the extension used to determine the plugin
  43925. * @returns The loaded plugin
  43926. */
  43927. 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>;
  43928. /**
  43929. * Append a scene
  43930. * @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)
  43931. * @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)
  43932. * @param scene is the instance of BABYLON.Scene to append to
  43933. * @param onProgress a callback with a progress event for each file being loaded
  43934. * @param pluginExtension the extension used to determine the plugin
  43935. * @returns The given scene
  43936. */
  43937. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43938. /**
  43939. * Load a scene into an asset container
  43940. * @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)
  43941. * @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)
  43942. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43943. * @param onSuccess a callback with the scene when import succeeds
  43944. * @param onProgress a callback with a progress event for each file being loaded
  43945. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43946. * @param pluginExtension the extension used to determine the plugin
  43947. * @returns The loaded plugin
  43948. */
  43949. 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>;
  43950. /**
  43951. * Load a scene into an asset container
  43952. * @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)
  43953. * @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)
  43954. * @param scene is the instance of Scene to append to
  43955. * @param onProgress a callback with a progress event for each file being loaded
  43956. * @param pluginExtension the extension used to determine the plugin
  43957. * @returns The loaded asset container
  43958. */
  43959. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43960. /**
  43961. * Import animations from a file into a scene
  43962. * @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)
  43963. * @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)
  43964. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43965. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43966. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43967. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43968. * @param onSuccess a callback with the scene when import succeeds
  43969. * @param onProgress a callback with a progress event for each file being loaded
  43970. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43971. */
  43972. 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;
  43973. /**
  43974. * Import animations from a file into a scene
  43975. * @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)
  43976. * @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)
  43977. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43978. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43979. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43980. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43981. * @param onSuccess a callback with the scene when import succeeds
  43982. * @param onProgress a callback with a progress event for each file being loaded
  43983. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43984. * @returns the updated scene with imported animations
  43985. */
  43986. 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>;
  43987. }
  43988. }
  43989. declare module BABYLON {
  43990. /**
  43991. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43992. */
  43993. export type MotionControllerHandness = "none" | "left" | "right";
  43994. /**
  43995. * The type of components available in motion controllers.
  43996. * This is not the name of the component.
  43997. */
  43998. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43999. /**
  44000. * The state of a controller component
  44001. */
  44002. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  44003. /**
  44004. * The schema of motion controller layout.
  44005. * No object will be initialized using this interface
  44006. * This is used just to define the profile.
  44007. */
  44008. export interface IMotionControllerLayout {
  44009. /**
  44010. * Path to load the assets. Usually relative to the base path
  44011. */
  44012. assetPath: string;
  44013. /**
  44014. * Available components (unsorted)
  44015. */
  44016. components: {
  44017. /**
  44018. * A map of component Ids
  44019. */
  44020. [componentId: string]: {
  44021. /**
  44022. * The type of input the component outputs
  44023. */
  44024. type: MotionControllerComponentType;
  44025. /**
  44026. * The indices of this component in the gamepad object
  44027. */
  44028. gamepadIndices: {
  44029. /**
  44030. * Index of button
  44031. */
  44032. button?: number;
  44033. /**
  44034. * If available, index of x-axis
  44035. */
  44036. xAxis?: number;
  44037. /**
  44038. * If available, index of y-axis
  44039. */
  44040. yAxis?: number;
  44041. };
  44042. /**
  44043. * The mesh's root node name
  44044. */
  44045. rootNodeName: string;
  44046. /**
  44047. * Animation definitions for this model
  44048. */
  44049. visualResponses: {
  44050. [stateKey: string]: {
  44051. /**
  44052. * What property will be animated
  44053. */
  44054. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  44055. /**
  44056. * What states influence this visual response
  44057. */
  44058. states: MotionControllerComponentStateType[];
  44059. /**
  44060. * Type of animation - movement or visibility
  44061. */
  44062. valueNodeProperty: "transform" | "visibility";
  44063. /**
  44064. * Base node name to move. Its position will be calculated according to the min and max nodes
  44065. */
  44066. valueNodeName?: string;
  44067. /**
  44068. * Minimum movement node
  44069. */
  44070. minNodeName?: string;
  44071. /**
  44072. * Max movement node
  44073. */
  44074. maxNodeName?: string;
  44075. };
  44076. };
  44077. /**
  44078. * If touch enabled, what is the name of node to display user feedback
  44079. */
  44080. touchPointNodeName?: string;
  44081. };
  44082. };
  44083. /**
  44084. * Is it xr standard mapping or not
  44085. */
  44086. gamepadMapping: "" | "xr-standard";
  44087. /**
  44088. * Base root node of this entire model
  44089. */
  44090. rootNodeName: string;
  44091. /**
  44092. * Defines the main button component id
  44093. */
  44094. selectComponentId: string;
  44095. }
  44096. /**
  44097. * A definition for the layout map in the input profile
  44098. */
  44099. export interface IMotionControllerLayoutMap {
  44100. /**
  44101. * Layouts with handness type as a key
  44102. */
  44103. [handness: string]: IMotionControllerLayout;
  44104. }
  44105. /**
  44106. * The XR Input profile schema
  44107. * Profiles can be found here:
  44108. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44109. */
  44110. export interface IMotionControllerProfile {
  44111. /**
  44112. * fallback profiles for this profileId
  44113. */
  44114. fallbackProfileIds: string[];
  44115. /**
  44116. * The layout map, with handness as key
  44117. */
  44118. layouts: IMotionControllerLayoutMap;
  44119. /**
  44120. * The id of this profile
  44121. * correlates to the profile(s) in the xrInput.profiles array
  44122. */
  44123. profileId: string;
  44124. }
  44125. /**
  44126. * A helper-interface for the 3 meshes needed for controller button animation
  44127. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44128. */
  44129. export interface IMotionControllerButtonMeshMap {
  44130. /**
  44131. * the mesh that defines the pressed value mesh position.
  44132. * This is used to find the max-position of this button
  44133. */
  44134. pressedMesh: AbstractMesh;
  44135. /**
  44136. * the mesh that defines the unpressed value mesh position.
  44137. * This is used to find the min (or initial) position of this button
  44138. */
  44139. unpressedMesh: AbstractMesh;
  44140. /**
  44141. * The mesh that will be changed when value changes
  44142. */
  44143. valueMesh: AbstractMesh;
  44144. }
  44145. /**
  44146. * A helper-interface for the 3 meshes needed for controller axis animation.
  44147. * This will be expanded when touchpad animations are fully supported
  44148. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44149. */
  44150. export interface IMotionControllerMeshMap {
  44151. /**
  44152. * the mesh that defines the maximum value mesh position.
  44153. */
  44154. maxMesh?: AbstractMesh;
  44155. /**
  44156. * the mesh that defines the minimum value mesh position.
  44157. */
  44158. minMesh?: AbstractMesh;
  44159. /**
  44160. * The mesh that will be changed when axis value changes
  44161. */
  44162. valueMesh: AbstractMesh;
  44163. }
  44164. /**
  44165. * The elements needed for change-detection of the gamepad objects in motion controllers
  44166. */
  44167. export interface IMinimalMotionControllerObject {
  44168. /**
  44169. * Available axes of this controller
  44170. */
  44171. axes: number[];
  44172. /**
  44173. * An array of available buttons
  44174. */
  44175. buttons: Array<{
  44176. /**
  44177. * Value of the button/trigger
  44178. */
  44179. value: number;
  44180. /**
  44181. * If the button/trigger is currently touched
  44182. */
  44183. touched: boolean;
  44184. /**
  44185. * If the button/trigger is currently pressed
  44186. */
  44187. pressed: boolean;
  44188. }>;
  44189. }
  44190. /**
  44191. * An Abstract Motion controller
  44192. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44193. * Each component has an observable to check for changes in value and state
  44194. */
  44195. export abstract class WebXRAbstractMotionController implements IDisposable {
  44196. protected scene: Scene;
  44197. protected layout: IMotionControllerLayout;
  44198. /**
  44199. * The gamepad object correlating to this controller
  44200. */
  44201. gamepadObject: IMinimalMotionControllerObject;
  44202. /**
  44203. * handness (left/right/none) of this controller
  44204. */
  44205. handness: MotionControllerHandness;
  44206. private _initComponent;
  44207. private _modelReady;
  44208. /**
  44209. * A map of components (WebXRControllerComponent) in this motion controller
  44210. * Components have a ComponentType and can also have both button and axis definitions
  44211. */
  44212. readonly components: {
  44213. [id: string]: WebXRControllerComponent;
  44214. };
  44215. /**
  44216. * Disable the model's animation. Can be set at any time.
  44217. */
  44218. disableAnimation: boolean;
  44219. /**
  44220. * Observers registered here will be triggered when the model of this controller is done loading
  44221. */
  44222. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44223. /**
  44224. * The profile id of this motion controller
  44225. */
  44226. abstract profileId: string;
  44227. /**
  44228. * The root mesh of the model. It is null if the model was not yet initialized
  44229. */
  44230. rootMesh: Nullable<AbstractMesh>;
  44231. /**
  44232. * constructs a new abstract motion controller
  44233. * @param scene the scene to which the model of the controller will be added
  44234. * @param layout The profile layout to load
  44235. * @param gamepadObject The gamepad object correlating to this controller
  44236. * @param handness handness (left/right/none) of this controller
  44237. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44238. */
  44239. constructor(scene: Scene, layout: IMotionControllerLayout,
  44240. /**
  44241. * The gamepad object correlating to this controller
  44242. */
  44243. gamepadObject: IMinimalMotionControllerObject,
  44244. /**
  44245. * handness (left/right/none) of this controller
  44246. */
  44247. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44248. /**
  44249. * Dispose this controller, the model mesh and all its components
  44250. */
  44251. dispose(): void;
  44252. /**
  44253. * Returns all components of specific type
  44254. * @param type the type to search for
  44255. * @return an array of components with this type
  44256. */
  44257. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  44258. /**
  44259. * get a component based an its component id as defined in layout.components
  44260. * @param id the id of the component
  44261. * @returns the component correlates to the id or undefined if not found
  44262. */
  44263. getComponent(id: string): WebXRControllerComponent;
  44264. /**
  44265. * Get the list of components available in this motion controller
  44266. * @returns an array of strings correlating to available components
  44267. */
  44268. getComponentIds(): string[];
  44269. /**
  44270. * Get the first component of specific type
  44271. * @param type type of component to find
  44272. * @return a controller component or null if not found
  44273. */
  44274. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  44275. /**
  44276. * Get the main (Select) component of this controller as defined in the layout
  44277. * @returns the main component of this controller
  44278. */
  44279. getMainComponent(): WebXRControllerComponent;
  44280. /**
  44281. * Loads the model correlating to this controller
  44282. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44283. * @returns A promise fulfilled with the result of the model loading
  44284. */
  44285. loadModel(): Promise<boolean>;
  44286. /**
  44287. * Update this model using the current XRFrame
  44288. * @param xrFrame the current xr frame to use and update the model
  44289. */
  44290. updateFromXRFrame(xrFrame: XRFrame): void;
  44291. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44292. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  44293. /**
  44294. * Moves the axis on the controller mesh based on its current state
  44295. * @param axis the index of the axis
  44296. * @param axisValue the value of the axis which determines the meshes new position
  44297. * @hidden
  44298. */
  44299. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  44300. /**
  44301. * Update the model itself with the current frame data
  44302. * @param xrFrame the frame to use for updating the model mesh
  44303. */
  44304. protected updateModel(xrFrame: XRFrame): void;
  44305. /**
  44306. * Get the filename and path for this controller's model
  44307. * @returns a map of filename and path
  44308. */
  44309. protected abstract _getFilenameAndPath(): {
  44310. filename: string;
  44311. path: string;
  44312. };
  44313. /**
  44314. * This function is called before the mesh is loaded. It checks for loading constraints.
  44315. * For example, this function can check if the GLB loader is available
  44316. * If this function returns false, the generic controller will be loaded instead
  44317. * @returns Is the client ready to load the mesh
  44318. */
  44319. protected abstract _getModelLoadingConstraints(): boolean;
  44320. /**
  44321. * This function will be called after the model was successfully loaded and can be used
  44322. * for mesh transformations before it is available for the user
  44323. * @param meshes the loaded meshes
  44324. */
  44325. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  44326. /**
  44327. * Set the root mesh for this controller. Important for the WebXR controller class
  44328. * @param meshes the loaded meshes
  44329. */
  44330. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  44331. /**
  44332. * A function executed each frame that updates the mesh (if needed)
  44333. * @param xrFrame the current xrFrame
  44334. */
  44335. protected abstract _updateModel(xrFrame: XRFrame): void;
  44336. private _getGenericFilenameAndPath;
  44337. private _getGenericParentMesh;
  44338. }
  44339. }
  44340. declare module BABYLON {
  44341. /**
  44342. * A generic trigger-only motion controller for WebXR
  44343. */
  44344. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  44345. /**
  44346. * Static version of the profile id of this controller
  44347. */
  44348. static ProfileId: string;
  44349. profileId: string;
  44350. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  44351. protected _getFilenameAndPath(): {
  44352. filename: string;
  44353. path: string;
  44354. };
  44355. protected _getModelLoadingConstraints(): boolean;
  44356. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  44357. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44358. protected _updateModel(): void;
  44359. }
  44360. }
  44361. declare module BABYLON {
  44362. /**
  44363. * Class containing static functions to help procedurally build meshes
  44364. */
  44365. export class SphereBuilder {
  44366. /**
  44367. * Creates a sphere mesh
  44368. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44369. * * 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`)
  44370. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44371. * * 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
  44372. * * 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)
  44373. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44374. * * 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
  44375. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44376. * @param name defines the name of the mesh
  44377. * @param options defines the options used to create the mesh
  44378. * @param scene defines the hosting scene
  44379. * @returns the sphere mesh
  44380. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44381. */
  44382. static CreateSphere(name: string, options: {
  44383. segments?: number;
  44384. diameter?: number;
  44385. diameterX?: number;
  44386. diameterY?: number;
  44387. diameterZ?: number;
  44388. arc?: number;
  44389. slice?: number;
  44390. sideOrientation?: number;
  44391. frontUVs?: Vector4;
  44392. backUVs?: Vector4;
  44393. updatable?: boolean;
  44394. }, scene?: Nullable<Scene>): Mesh;
  44395. }
  44396. }
  44397. declare module BABYLON {
  44398. /**
  44399. * A profiled motion controller has its profile loaded from an online repository.
  44400. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44401. */
  44402. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44403. private _repositoryUrl;
  44404. private _buttonMeshMapping;
  44405. private _touchDots;
  44406. /**
  44407. * The profile ID of this controller. Will be populated when the controller initializes.
  44408. */
  44409. profileId: string;
  44410. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44411. dispose(): void;
  44412. protected _getFilenameAndPath(): {
  44413. filename: string;
  44414. path: string;
  44415. };
  44416. protected _getModelLoadingConstraints(): boolean;
  44417. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44418. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44419. protected _updateModel(_xrFrame: XRFrame): void;
  44420. }
  44421. }
  44422. declare module BABYLON {
  44423. /**
  44424. * A construction function type to create a new controller based on an xrInput object
  44425. */
  44426. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44427. /**
  44428. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44429. *
  44430. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44431. * it should be replaced with auto-loaded controllers.
  44432. *
  44433. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44434. */
  44435. export class WebXRMotionControllerManager {
  44436. private static _AvailableControllers;
  44437. private static _Fallbacks;
  44438. private static _ProfileLoadingPromises;
  44439. private static _ProfilesList;
  44440. /**
  44441. * The base URL of the online controller repository. Can be changed at any time.
  44442. */
  44443. static BaseRepositoryUrl: string;
  44444. /**
  44445. * Which repository gets priority - local or online
  44446. */
  44447. static PrioritizeOnlineRepository: boolean;
  44448. /**
  44449. * Use the online repository, or use only locally-defined controllers
  44450. */
  44451. static UseOnlineRepository: boolean;
  44452. /**
  44453. * Clear the cache used for profile loading and reload when requested again
  44454. */
  44455. static ClearProfilesCache(): void;
  44456. /**
  44457. * Register the default fallbacks.
  44458. * This function is called automatically when this file is imported.
  44459. */
  44460. static DefaultFallbacks(): void;
  44461. /**
  44462. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44463. * @param profileId the profile to which a fallback needs to be found
  44464. * @return an array with corresponding fallback profiles
  44465. */
  44466. static FindFallbackWithProfileId(profileId: string): string[];
  44467. /**
  44468. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44469. * The order of search:
  44470. *
  44471. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44472. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44473. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44474. * 4) return the generic trigger controller if none were found
  44475. *
  44476. * @param xrInput the xrInput to which a new controller is initialized
  44477. * @param scene the scene to which the model will be added
  44478. * @param forceProfile force a certain profile for this controller
  44479. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44480. */
  44481. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44482. /**
  44483. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44484. *
  44485. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44486. *
  44487. * @param type the profile type to register
  44488. * @param constructFunction the function to be called when loading this profile
  44489. */
  44490. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44491. /**
  44492. * Register a fallback to a specific profile.
  44493. * @param profileId the profileId that will receive the fallbacks
  44494. * @param fallbacks A list of fallback profiles
  44495. */
  44496. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44497. /**
  44498. * Will update the list of profiles available in the repository
  44499. * @return a promise that resolves to a map of profiles available online
  44500. */
  44501. static UpdateProfilesList(): Promise<{
  44502. [profile: string]: string;
  44503. }>;
  44504. private static _LoadProfileFromRepository;
  44505. private static _LoadProfilesFromAvailableControllers;
  44506. }
  44507. }
  44508. declare module BABYLON {
  44509. /**
  44510. * Configuration options for the WebXR controller creation
  44511. */
  44512. export interface IWebXRControllerOptions {
  44513. /**
  44514. * Should the controller mesh be animated when a user interacts with it
  44515. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44516. */
  44517. disableMotionControllerAnimation?: boolean;
  44518. /**
  44519. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44520. */
  44521. doNotLoadControllerMesh?: boolean;
  44522. /**
  44523. * Force a specific controller type for this controller.
  44524. * This can be used when creating your own profile or when testing different controllers
  44525. */
  44526. forceControllerProfile?: string;
  44527. }
  44528. /**
  44529. * Represents an XR controller
  44530. */
  44531. export class WebXRInputSource {
  44532. private _scene;
  44533. /** The underlying input source for the controller */
  44534. inputSource: XRInputSource;
  44535. private _options;
  44536. private _tmpQuaternion;
  44537. private _tmpVector;
  44538. private _uniqueId;
  44539. /**
  44540. * 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
  44541. */
  44542. grip?: AbstractMesh;
  44543. /**
  44544. * If available, this is the gamepad object related to this controller.
  44545. * Using this object it is possible to get click events and trackpad changes of the
  44546. * webxr controller that is currently being used.
  44547. */
  44548. motionController?: WebXRAbstractMotionController;
  44549. /**
  44550. * Event that fires when the controller is removed/disposed.
  44551. * The object provided as event data is this controller, after associated assets were disposed.
  44552. * uniqueId is still available.
  44553. */
  44554. onDisposeObservable: Observable<WebXRInputSource>;
  44555. /**
  44556. * Will be triggered when the mesh associated with the motion controller is done loading.
  44557. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44558. * A shortened version of controller -> motion controller -> on mesh loaded.
  44559. */
  44560. onMeshLoadedObservable: Observable<AbstractMesh>;
  44561. /**
  44562. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44563. */
  44564. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44565. /**
  44566. * Pointer which can be used to select objects or attach a visible laser to
  44567. */
  44568. pointer: AbstractMesh;
  44569. /**
  44570. * Creates the controller
  44571. * @see https://doc.babylonjs.com/how_to/webxr
  44572. * @param _scene the scene which the controller should be associated to
  44573. * @param inputSource the underlying input source for the controller
  44574. * @param _options options for this controller creation
  44575. */
  44576. constructor(_scene: Scene,
  44577. /** The underlying input source for the controller */
  44578. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44579. /**
  44580. * Get this controllers unique id
  44581. */
  44582. get uniqueId(): string;
  44583. /**
  44584. * Disposes of the object
  44585. */
  44586. dispose(): void;
  44587. /**
  44588. * Gets a world space ray coming from the pointer or grip
  44589. * @param result the resulting ray
  44590. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44591. */
  44592. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44593. /**
  44594. * Updates the controller pose based on the given XRFrame
  44595. * @param xrFrame xr frame to update the pose with
  44596. * @param referenceSpace reference space to use
  44597. */
  44598. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44599. }
  44600. }
  44601. declare module BABYLON {
  44602. /**
  44603. * The schema for initialization options of the XR Input class
  44604. */
  44605. export interface IWebXRInputOptions {
  44606. /**
  44607. * If set to true no model will be automatically loaded
  44608. */
  44609. doNotLoadControllerMeshes?: boolean;
  44610. /**
  44611. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44612. * If not found, the xr input profile data will be used.
  44613. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44614. */
  44615. forceInputProfile?: string;
  44616. /**
  44617. * Do not send a request to the controller repository to load the profile.
  44618. *
  44619. * Instead, use the controllers available in babylon itself.
  44620. */
  44621. disableOnlineControllerRepository?: boolean;
  44622. /**
  44623. * A custom URL for the controllers repository
  44624. */
  44625. customControllersRepositoryURL?: string;
  44626. /**
  44627. * Should the controller model's components not move according to the user input
  44628. */
  44629. disableControllerAnimation?: boolean;
  44630. }
  44631. /**
  44632. * XR input used to track XR inputs such as controllers/rays
  44633. */
  44634. export class WebXRInput implements IDisposable {
  44635. /**
  44636. * the xr session manager for this session
  44637. */
  44638. xrSessionManager: WebXRSessionManager;
  44639. /**
  44640. * the WebXR camera for this session. Mainly used for teleportation
  44641. */
  44642. xrCamera: WebXRCamera;
  44643. private readonly options;
  44644. /**
  44645. * XR controllers being tracked
  44646. */
  44647. controllers: Array<WebXRInputSource>;
  44648. private _frameObserver;
  44649. private _sessionEndedObserver;
  44650. private _sessionInitObserver;
  44651. /**
  44652. * Event when a controller has been connected/added
  44653. */
  44654. onControllerAddedObservable: Observable<WebXRInputSource>;
  44655. /**
  44656. * Event when a controller has been removed/disconnected
  44657. */
  44658. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44659. /**
  44660. * Initializes the WebXRInput
  44661. * @param xrSessionManager the xr session manager for this session
  44662. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44663. * @param options = initialization options for this xr input
  44664. */
  44665. constructor(
  44666. /**
  44667. * the xr session manager for this session
  44668. */
  44669. xrSessionManager: WebXRSessionManager,
  44670. /**
  44671. * the WebXR camera for this session. Mainly used for teleportation
  44672. */
  44673. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44674. private _onInputSourcesChange;
  44675. private _addAndRemoveControllers;
  44676. /**
  44677. * Disposes of the object
  44678. */
  44679. dispose(): void;
  44680. }
  44681. }
  44682. declare module BABYLON {
  44683. /**
  44684. * This is the base class for all WebXR features.
  44685. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44686. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44687. */
  44688. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44689. protected _xrSessionManager: WebXRSessionManager;
  44690. private _attached;
  44691. private _removeOnDetach;
  44692. /**
  44693. * Should auto-attach be disabled?
  44694. */
  44695. disableAutoAttach: boolean;
  44696. /**
  44697. * Construct a new (abstract) WebXR feature
  44698. * @param _xrSessionManager the xr session manager for this feature
  44699. */
  44700. constructor(_xrSessionManager: WebXRSessionManager);
  44701. /**
  44702. * Is this feature attached
  44703. */
  44704. get attached(): boolean;
  44705. /**
  44706. * attach this feature
  44707. *
  44708. * @param force should attachment be forced (even when already attached)
  44709. * @returns true if successful, false is failed or already attached
  44710. */
  44711. attach(force?: boolean): boolean;
  44712. /**
  44713. * detach this feature.
  44714. *
  44715. * @returns true if successful, false if failed or already detached
  44716. */
  44717. detach(): boolean;
  44718. /**
  44719. * Dispose this feature and all of the resources attached
  44720. */
  44721. dispose(): void;
  44722. /**
  44723. * This is used to register callbacks that will automatically be removed when detach is called.
  44724. * @param observable the observable to which the observer will be attached
  44725. * @param callback the callback to register
  44726. */
  44727. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44728. /**
  44729. * Code in this function will be executed on each xrFrame received from the browser.
  44730. * This function will not execute after the feature is detached.
  44731. * @param _xrFrame the current frame
  44732. */
  44733. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44734. }
  44735. }
  44736. declare module BABYLON {
  44737. /**
  44738. * Renders a layer on top of an existing scene
  44739. */
  44740. export class UtilityLayerRenderer implements IDisposable {
  44741. /** the original scene that will be rendered on top of */
  44742. originalScene: Scene;
  44743. private _pointerCaptures;
  44744. private _lastPointerEvents;
  44745. private static _DefaultUtilityLayer;
  44746. private static _DefaultKeepDepthUtilityLayer;
  44747. private _sharedGizmoLight;
  44748. private _renderCamera;
  44749. /**
  44750. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44751. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  44752. * @returns the camera that is used when rendering the utility layer
  44753. */
  44754. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  44755. /**
  44756. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44757. * @param cam the camera that should be used when rendering the utility layer
  44758. */
  44759. setRenderCamera(cam: Nullable<Camera>): void;
  44760. /**
  44761. * @hidden
  44762. * Light which used by gizmos to get light shading
  44763. */
  44764. _getSharedGizmoLight(): HemisphericLight;
  44765. /**
  44766. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44767. */
  44768. pickUtilitySceneFirst: boolean;
  44769. /**
  44770. * 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)
  44771. */
  44772. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44773. /**
  44774. * 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)
  44775. */
  44776. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44777. /**
  44778. * The scene that is rendered on top of the original scene
  44779. */
  44780. utilityLayerScene: Scene;
  44781. /**
  44782. * If the utility layer should automatically be rendered on top of existing scene
  44783. */
  44784. shouldRender: boolean;
  44785. /**
  44786. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44787. */
  44788. onlyCheckPointerDownEvents: boolean;
  44789. /**
  44790. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44791. */
  44792. processAllEvents: boolean;
  44793. /**
  44794. * Observable raised when the pointer move from the utility layer scene to the main scene
  44795. */
  44796. onPointerOutObservable: Observable<number>;
  44797. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44798. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44799. private _afterRenderObserver;
  44800. private _sceneDisposeObserver;
  44801. private _originalPointerObserver;
  44802. /**
  44803. * Instantiates a UtilityLayerRenderer
  44804. * @param originalScene the original scene that will be rendered on top of
  44805. * @param handleEvents boolean indicating if the utility layer should handle events
  44806. */
  44807. constructor(
  44808. /** the original scene that will be rendered on top of */
  44809. originalScene: Scene, handleEvents?: boolean);
  44810. private _notifyObservers;
  44811. /**
  44812. * Renders the utility layers scene on top of the original scene
  44813. */
  44814. render(): void;
  44815. /**
  44816. * Disposes of the renderer
  44817. */
  44818. dispose(): void;
  44819. private _updateCamera;
  44820. }
  44821. }
  44822. declare module BABYLON {
  44823. /**
  44824. * Options interface for the pointer selection module
  44825. */
  44826. export interface IWebXRControllerPointerSelectionOptions {
  44827. /**
  44828. * if provided, this scene will be used to render meshes.
  44829. */
  44830. customUtilityLayerScene?: Scene;
  44831. /**
  44832. * 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)
  44833. * If not disabled, the last picked point will be used to execute a pointer up event
  44834. * If disabled, pointer up event will be triggered right after the pointer down event.
  44835. * Used in screen and gaze target ray mode only
  44836. */
  44837. disablePointerUpOnTouchOut: boolean;
  44838. /**
  44839. * For gaze mode (time to select instead of press)
  44840. */
  44841. forceGazeMode: boolean;
  44842. /**
  44843. * 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
  44844. * to start a new countdown to the pointer down event.
  44845. * Defaults to 1.
  44846. */
  44847. gazeModePointerMovedFactor?: number;
  44848. /**
  44849. * Different button type to use instead of the main component
  44850. */
  44851. overrideButtonId?: string;
  44852. /**
  44853. * use this rendering group id for the meshes (optional)
  44854. */
  44855. renderingGroupId?: number;
  44856. /**
  44857. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  44858. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44859. * 3000 means 3 seconds between pointing at something and selecting it
  44860. */
  44861. timeToSelect?: number;
  44862. /**
  44863. * Should meshes created here be added to a utility layer or the main scene
  44864. */
  44865. useUtilityLayer?: boolean;
  44866. /**
  44867. * the xr input to use with this pointer selection
  44868. */
  44869. xrInput: WebXRInput;
  44870. }
  44871. /**
  44872. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44873. */
  44874. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44875. private readonly _options;
  44876. private static _idCounter;
  44877. private _attachController;
  44878. private _controllers;
  44879. private _scene;
  44880. private _tmpVectorForPickCompare;
  44881. /**
  44882. * The module's name
  44883. */
  44884. static readonly Name: string;
  44885. /**
  44886. * The (Babylon) version of this module.
  44887. * This is an integer representing the implementation version.
  44888. * This number does not correspond to the WebXR specs version
  44889. */
  44890. static readonly Version: number;
  44891. /**
  44892. * Disable lighting on the laser pointer (so it will always be visible)
  44893. */
  44894. disablePointerLighting: boolean;
  44895. /**
  44896. * Disable lighting on the selection mesh (so it will always be visible)
  44897. */
  44898. disableSelectionMeshLighting: boolean;
  44899. /**
  44900. * Should the laser pointer be displayed
  44901. */
  44902. displayLaserPointer: boolean;
  44903. /**
  44904. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44905. */
  44906. displaySelectionMesh: boolean;
  44907. /**
  44908. * This color will be set to the laser pointer when selection is triggered
  44909. */
  44910. laserPointerPickedColor: Color3;
  44911. /**
  44912. * Default color of the laser pointer
  44913. */
  44914. lasterPointerDefaultColor: Color3;
  44915. /**
  44916. * default color of the selection ring
  44917. */
  44918. selectionMeshDefaultColor: Color3;
  44919. /**
  44920. * This color will be applied to the selection ring when selection is triggered
  44921. */
  44922. selectionMeshPickedColor: Color3;
  44923. /**
  44924. * Optional filter to be used for ray selection. This predicate shares behavior with
  44925. * scene.pointerMovePredicate which takes priority if it is also assigned.
  44926. */
  44927. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44928. /**
  44929. * constructs a new background remover module
  44930. * @param _xrSessionManager the session manager for this module
  44931. * @param _options read-only options to be used in this module
  44932. */
  44933. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44934. /**
  44935. * attach this feature
  44936. * Will usually be called by the features manager
  44937. *
  44938. * @returns true if successful.
  44939. */
  44940. attach(): boolean;
  44941. /**
  44942. * detach this feature.
  44943. * Will usually be called by the features manager
  44944. *
  44945. * @returns true if successful.
  44946. */
  44947. detach(): boolean;
  44948. /**
  44949. * Will get the mesh under a specific pointer.
  44950. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44951. * @param controllerId the controllerId to check
  44952. * @returns The mesh under pointer or null if no mesh is under the pointer
  44953. */
  44954. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44955. /**
  44956. * Get the xr controller that correlates to the pointer id in the pointer event
  44957. *
  44958. * @param id the pointer id to search for
  44959. * @returns the controller that correlates to this id or null if not found
  44960. */
  44961. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44962. protected _onXRFrame(_xrFrame: XRFrame): void;
  44963. private _attachGazeMode;
  44964. private _attachScreenRayMode;
  44965. private _attachTrackedPointerRayMode;
  44966. private _convertNormalToDirectionOfRay;
  44967. private _detachController;
  44968. private _generateNewMeshPair;
  44969. private _pickingMoved;
  44970. private _updatePointerDistance;
  44971. }
  44972. }
  44973. declare module BABYLON {
  44974. /**
  44975. * Button which can be used to enter a different mode of XR
  44976. */
  44977. export class WebXREnterExitUIButton {
  44978. /** button element */
  44979. element: HTMLElement;
  44980. /** XR initialization options for the button */
  44981. sessionMode: XRSessionMode;
  44982. /** Reference space type */
  44983. referenceSpaceType: XRReferenceSpaceType;
  44984. /**
  44985. * Creates a WebXREnterExitUIButton
  44986. * @param element button element
  44987. * @param sessionMode XR initialization session mode
  44988. * @param referenceSpaceType the type of reference space to be used
  44989. */
  44990. constructor(
  44991. /** button element */
  44992. element: HTMLElement,
  44993. /** XR initialization options for the button */
  44994. sessionMode: XRSessionMode,
  44995. /** Reference space type */
  44996. referenceSpaceType: XRReferenceSpaceType);
  44997. /**
  44998. * Extendable function which can be used to update the button's visuals when the state changes
  44999. * @param activeButton the current active button in the UI
  45000. */
  45001. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45002. }
  45003. /**
  45004. * Options to create the webXR UI
  45005. */
  45006. export class WebXREnterExitUIOptions {
  45007. /**
  45008. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45009. */
  45010. customButtons?: Array<WebXREnterExitUIButton>;
  45011. /**
  45012. * A reference space type to use when creating the default button.
  45013. * Default is local-floor
  45014. */
  45015. referenceSpaceType?: XRReferenceSpaceType;
  45016. /**
  45017. * Context to enter xr with
  45018. */
  45019. renderTarget?: Nullable<WebXRRenderTarget>;
  45020. /**
  45021. * A session mode to use when creating the default button.
  45022. * Default is immersive-vr
  45023. */
  45024. sessionMode?: XRSessionMode;
  45025. }
  45026. /**
  45027. * UI to allow the user to enter/exit XR mode
  45028. */
  45029. export class WebXREnterExitUI implements IDisposable {
  45030. private scene;
  45031. /** version of the options passed to this UI */
  45032. options: WebXREnterExitUIOptions;
  45033. private _activeButton;
  45034. private _buttons;
  45035. private _overlay;
  45036. /**
  45037. * Fired every time the active button is changed.
  45038. *
  45039. * When xr is entered via a button that launches xr that button will be the callback parameter
  45040. *
  45041. * When exiting xr the callback parameter will be null)
  45042. */
  45043. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45044. /**
  45045. *
  45046. * @param scene babylon scene object to use
  45047. * @param options (read-only) version of the options passed to this UI
  45048. */
  45049. private constructor();
  45050. /**
  45051. * Creates UI to allow the user to enter/exit XR mode
  45052. * @param scene the scene to add the ui to
  45053. * @param helper the xr experience helper to enter/exit xr with
  45054. * @param options options to configure the UI
  45055. * @returns the created ui
  45056. */
  45057. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45058. /**
  45059. * Disposes of the XR UI component
  45060. */
  45061. dispose(): void;
  45062. private _updateButtons;
  45063. }
  45064. }
  45065. declare module BABYLON {
  45066. /**
  45067. * Class containing static functions to help procedurally build meshes
  45068. */
  45069. export class LinesBuilder {
  45070. /**
  45071. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45072. * * 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
  45073. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45074. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45075. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45076. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45077. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45078. * * 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
  45079. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45081. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45082. * @param name defines the name of the new line system
  45083. * @param options defines the options used to create the line system
  45084. * @param scene defines the hosting scene
  45085. * @returns a new line system mesh
  45086. */
  45087. static CreateLineSystem(name: string, options: {
  45088. lines: Vector3[][];
  45089. updatable?: boolean;
  45090. instance?: Nullable<LinesMesh>;
  45091. colors?: Nullable<Color4[][]>;
  45092. useVertexAlpha?: boolean;
  45093. }, scene: Nullable<Scene>): LinesMesh;
  45094. /**
  45095. * Creates a line mesh
  45096. * 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
  45097. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45098. * * The parameter `points` is an array successive Vector3
  45099. * * 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
  45100. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45101. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45102. * * When updating an instance, remember that only point positions can change, not the number of points
  45103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45104. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45105. * @param name defines the name of the new line system
  45106. * @param options defines the options used to create the line system
  45107. * @param scene defines the hosting scene
  45108. * @returns a new line mesh
  45109. */
  45110. static CreateLines(name: string, options: {
  45111. points: Vector3[];
  45112. updatable?: boolean;
  45113. instance?: Nullable<LinesMesh>;
  45114. colors?: Color4[];
  45115. useVertexAlpha?: boolean;
  45116. }, scene?: Nullable<Scene>): LinesMesh;
  45117. /**
  45118. * Creates a dashed line mesh
  45119. * * 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
  45120. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45121. * * The parameter `points` is an array successive Vector3
  45122. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45123. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45124. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45125. * * 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
  45126. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45127. * * When updating an instance, remember that only point positions can change, not the number of points
  45128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45129. * @param name defines the name of the mesh
  45130. * @param options defines the options used to create the mesh
  45131. * @param scene defines the hosting scene
  45132. * @returns the dashed line mesh
  45133. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45134. */
  45135. static CreateDashedLines(name: string, options: {
  45136. points: Vector3[];
  45137. dashSize?: number;
  45138. gapSize?: number;
  45139. dashNb?: number;
  45140. updatable?: boolean;
  45141. instance?: LinesMesh;
  45142. useVertexAlpha?: boolean;
  45143. }, scene?: Nullable<Scene>): LinesMesh;
  45144. }
  45145. }
  45146. declare module BABYLON {
  45147. /**
  45148. * The options container for the teleportation module
  45149. */
  45150. export interface IWebXRTeleportationOptions {
  45151. /**
  45152. * if provided, this scene will be used to render meshes.
  45153. */
  45154. customUtilityLayerScene?: Scene;
  45155. /**
  45156. * Values to configure the default target mesh
  45157. */
  45158. defaultTargetMeshOptions?: {
  45159. /**
  45160. * Fill color of the teleportation area
  45161. */
  45162. teleportationFillColor?: string;
  45163. /**
  45164. * Border color for the teleportation area
  45165. */
  45166. teleportationBorderColor?: string;
  45167. /**
  45168. * Disable the mesh's animation sequence
  45169. */
  45170. disableAnimation?: boolean;
  45171. /**
  45172. * Disable lighting on the material or the ring and arrow
  45173. */
  45174. disableLighting?: boolean;
  45175. /**
  45176. * Override the default material of the torus and arrow
  45177. */
  45178. torusArrowMaterial?: Material;
  45179. };
  45180. /**
  45181. * A list of meshes to use as floor meshes.
  45182. * Meshes can be added and removed after initializing the feature using the
  45183. * addFloorMesh and removeFloorMesh functions
  45184. * If empty, rotation will still work
  45185. */
  45186. floorMeshes?: AbstractMesh[];
  45187. /**
  45188. * use this rendering group id for the meshes (optional)
  45189. */
  45190. renderingGroupId?: number;
  45191. /**
  45192. * Should teleportation move only to snap points
  45193. */
  45194. snapPointsOnly?: boolean;
  45195. /**
  45196. * An array of points to which the teleportation will snap to.
  45197. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  45198. */
  45199. snapPositions?: Vector3[];
  45200. /**
  45201. * How close should the teleportation ray be in order to snap to position.
  45202. * Default to 0.8 units (meters)
  45203. */
  45204. snapToPositionRadius?: number;
  45205. /**
  45206. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  45207. * If you want to support rotation, make sure your mesh has a direction indicator.
  45208. *
  45209. * When left untouched, the default mesh will be initialized.
  45210. */
  45211. teleportationTargetMesh?: AbstractMesh;
  45212. /**
  45213. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  45214. */
  45215. timeToTeleport?: number;
  45216. /**
  45217. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  45218. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  45219. */
  45220. useMainComponentOnly?: boolean;
  45221. /**
  45222. * Should meshes created here be added to a utility layer or the main scene
  45223. */
  45224. useUtilityLayer?: boolean;
  45225. /**
  45226. * Babylon XR Input class for controller
  45227. */
  45228. xrInput: WebXRInput;
  45229. }
  45230. /**
  45231. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  45232. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  45233. * the input of the attached controllers.
  45234. */
  45235. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  45236. private _options;
  45237. private _controllers;
  45238. private _currentTeleportationControllerId;
  45239. private _floorMeshes;
  45240. private _quadraticBezierCurve;
  45241. private _selectionFeature;
  45242. private _snapToPositions;
  45243. private _snappedToPoint;
  45244. private _teleportationRingMaterial?;
  45245. private _tmpRay;
  45246. private _tmpVector;
  45247. /**
  45248. * The module's name
  45249. */
  45250. static readonly Name: string;
  45251. /**
  45252. * The (Babylon) version of this module.
  45253. * This is an integer representing the implementation version.
  45254. * This number does not correspond to the webxr specs version
  45255. */
  45256. static readonly Version: number;
  45257. /**
  45258. * Is movement backwards enabled
  45259. */
  45260. backwardsMovementEnabled: boolean;
  45261. /**
  45262. * Distance to travel when moving backwards
  45263. */
  45264. backwardsTeleportationDistance: number;
  45265. /**
  45266. * The distance from the user to the inspection point in the direction of the controller
  45267. * A higher number will allow the user to move further
  45268. * defaults to 5 (meters, in xr units)
  45269. */
  45270. parabolicCheckRadius: number;
  45271. /**
  45272. * Should the module support parabolic ray on top of direct ray
  45273. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  45274. * Very helpful when moving between floors / different heights
  45275. */
  45276. parabolicRayEnabled: boolean;
  45277. /**
  45278. * How much rotation should be applied when rotating right and left
  45279. */
  45280. rotationAngle: number;
  45281. /**
  45282. * Is rotation enabled when moving forward?
  45283. * Disabling this feature will prevent the user from deciding the direction when teleporting
  45284. */
  45285. rotationEnabled: boolean;
  45286. /**
  45287. * constructs a new anchor system
  45288. * @param _xrSessionManager an instance of WebXRSessionManager
  45289. * @param _options configuration object for this feature
  45290. */
  45291. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  45292. /**
  45293. * Get the snapPointsOnly flag
  45294. */
  45295. get snapPointsOnly(): boolean;
  45296. /**
  45297. * Sets the snapPointsOnly flag
  45298. * @param snapToPoints should teleportation be exclusively to snap points
  45299. */
  45300. set snapPointsOnly(snapToPoints: boolean);
  45301. /**
  45302. * Add a new mesh to the floor meshes array
  45303. * @param mesh the mesh to use as floor mesh
  45304. */
  45305. addFloorMesh(mesh: AbstractMesh): void;
  45306. /**
  45307. * Add a new snap-to point to fix teleportation to this position
  45308. * @param newSnapPoint The new Snap-To point
  45309. */
  45310. addSnapPoint(newSnapPoint: Vector3): void;
  45311. attach(): boolean;
  45312. detach(): boolean;
  45313. dispose(): void;
  45314. /**
  45315. * Remove a mesh from the floor meshes array
  45316. * @param mesh the mesh to remove
  45317. */
  45318. removeFloorMesh(mesh: AbstractMesh): void;
  45319. /**
  45320. * Remove a mesh from the floor meshes array using its name
  45321. * @param name the mesh name to remove
  45322. */
  45323. removeFloorMeshByName(name: string): void;
  45324. /**
  45325. * 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
  45326. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  45327. * @returns was the point found and removed or not
  45328. */
  45329. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  45330. /**
  45331. * This function sets a selection feature that will be disabled when
  45332. * the forward ray is shown and will be reattached when hidden.
  45333. * This is used to remove the selection rays when moving.
  45334. * @param selectionFeature the feature to disable when forward movement is enabled
  45335. */
  45336. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  45337. protected _onXRFrame(_xrFrame: XRFrame): void;
  45338. private _attachController;
  45339. private _createDefaultTargetMesh;
  45340. private _detachController;
  45341. private _findClosestSnapPointWithRadius;
  45342. private _setTargetMeshPosition;
  45343. private _setTargetMeshVisibility;
  45344. private _showParabolicPath;
  45345. private _teleportForward;
  45346. }
  45347. }
  45348. declare module BABYLON {
  45349. /**
  45350. * Options for the default xr helper
  45351. */
  45352. export class WebXRDefaultExperienceOptions {
  45353. /**
  45354. * Enable or disable default UI to enter XR
  45355. */
  45356. disableDefaultUI?: boolean;
  45357. /**
  45358. * Should teleportation not initialize. defaults to false.
  45359. */
  45360. disableTeleportation?: boolean;
  45361. /**
  45362. * Floor meshes that will be used for teleport
  45363. */
  45364. floorMeshes?: Array<AbstractMesh>;
  45365. /**
  45366. * If set to true, the first frame will not be used to reset position
  45367. * The first frame is mainly used when copying transformation from the old camera
  45368. * Mainly used in AR
  45369. */
  45370. ignoreNativeCameraTransformation?: boolean;
  45371. /**
  45372. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45373. */
  45374. inputOptions?: IWebXRInputOptions;
  45375. /**
  45376. * optional configuration for the output canvas
  45377. */
  45378. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45379. /**
  45380. * optional UI options. This can be used among other to change session mode and reference space type
  45381. */
  45382. uiOptions?: WebXREnterExitUIOptions;
  45383. /**
  45384. * When loading teleportation and pointer select, use stable versions instead of latest.
  45385. */
  45386. useStablePlugins?: boolean;
  45387. }
  45388. /**
  45389. * Default experience which provides a similar setup to the previous webVRExperience
  45390. */
  45391. export class WebXRDefaultExperience {
  45392. /**
  45393. * Base experience
  45394. */
  45395. baseExperience: WebXRExperienceHelper;
  45396. /**
  45397. * Enables ui for entering/exiting xr
  45398. */
  45399. enterExitUI: WebXREnterExitUI;
  45400. /**
  45401. * Input experience extension
  45402. */
  45403. input: WebXRInput;
  45404. /**
  45405. * Enables laser pointer and selection
  45406. */
  45407. pointerSelection: WebXRControllerPointerSelection;
  45408. /**
  45409. * Default target xr should render to
  45410. */
  45411. renderTarget: WebXRRenderTarget;
  45412. /**
  45413. * Enables teleportation
  45414. */
  45415. teleportation: WebXRMotionControllerTeleportation;
  45416. private constructor();
  45417. /**
  45418. * Creates the default xr experience
  45419. * @param scene scene
  45420. * @param options options for basic configuration
  45421. * @returns resulting WebXRDefaultExperience
  45422. */
  45423. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45424. /**
  45425. * DIsposes of the experience helper
  45426. */
  45427. dispose(): void;
  45428. }
  45429. }
  45430. declare module BABYLON {
  45431. /**
  45432. * Options to modify the vr teleportation behavior.
  45433. */
  45434. export interface VRTeleportationOptions {
  45435. /**
  45436. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45437. */
  45438. floorMeshName?: string;
  45439. /**
  45440. * A list of meshes to be used as the teleportation floor. (default: empty)
  45441. */
  45442. floorMeshes?: Mesh[];
  45443. /**
  45444. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45445. */
  45446. teleportationMode?: number;
  45447. /**
  45448. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45449. */
  45450. teleportationTime?: number;
  45451. /**
  45452. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45453. */
  45454. teleportationSpeed?: number;
  45455. /**
  45456. * The easing function used in the animation or null for Linear. (default CircleEase)
  45457. */
  45458. easingFunction?: EasingFunction;
  45459. }
  45460. /**
  45461. * Options to modify the vr experience helper's behavior.
  45462. */
  45463. export interface VRExperienceHelperOptions extends WebVROptions {
  45464. /**
  45465. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45466. */
  45467. createDeviceOrientationCamera?: boolean;
  45468. /**
  45469. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45470. */
  45471. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45472. /**
  45473. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45474. */
  45475. laserToggle?: boolean;
  45476. /**
  45477. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45478. */
  45479. floorMeshes?: Mesh[];
  45480. /**
  45481. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45482. */
  45483. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45484. /**
  45485. * Defines if WebXR should be used instead of WebVR (if available)
  45486. */
  45487. useXR?: boolean;
  45488. }
  45489. /**
  45490. * Event containing information after VR has been entered
  45491. */
  45492. export class OnAfterEnteringVRObservableEvent {
  45493. /**
  45494. * If entering vr was successful
  45495. */
  45496. success: boolean;
  45497. }
  45498. /**
  45499. * Helps to quickly add VR support to an existing scene.
  45500. * See http://doc.babylonjs.com/how_to/webvr_helper
  45501. */
  45502. export class VRExperienceHelper {
  45503. /** Options to modify the vr experience helper's behavior. */
  45504. webVROptions: VRExperienceHelperOptions;
  45505. private _scene;
  45506. private _position;
  45507. private _btnVR;
  45508. private _btnVRDisplayed;
  45509. private _webVRsupported;
  45510. private _webVRready;
  45511. private _webVRrequesting;
  45512. private _webVRpresenting;
  45513. private _hasEnteredVR;
  45514. private _fullscreenVRpresenting;
  45515. private _inputElement;
  45516. private _webVRCamera;
  45517. private _vrDeviceOrientationCamera;
  45518. private _deviceOrientationCamera;
  45519. private _existingCamera;
  45520. private _onKeyDown;
  45521. private _onVrDisplayPresentChange;
  45522. private _onVRDisplayChanged;
  45523. private _onVRRequestPresentStart;
  45524. private _onVRRequestPresentComplete;
  45525. /**
  45526. * 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)
  45527. */
  45528. enableGazeEvenWhenNoPointerLock: boolean;
  45529. /**
  45530. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45531. */
  45532. exitVROnDoubleTap: boolean;
  45533. /**
  45534. * Observable raised right before entering VR.
  45535. */
  45536. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45537. /**
  45538. * Observable raised when entering VR has completed.
  45539. */
  45540. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45541. /**
  45542. * Observable raised when exiting VR.
  45543. */
  45544. onExitingVRObservable: Observable<VRExperienceHelper>;
  45545. /**
  45546. * Observable raised when controller mesh is loaded.
  45547. */
  45548. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45549. /** Return this.onEnteringVRObservable
  45550. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45551. */
  45552. get onEnteringVR(): Observable<VRExperienceHelper>;
  45553. /** Return this.onExitingVRObservable
  45554. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45555. */
  45556. get onExitingVR(): Observable<VRExperienceHelper>;
  45557. /** Return this.onControllerMeshLoadedObservable
  45558. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45559. */
  45560. get onControllerMeshLoaded(): Observable<WebVRController>;
  45561. private _rayLength;
  45562. private _useCustomVRButton;
  45563. private _teleportationRequested;
  45564. private _teleportActive;
  45565. private _floorMeshName;
  45566. private _floorMeshesCollection;
  45567. private _teleportationMode;
  45568. private _teleportationTime;
  45569. private _teleportationSpeed;
  45570. private _teleportationEasing;
  45571. private _rotationAllowed;
  45572. private _teleportBackwardsVector;
  45573. private _teleportationTarget;
  45574. private _isDefaultTeleportationTarget;
  45575. private _postProcessMove;
  45576. private _teleportationFillColor;
  45577. private _teleportationBorderColor;
  45578. private _rotationAngle;
  45579. private _haloCenter;
  45580. private _cameraGazer;
  45581. private _padSensibilityUp;
  45582. private _padSensibilityDown;
  45583. private _leftController;
  45584. private _rightController;
  45585. private _gazeColor;
  45586. private _laserColor;
  45587. private _pickedLaserColor;
  45588. private _pickedGazeColor;
  45589. /**
  45590. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45591. */
  45592. onNewMeshSelected: Observable<AbstractMesh>;
  45593. /**
  45594. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45595. * This observable will provide the mesh and the controller used to select the mesh
  45596. */
  45597. onMeshSelectedWithController: Observable<{
  45598. mesh: AbstractMesh;
  45599. controller: WebVRController;
  45600. }>;
  45601. /**
  45602. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45603. */
  45604. onNewMeshPicked: Observable<PickingInfo>;
  45605. private _circleEase;
  45606. /**
  45607. * Observable raised before camera teleportation
  45608. */
  45609. onBeforeCameraTeleport: Observable<Vector3>;
  45610. /**
  45611. * Observable raised after camera teleportation
  45612. */
  45613. onAfterCameraTeleport: Observable<Vector3>;
  45614. /**
  45615. * Observable raised when current selected mesh gets unselected
  45616. */
  45617. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45618. private _raySelectionPredicate;
  45619. /**
  45620. * To be optionaly changed by user to define custom ray selection
  45621. */
  45622. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45623. /**
  45624. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45625. */
  45626. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45627. /**
  45628. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45629. */
  45630. teleportationEnabled: boolean;
  45631. private _defaultHeight;
  45632. private _teleportationInitialized;
  45633. private _interactionsEnabled;
  45634. private _interactionsRequested;
  45635. private _displayGaze;
  45636. private _displayLaserPointer;
  45637. /**
  45638. * The mesh used to display where the user is going to teleport.
  45639. */
  45640. get teleportationTarget(): Mesh;
  45641. /**
  45642. * Sets the mesh to be used to display where the user is going to teleport.
  45643. */
  45644. set teleportationTarget(value: Mesh);
  45645. /**
  45646. * 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
  45647. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45648. * See http://doc.babylonjs.com/resources/baking_transformations
  45649. */
  45650. get gazeTrackerMesh(): Mesh;
  45651. set gazeTrackerMesh(value: Mesh);
  45652. /**
  45653. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45654. */
  45655. updateGazeTrackerScale: boolean;
  45656. /**
  45657. * If the gaze trackers color should be updated when selecting meshes
  45658. */
  45659. updateGazeTrackerColor: boolean;
  45660. /**
  45661. * If the controller laser color should be updated when selecting meshes
  45662. */
  45663. updateControllerLaserColor: boolean;
  45664. /**
  45665. * The gaze tracking mesh corresponding to the left controller
  45666. */
  45667. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45668. /**
  45669. * The gaze tracking mesh corresponding to the right controller
  45670. */
  45671. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45672. /**
  45673. * If the ray of the gaze should be displayed.
  45674. */
  45675. get displayGaze(): boolean;
  45676. /**
  45677. * Sets if the ray of the gaze should be displayed.
  45678. */
  45679. set displayGaze(value: boolean);
  45680. /**
  45681. * If the ray of the LaserPointer should be displayed.
  45682. */
  45683. get displayLaserPointer(): boolean;
  45684. /**
  45685. * Sets if the ray of the LaserPointer should be displayed.
  45686. */
  45687. set displayLaserPointer(value: boolean);
  45688. /**
  45689. * The deviceOrientationCamera used as the camera when not in VR.
  45690. */
  45691. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45692. /**
  45693. * Based on the current WebVR support, returns the current VR camera used.
  45694. */
  45695. get currentVRCamera(): Nullable<Camera>;
  45696. /**
  45697. * The webVRCamera which is used when in VR.
  45698. */
  45699. get webVRCamera(): WebVRFreeCamera;
  45700. /**
  45701. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45702. */
  45703. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45704. /**
  45705. * The html button that is used to trigger entering into VR.
  45706. */
  45707. get vrButton(): Nullable<HTMLButtonElement>;
  45708. private get _teleportationRequestInitiated();
  45709. /**
  45710. * Defines whether or not Pointer lock should be requested when switching to
  45711. * full screen.
  45712. */
  45713. requestPointerLockOnFullScreen: boolean;
  45714. /**
  45715. * If asking to force XR, this will be populated with the default xr experience
  45716. */
  45717. xr: WebXRDefaultExperience;
  45718. /**
  45719. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45720. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45721. */
  45722. xrTestDone: boolean;
  45723. /**
  45724. * Instantiates a VRExperienceHelper.
  45725. * Helps to quickly add VR support to an existing scene.
  45726. * @param scene The scene the VRExperienceHelper belongs to.
  45727. * @param webVROptions Options to modify the vr experience helper's behavior.
  45728. */
  45729. constructor(scene: Scene,
  45730. /** Options to modify the vr experience helper's behavior. */
  45731. webVROptions?: VRExperienceHelperOptions);
  45732. private completeVRInit;
  45733. private _onDefaultMeshLoaded;
  45734. private _onResize;
  45735. private _onFullscreenChange;
  45736. /**
  45737. * Gets a value indicating if we are currently in VR mode.
  45738. */
  45739. get isInVRMode(): boolean;
  45740. private onVrDisplayPresentChange;
  45741. private onVRDisplayChanged;
  45742. private moveButtonToBottomRight;
  45743. private displayVRButton;
  45744. private updateButtonVisibility;
  45745. private _cachedAngularSensibility;
  45746. /**
  45747. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45748. * Otherwise, will use the fullscreen API.
  45749. */
  45750. enterVR(): void;
  45751. /**
  45752. * Attempt to exit VR, or fullscreen.
  45753. */
  45754. exitVR(): void;
  45755. /**
  45756. * The position of the vr experience helper.
  45757. */
  45758. get position(): Vector3;
  45759. /**
  45760. * Sets the position of the vr experience helper.
  45761. */
  45762. set position(value: Vector3);
  45763. /**
  45764. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45765. */
  45766. enableInteractions(): void;
  45767. private get _noControllerIsActive();
  45768. private beforeRender;
  45769. private _isTeleportationFloor;
  45770. /**
  45771. * Adds a floor mesh to be used for teleportation.
  45772. * @param floorMesh the mesh to be used for teleportation.
  45773. */
  45774. addFloorMesh(floorMesh: Mesh): void;
  45775. /**
  45776. * Removes a floor mesh from being used for teleportation.
  45777. * @param floorMesh the mesh to be removed.
  45778. */
  45779. removeFloorMesh(floorMesh: Mesh): void;
  45780. /**
  45781. * Enables interactions and teleportation using the VR controllers and gaze.
  45782. * @param vrTeleportationOptions options to modify teleportation behavior.
  45783. */
  45784. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45785. private _onNewGamepadConnected;
  45786. private _tryEnableInteractionOnController;
  45787. private _onNewGamepadDisconnected;
  45788. private _enableInteractionOnController;
  45789. private _checkTeleportWithRay;
  45790. private _checkRotate;
  45791. private _checkTeleportBackwards;
  45792. private _enableTeleportationOnController;
  45793. private _createTeleportationCircles;
  45794. private _displayTeleportationTarget;
  45795. private _hideTeleportationTarget;
  45796. private _rotateCamera;
  45797. private _moveTeleportationSelectorTo;
  45798. private _workingVector;
  45799. private _workingQuaternion;
  45800. private _workingMatrix;
  45801. /**
  45802. * Time Constant Teleportation Mode
  45803. */
  45804. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45805. /**
  45806. * Speed Constant Teleportation Mode
  45807. */
  45808. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45809. /**
  45810. * Teleports the users feet to the desired location
  45811. * @param location The location where the user's feet should be placed
  45812. */
  45813. teleportCamera(location: Vector3): void;
  45814. private _convertNormalToDirectionOfRay;
  45815. private _castRayAndSelectObject;
  45816. private _notifySelectedMeshUnselected;
  45817. /**
  45818. * Permanently set new colors for the laser pointer
  45819. * @param color the new laser color
  45820. * @param pickedColor the new laser color when picked mesh detected
  45821. */
  45822. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45823. /**
  45824. * Set lighting enabled / disabled on the laser pointer of both controllers
  45825. * @param enabled should the lighting be enabled on the laser pointer
  45826. */
  45827. setLaserLightingState(enabled?: boolean): void;
  45828. /**
  45829. * Permanently set new colors for the gaze pointer
  45830. * @param color the new gaze color
  45831. * @param pickedColor the new gaze color when picked mesh detected
  45832. */
  45833. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45834. /**
  45835. * Sets the color of the laser ray from the vr controllers.
  45836. * @param color new color for the ray.
  45837. */
  45838. changeLaserColor(color: Color3): void;
  45839. /**
  45840. * Sets the color of the ray from the vr headsets gaze.
  45841. * @param color new color for the ray.
  45842. */
  45843. changeGazeColor(color: Color3): void;
  45844. /**
  45845. * Exits VR and disposes of the vr experience helper
  45846. */
  45847. dispose(): void;
  45848. /**
  45849. * Gets the name of the VRExperienceHelper class
  45850. * @returns "VRExperienceHelper"
  45851. */
  45852. getClassName(): string;
  45853. }
  45854. }
  45855. declare module BABYLON {
  45856. /**
  45857. * Contains an array of blocks representing the octree
  45858. */
  45859. export interface IOctreeContainer<T> {
  45860. /**
  45861. * Blocks within the octree
  45862. */
  45863. blocks: Array<OctreeBlock<T>>;
  45864. }
  45865. /**
  45866. * Class used to store a cell in an octree
  45867. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45868. */
  45869. export class OctreeBlock<T> {
  45870. /**
  45871. * Gets the content of the current block
  45872. */
  45873. entries: T[];
  45874. /**
  45875. * Gets the list of block children
  45876. */
  45877. blocks: Array<OctreeBlock<T>>;
  45878. private _depth;
  45879. private _maxDepth;
  45880. private _capacity;
  45881. private _minPoint;
  45882. private _maxPoint;
  45883. private _boundingVectors;
  45884. private _creationFunc;
  45885. /**
  45886. * Creates a new block
  45887. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45888. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45889. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45890. * @param depth defines the current depth of this block in the octree
  45891. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45892. * @param creationFunc defines a callback to call when an element is added to the block
  45893. */
  45894. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45895. /**
  45896. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45897. */
  45898. get capacity(): number;
  45899. /**
  45900. * Gets the minimum vector (in world space) of the block's bounding box
  45901. */
  45902. get minPoint(): Vector3;
  45903. /**
  45904. * Gets the maximum vector (in world space) of the block's bounding box
  45905. */
  45906. get maxPoint(): Vector3;
  45907. /**
  45908. * Add a new element to this block
  45909. * @param entry defines the element to add
  45910. */
  45911. addEntry(entry: T): void;
  45912. /**
  45913. * Remove an element from this block
  45914. * @param entry defines the element to remove
  45915. */
  45916. removeEntry(entry: T): void;
  45917. /**
  45918. * Add an array of elements to this block
  45919. * @param entries defines the array of elements to add
  45920. */
  45921. addEntries(entries: T[]): void;
  45922. /**
  45923. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45924. * @param frustumPlanes defines the frustum planes to test
  45925. * @param selection defines the array to store current content if selection is positive
  45926. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45927. */
  45928. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45929. /**
  45930. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45931. * @param sphereCenter defines the bounding sphere center
  45932. * @param sphereRadius defines the bounding sphere radius
  45933. * @param selection defines the array to store current content if selection is positive
  45934. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45935. */
  45936. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45937. /**
  45938. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45939. * @param ray defines the ray to test with
  45940. * @param selection defines the array to store current content if selection is positive
  45941. */
  45942. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45943. /**
  45944. * Subdivide the content into child blocks (this block will then be empty)
  45945. */
  45946. createInnerBlocks(): void;
  45947. /**
  45948. * @hidden
  45949. */
  45950. 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;
  45951. }
  45952. }
  45953. declare module BABYLON {
  45954. /**
  45955. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45956. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45957. */
  45958. export class Octree<T> {
  45959. /** 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.) */
  45960. maxDepth: number;
  45961. /**
  45962. * Blocks within the octree containing objects
  45963. */
  45964. blocks: Array<OctreeBlock<T>>;
  45965. /**
  45966. * Content stored in the octree
  45967. */
  45968. dynamicContent: T[];
  45969. private _maxBlockCapacity;
  45970. private _selectionContent;
  45971. private _creationFunc;
  45972. /**
  45973. * Creates a octree
  45974. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45975. * @param creationFunc function to be used to instatiate the octree
  45976. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45977. * @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.)
  45978. */
  45979. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45980. /** 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.) */
  45981. maxDepth?: number);
  45982. /**
  45983. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45984. * @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);
  45985. * @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);
  45986. * @param entries meshes to be added to the octree blocks
  45987. */
  45988. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45989. /**
  45990. * Adds a mesh to the octree
  45991. * @param entry Mesh to add to the octree
  45992. */
  45993. addMesh(entry: T): void;
  45994. /**
  45995. * Remove an element from the octree
  45996. * @param entry defines the element to remove
  45997. */
  45998. removeMesh(entry: T): void;
  45999. /**
  46000. * Selects an array of meshes within the frustum
  46001. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46002. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46003. * @returns array of meshes within the frustum
  46004. */
  46005. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46006. /**
  46007. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46008. * @param sphereCenter defines the bounding sphere center
  46009. * @param sphereRadius defines the bounding sphere radius
  46010. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46011. * @returns an array of objects that intersect the sphere
  46012. */
  46013. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46014. /**
  46015. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46016. * @param ray defines the ray to test with
  46017. * @returns array of intersected objects
  46018. */
  46019. intersectsRay(ray: Ray): SmartArray<T>;
  46020. /**
  46021. * Adds a mesh into the octree block if it intersects the block
  46022. */
  46023. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46024. /**
  46025. * Adds a submesh into the octree block if it intersects the block
  46026. */
  46027. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46028. }
  46029. }
  46030. declare module BABYLON {
  46031. interface Scene {
  46032. /**
  46033. * @hidden
  46034. * Backing Filed
  46035. */
  46036. _selectionOctree: Octree<AbstractMesh>;
  46037. /**
  46038. * Gets the octree used to boost mesh selection (picking)
  46039. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46040. */
  46041. selectionOctree: Octree<AbstractMesh>;
  46042. /**
  46043. * Creates or updates the octree used to boost selection (picking)
  46044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46045. * @param maxCapacity defines the maximum capacity per leaf
  46046. * @param maxDepth defines the maximum depth of the octree
  46047. * @returns an octree of AbstractMesh
  46048. */
  46049. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46050. }
  46051. interface AbstractMesh {
  46052. /**
  46053. * @hidden
  46054. * Backing Field
  46055. */
  46056. _submeshesOctree: Octree<SubMesh>;
  46057. /**
  46058. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46059. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46060. * @param maxCapacity defines the maximum size of each block (64 by default)
  46061. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46062. * @returns the new octree
  46063. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46064. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46065. */
  46066. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46067. }
  46068. /**
  46069. * Defines the octree scene component responsible to manage any octrees
  46070. * in a given scene.
  46071. */
  46072. export class OctreeSceneComponent {
  46073. /**
  46074. * The component name help to identify the component in the list of scene components.
  46075. */
  46076. readonly name: string;
  46077. /**
  46078. * The scene the component belongs to.
  46079. */
  46080. scene: Scene;
  46081. /**
  46082. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46083. */
  46084. readonly checksIsEnabled: boolean;
  46085. /**
  46086. * Creates a new instance of the component for the given scene
  46087. * @param scene Defines the scene to register the component in
  46088. */
  46089. constructor(scene: Scene);
  46090. /**
  46091. * Registers the component in a given scene
  46092. */
  46093. register(): void;
  46094. /**
  46095. * Return the list of active meshes
  46096. * @returns the list of active meshes
  46097. */
  46098. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46099. /**
  46100. * Return the list of active sub meshes
  46101. * @param mesh The mesh to get the candidates sub meshes from
  46102. * @returns the list of active sub meshes
  46103. */
  46104. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46105. private _tempRay;
  46106. /**
  46107. * Return the list of sub meshes intersecting with a given local ray
  46108. * @param mesh defines the mesh to find the submesh for
  46109. * @param localRay defines the ray in local space
  46110. * @returns the list of intersecting sub meshes
  46111. */
  46112. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46113. /**
  46114. * Return the list of sub meshes colliding with a collider
  46115. * @param mesh defines the mesh to find the submesh for
  46116. * @param collider defines the collider to evaluate the collision against
  46117. * @returns the list of colliding sub meshes
  46118. */
  46119. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46120. /**
  46121. * Rebuilds the elements related to this component in case of
  46122. * context lost for instance.
  46123. */
  46124. rebuild(): void;
  46125. /**
  46126. * Disposes the component and the associated ressources.
  46127. */
  46128. dispose(): void;
  46129. }
  46130. }
  46131. declare module BABYLON {
  46132. /**
  46133. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  46134. */
  46135. export class Gizmo implements IDisposable {
  46136. /** The utility layer the gizmo will be added to */
  46137. gizmoLayer: UtilityLayerRenderer;
  46138. /**
  46139. * The root mesh of the gizmo
  46140. */
  46141. _rootMesh: Mesh;
  46142. private _attachedMesh;
  46143. /**
  46144. * Ratio for the scale of the gizmo (Default: 1)
  46145. */
  46146. scaleRatio: number;
  46147. /**
  46148. * If a custom mesh has been set (Default: false)
  46149. */
  46150. protected _customMeshSet: boolean;
  46151. /**
  46152. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  46153. * * When set, interactions will be enabled
  46154. */
  46155. get attachedMesh(): Nullable<AbstractMesh>;
  46156. set attachedMesh(value: Nullable<AbstractMesh>);
  46157. /**
  46158. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46159. * @param mesh The mesh to replace the default mesh of the gizmo
  46160. */
  46161. setCustomMesh(mesh: Mesh): void;
  46162. /**
  46163. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  46164. */
  46165. updateGizmoRotationToMatchAttachedMesh: boolean;
  46166. /**
  46167. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  46168. */
  46169. updateGizmoPositionToMatchAttachedMesh: boolean;
  46170. /**
  46171. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  46172. */
  46173. updateScale: boolean;
  46174. protected _interactionsEnabled: boolean;
  46175. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46176. private _beforeRenderObserver;
  46177. private _tempVector;
  46178. /**
  46179. * Creates a gizmo
  46180. * @param gizmoLayer The utility layer the gizmo will be added to
  46181. */
  46182. constructor(
  46183. /** The utility layer the gizmo will be added to */
  46184. gizmoLayer?: UtilityLayerRenderer);
  46185. /**
  46186. * Updates the gizmo to match the attached mesh's position/rotation
  46187. */
  46188. protected _update(): void;
  46189. /**
  46190. * Disposes of the gizmo
  46191. */
  46192. dispose(): void;
  46193. }
  46194. }
  46195. declare module BABYLON {
  46196. /**
  46197. * Single plane drag gizmo
  46198. */
  46199. export class PlaneDragGizmo extends Gizmo {
  46200. /**
  46201. * Drag behavior responsible for the gizmos dragging interactions
  46202. */
  46203. dragBehavior: PointerDragBehavior;
  46204. private _pointerObserver;
  46205. /**
  46206. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46207. */
  46208. snapDistance: number;
  46209. /**
  46210. * Event that fires each time the gizmo snaps to a new location.
  46211. * * snapDistance is the the change in distance
  46212. */
  46213. onSnapObservable: Observable<{
  46214. snapDistance: number;
  46215. }>;
  46216. private _plane;
  46217. private _coloredMaterial;
  46218. private _hoverMaterial;
  46219. private _isEnabled;
  46220. private _parent;
  46221. /** @hidden */
  46222. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  46223. /** @hidden */
  46224. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46225. /**
  46226. * Creates a PlaneDragGizmo
  46227. * @param gizmoLayer The utility layer the gizmo will be added to
  46228. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  46229. * @param color The color of the gizmo
  46230. */
  46231. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46232. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46233. /**
  46234. * If the gizmo is enabled
  46235. */
  46236. set isEnabled(value: boolean);
  46237. get isEnabled(): boolean;
  46238. /**
  46239. * Disposes of the gizmo
  46240. */
  46241. dispose(): void;
  46242. }
  46243. }
  46244. declare module BABYLON {
  46245. /**
  46246. * Gizmo that enables dragging a mesh along 3 axis
  46247. */
  46248. export class PositionGizmo extends Gizmo {
  46249. /**
  46250. * Internal gizmo used for interactions on the x axis
  46251. */
  46252. xGizmo: AxisDragGizmo;
  46253. /**
  46254. * Internal gizmo used for interactions on the y axis
  46255. */
  46256. yGizmo: AxisDragGizmo;
  46257. /**
  46258. * Internal gizmo used for interactions on the z axis
  46259. */
  46260. zGizmo: AxisDragGizmo;
  46261. /**
  46262. * Internal gizmo used for interactions on the yz plane
  46263. */
  46264. xPlaneGizmo: PlaneDragGizmo;
  46265. /**
  46266. * Internal gizmo used for interactions on the xz plane
  46267. */
  46268. yPlaneGizmo: PlaneDragGizmo;
  46269. /**
  46270. * Internal gizmo used for interactions on the xy plane
  46271. */
  46272. zPlaneGizmo: PlaneDragGizmo;
  46273. /**
  46274. * private variables
  46275. */
  46276. private _meshAttached;
  46277. private _updateGizmoRotationToMatchAttachedMesh;
  46278. private _snapDistance;
  46279. private _scaleRatio;
  46280. /** Fires an event when any of it's sub gizmos are dragged */
  46281. onDragStartObservable: Observable<unknown>;
  46282. /** Fires an event when any of it's sub gizmos are released from dragging */
  46283. onDragEndObservable: Observable<unknown>;
  46284. /**
  46285. * If set to true, planar drag is enabled
  46286. */
  46287. private _planarGizmoEnabled;
  46288. get attachedMesh(): Nullable<AbstractMesh>;
  46289. set attachedMesh(mesh: Nullable<AbstractMesh>);
  46290. /**
  46291. * Creates a PositionGizmo
  46292. * @param gizmoLayer The utility layer the gizmo will be added to
  46293. */
  46294. constructor(gizmoLayer?: UtilityLayerRenderer);
  46295. /**
  46296. * If the planar drag gizmo is enabled
  46297. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  46298. */
  46299. set planarGizmoEnabled(value: boolean);
  46300. get planarGizmoEnabled(): boolean;
  46301. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  46302. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  46303. /**
  46304. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46305. */
  46306. set snapDistance(value: number);
  46307. get snapDistance(): number;
  46308. /**
  46309. * Ratio for the scale of the gizmo (Default: 1)
  46310. */
  46311. set scaleRatio(value: number);
  46312. get scaleRatio(): number;
  46313. /**
  46314. * Disposes of the gizmo
  46315. */
  46316. dispose(): void;
  46317. /**
  46318. * CustomMeshes are not supported by this gizmo
  46319. * @param mesh The mesh to replace the default mesh of the gizmo
  46320. */
  46321. setCustomMesh(mesh: Mesh): void;
  46322. }
  46323. }
  46324. declare module BABYLON {
  46325. /**
  46326. * Single axis drag gizmo
  46327. */
  46328. export class AxisDragGizmo extends Gizmo {
  46329. /**
  46330. * Drag behavior responsible for the gizmos dragging interactions
  46331. */
  46332. dragBehavior: PointerDragBehavior;
  46333. private _pointerObserver;
  46334. /**
  46335. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46336. */
  46337. snapDistance: number;
  46338. /**
  46339. * Event that fires each time the gizmo snaps to a new location.
  46340. * * snapDistance is the the change in distance
  46341. */
  46342. onSnapObservable: Observable<{
  46343. snapDistance: number;
  46344. }>;
  46345. private _isEnabled;
  46346. private _parent;
  46347. private _arrow;
  46348. private _coloredMaterial;
  46349. private _hoverMaterial;
  46350. /** @hidden */
  46351. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46352. /** @hidden */
  46353. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46354. /**
  46355. * Creates an AxisDragGizmo
  46356. * @param gizmoLayer The utility layer the gizmo will be added to
  46357. * @param dragAxis The axis which the gizmo will be able to drag on
  46358. * @param color The color of the gizmo
  46359. */
  46360. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46361. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46362. /**
  46363. * If the gizmo is enabled
  46364. */
  46365. set isEnabled(value: boolean);
  46366. get isEnabled(): boolean;
  46367. /**
  46368. * Disposes of the gizmo
  46369. */
  46370. dispose(): void;
  46371. }
  46372. }
  46373. declare module BABYLON.Debug {
  46374. /**
  46375. * The Axes viewer will show 3 axes in a specific point in space
  46376. */
  46377. export class AxesViewer {
  46378. private _xAxis;
  46379. private _yAxis;
  46380. private _zAxis;
  46381. private _scaleLinesFactor;
  46382. private _instanced;
  46383. /**
  46384. * Gets the hosting scene
  46385. */
  46386. scene: Scene;
  46387. /**
  46388. * Gets or sets a number used to scale line length
  46389. */
  46390. scaleLines: number;
  46391. /** Gets the node hierarchy used to render x-axis */
  46392. get xAxis(): TransformNode;
  46393. /** Gets the node hierarchy used to render y-axis */
  46394. get yAxis(): TransformNode;
  46395. /** Gets the node hierarchy used to render z-axis */
  46396. get zAxis(): TransformNode;
  46397. /**
  46398. * Creates a new AxesViewer
  46399. * @param scene defines the hosting scene
  46400. * @param scaleLines defines a number used to scale line length (1 by default)
  46401. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46402. * @param xAxis defines the node hierarchy used to render the x-axis
  46403. * @param yAxis defines the node hierarchy used to render the y-axis
  46404. * @param zAxis defines the node hierarchy used to render the z-axis
  46405. */
  46406. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46407. /**
  46408. * Force the viewer to update
  46409. * @param position defines the position of the viewer
  46410. * @param xaxis defines the x axis of the viewer
  46411. * @param yaxis defines the y axis of the viewer
  46412. * @param zaxis defines the z axis of the viewer
  46413. */
  46414. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46415. /**
  46416. * Creates an instance of this axes viewer.
  46417. * @returns a new axes viewer with instanced meshes
  46418. */
  46419. createInstance(): AxesViewer;
  46420. /** Releases resources */
  46421. dispose(): void;
  46422. private static _SetRenderingGroupId;
  46423. }
  46424. }
  46425. declare module BABYLON.Debug {
  46426. /**
  46427. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46428. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46429. */
  46430. export class BoneAxesViewer extends AxesViewer {
  46431. /**
  46432. * Gets or sets the target mesh where to display the axes viewer
  46433. */
  46434. mesh: Nullable<Mesh>;
  46435. /**
  46436. * Gets or sets the target bone where to display the axes viewer
  46437. */
  46438. bone: Nullable<Bone>;
  46439. /** Gets current position */
  46440. pos: Vector3;
  46441. /** Gets direction of X axis */
  46442. xaxis: Vector3;
  46443. /** Gets direction of Y axis */
  46444. yaxis: Vector3;
  46445. /** Gets direction of Z axis */
  46446. zaxis: Vector3;
  46447. /**
  46448. * Creates a new BoneAxesViewer
  46449. * @param scene defines the hosting scene
  46450. * @param bone defines the target bone
  46451. * @param mesh defines the target mesh
  46452. * @param scaleLines defines a scaling factor for line length (1 by default)
  46453. */
  46454. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46455. /**
  46456. * Force the viewer to update
  46457. */
  46458. update(): void;
  46459. /** Releases resources */
  46460. dispose(): void;
  46461. }
  46462. }
  46463. declare module BABYLON {
  46464. /**
  46465. * Interface used to define scene explorer extensibility option
  46466. */
  46467. export interface IExplorerExtensibilityOption {
  46468. /**
  46469. * Define the option label
  46470. */
  46471. label: string;
  46472. /**
  46473. * Defines the action to execute on click
  46474. */
  46475. action: (entity: any) => void;
  46476. }
  46477. /**
  46478. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46479. */
  46480. export interface IExplorerExtensibilityGroup {
  46481. /**
  46482. * Defines a predicate to test if a given type mut be extended
  46483. */
  46484. predicate: (entity: any) => boolean;
  46485. /**
  46486. * Gets the list of options added to a type
  46487. */
  46488. entries: IExplorerExtensibilityOption[];
  46489. }
  46490. /**
  46491. * Interface used to define the options to use to create the Inspector
  46492. */
  46493. export interface IInspectorOptions {
  46494. /**
  46495. * Display in overlay mode (default: false)
  46496. */
  46497. overlay?: boolean;
  46498. /**
  46499. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46500. */
  46501. globalRoot?: HTMLElement;
  46502. /**
  46503. * Display the Scene explorer
  46504. */
  46505. showExplorer?: boolean;
  46506. /**
  46507. * Display the property inspector
  46508. */
  46509. showInspector?: boolean;
  46510. /**
  46511. * Display in embed mode (both panes on the right)
  46512. */
  46513. embedMode?: boolean;
  46514. /**
  46515. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46516. */
  46517. handleResize?: boolean;
  46518. /**
  46519. * Allow the panes to popup (default: true)
  46520. */
  46521. enablePopup?: boolean;
  46522. /**
  46523. * Allow the panes to be closed by users (default: true)
  46524. */
  46525. enableClose?: boolean;
  46526. /**
  46527. * Optional list of extensibility entries
  46528. */
  46529. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46530. /**
  46531. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46532. */
  46533. inspectorURL?: string;
  46534. /**
  46535. * Optional initial tab (default to DebugLayerTab.Properties)
  46536. */
  46537. initialTab?: DebugLayerTab;
  46538. }
  46539. interface Scene {
  46540. /**
  46541. * @hidden
  46542. * Backing field
  46543. */
  46544. _debugLayer: DebugLayer;
  46545. /**
  46546. * Gets the debug layer (aka Inspector) associated with the scene
  46547. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46548. */
  46549. debugLayer: DebugLayer;
  46550. }
  46551. /**
  46552. * Enum of inspector action tab
  46553. */
  46554. export enum DebugLayerTab {
  46555. /**
  46556. * Properties tag (default)
  46557. */
  46558. Properties = 0,
  46559. /**
  46560. * Debug tab
  46561. */
  46562. Debug = 1,
  46563. /**
  46564. * Statistics tab
  46565. */
  46566. Statistics = 2,
  46567. /**
  46568. * Tools tab
  46569. */
  46570. Tools = 3,
  46571. /**
  46572. * Settings tab
  46573. */
  46574. Settings = 4
  46575. }
  46576. /**
  46577. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46578. * what is happening in your scene
  46579. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46580. */
  46581. export class DebugLayer {
  46582. /**
  46583. * Define the url to get the inspector script from.
  46584. * By default it uses the babylonjs CDN.
  46585. * @ignoreNaming
  46586. */
  46587. static InspectorURL: string;
  46588. private _scene;
  46589. private BJSINSPECTOR;
  46590. private _onPropertyChangedObservable?;
  46591. /**
  46592. * Observable triggered when a property is changed through the inspector.
  46593. */
  46594. get onPropertyChangedObservable(): any;
  46595. /**
  46596. * Instantiates a new debug layer.
  46597. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46598. * what is happening in your scene
  46599. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46600. * @param scene Defines the scene to inspect
  46601. */
  46602. constructor(scene: Scene);
  46603. /** Creates the inspector window. */
  46604. private _createInspector;
  46605. /**
  46606. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46607. * @param entity defines the entity to select
  46608. * @param lineContainerTitle defines the specific block to highlight
  46609. */
  46610. select(entity: any, lineContainerTitle?: string): void;
  46611. /** Get the inspector from bundle or global */
  46612. private _getGlobalInspector;
  46613. /**
  46614. * Get if the inspector is visible or not.
  46615. * @returns true if visible otherwise, false
  46616. */
  46617. isVisible(): boolean;
  46618. /**
  46619. * Hide the inspector and close its window.
  46620. */
  46621. hide(): void;
  46622. /**
  46623. * Launch the debugLayer.
  46624. * @param config Define the configuration of the inspector
  46625. * @return a promise fulfilled when the debug layer is visible
  46626. */
  46627. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46628. }
  46629. }
  46630. declare module BABYLON {
  46631. /**
  46632. * Class containing static functions to help procedurally build meshes
  46633. */
  46634. export class BoxBuilder {
  46635. /**
  46636. * Creates a box mesh
  46637. * * The parameter `size` sets the size (float) of each box side (default 1)
  46638. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46639. * * 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)
  46640. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46641. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46642. * * 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
  46643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46644. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46645. * @param name defines the name of the mesh
  46646. * @param options defines the options used to create the mesh
  46647. * @param scene defines the hosting scene
  46648. * @returns the box mesh
  46649. */
  46650. static CreateBox(name: string, options: {
  46651. size?: number;
  46652. width?: number;
  46653. height?: number;
  46654. depth?: number;
  46655. faceUV?: Vector4[];
  46656. faceColors?: Color4[];
  46657. sideOrientation?: number;
  46658. frontUVs?: Vector4;
  46659. backUVs?: Vector4;
  46660. wrap?: boolean;
  46661. topBaseAt?: number;
  46662. bottomBaseAt?: number;
  46663. updatable?: boolean;
  46664. }, scene?: Nullable<Scene>): Mesh;
  46665. }
  46666. }
  46667. declare module BABYLON.Debug {
  46668. /**
  46669. * Used to show the physics impostor around the specific mesh
  46670. */
  46671. export class PhysicsViewer {
  46672. /** @hidden */
  46673. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46674. /** @hidden */
  46675. protected _meshes: Array<Nullable<AbstractMesh>>;
  46676. /** @hidden */
  46677. protected _scene: Nullable<Scene>;
  46678. /** @hidden */
  46679. protected _numMeshes: number;
  46680. /** @hidden */
  46681. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46682. private _renderFunction;
  46683. private _utilityLayer;
  46684. private _debugBoxMesh;
  46685. private _debugSphereMesh;
  46686. private _debugCylinderMesh;
  46687. private _debugMaterial;
  46688. private _debugMeshMeshes;
  46689. /**
  46690. * Creates a new PhysicsViewer
  46691. * @param scene defines the hosting scene
  46692. */
  46693. constructor(scene: Scene);
  46694. /** @hidden */
  46695. protected _updateDebugMeshes(): void;
  46696. /**
  46697. * Renders a specified physic impostor
  46698. * @param impostor defines the impostor to render
  46699. * @param targetMesh defines the mesh represented by the impostor
  46700. * @returns the new debug mesh used to render the impostor
  46701. */
  46702. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46703. /**
  46704. * Hides a specified physic impostor
  46705. * @param impostor defines the impostor to hide
  46706. */
  46707. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46708. private _getDebugMaterial;
  46709. private _getDebugBoxMesh;
  46710. private _getDebugSphereMesh;
  46711. private _getDebugCylinderMesh;
  46712. private _getDebugMeshMesh;
  46713. private _getDebugMesh;
  46714. /** Releases all resources */
  46715. dispose(): void;
  46716. }
  46717. }
  46718. declare module BABYLON {
  46719. /**
  46720. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46721. * in order to better appreciate the issue one might have.
  46722. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46723. */
  46724. export class RayHelper {
  46725. /**
  46726. * Defines the ray we are currently tryin to visualize.
  46727. */
  46728. ray: Nullable<Ray>;
  46729. private _renderPoints;
  46730. private _renderLine;
  46731. private _renderFunction;
  46732. private _scene;
  46733. private _updateToMeshFunction;
  46734. private _attachedToMesh;
  46735. private _meshSpaceDirection;
  46736. private _meshSpaceOrigin;
  46737. /**
  46738. * Helper function to create a colored helper in a scene in one line.
  46739. * @param ray Defines the ray we are currently tryin to visualize
  46740. * @param scene Defines the scene the ray is used in
  46741. * @param color Defines the color we want to see the ray in
  46742. * @returns The newly created ray helper.
  46743. */
  46744. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46745. /**
  46746. * Instantiate a new ray helper.
  46747. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46748. * in order to better appreciate the issue one might have.
  46749. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46750. * @param ray Defines the ray we are currently tryin to visualize
  46751. */
  46752. constructor(ray: Ray);
  46753. /**
  46754. * Shows the ray we are willing to debug.
  46755. * @param scene Defines the scene the ray needs to be rendered in
  46756. * @param color Defines the color the ray needs to be rendered in
  46757. */
  46758. show(scene: Scene, color?: Color3): void;
  46759. /**
  46760. * Hides the ray we are debugging.
  46761. */
  46762. hide(): void;
  46763. private _render;
  46764. /**
  46765. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46766. * @param mesh Defines the mesh we want the helper attached to
  46767. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46768. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46769. * @param length Defines the length of the ray
  46770. */
  46771. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46772. /**
  46773. * Detach the ray helper from the mesh it has previously been attached to.
  46774. */
  46775. detachFromMesh(): void;
  46776. private _updateToMesh;
  46777. /**
  46778. * Dispose the helper and release its associated resources.
  46779. */
  46780. dispose(): void;
  46781. }
  46782. }
  46783. declare module BABYLON.Debug {
  46784. /**
  46785. * Class used to render a debug view of a given skeleton
  46786. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46787. */
  46788. export class SkeletonViewer {
  46789. /** defines the skeleton to render */
  46790. skeleton: Skeleton;
  46791. /** defines the mesh attached to the skeleton */
  46792. mesh: AbstractMesh;
  46793. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46794. autoUpdateBonesMatrices: boolean;
  46795. /** defines the rendering group id to use with the viewer */
  46796. renderingGroupId: number;
  46797. /** Gets or sets the color used to render the skeleton */
  46798. color: Color3;
  46799. private _scene;
  46800. private _debugLines;
  46801. private _debugMesh;
  46802. private _isEnabled;
  46803. private _renderFunction;
  46804. private _utilityLayer;
  46805. /**
  46806. * Returns the mesh used to render the bones
  46807. */
  46808. get debugMesh(): Nullable<LinesMesh>;
  46809. /**
  46810. * Creates a new SkeletonViewer
  46811. * @param skeleton defines the skeleton to render
  46812. * @param mesh defines the mesh attached to the skeleton
  46813. * @param scene defines the hosting scene
  46814. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46815. * @param renderingGroupId defines the rendering group id to use with the viewer
  46816. */
  46817. constructor(
  46818. /** defines the skeleton to render */
  46819. skeleton: Skeleton,
  46820. /** defines the mesh attached to the skeleton */
  46821. mesh: AbstractMesh, scene: Scene,
  46822. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46823. autoUpdateBonesMatrices?: boolean,
  46824. /** defines the rendering group id to use with the viewer */
  46825. renderingGroupId?: number);
  46826. /** Gets or sets a boolean indicating if the viewer is enabled */
  46827. set isEnabled(value: boolean);
  46828. get isEnabled(): boolean;
  46829. private _getBonePosition;
  46830. private _getLinesForBonesWithLength;
  46831. private _getLinesForBonesNoLength;
  46832. /** Update the viewer to sync with current skeleton state */
  46833. update(): void;
  46834. /** Release associated resources */
  46835. dispose(): void;
  46836. }
  46837. }
  46838. declare module BABYLON {
  46839. /**
  46840. * Options to create the null engine
  46841. */
  46842. export class NullEngineOptions {
  46843. /**
  46844. * Render width (Default: 512)
  46845. */
  46846. renderWidth: number;
  46847. /**
  46848. * Render height (Default: 256)
  46849. */
  46850. renderHeight: number;
  46851. /**
  46852. * Texture size (Default: 512)
  46853. */
  46854. textureSize: number;
  46855. /**
  46856. * If delta time between frames should be constant
  46857. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46858. */
  46859. deterministicLockstep: boolean;
  46860. /**
  46861. * Maximum about of steps between frames (Default: 4)
  46862. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46863. */
  46864. lockstepMaxSteps: number;
  46865. }
  46866. /**
  46867. * The null engine class provides support for headless version of babylon.js.
  46868. * This can be used in server side scenario or for testing purposes
  46869. */
  46870. export class NullEngine extends Engine {
  46871. private _options;
  46872. /**
  46873. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46874. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46875. * @returns true if engine is in deterministic lock step mode
  46876. */
  46877. isDeterministicLockStep(): boolean;
  46878. /**
  46879. * Gets the max steps when engine is running in deterministic lock step
  46880. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46881. * @returns the max steps
  46882. */
  46883. getLockstepMaxSteps(): number;
  46884. /**
  46885. * Gets the current hardware scaling level.
  46886. * By default the hardware scaling level is computed from the window device ratio.
  46887. * 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.
  46888. * @returns a number indicating the current hardware scaling level
  46889. */
  46890. getHardwareScalingLevel(): number;
  46891. constructor(options?: NullEngineOptions);
  46892. /**
  46893. * Creates a vertex buffer
  46894. * @param vertices the data for the vertex buffer
  46895. * @returns the new WebGL static buffer
  46896. */
  46897. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46898. /**
  46899. * Creates a new index buffer
  46900. * @param indices defines the content of the index buffer
  46901. * @param updatable defines if the index buffer must be updatable
  46902. * @returns a new webGL buffer
  46903. */
  46904. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46905. /**
  46906. * Clear the current render buffer or the current render target (if any is set up)
  46907. * @param color defines the color to use
  46908. * @param backBuffer defines if the back buffer must be cleared
  46909. * @param depth defines if the depth buffer must be cleared
  46910. * @param stencil defines if the stencil buffer must be cleared
  46911. */
  46912. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46913. /**
  46914. * Gets the current render width
  46915. * @param useScreen defines if screen size must be used (or the current render target if any)
  46916. * @returns a number defining the current render width
  46917. */
  46918. getRenderWidth(useScreen?: boolean): number;
  46919. /**
  46920. * Gets the current render height
  46921. * @param useScreen defines if screen size must be used (or the current render target if any)
  46922. * @returns a number defining the current render height
  46923. */
  46924. getRenderHeight(useScreen?: boolean): number;
  46925. /**
  46926. * Set the WebGL's viewport
  46927. * @param viewport defines the viewport element to be used
  46928. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46929. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46930. */
  46931. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46932. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46933. /**
  46934. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46935. * @param pipelineContext defines the pipeline context to use
  46936. * @param uniformsNames defines the list of uniform names
  46937. * @returns an array of webGL uniform locations
  46938. */
  46939. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46940. /**
  46941. * Gets the lsit of active attributes for a given webGL program
  46942. * @param pipelineContext defines the pipeline context to use
  46943. * @param attributesNames defines the list of attribute names to get
  46944. * @returns an array of indices indicating the offset of each attribute
  46945. */
  46946. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46947. /**
  46948. * Binds an effect to the webGL context
  46949. * @param effect defines the effect to bind
  46950. */
  46951. bindSamplers(effect: Effect): void;
  46952. /**
  46953. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46954. * @param effect defines the effect to activate
  46955. */
  46956. enableEffect(effect: Effect): void;
  46957. /**
  46958. * Set various states to the webGL context
  46959. * @param culling defines backface culling state
  46960. * @param zOffset defines the value to apply to zOffset (0 by default)
  46961. * @param force defines if states must be applied even if cache is up to date
  46962. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46963. */
  46964. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46965. /**
  46966. * Set the value of an uniform to an array of int32
  46967. * @param uniform defines the webGL uniform location where to store the value
  46968. * @param array defines the array of int32 to store
  46969. */
  46970. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46971. /**
  46972. * Set the value of an uniform to an array of int32 (stored as vec2)
  46973. * @param uniform defines the webGL uniform location where to store the value
  46974. * @param array defines the array of int32 to store
  46975. */
  46976. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46977. /**
  46978. * Set the value of an uniform to an array of int32 (stored as vec3)
  46979. * @param uniform defines the webGL uniform location where to store the value
  46980. * @param array defines the array of int32 to store
  46981. */
  46982. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46983. /**
  46984. * Set the value of an uniform to an array of int32 (stored as vec4)
  46985. * @param uniform defines the webGL uniform location where to store the value
  46986. * @param array defines the array of int32 to store
  46987. */
  46988. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46989. /**
  46990. * Set the value of an uniform to an array of float32
  46991. * @param uniform defines the webGL uniform location where to store the value
  46992. * @param array defines the array of float32 to store
  46993. */
  46994. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46995. /**
  46996. * Set the value of an uniform to an array of float32 (stored as vec2)
  46997. * @param uniform defines the webGL uniform location where to store the value
  46998. * @param array defines the array of float32 to store
  46999. */
  47000. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47001. /**
  47002. * Set the value of an uniform to an array of float32 (stored as vec3)
  47003. * @param uniform defines the webGL uniform location where to store the value
  47004. * @param array defines the array of float32 to store
  47005. */
  47006. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47007. /**
  47008. * Set the value of an uniform to an array of float32 (stored as vec4)
  47009. * @param uniform defines the webGL uniform location where to store the value
  47010. * @param array defines the array of float32 to store
  47011. */
  47012. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47013. /**
  47014. * Set the value of an uniform to an array of number
  47015. * @param uniform defines the webGL uniform location where to store the value
  47016. * @param array defines the array of number to store
  47017. */
  47018. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47019. /**
  47020. * Set the value of an uniform to an array of number (stored as vec2)
  47021. * @param uniform defines the webGL uniform location where to store the value
  47022. * @param array defines the array of number to store
  47023. */
  47024. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47025. /**
  47026. * Set the value of an uniform to an array of number (stored as vec3)
  47027. * @param uniform defines the webGL uniform location where to store the value
  47028. * @param array defines the array of number to store
  47029. */
  47030. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47031. /**
  47032. * Set the value of an uniform to an array of number (stored as vec4)
  47033. * @param uniform defines the webGL uniform location where to store the value
  47034. * @param array defines the array of number to store
  47035. */
  47036. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47037. /**
  47038. * Set the value of an uniform to an array of float32 (stored as matrices)
  47039. * @param uniform defines the webGL uniform location where to store the value
  47040. * @param matrices defines the array of float32 to store
  47041. */
  47042. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47043. /**
  47044. * Set the value of an uniform to a matrix (3x3)
  47045. * @param uniform defines the webGL uniform location where to store the value
  47046. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  47047. */
  47048. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47049. /**
  47050. * Set the value of an uniform to a matrix (2x2)
  47051. * @param uniform defines the webGL uniform location where to store the value
  47052. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  47053. */
  47054. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47055. /**
  47056. * Set the value of an uniform to a number (float)
  47057. * @param uniform defines the webGL uniform location where to store the value
  47058. * @param value defines the float number to store
  47059. */
  47060. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47061. /**
  47062. * Set the value of an uniform to a vec2
  47063. * @param uniform defines the webGL uniform location where to store the value
  47064. * @param x defines the 1st component of the value
  47065. * @param y defines the 2nd component of the value
  47066. */
  47067. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47068. /**
  47069. * Set the value of an uniform to a vec3
  47070. * @param uniform defines the webGL uniform location where to store the value
  47071. * @param x defines the 1st component of the value
  47072. * @param y defines the 2nd component of the value
  47073. * @param z defines the 3rd component of the value
  47074. */
  47075. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47076. /**
  47077. * Set the value of an uniform to a boolean
  47078. * @param uniform defines the webGL uniform location where to store the value
  47079. * @param bool defines the boolean to store
  47080. */
  47081. setBool(uniform: WebGLUniformLocation, bool: number): void;
  47082. /**
  47083. * Set the value of an uniform to a vec4
  47084. * @param uniform defines the webGL uniform location where to store the value
  47085. * @param x defines the 1st component of the value
  47086. * @param y defines the 2nd component of the value
  47087. * @param z defines the 3rd component of the value
  47088. * @param w defines the 4th component of the value
  47089. */
  47090. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47091. /**
  47092. * Sets the current alpha mode
  47093. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  47094. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47095. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47096. */
  47097. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47098. /**
  47099. * Bind webGl buffers directly to the webGL context
  47100. * @param vertexBuffers defines the vertex buffer to bind
  47101. * @param indexBuffer defines the index buffer to bind
  47102. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  47103. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  47104. * @param effect defines the effect associated with the vertex buffer
  47105. */
  47106. bindBuffers(vertexBuffers: {
  47107. [key: string]: VertexBuffer;
  47108. }, indexBuffer: DataBuffer, effect: Effect): void;
  47109. /**
  47110. * Force the entire cache to be cleared
  47111. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  47112. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  47113. */
  47114. wipeCaches(bruteForce?: boolean): void;
  47115. /**
  47116. * Send a draw order
  47117. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  47118. * @param indexStart defines the starting index
  47119. * @param indexCount defines the number of index to draw
  47120. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47121. */
  47122. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  47123. /**
  47124. * Draw a list of indexed primitives
  47125. * @param fillMode defines the primitive to use
  47126. * @param indexStart defines the starting index
  47127. * @param indexCount defines the number of index to draw
  47128. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47129. */
  47130. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47131. /**
  47132. * Draw a list of unindexed primitives
  47133. * @param fillMode defines the primitive to use
  47134. * @param verticesStart defines the index of first vertex to draw
  47135. * @param verticesCount defines the count of vertices to draw
  47136. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47137. */
  47138. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47139. /** @hidden */
  47140. _createTexture(): WebGLTexture;
  47141. /** @hidden */
  47142. _releaseTexture(texture: InternalTexture): void;
  47143. /**
  47144. * Usually called from Texture.ts.
  47145. * Passed information to create a WebGLTexture
  47146. * @param urlArg defines a value which contains one of the following:
  47147. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47148. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47149. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47150. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47151. * @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)
  47152. * @param scene needed for loading to the correct scene
  47153. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  47154. * @param onLoad optional callback to be called upon successful completion
  47155. * @param onError optional callback to be called upon failure
  47156. * @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
  47157. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47158. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47159. * @param forcedExtension defines the extension to use to pick the right loader
  47160. * @param mimeType defines an optional mime type
  47161. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47162. */
  47163. 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;
  47164. /**
  47165. * Creates a new render target texture
  47166. * @param size defines the size of the texture
  47167. * @param options defines the options used to create the texture
  47168. * @returns a new render target texture stored in an InternalTexture
  47169. */
  47170. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  47171. /**
  47172. * Update the sampling mode of a given texture
  47173. * @param samplingMode defines the required sampling mode
  47174. * @param texture defines the texture to update
  47175. */
  47176. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47177. /**
  47178. * Binds the frame buffer to the specified texture.
  47179. * @param texture The texture to render to or null for the default canvas
  47180. * @param faceIndex The face of the texture to render to in case of cube texture
  47181. * @param requiredWidth The width of the target to render to
  47182. * @param requiredHeight The height of the target to render to
  47183. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  47184. * @param lodLevel defines le lod level to bind to the frame buffer
  47185. */
  47186. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47187. /**
  47188. * Unbind the current render target texture from the webGL context
  47189. * @param texture defines the render target texture to unbind
  47190. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47191. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47192. */
  47193. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47194. /**
  47195. * Creates a dynamic vertex buffer
  47196. * @param vertices the data for the dynamic vertex buffer
  47197. * @returns the new WebGL dynamic buffer
  47198. */
  47199. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  47200. /**
  47201. * Update the content of a dynamic texture
  47202. * @param texture defines the texture to update
  47203. * @param canvas defines the canvas containing the source
  47204. * @param invertY defines if data must be stored with Y axis inverted
  47205. * @param premulAlpha defines if alpha is stored as premultiplied
  47206. * @param format defines the format of the data
  47207. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  47208. */
  47209. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  47210. /**
  47211. * Gets a boolean indicating if all created effects are ready
  47212. * @returns true if all effects are ready
  47213. */
  47214. areAllEffectsReady(): boolean;
  47215. /**
  47216. * @hidden
  47217. * Get the current error code of the webGL context
  47218. * @returns the error code
  47219. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  47220. */
  47221. getError(): number;
  47222. /** @hidden */
  47223. _getUnpackAlignement(): number;
  47224. /** @hidden */
  47225. _unpackFlipY(value: boolean): void;
  47226. /**
  47227. * Update a dynamic index buffer
  47228. * @param indexBuffer defines the target index buffer
  47229. * @param indices defines the data to update
  47230. * @param offset defines the offset in the target index buffer where update should start
  47231. */
  47232. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  47233. /**
  47234. * Updates a dynamic vertex buffer.
  47235. * @param vertexBuffer the vertex buffer to update
  47236. * @param vertices the data used to update the vertex buffer
  47237. * @param byteOffset the byte offset of the data (optional)
  47238. * @param byteLength the byte length of the data (optional)
  47239. */
  47240. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  47241. /** @hidden */
  47242. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  47243. /** @hidden */
  47244. _bindTexture(channel: number, texture: InternalTexture): void;
  47245. protected _deleteBuffer(buffer: WebGLBuffer): void;
  47246. /**
  47247. * 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
  47248. */
  47249. releaseEffects(): void;
  47250. displayLoadingUI(): void;
  47251. hideLoadingUI(): void;
  47252. /** @hidden */
  47253. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47254. /** @hidden */
  47255. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47256. /** @hidden */
  47257. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47258. /** @hidden */
  47259. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47260. }
  47261. }
  47262. declare module BABYLON {
  47263. /**
  47264. * @hidden
  47265. **/
  47266. export class _TimeToken {
  47267. _startTimeQuery: Nullable<WebGLQuery>;
  47268. _endTimeQuery: Nullable<WebGLQuery>;
  47269. _timeElapsedQuery: Nullable<WebGLQuery>;
  47270. _timeElapsedQueryEnded: boolean;
  47271. }
  47272. }
  47273. declare module BABYLON {
  47274. /** @hidden */
  47275. export class _OcclusionDataStorage {
  47276. /** @hidden */
  47277. occlusionInternalRetryCounter: number;
  47278. /** @hidden */
  47279. isOcclusionQueryInProgress: boolean;
  47280. /** @hidden */
  47281. isOccluded: boolean;
  47282. /** @hidden */
  47283. occlusionRetryCount: number;
  47284. /** @hidden */
  47285. occlusionType: number;
  47286. /** @hidden */
  47287. occlusionQueryAlgorithmType: number;
  47288. }
  47289. interface Engine {
  47290. /**
  47291. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  47292. * @return the new query
  47293. */
  47294. createQuery(): WebGLQuery;
  47295. /**
  47296. * Delete and release a webGL query
  47297. * @param query defines the query to delete
  47298. * @return the current engine
  47299. */
  47300. deleteQuery(query: WebGLQuery): Engine;
  47301. /**
  47302. * Check if a given query has resolved and got its value
  47303. * @param query defines the query to check
  47304. * @returns true if the query got its value
  47305. */
  47306. isQueryResultAvailable(query: WebGLQuery): boolean;
  47307. /**
  47308. * Gets the value of a given query
  47309. * @param query defines the query to check
  47310. * @returns the value of the query
  47311. */
  47312. getQueryResult(query: WebGLQuery): number;
  47313. /**
  47314. * Initiates an occlusion query
  47315. * @param algorithmType defines the algorithm to use
  47316. * @param query defines the query to use
  47317. * @returns the current engine
  47318. * @see http://doc.babylonjs.com/features/occlusionquery
  47319. */
  47320. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47321. /**
  47322. * Ends an occlusion query
  47323. * @see http://doc.babylonjs.com/features/occlusionquery
  47324. * @param algorithmType defines the algorithm to use
  47325. * @returns the current engine
  47326. */
  47327. endOcclusionQuery(algorithmType: number): Engine;
  47328. /**
  47329. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47330. * Please note that only one query can be issued at a time
  47331. * @returns a time token used to track the time span
  47332. */
  47333. startTimeQuery(): Nullable<_TimeToken>;
  47334. /**
  47335. * Ends a time query
  47336. * @param token defines the token used to measure the time span
  47337. * @returns the time spent (in ns)
  47338. */
  47339. endTimeQuery(token: _TimeToken): int;
  47340. /** @hidden */
  47341. _currentNonTimestampToken: Nullable<_TimeToken>;
  47342. /** @hidden */
  47343. _createTimeQuery(): WebGLQuery;
  47344. /** @hidden */
  47345. _deleteTimeQuery(query: WebGLQuery): void;
  47346. /** @hidden */
  47347. _getGlAlgorithmType(algorithmType: number): number;
  47348. /** @hidden */
  47349. _getTimeQueryResult(query: WebGLQuery): any;
  47350. /** @hidden */
  47351. _getTimeQueryAvailability(query: WebGLQuery): any;
  47352. }
  47353. interface AbstractMesh {
  47354. /**
  47355. * Backing filed
  47356. * @hidden
  47357. */
  47358. __occlusionDataStorage: _OcclusionDataStorage;
  47359. /**
  47360. * Access property
  47361. * @hidden
  47362. */
  47363. _occlusionDataStorage: _OcclusionDataStorage;
  47364. /**
  47365. * 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.
  47366. * The default value is -1 which means don't break the query and wait till the result
  47367. * @see http://doc.babylonjs.com/features/occlusionquery
  47368. */
  47369. occlusionRetryCount: number;
  47370. /**
  47371. * 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:
  47372. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47373. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47374. * * 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.
  47375. * @see http://doc.babylonjs.com/features/occlusionquery
  47376. */
  47377. occlusionType: number;
  47378. /**
  47379. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47380. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47381. * * 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.
  47382. * @see http://doc.babylonjs.com/features/occlusionquery
  47383. */
  47384. occlusionQueryAlgorithmType: number;
  47385. /**
  47386. * 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
  47387. * @see http://doc.babylonjs.com/features/occlusionquery
  47388. */
  47389. isOccluded: boolean;
  47390. /**
  47391. * Flag to check the progress status of the query
  47392. * @see http://doc.babylonjs.com/features/occlusionquery
  47393. */
  47394. isOcclusionQueryInProgress: boolean;
  47395. }
  47396. }
  47397. declare module BABYLON {
  47398. /** @hidden */
  47399. export var _forceTransformFeedbackToBundle: boolean;
  47400. interface Engine {
  47401. /**
  47402. * Creates a webGL transform feedback object
  47403. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47404. * @returns the webGL transform feedback object
  47405. */
  47406. createTransformFeedback(): WebGLTransformFeedback;
  47407. /**
  47408. * Delete a webGL transform feedback object
  47409. * @param value defines the webGL transform feedback object to delete
  47410. */
  47411. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47412. /**
  47413. * Bind a webGL transform feedback object to the webgl context
  47414. * @param value defines the webGL transform feedback object to bind
  47415. */
  47416. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47417. /**
  47418. * Begins a transform feedback operation
  47419. * @param usePoints defines if points or triangles must be used
  47420. */
  47421. beginTransformFeedback(usePoints: boolean): void;
  47422. /**
  47423. * Ends a transform feedback operation
  47424. */
  47425. endTransformFeedback(): void;
  47426. /**
  47427. * Specify the varyings to use with transform feedback
  47428. * @param program defines the associated webGL program
  47429. * @param value defines the list of strings representing the varying names
  47430. */
  47431. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47432. /**
  47433. * Bind a webGL buffer for a transform feedback operation
  47434. * @param value defines the webGL buffer to bind
  47435. */
  47436. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47437. }
  47438. }
  47439. declare module BABYLON {
  47440. /**
  47441. * Creation options of the multi render target texture.
  47442. */
  47443. export interface IMultiRenderTargetOptions {
  47444. /**
  47445. * Define if the texture needs to create mip maps after render.
  47446. */
  47447. generateMipMaps?: boolean;
  47448. /**
  47449. * Define the types of all the draw buffers we want to create
  47450. */
  47451. types?: number[];
  47452. /**
  47453. * Define the sampling modes of all the draw buffers we want to create
  47454. */
  47455. samplingModes?: number[];
  47456. /**
  47457. * Define if a depth buffer is required
  47458. */
  47459. generateDepthBuffer?: boolean;
  47460. /**
  47461. * Define if a stencil buffer is required
  47462. */
  47463. generateStencilBuffer?: boolean;
  47464. /**
  47465. * Define if a depth texture is required instead of a depth buffer
  47466. */
  47467. generateDepthTexture?: boolean;
  47468. /**
  47469. * Define the number of desired draw buffers
  47470. */
  47471. textureCount?: number;
  47472. /**
  47473. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47474. */
  47475. doNotChangeAspectRatio?: boolean;
  47476. /**
  47477. * Define the default type of the buffers we are creating
  47478. */
  47479. defaultType?: number;
  47480. }
  47481. /**
  47482. * A multi render target, like a render target provides the ability to render to a texture.
  47483. * Unlike the render target, it can render to several draw buffers in one draw.
  47484. * This is specially interesting in deferred rendering or for any effects requiring more than
  47485. * just one color from a single pass.
  47486. */
  47487. export class MultiRenderTarget extends RenderTargetTexture {
  47488. private _internalTextures;
  47489. private _textures;
  47490. private _multiRenderTargetOptions;
  47491. /**
  47492. * Get if draw buffers are currently supported by the used hardware and browser.
  47493. */
  47494. get isSupported(): boolean;
  47495. /**
  47496. * Get the list of textures generated by the multi render target.
  47497. */
  47498. get textures(): Texture[];
  47499. /**
  47500. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47501. */
  47502. get depthTexture(): Texture;
  47503. /**
  47504. * Set the wrapping mode on U of all the textures we are rendering to.
  47505. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47506. */
  47507. set wrapU(wrap: number);
  47508. /**
  47509. * Set the wrapping mode on V of all the textures we are rendering to.
  47510. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47511. */
  47512. set wrapV(wrap: number);
  47513. /**
  47514. * Instantiate a new multi render target texture.
  47515. * A multi render target, like a render target provides the ability to render to a texture.
  47516. * Unlike the render target, it can render to several draw buffers in one draw.
  47517. * This is specially interesting in deferred rendering or for any effects requiring more than
  47518. * just one color from a single pass.
  47519. * @param name Define the name of the texture
  47520. * @param size Define the size of the buffers to render to
  47521. * @param count Define the number of target we are rendering into
  47522. * @param scene Define the scene the texture belongs to
  47523. * @param options Define the options used to create the multi render target
  47524. */
  47525. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47526. /** @hidden */
  47527. _rebuild(): void;
  47528. private _createInternalTextures;
  47529. private _createTextures;
  47530. /**
  47531. * Define the number of samples used if MSAA is enabled.
  47532. */
  47533. get samples(): number;
  47534. set samples(value: number);
  47535. /**
  47536. * Resize all the textures in the multi render target.
  47537. * Be carrefull as it will recreate all the data in the new texture.
  47538. * @param size Define the new size
  47539. */
  47540. resize(size: any): void;
  47541. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47542. /**
  47543. * Dispose the render targets and their associated resources
  47544. */
  47545. dispose(): void;
  47546. /**
  47547. * Release all the underlying texture used as draw buffers.
  47548. */
  47549. releaseInternalTextures(): void;
  47550. }
  47551. }
  47552. declare module BABYLON {
  47553. interface ThinEngine {
  47554. /**
  47555. * Unbind a list of render target textures from the webGL context
  47556. * This is used only when drawBuffer extension or webGL2 are active
  47557. * @param textures defines the render target textures to unbind
  47558. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47559. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47560. */
  47561. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47562. /**
  47563. * Create a multi render target texture
  47564. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47565. * @param size defines the size of the texture
  47566. * @param options defines the creation options
  47567. * @returns the cube texture as an InternalTexture
  47568. */
  47569. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47570. /**
  47571. * Update the sample count for a given multiple render target texture
  47572. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47573. * @param textures defines the textures to update
  47574. * @param samples defines the sample count to set
  47575. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47576. */
  47577. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47578. }
  47579. }
  47580. declare module BABYLON {
  47581. /**
  47582. * Class used to define an additional view for the engine
  47583. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47584. */
  47585. export class EngineView {
  47586. /** Defines the canvas where to render the view */
  47587. target: HTMLCanvasElement;
  47588. /** Defines an optional camera used to render the view (will use active camera else) */
  47589. camera?: Camera;
  47590. }
  47591. interface Engine {
  47592. /**
  47593. * Gets or sets the HTML element to use for attaching events
  47594. */
  47595. inputElement: Nullable<HTMLElement>;
  47596. /**
  47597. * Gets the current engine view
  47598. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47599. */
  47600. activeView: Nullable<EngineView>;
  47601. /** Gets or sets the list of views */
  47602. views: EngineView[];
  47603. /**
  47604. * Register a new child canvas
  47605. * @param canvas defines the canvas to register
  47606. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47607. * @returns the associated view
  47608. */
  47609. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47610. /**
  47611. * Remove a registered child canvas
  47612. * @param canvas defines the canvas to remove
  47613. * @returns the current engine
  47614. */
  47615. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47616. }
  47617. }
  47618. declare module BABYLON {
  47619. interface Engine {
  47620. /** @hidden */
  47621. _excludedCompressedTextures: string[];
  47622. /** @hidden */
  47623. _textureFormatInUse: string;
  47624. /**
  47625. * Gets the list of texture formats supported
  47626. */
  47627. readonly texturesSupported: Array<string>;
  47628. /**
  47629. * Gets the texture format in use
  47630. */
  47631. readonly textureFormatInUse: Nullable<string>;
  47632. /**
  47633. * Set the compressed texture extensions or file names to skip.
  47634. *
  47635. * @param skippedFiles defines the list of those texture files you want to skip
  47636. * Example: [".dds", ".env", "myfile.png"]
  47637. */
  47638. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  47639. /**
  47640. * Set the compressed texture format to use, based on the formats you have, and the formats
  47641. * supported by the hardware / browser.
  47642. *
  47643. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  47644. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  47645. * to API arguments needed to compressed textures. This puts the burden on the container
  47646. * generator to house the arcane code for determining these for current & future formats.
  47647. *
  47648. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47649. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47650. *
  47651. * Note: The result of this call is not taken into account when a texture is base64.
  47652. *
  47653. * @param formatsAvailable defines the list of those format families you have created
  47654. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  47655. *
  47656. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  47657. * @returns The extension selected.
  47658. */
  47659. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  47660. }
  47661. }
  47662. declare module BABYLON {
  47663. /**
  47664. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47665. */
  47666. export interface CubeMapInfo {
  47667. /**
  47668. * The pixel array for the front face.
  47669. * This is stored in format, left to right, up to down format.
  47670. */
  47671. front: Nullable<ArrayBufferView>;
  47672. /**
  47673. * The pixel array for the back face.
  47674. * This is stored in format, left to right, up to down format.
  47675. */
  47676. back: Nullable<ArrayBufferView>;
  47677. /**
  47678. * The pixel array for the left face.
  47679. * This is stored in format, left to right, up to down format.
  47680. */
  47681. left: Nullable<ArrayBufferView>;
  47682. /**
  47683. * The pixel array for the right face.
  47684. * This is stored in format, left to right, up to down format.
  47685. */
  47686. right: Nullable<ArrayBufferView>;
  47687. /**
  47688. * The pixel array for the up face.
  47689. * This is stored in format, left to right, up to down format.
  47690. */
  47691. up: Nullable<ArrayBufferView>;
  47692. /**
  47693. * The pixel array for the down face.
  47694. * This is stored in format, left to right, up to down format.
  47695. */
  47696. down: Nullable<ArrayBufferView>;
  47697. /**
  47698. * The size of the cubemap stored.
  47699. *
  47700. * Each faces will be size * size pixels.
  47701. */
  47702. size: number;
  47703. /**
  47704. * The format of the texture.
  47705. *
  47706. * RGBA, RGB.
  47707. */
  47708. format: number;
  47709. /**
  47710. * The type of the texture data.
  47711. *
  47712. * UNSIGNED_INT, FLOAT.
  47713. */
  47714. type: number;
  47715. /**
  47716. * Specifies whether the texture is in gamma space.
  47717. */
  47718. gammaSpace: boolean;
  47719. }
  47720. /**
  47721. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47722. */
  47723. export class PanoramaToCubeMapTools {
  47724. private static FACE_FRONT;
  47725. private static FACE_BACK;
  47726. private static FACE_RIGHT;
  47727. private static FACE_LEFT;
  47728. private static FACE_DOWN;
  47729. private static FACE_UP;
  47730. /**
  47731. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47732. *
  47733. * @param float32Array The source data.
  47734. * @param inputWidth The width of the input panorama.
  47735. * @param inputHeight The height of the input panorama.
  47736. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47737. * @return The cubemap data
  47738. */
  47739. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47740. private static CreateCubemapTexture;
  47741. private static CalcProjectionSpherical;
  47742. }
  47743. }
  47744. declare module BABYLON {
  47745. /**
  47746. * Helper class dealing with the extraction of spherical polynomial dataArray
  47747. * from a cube map.
  47748. */
  47749. export class CubeMapToSphericalPolynomialTools {
  47750. private static FileFaces;
  47751. /**
  47752. * Converts a texture to the according Spherical Polynomial data.
  47753. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47754. *
  47755. * @param texture The texture to extract the information from.
  47756. * @return The Spherical Polynomial data.
  47757. */
  47758. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47759. /**
  47760. * Converts a cubemap to the according Spherical Polynomial data.
  47761. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47762. *
  47763. * @param cubeInfo The Cube map to extract the information from.
  47764. * @return The Spherical Polynomial data.
  47765. */
  47766. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47767. }
  47768. }
  47769. declare module BABYLON {
  47770. interface BaseTexture {
  47771. /**
  47772. * Get the polynomial representation of the texture data.
  47773. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47774. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47775. */
  47776. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47777. }
  47778. }
  47779. declare module BABYLON {
  47780. /** @hidden */
  47781. export var rgbdEncodePixelShader: {
  47782. name: string;
  47783. shader: string;
  47784. };
  47785. }
  47786. declare module BABYLON {
  47787. /** @hidden */
  47788. export var rgbdDecodePixelShader: {
  47789. name: string;
  47790. shader: string;
  47791. };
  47792. }
  47793. declare module BABYLON {
  47794. /**
  47795. * Raw texture data and descriptor sufficient for WebGL texture upload
  47796. */
  47797. export interface EnvironmentTextureInfo {
  47798. /**
  47799. * Version of the environment map
  47800. */
  47801. version: number;
  47802. /**
  47803. * Width of image
  47804. */
  47805. width: number;
  47806. /**
  47807. * Irradiance information stored in the file.
  47808. */
  47809. irradiance: any;
  47810. /**
  47811. * Specular information stored in the file.
  47812. */
  47813. specular: any;
  47814. }
  47815. /**
  47816. * Defines One Image in the file. It requires only the position in the file
  47817. * as well as the length.
  47818. */
  47819. interface BufferImageData {
  47820. /**
  47821. * Length of the image data.
  47822. */
  47823. length: number;
  47824. /**
  47825. * Position of the data from the null terminator delimiting the end of the JSON.
  47826. */
  47827. position: number;
  47828. }
  47829. /**
  47830. * Defines the specular data enclosed in the file.
  47831. * This corresponds to the version 1 of the data.
  47832. */
  47833. export interface EnvironmentTextureSpecularInfoV1 {
  47834. /**
  47835. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47836. */
  47837. specularDataPosition?: number;
  47838. /**
  47839. * This contains all the images data needed to reconstruct the cubemap.
  47840. */
  47841. mipmaps: Array<BufferImageData>;
  47842. /**
  47843. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47844. */
  47845. lodGenerationScale: number;
  47846. }
  47847. /**
  47848. * Sets of helpers addressing the serialization and deserialization of environment texture
  47849. * stored in a BabylonJS env file.
  47850. * Those files are usually stored as .env files.
  47851. */
  47852. export class EnvironmentTextureTools {
  47853. /**
  47854. * Magic number identifying the env file.
  47855. */
  47856. private static _MagicBytes;
  47857. /**
  47858. * Gets the environment info from an env file.
  47859. * @param data The array buffer containing the .env bytes.
  47860. * @returns the environment file info (the json header) if successfully parsed.
  47861. */
  47862. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47863. /**
  47864. * Creates an environment texture from a loaded cube texture.
  47865. * @param texture defines the cube texture to convert in env file
  47866. * @return a promise containing the environment data if succesfull.
  47867. */
  47868. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47869. /**
  47870. * Creates a JSON representation of the spherical data.
  47871. * @param texture defines the texture containing the polynomials
  47872. * @return the JSON representation of the spherical info
  47873. */
  47874. private static _CreateEnvTextureIrradiance;
  47875. /**
  47876. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47877. * @param data the image data
  47878. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47879. * @return the views described by info providing access to the underlying buffer
  47880. */
  47881. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47882. /**
  47883. * Uploads the texture info contained in the env file to the GPU.
  47884. * @param texture defines the internal texture to upload to
  47885. * @param data defines the data to load
  47886. * @param info defines the texture info retrieved through the GetEnvInfo method
  47887. * @returns a promise
  47888. */
  47889. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47890. private static _OnImageReadyAsync;
  47891. /**
  47892. * Uploads the levels of image data to the GPU.
  47893. * @param texture defines the internal texture to upload to
  47894. * @param imageData defines the array buffer views of image data [mipmap][face]
  47895. * @returns a promise
  47896. */
  47897. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47898. /**
  47899. * Uploads spherical polynomials information to the texture.
  47900. * @param texture defines the texture we are trying to upload the information to
  47901. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47902. */
  47903. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47904. /** @hidden */
  47905. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47906. }
  47907. }
  47908. declare module BABYLON {
  47909. /**
  47910. * Contains position and normal vectors for a vertex
  47911. */
  47912. export class PositionNormalVertex {
  47913. /** the position of the vertex (defaut: 0,0,0) */
  47914. position: Vector3;
  47915. /** the normal of the vertex (defaut: 0,1,0) */
  47916. normal: Vector3;
  47917. /**
  47918. * Creates a PositionNormalVertex
  47919. * @param position the position of the vertex (defaut: 0,0,0)
  47920. * @param normal the normal of the vertex (defaut: 0,1,0)
  47921. */
  47922. constructor(
  47923. /** the position of the vertex (defaut: 0,0,0) */
  47924. position?: Vector3,
  47925. /** the normal of the vertex (defaut: 0,1,0) */
  47926. normal?: Vector3);
  47927. /**
  47928. * Clones the PositionNormalVertex
  47929. * @returns the cloned PositionNormalVertex
  47930. */
  47931. clone(): PositionNormalVertex;
  47932. }
  47933. /**
  47934. * Contains position, normal and uv vectors for a vertex
  47935. */
  47936. export class PositionNormalTextureVertex {
  47937. /** the position of the vertex (defaut: 0,0,0) */
  47938. position: Vector3;
  47939. /** the normal of the vertex (defaut: 0,1,0) */
  47940. normal: Vector3;
  47941. /** the uv of the vertex (default: 0,0) */
  47942. uv: Vector2;
  47943. /**
  47944. * Creates a PositionNormalTextureVertex
  47945. * @param position the position of the vertex (defaut: 0,0,0)
  47946. * @param normal the normal of the vertex (defaut: 0,1,0)
  47947. * @param uv the uv of the vertex (default: 0,0)
  47948. */
  47949. constructor(
  47950. /** the position of the vertex (defaut: 0,0,0) */
  47951. position?: Vector3,
  47952. /** the normal of the vertex (defaut: 0,1,0) */
  47953. normal?: Vector3,
  47954. /** the uv of the vertex (default: 0,0) */
  47955. uv?: Vector2);
  47956. /**
  47957. * Clones the PositionNormalTextureVertex
  47958. * @returns the cloned PositionNormalTextureVertex
  47959. */
  47960. clone(): PositionNormalTextureVertex;
  47961. }
  47962. }
  47963. declare module BABYLON {
  47964. /** @hidden */
  47965. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47966. private _genericAttributeLocation;
  47967. private _varyingLocationCount;
  47968. private _varyingLocationMap;
  47969. private _replacements;
  47970. private _textureCount;
  47971. private _uniforms;
  47972. lineProcessor(line: string): string;
  47973. attributeProcessor(attribute: string): string;
  47974. varyingProcessor(varying: string, isFragment: boolean): string;
  47975. uniformProcessor(uniform: string): string;
  47976. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47977. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47978. }
  47979. }
  47980. declare module BABYLON {
  47981. /**
  47982. * Container for accessors for natively-stored mesh data buffers.
  47983. */
  47984. class NativeDataBuffer extends DataBuffer {
  47985. /**
  47986. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47987. */
  47988. nativeIndexBuffer?: any;
  47989. /**
  47990. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47991. */
  47992. nativeVertexBuffer?: any;
  47993. }
  47994. /** @hidden */
  47995. class NativeTexture extends InternalTexture {
  47996. getInternalTexture(): InternalTexture;
  47997. getViewCount(): number;
  47998. }
  47999. /** @hidden */
  48000. export class NativeEngine extends Engine {
  48001. private readonly _native;
  48002. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  48003. private readonly INVALID_HANDLE;
  48004. getHardwareScalingLevel(): number;
  48005. constructor();
  48006. /**
  48007. * Can be used to override the current requestAnimationFrame requester.
  48008. * @hidden
  48009. */
  48010. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  48011. /**
  48012. * Override default engine behavior.
  48013. * @param color
  48014. * @param backBuffer
  48015. * @param depth
  48016. * @param stencil
  48017. */
  48018. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  48019. /**
  48020. * Gets host document
  48021. * @returns the host document object
  48022. */
  48023. getHostDocument(): Nullable<Document>;
  48024. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48025. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  48026. createVertexBuffer(data: DataArray): NativeDataBuffer;
  48027. recordVertexArrayObject(vertexBuffers: {
  48028. [key: string]: VertexBuffer;
  48029. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  48030. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48031. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  48032. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48033. /**
  48034. * Draw a list of indexed primitives
  48035. * @param fillMode defines the primitive to use
  48036. * @param indexStart defines the starting index
  48037. * @param indexCount defines the number of index to draw
  48038. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48039. */
  48040. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48041. /**
  48042. * Draw a list of unindexed primitives
  48043. * @param fillMode defines the primitive to use
  48044. * @param verticesStart defines the index of first vertex to draw
  48045. * @param verticesCount defines the count of vertices to draw
  48046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48047. */
  48048. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48049. createPipelineContext(): IPipelineContext;
  48050. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  48051. /** @hidden */
  48052. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  48053. /** @hidden */
  48054. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  48055. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48056. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  48057. protected _setProgram(program: WebGLProgram): void;
  48058. _releaseEffect(effect: Effect): void;
  48059. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  48060. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  48061. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  48062. bindSamplers(effect: Effect): void;
  48063. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  48064. getRenderWidth(useScreen?: boolean): number;
  48065. getRenderHeight(useScreen?: boolean): number;
  48066. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  48067. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48068. /**
  48069. * Set the z offset to apply to current rendering
  48070. * @param value defines the offset to apply
  48071. */
  48072. setZOffset(value: number): void;
  48073. /**
  48074. * Gets the current value of the zOffset
  48075. * @returns the current zOffset state
  48076. */
  48077. getZOffset(): number;
  48078. /**
  48079. * Enable or disable depth buffering
  48080. * @param enable defines the state to set
  48081. */
  48082. setDepthBuffer(enable: boolean): void;
  48083. /**
  48084. * Gets a boolean indicating if depth writing is enabled
  48085. * @returns the current depth writing state
  48086. */
  48087. getDepthWrite(): boolean;
  48088. /**
  48089. * Enable or disable depth writing
  48090. * @param enable defines the state to set
  48091. */
  48092. setDepthWrite(enable: boolean): void;
  48093. /**
  48094. * Enable or disable color writing
  48095. * @param enable defines the state to set
  48096. */
  48097. setColorWrite(enable: boolean): void;
  48098. /**
  48099. * Gets a boolean indicating if color writing is enabled
  48100. * @returns the current color writing state
  48101. */
  48102. getColorWrite(): boolean;
  48103. /**
  48104. * Sets alpha constants used by some alpha blending modes
  48105. * @param r defines the red component
  48106. * @param g defines the green component
  48107. * @param b defines the blue component
  48108. * @param a defines the alpha component
  48109. */
  48110. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  48111. /**
  48112. * Sets the current alpha mode
  48113. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  48114. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48115. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48116. */
  48117. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48118. /**
  48119. * Gets the current alpha mode
  48120. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48121. * @returns the current alpha mode
  48122. */
  48123. getAlphaMode(): number;
  48124. setInt(uniform: WebGLUniformLocation, int: number): void;
  48125. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48126. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48127. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48128. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48129. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48130. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48131. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48132. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48133. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48134. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48135. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48136. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48137. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48138. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48139. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48140. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48141. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48142. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48143. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48144. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  48145. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  48146. wipeCaches(bruteForce?: boolean): void;
  48147. _createTexture(): WebGLTexture;
  48148. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  48149. /**
  48150. * Usually called from Texture.ts.
  48151. * Passed information to create a WebGLTexture
  48152. * @param urlArg defines a value which contains one of the following:
  48153. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48154. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48155. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48156. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48157. * @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)
  48158. * @param scene needed for loading to the correct scene
  48159. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48160. * @param onLoad optional callback to be called upon successful completion
  48161. * @param onError optional callback to be called upon failure
  48162. * @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
  48163. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48164. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48165. * @param forcedExtension defines the extension to use to pick the right loader
  48166. * @param mimeType defines an optional mime type
  48167. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48168. */
  48169. 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;
  48170. /**
  48171. * Creates a cube texture
  48172. * @param rootUrl defines the url where the files to load is located
  48173. * @param scene defines the current scene
  48174. * @param files defines the list of files to load (1 per face)
  48175. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  48176. * @param onLoad defines an optional callback raised when the texture is loaded
  48177. * @param onError defines an optional callback raised if there is an issue to load the texture
  48178. * @param format defines the format of the data
  48179. * @param forcedExtension defines the extension to use to pick the right loader
  48180. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  48181. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48182. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48183. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  48184. * @returns the cube texture as an InternalTexture
  48185. */
  48186. 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;
  48187. private _getSamplingFilter;
  48188. private static _GetNativeTextureFormat;
  48189. createRenderTargetTexture(size: number | {
  48190. width: number;
  48191. height: number;
  48192. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  48193. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48194. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48195. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48196. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  48197. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  48198. /**
  48199. * Updates a dynamic vertex buffer.
  48200. * @param vertexBuffer the vertex buffer to update
  48201. * @param data the data used to update the vertex buffer
  48202. * @param byteOffset the byte offset of the data (optional)
  48203. * @param byteLength the byte length of the data (optional)
  48204. */
  48205. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  48206. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  48207. private _updateAnisotropicLevel;
  48208. private _getAddressMode;
  48209. /** @hidden */
  48210. _bindTexture(channel: number, texture: InternalTexture): void;
  48211. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  48212. releaseEffects(): void;
  48213. /** @hidden */
  48214. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48215. /** @hidden */
  48216. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48217. /** @hidden */
  48218. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48219. /** @hidden */
  48220. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48221. }
  48222. }
  48223. declare module BABYLON {
  48224. /**
  48225. * Gather the list of clipboard event types as constants.
  48226. */
  48227. export class ClipboardEventTypes {
  48228. /**
  48229. * The clipboard event is fired when a copy command is active (pressed).
  48230. */
  48231. static readonly COPY: number;
  48232. /**
  48233. * The clipboard event is fired when a cut command is active (pressed).
  48234. */
  48235. static readonly CUT: number;
  48236. /**
  48237. * The clipboard event is fired when a paste command is active (pressed).
  48238. */
  48239. static readonly PASTE: number;
  48240. }
  48241. /**
  48242. * This class is used to store clipboard related info for the onClipboardObservable event.
  48243. */
  48244. export class ClipboardInfo {
  48245. /**
  48246. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48247. */
  48248. type: number;
  48249. /**
  48250. * Defines the related dom event
  48251. */
  48252. event: ClipboardEvent;
  48253. /**
  48254. *Creates an instance of ClipboardInfo.
  48255. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  48256. * @param event Defines the related dom event
  48257. */
  48258. constructor(
  48259. /**
  48260. * Defines the type of event (BABYLON.ClipboardEventTypes)
  48261. */
  48262. type: number,
  48263. /**
  48264. * Defines the related dom event
  48265. */
  48266. event: ClipboardEvent);
  48267. /**
  48268. * Get the clipboard event's type from the keycode.
  48269. * @param keyCode Defines the keyCode for the current keyboard event.
  48270. * @return {number}
  48271. */
  48272. static GetTypeFromCharacter(keyCode: number): number;
  48273. }
  48274. }
  48275. declare module BABYLON {
  48276. /**
  48277. * Google Daydream controller
  48278. */
  48279. export class DaydreamController extends WebVRController {
  48280. /**
  48281. * Base Url for the controller model.
  48282. */
  48283. static MODEL_BASE_URL: string;
  48284. /**
  48285. * File name for the controller model.
  48286. */
  48287. static MODEL_FILENAME: string;
  48288. /**
  48289. * Gamepad Id prefix used to identify Daydream Controller.
  48290. */
  48291. static readonly GAMEPAD_ID_PREFIX: string;
  48292. /**
  48293. * Creates a new DaydreamController from a gamepad
  48294. * @param vrGamepad the gamepad that the controller should be created from
  48295. */
  48296. constructor(vrGamepad: any);
  48297. /**
  48298. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48299. * @param scene scene in which to add meshes
  48300. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48301. */
  48302. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48303. /**
  48304. * Called once for each button that changed state since the last frame
  48305. * @param buttonIdx Which button index changed
  48306. * @param state New state of the button
  48307. * @param changes Which properties on the state changed since last frame
  48308. */
  48309. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48310. }
  48311. }
  48312. declare module BABYLON {
  48313. /**
  48314. * Gear VR Controller
  48315. */
  48316. export class GearVRController extends WebVRController {
  48317. /**
  48318. * Base Url for the controller model.
  48319. */
  48320. static MODEL_BASE_URL: string;
  48321. /**
  48322. * File name for the controller model.
  48323. */
  48324. static MODEL_FILENAME: string;
  48325. /**
  48326. * Gamepad Id prefix used to identify this controller.
  48327. */
  48328. static readonly GAMEPAD_ID_PREFIX: string;
  48329. private readonly _buttonIndexToObservableNameMap;
  48330. /**
  48331. * Creates a new GearVRController from a gamepad
  48332. * @param vrGamepad the gamepad that the controller should be created from
  48333. */
  48334. constructor(vrGamepad: any);
  48335. /**
  48336. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48337. * @param scene scene in which to add meshes
  48338. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48339. */
  48340. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48341. /**
  48342. * Called once for each button that changed state since the last frame
  48343. * @param buttonIdx Which button index changed
  48344. * @param state New state of the button
  48345. * @param changes Which properties on the state changed since last frame
  48346. */
  48347. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48348. }
  48349. }
  48350. declare module BABYLON {
  48351. /**
  48352. * Generic Controller
  48353. */
  48354. export class GenericController extends WebVRController {
  48355. /**
  48356. * Base Url for the controller model.
  48357. */
  48358. static readonly MODEL_BASE_URL: string;
  48359. /**
  48360. * File name for the controller model.
  48361. */
  48362. static readonly MODEL_FILENAME: string;
  48363. /**
  48364. * Creates a new GenericController from a gamepad
  48365. * @param vrGamepad the gamepad that the controller should be created from
  48366. */
  48367. constructor(vrGamepad: any);
  48368. /**
  48369. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48370. * @param scene scene in which to add meshes
  48371. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48372. */
  48373. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48374. /**
  48375. * Called once for each button that changed state since the last frame
  48376. * @param buttonIdx Which button index changed
  48377. * @param state New state of the button
  48378. * @param changes Which properties on the state changed since last frame
  48379. */
  48380. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48381. }
  48382. }
  48383. declare module BABYLON {
  48384. /**
  48385. * Oculus Touch Controller
  48386. */
  48387. export class OculusTouchController extends WebVRController {
  48388. /**
  48389. * Base Url for the controller model.
  48390. */
  48391. static MODEL_BASE_URL: string;
  48392. /**
  48393. * File name for the left controller model.
  48394. */
  48395. static MODEL_LEFT_FILENAME: string;
  48396. /**
  48397. * File name for the right controller model.
  48398. */
  48399. static MODEL_RIGHT_FILENAME: string;
  48400. /**
  48401. * Base Url for the Quest controller model.
  48402. */
  48403. static QUEST_MODEL_BASE_URL: string;
  48404. /**
  48405. * @hidden
  48406. * If the controllers are running on a device that needs the updated Quest controller models
  48407. */
  48408. static _IsQuest: boolean;
  48409. /**
  48410. * Fired when the secondary trigger on this controller is modified
  48411. */
  48412. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48413. /**
  48414. * Fired when the thumb rest on this controller is modified
  48415. */
  48416. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48417. /**
  48418. * Creates a new OculusTouchController from a gamepad
  48419. * @param vrGamepad the gamepad that the controller should be created from
  48420. */
  48421. constructor(vrGamepad: any);
  48422. /**
  48423. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48424. * @param scene scene in which to add meshes
  48425. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48426. */
  48427. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48428. /**
  48429. * Fired when the A button on this controller is modified
  48430. */
  48431. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48432. /**
  48433. * Fired when the B button on this controller is modified
  48434. */
  48435. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48436. /**
  48437. * Fired when the X button on this controller is modified
  48438. */
  48439. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48440. /**
  48441. * Fired when the Y button on this controller is modified
  48442. */
  48443. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48444. /**
  48445. * Called once for each button that changed state since the last frame
  48446. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48447. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48448. * 2) secondary trigger (same)
  48449. * 3) A (right) X (left), touch, pressed = value
  48450. * 4) B / Y
  48451. * 5) thumb rest
  48452. * @param buttonIdx Which button index changed
  48453. * @param state New state of the button
  48454. * @param changes Which properties on the state changed since last frame
  48455. */
  48456. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48457. }
  48458. }
  48459. declare module BABYLON {
  48460. /**
  48461. * Vive Controller
  48462. */
  48463. export class ViveController extends WebVRController {
  48464. /**
  48465. * Base Url for the controller model.
  48466. */
  48467. static MODEL_BASE_URL: string;
  48468. /**
  48469. * File name for the controller model.
  48470. */
  48471. static MODEL_FILENAME: string;
  48472. /**
  48473. * Creates a new ViveController from a gamepad
  48474. * @param vrGamepad the gamepad that the controller should be created from
  48475. */
  48476. constructor(vrGamepad: any);
  48477. /**
  48478. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48479. * @param scene scene in which to add meshes
  48480. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48481. */
  48482. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48483. /**
  48484. * Fired when the left button on this controller is modified
  48485. */
  48486. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48487. /**
  48488. * Fired when the right button on this controller is modified
  48489. */
  48490. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48491. /**
  48492. * Fired when the menu button on this controller is modified
  48493. */
  48494. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48495. /**
  48496. * Called once for each button that changed state since the last frame
  48497. * Vive mapping:
  48498. * 0: touchpad
  48499. * 1: trigger
  48500. * 2: left AND right buttons
  48501. * 3: menu button
  48502. * @param buttonIdx Which button index changed
  48503. * @param state New state of the button
  48504. * @param changes Which properties on the state changed since last frame
  48505. */
  48506. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48507. }
  48508. }
  48509. declare module BABYLON {
  48510. /**
  48511. * Defines the WindowsMotionController object that the state of the windows motion controller
  48512. */
  48513. export class WindowsMotionController extends WebVRController {
  48514. /**
  48515. * The base url used to load the left and right controller models
  48516. */
  48517. static MODEL_BASE_URL: string;
  48518. /**
  48519. * The name of the left controller model file
  48520. */
  48521. static MODEL_LEFT_FILENAME: string;
  48522. /**
  48523. * The name of the right controller model file
  48524. */
  48525. static MODEL_RIGHT_FILENAME: string;
  48526. /**
  48527. * The controller name prefix for this controller type
  48528. */
  48529. static readonly GAMEPAD_ID_PREFIX: string;
  48530. /**
  48531. * The controller id pattern for this controller type
  48532. */
  48533. private static readonly GAMEPAD_ID_PATTERN;
  48534. private _loadedMeshInfo;
  48535. protected readonly _mapping: {
  48536. buttons: string[];
  48537. buttonMeshNames: {
  48538. trigger: string;
  48539. menu: string;
  48540. grip: string;
  48541. thumbstick: string;
  48542. trackpad: string;
  48543. };
  48544. buttonObservableNames: {
  48545. trigger: string;
  48546. menu: string;
  48547. grip: string;
  48548. thumbstick: string;
  48549. trackpad: string;
  48550. };
  48551. axisMeshNames: string[];
  48552. pointingPoseMeshName: string;
  48553. };
  48554. /**
  48555. * Fired when the trackpad on this controller is clicked
  48556. */
  48557. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48558. /**
  48559. * Fired when the trackpad on this controller is modified
  48560. */
  48561. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48562. /**
  48563. * The current x and y values of this controller's trackpad
  48564. */
  48565. trackpad: StickValues;
  48566. /**
  48567. * Creates a new WindowsMotionController from a gamepad
  48568. * @param vrGamepad the gamepad that the controller should be created from
  48569. */
  48570. constructor(vrGamepad: any);
  48571. /**
  48572. * Fired when the trigger on this controller is modified
  48573. */
  48574. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48575. /**
  48576. * Fired when the menu button on this controller is modified
  48577. */
  48578. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48579. /**
  48580. * Fired when the grip button on this controller is modified
  48581. */
  48582. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48583. /**
  48584. * Fired when the thumbstick button on this controller is modified
  48585. */
  48586. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48587. /**
  48588. * Fired when the touchpad button on this controller is modified
  48589. */
  48590. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48591. /**
  48592. * Fired when the touchpad values on this controller are modified
  48593. */
  48594. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48595. protected _updateTrackpad(): void;
  48596. /**
  48597. * Called once per frame by the engine.
  48598. */
  48599. update(): void;
  48600. /**
  48601. * Called once for each button that changed state since the last frame
  48602. * @param buttonIdx Which button index changed
  48603. * @param state New state of the button
  48604. * @param changes Which properties on the state changed since last frame
  48605. */
  48606. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48607. /**
  48608. * Moves the buttons on the controller mesh based on their current state
  48609. * @param buttonName the name of the button to move
  48610. * @param buttonValue the value of the button which determines the buttons new position
  48611. */
  48612. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48613. /**
  48614. * Moves the axis on the controller mesh based on its current state
  48615. * @param axis the index of the axis
  48616. * @param axisValue the value of the axis which determines the meshes new position
  48617. * @hidden
  48618. */
  48619. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48620. /**
  48621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48622. * @param scene scene in which to add meshes
  48623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48624. */
  48625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48626. /**
  48627. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48628. * can be transformed by button presses and axes values, based on this._mapping.
  48629. *
  48630. * @param scene scene in which the meshes exist
  48631. * @param meshes list of meshes that make up the controller model to process
  48632. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48633. */
  48634. private processModel;
  48635. private createMeshInfo;
  48636. /**
  48637. * Gets the ray of the controller in the direction the controller is pointing
  48638. * @param length the length the resulting ray should be
  48639. * @returns a ray in the direction the controller is pointing
  48640. */
  48641. getForwardRay(length?: number): Ray;
  48642. /**
  48643. * Disposes of the controller
  48644. */
  48645. dispose(): void;
  48646. }
  48647. /**
  48648. * This class represents a new windows motion controller in XR.
  48649. */
  48650. export class XRWindowsMotionController extends WindowsMotionController {
  48651. /**
  48652. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48653. */
  48654. protected readonly _mapping: {
  48655. buttons: string[];
  48656. buttonMeshNames: {
  48657. trigger: string;
  48658. menu: string;
  48659. grip: string;
  48660. thumbstick: string;
  48661. trackpad: string;
  48662. };
  48663. buttonObservableNames: {
  48664. trigger: string;
  48665. menu: string;
  48666. grip: string;
  48667. thumbstick: string;
  48668. trackpad: string;
  48669. };
  48670. axisMeshNames: string[];
  48671. pointingPoseMeshName: string;
  48672. };
  48673. /**
  48674. * Construct a new XR-Based windows motion controller
  48675. *
  48676. * @param gamepadInfo the gamepad object from the browser
  48677. */
  48678. constructor(gamepadInfo: any);
  48679. /**
  48680. * holds the thumbstick values (X,Y)
  48681. */
  48682. thumbstickValues: StickValues;
  48683. /**
  48684. * Fired when the thumbstick on this controller is clicked
  48685. */
  48686. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48687. /**
  48688. * Fired when the thumbstick on this controller is modified
  48689. */
  48690. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48691. /**
  48692. * Fired when the touchpad button on this controller is modified
  48693. */
  48694. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48695. /**
  48696. * Fired when the touchpad values on this controller are modified
  48697. */
  48698. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48699. /**
  48700. * Fired when the thumbstick button on this controller is modified
  48701. * here to prevent breaking changes
  48702. */
  48703. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48704. /**
  48705. * updating the thumbstick(!) and not the trackpad.
  48706. * This is named this way due to the difference between WebVR and XR and to avoid
  48707. * changing the parent class.
  48708. */
  48709. protected _updateTrackpad(): void;
  48710. /**
  48711. * Disposes the class with joy
  48712. */
  48713. dispose(): void;
  48714. }
  48715. }
  48716. declare module BABYLON {
  48717. /**
  48718. * Class containing static functions to help procedurally build meshes
  48719. */
  48720. export class PolyhedronBuilder {
  48721. /**
  48722. * Creates a polyhedron mesh
  48723. * * 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
  48724. * * The parameter `size` (positive float, default 1) sets the polygon size
  48725. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48726. * * 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`
  48727. * * 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
  48728. * * 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)`)
  48729. * * 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
  48730. * * 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
  48731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48732. * * 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
  48733. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48734. * @param name defines the name of the mesh
  48735. * @param options defines the options used to create the mesh
  48736. * @param scene defines the hosting scene
  48737. * @returns the polyhedron mesh
  48738. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48739. */
  48740. static CreatePolyhedron(name: string, options: {
  48741. type?: number;
  48742. size?: number;
  48743. sizeX?: number;
  48744. sizeY?: number;
  48745. sizeZ?: number;
  48746. custom?: any;
  48747. faceUV?: Vector4[];
  48748. faceColors?: Color4[];
  48749. flat?: boolean;
  48750. updatable?: boolean;
  48751. sideOrientation?: number;
  48752. frontUVs?: Vector4;
  48753. backUVs?: Vector4;
  48754. }, scene?: Nullable<Scene>): Mesh;
  48755. }
  48756. }
  48757. declare module BABYLON {
  48758. /**
  48759. * Gizmo that enables scaling a mesh along 3 axis
  48760. */
  48761. export class ScaleGizmo extends Gizmo {
  48762. /**
  48763. * Internal gizmo used for interactions on the x axis
  48764. */
  48765. xGizmo: AxisScaleGizmo;
  48766. /**
  48767. * Internal gizmo used for interactions on the y axis
  48768. */
  48769. yGizmo: AxisScaleGizmo;
  48770. /**
  48771. * Internal gizmo used for interactions on the z axis
  48772. */
  48773. zGizmo: AxisScaleGizmo;
  48774. /**
  48775. * Internal gizmo used to scale all axis equally
  48776. */
  48777. uniformScaleGizmo: AxisScaleGizmo;
  48778. private _meshAttached;
  48779. private _updateGizmoRotationToMatchAttachedMesh;
  48780. private _snapDistance;
  48781. private _scaleRatio;
  48782. private _uniformScalingMesh;
  48783. private _octahedron;
  48784. private _sensitivity;
  48785. /** Fires an event when any of it's sub gizmos are dragged */
  48786. onDragStartObservable: Observable<unknown>;
  48787. /** Fires an event when any of it's sub gizmos are released from dragging */
  48788. onDragEndObservable: Observable<unknown>;
  48789. get attachedMesh(): Nullable<AbstractMesh>;
  48790. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48791. /**
  48792. * Creates a ScaleGizmo
  48793. * @param gizmoLayer The utility layer the gizmo will be added to
  48794. */
  48795. constructor(gizmoLayer?: UtilityLayerRenderer);
  48796. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48797. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48798. /**
  48799. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48800. */
  48801. set snapDistance(value: number);
  48802. get snapDistance(): number;
  48803. /**
  48804. * Ratio for the scale of the gizmo (Default: 1)
  48805. */
  48806. set scaleRatio(value: number);
  48807. get scaleRatio(): number;
  48808. /**
  48809. * Sensitivity factor for dragging (Default: 1)
  48810. */
  48811. set sensitivity(value: number);
  48812. get sensitivity(): number;
  48813. /**
  48814. * Disposes of the gizmo
  48815. */
  48816. dispose(): void;
  48817. }
  48818. }
  48819. declare module BABYLON {
  48820. /**
  48821. * Single axis scale gizmo
  48822. */
  48823. export class AxisScaleGizmo extends Gizmo {
  48824. /**
  48825. * Drag behavior responsible for the gizmos dragging interactions
  48826. */
  48827. dragBehavior: PointerDragBehavior;
  48828. private _pointerObserver;
  48829. /**
  48830. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48831. */
  48832. snapDistance: number;
  48833. /**
  48834. * Event that fires each time the gizmo snaps to a new location.
  48835. * * snapDistance is the the change in distance
  48836. */
  48837. onSnapObservable: Observable<{
  48838. snapDistance: number;
  48839. }>;
  48840. /**
  48841. * If the scaling operation should be done on all axis (default: false)
  48842. */
  48843. uniformScaling: boolean;
  48844. /**
  48845. * Custom sensitivity value for the drag strength
  48846. */
  48847. sensitivity: number;
  48848. private _isEnabled;
  48849. private _parent;
  48850. private _arrow;
  48851. private _coloredMaterial;
  48852. private _hoverMaterial;
  48853. /**
  48854. * Creates an AxisScaleGizmo
  48855. * @param gizmoLayer The utility layer the gizmo will be added to
  48856. * @param dragAxis The axis which the gizmo will be able to scale on
  48857. * @param color The color of the gizmo
  48858. */
  48859. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48860. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48861. /**
  48862. * If the gizmo is enabled
  48863. */
  48864. set isEnabled(value: boolean);
  48865. get isEnabled(): boolean;
  48866. /**
  48867. * Disposes of the gizmo
  48868. */
  48869. dispose(): void;
  48870. /**
  48871. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48872. * @param mesh The mesh to replace the default mesh of the gizmo
  48873. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48874. */
  48875. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48876. }
  48877. }
  48878. declare module BABYLON {
  48879. /**
  48880. * Bounding box gizmo
  48881. */
  48882. export class BoundingBoxGizmo extends Gizmo {
  48883. private _lineBoundingBox;
  48884. private _rotateSpheresParent;
  48885. private _scaleBoxesParent;
  48886. private _boundingDimensions;
  48887. private _renderObserver;
  48888. private _pointerObserver;
  48889. private _scaleDragSpeed;
  48890. private _tmpQuaternion;
  48891. private _tmpVector;
  48892. private _tmpRotationMatrix;
  48893. /**
  48894. * 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)
  48895. */
  48896. ignoreChildren: boolean;
  48897. /**
  48898. * 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)
  48899. */
  48900. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48901. /**
  48902. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48903. */
  48904. rotationSphereSize: number;
  48905. /**
  48906. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48907. */
  48908. scaleBoxSize: number;
  48909. /**
  48910. * 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)
  48911. */
  48912. fixedDragMeshScreenSize: boolean;
  48913. /**
  48914. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48915. */
  48916. fixedDragMeshScreenSizeDistanceFactor: number;
  48917. /**
  48918. * Fired when a rotation sphere or scale box is dragged
  48919. */
  48920. onDragStartObservable: Observable<{}>;
  48921. /**
  48922. * Fired when a scale box is dragged
  48923. */
  48924. onScaleBoxDragObservable: Observable<{}>;
  48925. /**
  48926. * Fired when a scale box drag is ended
  48927. */
  48928. onScaleBoxDragEndObservable: Observable<{}>;
  48929. /**
  48930. * Fired when a rotation sphere is dragged
  48931. */
  48932. onRotationSphereDragObservable: Observable<{}>;
  48933. /**
  48934. * Fired when a rotation sphere drag is ended
  48935. */
  48936. onRotationSphereDragEndObservable: Observable<{}>;
  48937. /**
  48938. * 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)
  48939. */
  48940. scalePivot: Nullable<Vector3>;
  48941. /**
  48942. * Mesh used as a pivot to rotate the attached mesh
  48943. */
  48944. private _anchorMesh;
  48945. private _existingMeshScale;
  48946. private _dragMesh;
  48947. private pointerDragBehavior;
  48948. private coloredMaterial;
  48949. private hoverColoredMaterial;
  48950. /**
  48951. * Sets the color of the bounding box gizmo
  48952. * @param color the color to set
  48953. */
  48954. setColor(color: Color3): void;
  48955. /**
  48956. * Creates an BoundingBoxGizmo
  48957. * @param gizmoLayer The utility layer the gizmo will be added to
  48958. * @param color The color of the gizmo
  48959. */
  48960. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48961. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48962. private _selectNode;
  48963. /**
  48964. * Updates the bounding box information for the Gizmo
  48965. */
  48966. updateBoundingBox(): void;
  48967. private _updateRotationSpheres;
  48968. private _updateScaleBoxes;
  48969. /**
  48970. * Enables rotation on the specified axis and disables rotation on the others
  48971. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48972. */
  48973. setEnabledRotationAxis(axis: string): void;
  48974. /**
  48975. * Enables/disables scaling
  48976. * @param enable if scaling should be enabled
  48977. * @param homogeneousScaling defines if scaling should only be homogeneous
  48978. */
  48979. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  48980. private _updateDummy;
  48981. /**
  48982. * Enables a pointer drag behavior on the bounding box of the gizmo
  48983. */
  48984. enableDragBehavior(): void;
  48985. /**
  48986. * Disposes of the gizmo
  48987. */
  48988. dispose(): void;
  48989. /**
  48990. * 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)
  48991. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48992. * @returns the bounding box mesh with the passed in mesh as a child
  48993. */
  48994. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48995. /**
  48996. * CustomMeshes are not supported by this gizmo
  48997. * @param mesh The mesh to replace the default mesh of the gizmo
  48998. */
  48999. setCustomMesh(mesh: Mesh): void;
  49000. }
  49001. }
  49002. declare module BABYLON {
  49003. /**
  49004. * Single plane rotation gizmo
  49005. */
  49006. export class PlaneRotationGizmo extends Gizmo {
  49007. /**
  49008. * Drag behavior responsible for the gizmos dragging interactions
  49009. */
  49010. dragBehavior: PointerDragBehavior;
  49011. private _pointerObserver;
  49012. /**
  49013. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  49014. */
  49015. snapDistance: number;
  49016. /**
  49017. * Event that fires each time the gizmo snaps to a new location.
  49018. * * snapDistance is the the change in distance
  49019. */
  49020. onSnapObservable: Observable<{
  49021. snapDistance: number;
  49022. }>;
  49023. private _isEnabled;
  49024. private _parent;
  49025. /**
  49026. * Creates a PlaneRotationGizmo
  49027. * @param gizmoLayer The utility layer the gizmo will be added to
  49028. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  49029. * @param color The color of the gizmo
  49030. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49031. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49032. */
  49033. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  49034. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  49035. /**
  49036. * If the gizmo is enabled
  49037. */
  49038. set isEnabled(value: boolean);
  49039. get isEnabled(): boolean;
  49040. /**
  49041. * Disposes of the gizmo
  49042. */
  49043. dispose(): void;
  49044. }
  49045. }
  49046. declare module BABYLON {
  49047. /**
  49048. * Gizmo that enables rotating a mesh along 3 axis
  49049. */
  49050. export class RotationGizmo extends Gizmo {
  49051. /**
  49052. * Internal gizmo used for interactions on the x axis
  49053. */
  49054. xGizmo: PlaneRotationGizmo;
  49055. /**
  49056. * Internal gizmo used for interactions on the y axis
  49057. */
  49058. yGizmo: PlaneRotationGizmo;
  49059. /**
  49060. * Internal gizmo used for interactions on the z axis
  49061. */
  49062. zGizmo: PlaneRotationGizmo;
  49063. /** Fires an event when any of it's sub gizmos are dragged */
  49064. onDragStartObservable: Observable<unknown>;
  49065. /** Fires an event when any of it's sub gizmos are released from dragging */
  49066. onDragEndObservable: Observable<unknown>;
  49067. private _meshAttached;
  49068. get attachedMesh(): Nullable<AbstractMesh>;
  49069. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49070. /**
  49071. * Creates a RotationGizmo
  49072. * @param gizmoLayer The utility layer the gizmo will be added to
  49073. * @param tessellation Amount of tessellation to be used when creating rotation circles
  49074. * @param useEulerRotation Use and update Euler angle instead of quaternion
  49075. */
  49076. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  49077. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  49078. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  49079. /**
  49080. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  49081. */
  49082. set snapDistance(value: number);
  49083. get snapDistance(): number;
  49084. /**
  49085. * Ratio for the scale of the gizmo (Default: 1)
  49086. */
  49087. set scaleRatio(value: number);
  49088. get scaleRatio(): number;
  49089. /**
  49090. * Disposes of the gizmo
  49091. */
  49092. dispose(): void;
  49093. /**
  49094. * CustomMeshes are not supported by this gizmo
  49095. * @param mesh The mesh to replace the default mesh of the gizmo
  49096. */
  49097. setCustomMesh(mesh: Mesh): void;
  49098. }
  49099. }
  49100. declare module BABYLON {
  49101. /**
  49102. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  49103. */
  49104. export class GizmoManager implements IDisposable {
  49105. private scene;
  49106. /**
  49107. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  49108. */
  49109. gizmos: {
  49110. positionGizmo: Nullable<PositionGizmo>;
  49111. rotationGizmo: Nullable<RotationGizmo>;
  49112. scaleGizmo: Nullable<ScaleGizmo>;
  49113. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  49114. };
  49115. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  49116. clearGizmoOnEmptyPointerEvent: boolean;
  49117. /** Fires an event when the manager is attached to a mesh */
  49118. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  49119. private _gizmosEnabled;
  49120. private _pointerObserver;
  49121. private _attachedMesh;
  49122. private _boundingBoxColor;
  49123. private _defaultUtilityLayer;
  49124. private _defaultKeepDepthUtilityLayer;
  49125. /**
  49126. * When bounding box gizmo is enabled, this can be used to track drag/end events
  49127. */
  49128. boundingBoxDragBehavior: SixDofDragBehavior;
  49129. /**
  49130. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  49131. */
  49132. attachableMeshes: Nullable<Array<AbstractMesh>>;
  49133. /**
  49134. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  49135. */
  49136. usePointerToAttachGizmos: boolean;
  49137. /**
  49138. * Utility layer that the bounding box gizmo belongs to
  49139. */
  49140. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  49141. /**
  49142. * Utility layer that all gizmos besides bounding box belong to
  49143. */
  49144. get utilityLayer(): UtilityLayerRenderer;
  49145. /**
  49146. * Instatiates a gizmo manager
  49147. * @param scene the scene to overlay the gizmos on top of
  49148. */
  49149. constructor(scene: Scene);
  49150. /**
  49151. * Attaches a set of gizmos to the specified mesh
  49152. * @param mesh The mesh the gizmo's should be attached to
  49153. */
  49154. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49155. /**
  49156. * If the position gizmo is enabled
  49157. */
  49158. set positionGizmoEnabled(value: boolean);
  49159. get positionGizmoEnabled(): boolean;
  49160. /**
  49161. * If the rotation gizmo is enabled
  49162. */
  49163. set rotationGizmoEnabled(value: boolean);
  49164. get rotationGizmoEnabled(): boolean;
  49165. /**
  49166. * If the scale gizmo is enabled
  49167. */
  49168. set scaleGizmoEnabled(value: boolean);
  49169. get scaleGizmoEnabled(): boolean;
  49170. /**
  49171. * If the boundingBox gizmo is enabled
  49172. */
  49173. set boundingBoxGizmoEnabled(value: boolean);
  49174. get boundingBoxGizmoEnabled(): boolean;
  49175. /**
  49176. * Disposes of the gizmo manager
  49177. */
  49178. dispose(): void;
  49179. }
  49180. }
  49181. declare module BABYLON {
  49182. /**
  49183. * A directional light is defined by a direction (what a surprise!).
  49184. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  49185. * 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.
  49186. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49187. */
  49188. export class DirectionalLight extends ShadowLight {
  49189. private _shadowFrustumSize;
  49190. /**
  49191. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  49192. */
  49193. get shadowFrustumSize(): number;
  49194. /**
  49195. * Specifies a fix frustum size for the shadow generation.
  49196. */
  49197. set shadowFrustumSize(value: number);
  49198. private _shadowOrthoScale;
  49199. /**
  49200. * Gets the shadow projection scale against the optimal computed one.
  49201. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49202. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49203. */
  49204. get shadowOrthoScale(): number;
  49205. /**
  49206. * Sets the shadow projection scale against the optimal computed one.
  49207. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  49208. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  49209. */
  49210. set shadowOrthoScale(value: number);
  49211. /**
  49212. * Automatically compute the projection matrix to best fit (including all the casters)
  49213. * on each frame.
  49214. */
  49215. autoUpdateExtends: boolean;
  49216. /**
  49217. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  49218. * on each frame. autoUpdateExtends must be set to true for this to work
  49219. */
  49220. autoCalcShadowZBounds: boolean;
  49221. private _orthoLeft;
  49222. private _orthoRight;
  49223. private _orthoTop;
  49224. private _orthoBottom;
  49225. /**
  49226. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  49227. * The directional light is emitted from everywhere in the given direction.
  49228. * It can cast shadows.
  49229. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49230. * @param name The friendly name of the light
  49231. * @param direction The direction of the light
  49232. * @param scene The scene the light belongs to
  49233. */
  49234. constructor(name: string, direction: Vector3, scene: Scene);
  49235. /**
  49236. * Returns the string "DirectionalLight".
  49237. * @return The class name
  49238. */
  49239. getClassName(): string;
  49240. /**
  49241. * Returns the integer 1.
  49242. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49243. */
  49244. getTypeID(): number;
  49245. /**
  49246. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  49247. * Returns the DirectionalLight Shadow projection matrix.
  49248. */
  49249. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49250. /**
  49251. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  49252. * Returns the DirectionalLight Shadow projection matrix.
  49253. */
  49254. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  49255. /**
  49256. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  49257. * Returns the DirectionalLight Shadow projection matrix.
  49258. */
  49259. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49260. protected _buildUniformLayout(): void;
  49261. /**
  49262. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  49263. * @param effect The effect to update
  49264. * @param lightIndex The index of the light in the effect to update
  49265. * @returns The directional light
  49266. */
  49267. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  49268. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  49269. /**
  49270. * Gets the minZ used for shadow according to both the scene and the light.
  49271. *
  49272. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49273. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49274. * @param activeCamera The camera we are returning the min for
  49275. * @returns the depth min z
  49276. */
  49277. getDepthMinZ(activeCamera: Camera): number;
  49278. /**
  49279. * Gets the maxZ used for shadow according to both the scene and the light.
  49280. *
  49281. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  49282. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  49283. * @param activeCamera The camera we are returning the max for
  49284. * @returns the depth max z
  49285. */
  49286. getDepthMaxZ(activeCamera: Camera): number;
  49287. /**
  49288. * Prepares the list of defines specific to the light type.
  49289. * @param defines the list of defines
  49290. * @param lightIndex defines the index of the light for the effect
  49291. */
  49292. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49293. }
  49294. }
  49295. declare module BABYLON {
  49296. /**
  49297. * Class containing static functions to help procedurally build meshes
  49298. */
  49299. export class HemisphereBuilder {
  49300. /**
  49301. * Creates a hemisphere mesh
  49302. * @param name defines the name of the mesh
  49303. * @param options defines the options used to create the mesh
  49304. * @param scene defines the hosting scene
  49305. * @returns the hemisphere mesh
  49306. */
  49307. static CreateHemisphere(name: string, options: {
  49308. segments?: number;
  49309. diameter?: number;
  49310. sideOrientation?: number;
  49311. }, scene: any): Mesh;
  49312. }
  49313. }
  49314. declare module BABYLON {
  49315. /**
  49316. * A spot light is defined by a position, a direction, an angle, and an exponent.
  49317. * These values define a cone of light starting from the position, emitting toward the direction.
  49318. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  49319. * and the exponent defines the speed of the decay of the light with distance (reach).
  49320. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49321. */
  49322. export class SpotLight extends ShadowLight {
  49323. private _angle;
  49324. private _innerAngle;
  49325. private _cosHalfAngle;
  49326. private _lightAngleScale;
  49327. private _lightAngleOffset;
  49328. /**
  49329. * Gets the cone angle of the spot light in Radians.
  49330. */
  49331. get angle(): number;
  49332. /**
  49333. * Sets the cone angle of the spot light in Radians.
  49334. */
  49335. set angle(value: number);
  49336. /**
  49337. * Only used in gltf falloff mode, this defines the angle where
  49338. * the directional falloff will start before cutting at angle which could be seen
  49339. * as outer angle.
  49340. */
  49341. get innerAngle(): number;
  49342. /**
  49343. * Only used in gltf falloff mode, this defines the angle where
  49344. * the directional falloff will start before cutting at angle which could be seen
  49345. * as outer angle.
  49346. */
  49347. set innerAngle(value: number);
  49348. private _shadowAngleScale;
  49349. /**
  49350. * Allows scaling the angle of the light for shadow generation only.
  49351. */
  49352. get shadowAngleScale(): number;
  49353. /**
  49354. * Allows scaling the angle of the light for shadow generation only.
  49355. */
  49356. set shadowAngleScale(value: number);
  49357. /**
  49358. * The light decay speed with the distance from the emission spot.
  49359. */
  49360. exponent: number;
  49361. private _projectionTextureMatrix;
  49362. /**
  49363. * Allows reading the projecton texture
  49364. */
  49365. get projectionTextureMatrix(): Matrix;
  49366. protected _projectionTextureLightNear: number;
  49367. /**
  49368. * Gets the near clip of the Spotlight for texture projection.
  49369. */
  49370. get projectionTextureLightNear(): number;
  49371. /**
  49372. * Sets the near clip of the Spotlight for texture projection.
  49373. */
  49374. set projectionTextureLightNear(value: number);
  49375. protected _projectionTextureLightFar: number;
  49376. /**
  49377. * Gets the far clip of the Spotlight for texture projection.
  49378. */
  49379. get projectionTextureLightFar(): number;
  49380. /**
  49381. * Sets the far clip of the Spotlight for texture projection.
  49382. */
  49383. set projectionTextureLightFar(value: number);
  49384. protected _projectionTextureUpDirection: Vector3;
  49385. /**
  49386. * Gets the Up vector of the Spotlight for texture projection.
  49387. */
  49388. get projectionTextureUpDirection(): Vector3;
  49389. /**
  49390. * Sets the Up vector of the Spotlight for texture projection.
  49391. */
  49392. set projectionTextureUpDirection(value: Vector3);
  49393. private _projectionTexture;
  49394. /**
  49395. * Gets the projection texture of the light.
  49396. */
  49397. get projectionTexture(): Nullable<BaseTexture>;
  49398. /**
  49399. * Sets the projection texture of the light.
  49400. */
  49401. set projectionTexture(value: Nullable<BaseTexture>);
  49402. private _projectionTextureViewLightDirty;
  49403. private _projectionTextureProjectionLightDirty;
  49404. private _projectionTextureDirty;
  49405. private _projectionTextureViewTargetVector;
  49406. private _projectionTextureViewLightMatrix;
  49407. private _projectionTextureProjectionLightMatrix;
  49408. private _projectionTextureScalingMatrix;
  49409. /**
  49410. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49411. * It can cast shadows.
  49412. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49413. * @param name The light friendly name
  49414. * @param position The position of the spot light in the scene
  49415. * @param direction The direction of the light in the scene
  49416. * @param angle The cone angle of the light in Radians
  49417. * @param exponent The light decay speed with the distance from the emission spot
  49418. * @param scene The scene the lights belongs to
  49419. */
  49420. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49421. /**
  49422. * Returns the string "SpotLight".
  49423. * @returns the class name
  49424. */
  49425. getClassName(): string;
  49426. /**
  49427. * Returns the integer 2.
  49428. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49429. */
  49430. getTypeID(): number;
  49431. /**
  49432. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49433. */
  49434. protected _setDirection(value: Vector3): void;
  49435. /**
  49436. * Overrides the position setter to recompute the projection texture view light Matrix.
  49437. */
  49438. protected _setPosition(value: Vector3): void;
  49439. /**
  49440. * 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.
  49441. * Returns the SpotLight.
  49442. */
  49443. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49444. protected _computeProjectionTextureViewLightMatrix(): void;
  49445. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49446. /**
  49447. * Main function for light texture projection matrix computing.
  49448. */
  49449. protected _computeProjectionTextureMatrix(): void;
  49450. protected _buildUniformLayout(): void;
  49451. private _computeAngleValues;
  49452. /**
  49453. * Sets the passed Effect "effect" with the Light textures.
  49454. * @param effect The effect to update
  49455. * @param lightIndex The index of the light in the effect to update
  49456. * @returns The light
  49457. */
  49458. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49459. /**
  49460. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49461. * @param effect The effect to update
  49462. * @param lightIndex The index of the light in the effect to update
  49463. * @returns The spot light
  49464. */
  49465. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49466. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49467. /**
  49468. * Disposes the light and the associated resources.
  49469. */
  49470. dispose(): void;
  49471. /**
  49472. * Prepares the list of defines specific to the light type.
  49473. * @param defines the list of defines
  49474. * @param lightIndex defines the index of the light for the effect
  49475. */
  49476. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49477. }
  49478. }
  49479. declare module BABYLON {
  49480. /**
  49481. * Gizmo that enables viewing a light
  49482. */
  49483. export class LightGizmo extends Gizmo {
  49484. private _lightMesh;
  49485. private _material;
  49486. private _cachedPosition;
  49487. private _cachedForward;
  49488. private _attachedMeshParent;
  49489. /**
  49490. * Creates a LightGizmo
  49491. * @param gizmoLayer The utility layer the gizmo will be added to
  49492. */
  49493. constructor(gizmoLayer?: UtilityLayerRenderer);
  49494. private _light;
  49495. /**
  49496. * The light that the gizmo is attached to
  49497. */
  49498. set light(light: Nullable<Light>);
  49499. get light(): Nullable<Light>;
  49500. /**
  49501. * Gets the material used to render the light gizmo
  49502. */
  49503. get material(): StandardMaterial;
  49504. /**
  49505. * @hidden
  49506. * Updates the gizmo to match the attached mesh's position/rotation
  49507. */
  49508. protected _update(): void;
  49509. private static _Scale;
  49510. /**
  49511. * Creates the lines for a light mesh
  49512. */
  49513. private static _CreateLightLines;
  49514. /**
  49515. * Disposes of the light gizmo
  49516. */
  49517. dispose(): void;
  49518. private static _CreateHemisphericLightMesh;
  49519. private static _CreatePointLightMesh;
  49520. private static _CreateSpotLightMesh;
  49521. private static _CreateDirectionalLightMesh;
  49522. }
  49523. }
  49524. declare module BABYLON {
  49525. /** @hidden */
  49526. export var backgroundFragmentDeclaration: {
  49527. name: string;
  49528. shader: string;
  49529. };
  49530. }
  49531. declare module BABYLON {
  49532. /** @hidden */
  49533. export var backgroundUboDeclaration: {
  49534. name: string;
  49535. shader: string;
  49536. };
  49537. }
  49538. declare module BABYLON {
  49539. /** @hidden */
  49540. export var backgroundPixelShader: {
  49541. name: string;
  49542. shader: string;
  49543. };
  49544. }
  49545. declare module BABYLON {
  49546. /** @hidden */
  49547. export var backgroundVertexDeclaration: {
  49548. name: string;
  49549. shader: string;
  49550. };
  49551. }
  49552. declare module BABYLON {
  49553. /** @hidden */
  49554. export var backgroundVertexShader: {
  49555. name: string;
  49556. shader: string;
  49557. };
  49558. }
  49559. declare module BABYLON {
  49560. /**
  49561. * Background material used to create an efficient environement around your scene.
  49562. */
  49563. export class BackgroundMaterial extends PushMaterial {
  49564. /**
  49565. * Standard reflectance value at parallel view angle.
  49566. */
  49567. static StandardReflectance0: number;
  49568. /**
  49569. * Standard reflectance value at grazing angle.
  49570. */
  49571. static StandardReflectance90: number;
  49572. protected _primaryColor: Color3;
  49573. /**
  49574. * Key light Color (multiply against the environement texture)
  49575. */
  49576. primaryColor: Color3;
  49577. protected __perceptualColor: Nullable<Color3>;
  49578. /**
  49579. * Experimental Internal Use Only.
  49580. *
  49581. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49582. * This acts as a helper to set the primary color to a more "human friendly" value.
  49583. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49584. * output color as close as possible from the chosen value.
  49585. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49586. * part of lighting setup.)
  49587. */
  49588. get _perceptualColor(): Nullable<Color3>;
  49589. set _perceptualColor(value: Nullable<Color3>);
  49590. protected _primaryColorShadowLevel: float;
  49591. /**
  49592. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49593. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49594. */
  49595. get primaryColorShadowLevel(): float;
  49596. set primaryColorShadowLevel(value: float);
  49597. protected _primaryColorHighlightLevel: float;
  49598. /**
  49599. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49600. * The primary color is used at the level chosen to define what the white area would look.
  49601. */
  49602. get primaryColorHighlightLevel(): float;
  49603. set primaryColorHighlightLevel(value: float);
  49604. protected _reflectionTexture: Nullable<BaseTexture>;
  49605. /**
  49606. * Reflection Texture used in the material.
  49607. * Should be author in a specific way for the best result (refer to the documentation).
  49608. */
  49609. reflectionTexture: Nullable<BaseTexture>;
  49610. protected _reflectionBlur: float;
  49611. /**
  49612. * Reflection Texture level of blur.
  49613. *
  49614. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49615. * texture twice.
  49616. */
  49617. reflectionBlur: float;
  49618. protected _diffuseTexture: Nullable<BaseTexture>;
  49619. /**
  49620. * Diffuse Texture used in the material.
  49621. * Should be author in a specific way for the best result (refer to the documentation).
  49622. */
  49623. diffuseTexture: Nullable<BaseTexture>;
  49624. protected _shadowLights: Nullable<IShadowLight[]>;
  49625. /**
  49626. * Specify the list of lights casting shadow on the material.
  49627. * All scene shadow lights will be included if null.
  49628. */
  49629. shadowLights: Nullable<IShadowLight[]>;
  49630. protected _shadowLevel: float;
  49631. /**
  49632. * Helps adjusting the shadow to a softer level if required.
  49633. * 0 means black shadows and 1 means no shadows.
  49634. */
  49635. shadowLevel: float;
  49636. protected _sceneCenter: Vector3;
  49637. /**
  49638. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49639. * It is usually zero but might be interesting to modify according to your setup.
  49640. */
  49641. sceneCenter: Vector3;
  49642. protected _opacityFresnel: boolean;
  49643. /**
  49644. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49645. * This helps ensuring a nice transition when the camera goes under the ground.
  49646. */
  49647. opacityFresnel: boolean;
  49648. protected _reflectionFresnel: boolean;
  49649. /**
  49650. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49651. * This helps adding a mirror texture on the ground.
  49652. */
  49653. reflectionFresnel: boolean;
  49654. protected _reflectionFalloffDistance: number;
  49655. /**
  49656. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49657. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49658. */
  49659. reflectionFalloffDistance: number;
  49660. protected _reflectionAmount: number;
  49661. /**
  49662. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49663. */
  49664. reflectionAmount: number;
  49665. protected _reflectionReflectance0: number;
  49666. /**
  49667. * This specifies the weight of the reflection at grazing angle.
  49668. */
  49669. reflectionReflectance0: number;
  49670. protected _reflectionReflectance90: number;
  49671. /**
  49672. * This specifies the weight of the reflection at a perpendicular point of view.
  49673. */
  49674. reflectionReflectance90: number;
  49675. /**
  49676. * Sets the reflection reflectance fresnel values according to the default standard
  49677. * empirically know to work well :-)
  49678. */
  49679. set reflectionStandardFresnelWeight(value: number);
  49680. protected _useRGBColor: boolean;
  49681. /**
  49682. * Helps to directly use the maps channels instead of their level.
  49683. */
  49684. useRGBColor: boolean;
  49685. protected _enableNoise: boolean;
  49686. /**
  49687. * This helps reducing the banding effect that could occur on the background.
  49688. */
  49689. enableNoise: boolean;
  49690. /**
  49691. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49692. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49693. * Recommended to be keep at 1.0 except for special cases.
  49694. */
  49695. get fovMultiplier(): number;
  49696. set fovMultiplier(value: number);
  49697. private _fovMultiplier;
  49698. /**
  49699. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49700. */
  49701. useEquirectangularFOV: boolean;
  49702. private _maxSimultaneousLights;
  49703. /**
  49704. * Number of Simultaneous lights allowed on the material.
  49705. */
  49706. maxSimultaneousLights: int;
  49707. /**
  49708. * Default configuration related to image processing available in the Background Material.
  49709. */
  49710. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49711. /**
  49712. * Keep track of the image processing observer to allow dispose and replace.
  49713. */
  49714. private _imageProcessingObserver;
  49715. /**
  49716. * Attaches a new image processing configuration to the PBR Material.
  49717. * @param configuration (if null the scene configuration will be use)
  49718. */
  49719. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49720. /**
  49721. * Gets the image processing configuration used either in this material.
  49722. */
  49723. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49724. /**
  49725. * Sets the Default image processing configuration used either in the this material.
  49726. *
  49727. * If sets to null, the scene one is in use.
  49728. */
  49729. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49730. /**
  49731. * Gets wether the color curves effect is enabled.
  49732. */
  49733. get cameraColorCurvesEnabled(): boolean;
  49734. /**
  49735. * Sets wether the color curves effect is enabled.
  49736. */
  49737. set cameraColorCurvesEnabled(value: boolean);
  49738. /**
  49739. * Gets wether the color grading effect is enabled.
  49740. */
  49741. get cameraColorGradingEnabled(): boolean;
  49742. /**
  49743. * Gets wether the color grading effect is enabled.
  49744. */
  49745. set cameraColorGradingEnabled(value: boolean);
  49746. /**
  49747. * Gets wether tonemapping is enabled or not.
  49748. */
  49749. get cameraToneMappingEnabled(): boolean;
  49750. /**
  49751. * Sets wether tonemapping is enabled or not
  49752. */
  49753. set cameraToneMappingEnabled(value: boolean);
  49754. /**
  49755. * The camera exposure used on this material.
  49756. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49757. * This corresponds to a photographic exposure.
  49758. */
  49759. get cameraExposure(): float;
  49760. /**
  49761. * The camera exposure used on this material.
  49762. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49763. * This corresponds to a photographic exposure.
  49764. */
  49765. set cameraExposure(value: float);
  49766. /**
  49767. * Gets The camera contrast used on this material.
  49768. */
  49769. get cameraContrast(): float;
  49770. /**
  49771. * Sets The camera contrast used on this material.
  49772. */
  49773. set cameraContrast(value: float);
  49774. /**
  49775. * Gets the Color Grading 2D Lookup Texture.
  49776. */
  49777. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49778. /**
  49779. * Sets the Color Grading 2D Lookup Texture.
  49780. */
  49781. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49782. /**
  49783. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49784. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49785. * 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;
  49786. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49787. */
  49788. get cameraColorCurves(): Nullable<ColorCurves>;
  49789. /**
  49790. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49791. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49792. * 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;
  49793. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49794. */
  49795. set cameraColorCurves(value: Nullable<ColorCurves>);
  49796. /**
  49797. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49798. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49799. */
  49800. switchToBGR: boolean;
  49801. private _renderTargets;
  49802. private _reflectionControls;
  49803. private _white;
  49804. private _primaryShadowColor;
  49805. private _primaryHighlightColor;
  49806. /**
  49807. * Instantiates a Background Material in the given scene
  49808. * @param name The friendly name of the material
  49809. * @param scene The scene to add the material to
  49810. */
  49811. constructor(name: string, scene: Scene);
  49812. /**
  49813. * Gets a boolean indicating that current material needs to register RTT
  49814. */
  49815. get hasRenderTargetTextures(): boolean;
  49816. /**
  49817. * The entire material has been created in order to prevent overdraw.
  49818. * @returns false
  49819. */
  49820. needAlphaTesting(): boolean;
  49821. /**
  49822. * The entire material has been created in order to prevent overdraw.
  49823. * @returns true if blending is enable
  49824. */
  49825. needAlphaBlending(): boolean;
  49826. /**
  49827. * Checks wether the material is ready to be rendered for a given mesh.
  49828. * @param mesh The mesh to render
  49829. * @param subMesh The submesh to check against
  49830. * @param useInstances Specify wether or not the material is used with instances
  49831. * @returns true if all the dependencies are ready (Textures, Effects...)
  49832. */
  49833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49834. /**
  49835. * Compute the primary color according to the chosen perceptual color.
  49836. */
  49837. private _computePrimaryColorFromPerceptualColor;
  49838. /**
  49839. * Compute the highlights and shadow colors according to their chosen levels.
  49840. */
  49841. private _computePrimaryColors;
  49842. /**
  49843. * Build the uniform buffer used in the material.
  49844. */
  49845. buildUniformLayout(): void;
  49846. /**
  49847. * Unbind the material.
  49848. */
  49849. unbind(): void;
  49850. /**
  49851. * Bind only the world matrix to the material.
  49852. * @param world The world matrix to bind.
  49853. */
  49854. bindOnlyWorldMatrix(world: Matrix): void;
  49855. /**
  49856. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49857. * @param world The world matrix to bind.
  49858. * @param subMesh The submesh to bind for.
  49859. */
  49860. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49861. /**
  49862. * Checks to see if a texture is used in the material.
  49863. * @param texture - Base texture to use.
  49864. * @returns - Boolean specifying if a texture is used in the material.
  49865. */
  49866. hasTexture(texture: BaseTexture): boolean;
  49867. /**
  49868. * Dispose the material.
  49869. * @param forceDisposeEffect Force disposal of the associated effect.
  49870. * @param forceDisposeTextures Force disposal of the associated textures.
  49871. */
  49872. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49873. /**
  49874. * Clones the material.
  49875. * @param name The cloned name.
  49876. * @returns The cloned material.
  49877. */
  49878. clone(name: string): BackgroundMaterial;
  49879. /**
  49880. * Serializes the current material to its JSON representation.
  49881. * @returns The JSON representation.
  49882. */
  49883. serialize(): any;
  49884. /**
  49885. * Gets the class name of the material
  49886. * @returns "BackgroundMaterial"
  49887. */
  49888. getClassName(): string;
  49889. /**
  49890. * Parse a JSON input to create back a background material.
  49891. * @param source The JSON data to parse
  49892. * @param scene The scene to create the parsed material in
  49893. * @param rootUrl The root url of the assets the material depends upon
  49894. * @returns the instantiated BackgroundMaterial.
  49895. */
  49896. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49897. }
  49898. }
  49899. declare module BABYLON {
  49900. /**
  49901. * Represents the different options available during the creation of
  49902. * a Environment helper.
  49903. *
  49904. * This can control the default ground, skybox and image processing setup of your scene.
  49905. */
  49906. export interface IEnvironmentHelperOptions {
  49907. /**
  49908. * Specifies whether or not to create a ground.
  49909. * True by default.
  49910. */
  49911. createGround: boolean;
  49912. /**
  49913. * Specifies the ground size.
  49914. * 15 by default.
  49915. */
  49916. groundSize: number;
  49917. /**
  49918. * The texture used on the ground for the main color.
  49919. * Comes from the BabylonJS CDN by default.
  49920. *
  49921. * Remarks: Can be either a texture or a url.
  49922. */
  49923. groundTexture: string | BaseTexture;
  49924. /**
  49925. * The color mixed in the ground texture by default.
  49926. * BabylonJS clearColor by default.
  49927. */
  49928. groundColor: Color3;
  49929. /**
  49930. * Specifies the ground opacity.
  49931. * 1 by default.
  49932. */
  49933. groundOpacity: number;
  49934. /**
  49935. * Enables the ground to receive shadows.
  49936. * True by default.
  49937. */
  49938. enableGroundShadow: boolean;
  49939. /**
  49940. * Helps preventing the shadow to be fully black on the ground.
  49941. * 0.5 by default.
  49942. */
  49943. groundShadowLevel: number;
  49944. /**
  49945. * Creates a mirror texture attach to the ground.
  49946. * false by default.
  49947. */
  49948. enableGroundMirror: boolean;
  49949. /**
  49950. * Specifies the ground mirror size ratio.
  49951. * 0.3 by default as the default kernel is 64.
  49952. */
  49953. groundMirrorSizeRatio: number;
  49954. /**
  49955. * Specifies the ground mirror blur kernel size.
  49956. * 64 by default.
  49957. */
  49958. groundMirrorBlurKernel: number;
  49959. /**
  49960. * Specifies the ground mirror visibility amount.
  49961. * 1 by default
  49962. */
  49963. groundMirrorAmount: number;
  49964. /**
  49965. * Specifies the ground mirror reflectance weight.
  49966. * This uses the standard weight of the background material to setup the fresnel effect
  49967. * of the mirror.
  49968. * 1 by default.
  49969. */
  49970. groundMirrorFresnelWeight: number;
  49971. /**
  49972. * Specifies the ground mirror Falloff distance.
  49973. * This can helps reducing the size of the reflection.
  49974. * 0 by Default.
  49975. */
  49976. groundMirrorFallOffDistance: number;
  49977. /**
  49978. * Specifies the ground mirror texture type.
  49979. * Unsigned Int by Default.
  49980. */
  49981. groundMirrorTextureType: number;
  49982. /**
  49983. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49984. * the shown objects.
  49985. */
  49986. groundYBias: number;
  49987. /**
  49988. * Specifies whether or not to create a skybox.
  49989. * True by default.
  49990. */
  49991. createSkybox: boolean;
  49992. /**
  49993. * Specifies the skybox size.
  49994. * 20 by default.
  49995. */
  49996. skyboxSize: number;
  49997. /**
  49998. * The texture used on the skybox for the main color.
  49999. * Comes from the BabylonJS CDN by default.
  50000. *
  50001. * Remarks: Can be either a texture or a url.
  50002. */
  50003. skyboxTexture: string | BaseTexture;
  50004. /**
  50005. * The color mixed in the skybox texture by default.
  50006. * BabylonJS clearColor by default.
  50007. */
  50008. skyboxColor: Color3;
  50009. /**
  50010. * The background rotation around the Y axis of the scene.
  50011. * This helps aligning the key lights of your scene with the background.
  50012. * 0 by default.
  50013. */
  50014. backgroundYRotation: number;
  50015. /**
  50016. * Compute automatically the size of the elements to best fit with the scene.
  50017. */
  50018. sizeAuto: boolean;
  50019. /**
  50020. * Default position of the rootMesh if autoSize is not true.
  50021. */
  50022. rootPosition: Vector3;
  50023. /**
  50024. * Sets up the image processing in the scene.
  50025. * true by default.
  50026. */
  50027. setupImageProcessing: boolean;
  50028. /**
  50029. * The texture used as your environment texture in the scene.
  50030. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  50031. *
  50032. * Remarks: Can be either a texture or a url.
  50033. */
  50034. environmentTexture: string | BaseTexture;
  50035. /**
  50036. * The value of the exposure to apply to the scene.
  50037. * 0.6 by default if setupImageProcessing is true.
  50038. */
  50039. cameraExposure: number;
  50040. /**
  50041. * The value of the contrast to apply to the scene.
  50042. * 1.6 by default if setupImageProcessing is true.
  50043. */
  50044. cameraContrast: number;
  50045. /**
  50046. * Specifies whether or not tonemapping should be enabled in the scene.
  50047. * true by default if setupImageProcessing is true.
  50048. */
  50049. toneMappingEnabled: boolean;
  50050. }
  50051. /**
  50052. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  50053. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  50054. * It also helps with the default setup of your imageProcessing configuration.
  50055. */
  50056. export class EnvironmentHelper {
  50057. /**
  50058. * Default ground texture URL.
  50059. */
  50060. private static _groundTextureCDNUrl;
  50061. /**
  50062. * Default skybox texture URL.
  50063. */
  50064. private static _skyboxTextureCDNUrl;
  50065. /**
  50066. * Default environment texture URL.
  50067. */
  50068. private static _environmentTextureCDNUrl;
  50069. /**
  50070. * Creates the default options for the helper.
  50071. */
  50072. private static _getDefaultOptions;
  50073. private _rootMesh;
  50074. /**
  50075. * Gets the root mesh created by the helper.
  50076. */
  50077. get rootMesh(): Mesh;
  50078. private _skybox;
  50079. /**
  50080. * Gets the skybox created by the helper.
  50081. */
  50082. get skybox(): Nullable<Mesh>;
  50083. private _skyboxTexture;
  50084. /**
  50085. * Gets the skybox texture created by the helper.
  50086. */
  50087. get skyboxTexture(): Nullable<BaseTexture>;
  50088. private _skyboxMaterial;
  50089. /**
  50090. * Gets the skybox material created by the helper.
  50091. */
  50092. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  50093. private _ground;
  50094. /**
  50095. * Gets the ground mesh created by the helper.
  50096. */
  50097. get ground(): Nullable<Mesh>;
  50098. private _groundTexture;
  50099. /**
  50100. * Gets the ground texture created by the helper.
  50101. */
  50102. get groundTexture(): Nullable<BaseTexture>;
  50103. private _groundMirror;
  50104. /**
  50105. * Gets the ground mirror created by the helper.
  50106. */
  50107. get groundMirror(): Nullable<MirrorTexture>;
  50108. /**
  50109. * Gets the ground mirror render list to helps pushing the meshes
  50110. * you wish in the ground reflection.
  50111. */
  50112. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  50113. private _groundMaterial;
  50114. /**
  50115. * Gets the ground material created by the helper.
  50116. */
  50117. get groundMaterial(): Nullable<BackgroundMaterial>;
  50118. /**
  50119. * Stores the creation options.
  50120. */
  50121. private readonly _scene;
  50122. private _options;
  50123. /**
  50124. * This observable will be notified with any error during the creation of the environment,
  50125. * mainly texture creation errors.
  50126. */
  50127. onErrorObservable: Observable<{
  50128. message?: string;
  50129. exception?: any;
  50130. }>;
  50131. /**
  50132. * constructor
  50133. * @param options Defines the options we want to customize the helper
  50134. * @param scene The scene to add the material to
  50135. */
  50136. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  50137. /**
  50138. * Updates the background according to the new options
  50139. * @param options
  50140. */
  50141. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  50142. /**
  50143. * Sets the primary color of all the available elements.
  50144. * @param color the main color to affect to the ground and the background
  50145. */
  50146. setMainColor(color: Color3): void;
  50147. /**
  50148. * Setup the image processing according to the specified options.
  50149. */
  50150. private _setupImageProcessing;
  50151. /**
  50152. * Setup the environment texture according to the specified options.
  50153. */
  50154. private _setupEnvironmentTexture;
  50155. /**
  50156. * Setup the background according to the specified options.
  50157. */
  50158. private _setupBackground;
  50159. /**
  50160. * Get the scene sizes according to the setup.
  50161. */
  50162. private _getSceneSize;
  50163. /**
  50164. * Setup the ground according to the specified options.
  50165. */
  50166. private _setupGround;
  50167. /**
  50168. * Setup the ground material according to the specified options.
  50169. */
  50170. private _setupGroundMaterial;
  50171. /**
  50172. * Setup the ground diffuse texture according to the specified options.
  50173. */
  50174. private _setupGroundDiffuseTexture;
  50175. /**
  50176. * Setup the ground mirror texture according to the specified options.
  50177. */
  50178. private _setupGroundMirrorTexture;
  50179. /**
  50180. * Setup the ground to receive the mirror texture.
  50181. */
  50182. private _setupMirrorInGroundMaterial;
  50183. /**
  50184. * Setup the skybox according to the specified options.
  50185. */
  50186. private _setupSkybox;
  50187. /**
  50188. * Setup the skybox material according to the specified options.
  50189. */
  50190. private _setupSkyboxMaterial;
  50191. /**
  50192. * Setup the skybox reflection texture according to the specified options.
  50193. */
  50194. private _setupSkyboxReflectionTexture;
  50195. private _errorHandler;
  50196. /**
  50197. * Dispose all the elements created by the Helper.
  50198. */
  50199. dispose(): void;
  50200. }
  50201. }
  50202. declare module BABYLON {
  50203. /**
  50204. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  50205. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  50206. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  50207. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  50208. */
  50209. export class PhotoDome extends TransformNode {
  50210. /**
  50211. * Define the image as a Monoscopic panoramic 360 image.
  50212. */
  50213. static readonly MODE_MONOSCOPIC: number;
  50214. /**
  50215. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50216. */
  50217. static readonly MODE_TOPBOTTOM: number;
  50218. /**
  50219. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50220. */
  50221. static readonly MODE_SIDEBYSIDE: number;
  50222. private _useDirectMapping;
  50223. /**
  50224. * The texture being displayed on the sphere
  50225. */
  50226. protected _photoTexture: Texture;
  50227. /**
  50228. * Gets or sets the texture being displayed on the sphere
  50229. */
  50230. get photoTexture(): Texture;
  50231. set photoTexture(value: Texture);
  50232. /**
  50233. * Observable raised when an error occured while loading the 360 image
  50234. */
  50235. onLoadErrorObservable: Observable<string>;
  50236. /**
  50237. * The skybox material
  50238. */
  50239. protected _material: BackgroundMaterial;
  50240. /**
  50241. * The surface used for the skybox
  50242. */
  50243. protected _mesh: Mesh;
  50244. /**
  50245. * Gets the mesh used for the skybox.
  50246. */
  50247. get mesh(): Mesh;
  50248. /**
  50249. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  50250. * Also see the options.resolution property.
  50251. */
  50252. get fovMultiplier(): number;
  50253. set fovMultiplier(value: number);
  50254. private _imageMode;
  50255. /**
  50256. * Gets or set the current video mode for the video. It can be:
  50257. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  50258. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  50259. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  50260. */
  50261. get imageMode(): number;
  50262. set imageMode(value: number);
  50263. /**
  50264. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  50265. * @param name Element's name, child elements will append suffixes for their own names.
  50266. * @param urlsOfPhoto defines the url of the photo to display
  50267. * @param options defines an object containing optional or exposed sub element properties
  50268. * @param onError defines a callback called when an error occured while loading the texture
  50269. */
  50270. constructor(name: string, urlOfPhoto: string, options: {
  50271. resolution?: number;
  50272. size?: number;
  50273. useDirectMapping?: boolean;
  50274. faceForward?: boolean;
  50275. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  50276. private _onBeforeCameraRenderObserver;
  50277. private _changeImageMode;
  50278. /**
  50279. * Releases resources associated with this node.
  50280. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  50281. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  50282. */
  50283. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  50284. }
  50285. }
  50286. declare module BABYLON {
  50287. /**
  50288. * Class used to host RGBD texture specific utilities
  50289. */
  50290. export class RGBDTextureTools {
  50291. /**
  50292. * Expand the RGBD Texture from RGBD to Half Float if possible.
  50293. * @param texture the texture to expand.
  50294. */
  50295. static ExpandRGBDTexture(texture: Texture): void;
  50296. }
  50297. }
  50298. declare module BABYLON {
  50299. /**
  50300. * Class used to host texture specific utilities
  50301. */
  50302. export class BRDFTextureTools {
  50303. /**
  50304. * Prevents texture cache collision
  50305. */
  50306. private static _instanceNumber;
  50307. /**
  50308. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  50309. * @param scene defines the hosting scene
  50310. * @returns the environment BRDF texture
  50311. */
  50312. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  50313. private static _environmentBRDFBase64Texture;
  50314. }
  50315. }
  50316. declare module BABYLON {
  50317. /**
  50318. * @hidden
  50319. */
  50320. export interface IMaterialClearCoatDefines {
  50321. CLEARCOAT: boolean;
  50322. CLEARCOAT_DEFAULTIOR: boolean;
  50323. CLEARCOAT_TEXTURE: boolean;
  50324. CLEARCOAT_TEXTUREDIRECTUV: number;
  50325. CLEARCOAT_BUMP: boolean;
  50326. CLEARCOAT_BUMPDIRECTUV: number;
  50327. CLEARCOAT_TINT: boolean;
  50328. CLEARCOAT_TINT_TEXTURE: boolean;
  50329. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50330. /** @hidden */
  50331. _areTexturesDirty: boolean;
  50332. }
  50333. /**
  50334. * Define the code related to the clear coat parameters of the pbr material.
  50335. */
  50336. export class PBRClearCoatConfiguration {
  50337. /**
  50338. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50339. * The default fits with a polyurethane material.
  50340. */
  50341. private static readonly _DefaultIndexOfRefraction;
  50342. private _isEnabled;
  50343. /**
  50344. * Defines if the clear coat is enabled in the material.
  50345. */
  50346. isEnabled: boolean;
  50347. /**
  50348. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  50349. */
  50350. intensity: number;
  50351. /**
  50352. * Defines the clear coat layer roughness.
  50353. */
  50354. roughness: number;
  50355. private _indexOfRefraction;
  50356. /**
  50357. * Defines the index of refraction of the clear coat.
  50358. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  50359. * The default fits with a polyurethane material.
  50360. * Changing the default value is more performance intensive.
  50361. */
  50362. indexOfRefraction: number;
  50363. private _texture;
  50364. /**
  50365. * Stores the clear coat values in a texture.
  50366. */
  50367. texture: Nullable<BaseTexture>;
  50368. private _bumpTexture;
  50369. /**
  50370. * Define the clear coat specific bump texture.
  50371. */
  50372. bumpTexture: Nullable<BaseTexture>;
  50373. private _isTintEnabled;
  50374. /**
  50375. * Defines if the clear coat tint is enabled in the material.
  50376. */
  50377. isTintEnabled: boolean;
  50378. /**
  50379. * Defines the clear coat tint of the material.
  50380. * This is only use if tint is enabled
  50381. */
  50382. tintColor: Color3;
  50383. /**
  50384. * Defines the distance at which the tint color should be found in the
  50385. * clear coat media.
  50386. * This is only use if tint is enabled
  50387. */
  50388. tintColorAtDistance: number;
  50389. /**
  50390. * Defines the clear coat layer thickness.
  50391. * This is only use if tint is enabled
  50392. */
  50393. tintThickness: number;
  50394. private _tintTexture;
  50395. /**
  50396. * Stores the clear tint values in a texture.
  50397. * rgb is tint
  50398. * a is a thickness factor
  50399. */
  50400. tintTexture: Nullable<BaseTexture>;
  50401. /** @hidden */
  50402. private _internalMarkAllSubMeshesAsTexturesDirty;
  50403. /** @hidden */
  50404. _markAllSubMeshesAsTexturesDirty(): void;
  50405. /**
  50406. * Instantiate a new istance of clear coat configuration.
  50407. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50408. */
  50409. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50410. /**
  50411. * Gets wehter the submesh is ready to be used or not.
  50412. * @param defines the list of "defines" to update.
  50413. * @param scene defines the scene the material belongs to.
  50414. * @param engine defines the engine the material belongs to.
  50415. * @param disableBumpMap defines wether the material disables bump or not.
  50416. * @returns - boolean indicating that the submesh is ready or not.
  50417. */
  50418. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50419. /**
  50420. * Checks to see if a texture is used in the material.
  50421. * @param defines the list of "defines" to update.
  50422. * @param scene defines the scene to the material belongs to.
  50423. */
  50424. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50425. /**
  50426. * Binds the material data.
  50427. * @param uniformBuffer defines the Uniform buffer to fill in.
  50428. * @param scene defines the scene the material belongs to.
  50429. * @param engine defines the engine the material belongs to.
  50430. * @param disableBumpMap defines wether the material disables bump or not.
  50431. * @param isFrozen defines wether the material is frozen or not.
  50432. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50433. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50434. */
  50435. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50436. /**
  50437. * Checks to see if a texture is used in the material.
  50438. * @param texture - Base texture to use.
  50439. * @returns - Boolean specifying if a texture is used in the material.
  50440. */
  50441. hasTexture(texture: BaseTexture): boolean;
  50442. /**
  50443. * Returns an array of the actively used textures.
  50444. * @param activeTextures Array of BaseTextures
  50445. */
  50446. getActiveTextures(activeTextures: BaseTexture[]): void;
  50447. /**
  50448. * Returns the animatable textures.
  50449. * @param animatables Array of animatable textures.
  50450. */
  50451. getAnimatables(animatables: IAnimatable[]): void;
  50452. /**
  50453. * Disposes the resources of the material.
  50454. * @param forceDisposeTextures - Forces the disposal of all textures.
  50455. */
  50456. dispose(forceDisposeTextures?: boolean): void;
  50457. /**
  50458. * Get the current class name of the texture useful for serialization or dynamic coding.
  50459. * @returns "PBRClearCoatConfiguration"
  50460. */
  50461. getClassName(): string;
  50462. /**
  50463. * Add fallbacks to the effect fallbacks list.
  50464. * @param defines defines the Base texture to use.
  50465. * @param fallbacks defines the current fallback list.
  50466. * @param currentRank defines the current fallback rank.
  50467. * @returns the new fallback rank.
  50468. */
  50469. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50470. /**
  50471. * Add the required uniforms to the current list.
  50472. * @param uniforms defines the current uniform list.
  50473. */
  50474. static AddUniforms(uniforms: string[]): void;
  50475. /**
  50476. * Add the required samplers to the current list.
  50477. * @param samplers defines the current sampler list.
  50478. */
  50479. static AddSamplers(samplers: string[]): void;
  50480. /**
  50481. * Add the required uniforms to the current buffer.
  50482. * @param uniformBuffer defines the current uniform buffer.
  50483. */
  50484. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50485. /**
  50486. * Makes a duplicate of the current configuration into another one.
  50487. * @param clearCoatConfiguration define the config where to copy the info
  50488. */
  50489. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50490. /**
  50491. * Serializes this clear coat configuration.
  50492. * @returns - An object with the serialized config.
  50493. */
  50494. serialize(): any;
  50495. /**
  50496. * Parses a anisotropy Configuration from a serialized object.
  50497. * @param source - Serialized object.
  50498. * @param scene Defines the scene we are parsing for
  50499. * @param rootUrl Defines the rootUrl to load from
  50500. */
  50501. parse(source: any, scene: Scene, rootUrl: string): void;
  50502. }
  50503. }
  50504. declare module BABYLON {
  50505. /**
  50506. * @hidden
  50507. */
  50508. export interface IMaterialAnisotropicDefines {
  50509. ANISOTROPIC: boolean;
  50510. ANISOTROPIC_TEXTURE: boolean;
  50511. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50512. MAINUV1: boolean;
  50513. _areTexturesDirty: boolean;
  50514. _needUVs: boolean;
  50515. }
  50516. /**
  50517. * Define the code related to the anisotropic parameters of the pbr material.
  50518. */
  50519. export class PBRAnisotropicConfiguration {
  50520. private _isEnabled;
  50521. /**
  50522. * Defines if the anisotropy is enabled in the material.
  50523. */
  50524. isEnabled: boolean;
  50525. /**
  50526. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50527. */
  50528. intensity: number;
  50529. /**
  50530. * Defines if the effect is along the tangents, bitangents or in between.
  50531. * By default, the effect is "strectching" the highlights along the tangents.
  50532. */
  50533. direction: Vector2;
  50534. private _texture;
  50535. /**
  50536. * Stores the anisotropy values in a texture.
  50537. * rg is direction (like normal from -1 to 1)
  50538. * b is a intensity
  50539. */
  50540. texture: Nullable<BaseTexture>;
  50541. /** @hidden */
  50542. private _internalMarkAllSubMeshesAsTexturesDirty;
  50543. /** @hidden */
  50544. _markAllSubMeshesAsTexturesDirty(): void;
  50545. /**
  50546. * Instantiate a new istance of anisotropy configuration.
  50547. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50548. */
  50549. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50550. /**
  50551. * Specifies that the submesh is ready to be used.
  50552. * @param defines the list of "defines" to update.
  50553. * @param scene defines the scene the material belongs to.
  50554. * @returns - boolean indicating that the submesh is ready or not.
  50555. */
  50556. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50557. /**
  50558. * Checks to see if a texture is used in the material.
  50559. * @param defines the list of "defines" to update.
  50560. * @param mesh the mesh we are preparing the defines for.
  50561. * @param scene defines the scene the material belongs to.
  50562. */
  50563. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50564. /**
  50565. * Binds the material data.
  50566. * @param uniformBuffer defines the Uniform buffer to fill in.
  50567. * @param scene defines the scene the material belongs to.
  50568. * @param isFrozen defines wether the material is frozen or not.
  50569. */
  50570. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50571. /**
  50572. * Checks to see if a texture is used in the material.
  50573. * @param texture - Base texture to use.
  50574. * @returns - Boolean specifying if a texture is used in the material.
  50575. */
  50576. hasTexture(texture: BaseTexture): boolean;
  50577. /**
  50578. * Returns an array of the actively used textures.
  50579. * @param activeTextures Array of BaseTextures
  50580. */
  50581. getActiveTextures(activeTextures: BaseTexture[]): void;
  50582. /**
  50583. * Returns the animatable textures.
  50584. * @param animatables Array of animatable textures.
  50585. */
  50586. getAnimatables(animatables: IAnimatable[]): void;
  50587. /**
  50588. * Disposes the resources of the material.
  50589. * @param forceDisposeTextures - Forces the disposal of all textures.
  50590. */
  50591. dispose(forceDisposeTextures?: boolean): void;
  50592. /**
  50593. * Get the current class name of the texture useful for serialization or dynamic coding.
  50594. * @returns "PBRAnisotropicConfiguration"
  50595. */
  50596. getClassName(): string;
  50597. /**
  50598. * Add fallbacks to the effect fallbacks list.
  50599. * @param defines defines the Base texture to use.
  50600. * @param fallbacks defines the current fallback list.
  50601. * @param currentRank defines the current fallback rank.
  50602. * @returns the new fallback rank.
  50603. */
  50604. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50605. /**
  50606. * Add the required uniforms to the current list.
  50607. * @param uniforms defines the current uniform list.
  50608. */
  50609. static AddUniforms(uniforms: string[]): void;
  50610. /**
  50611. * Add the required uniforms to the current buffer.
  50612. * @param uniformBuffer defines the current uniform buffer.
  50613. */
  50614. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50615. /**
  50616. * Add the required samplers to the current list.
  50617. * @param samplers defines the current sampler list.
  50618. */
  50619. static AddSamplers(samplers: string[]): void;
  50620. /**
  50621. * Makes a duplicate of the current configuration into another one.
  50622. * @param anisotropicConfiguration define the config where to copy the info
  50623. */
  50624. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50625. /**
  50626. * Serializes this anisotropy configuration.
  50627. * @returns - An object with the serialized config.
  50628. */
  50629. serialize(): any;
  50630. /**
  50631. * Parses a anisotropy Configuration from a serialized object.
  50632. * @param source - Serialized object.
  50633. * @param scene Defines the scene we are parsing for
  50634. * @param rootUrl Defines the rootUrl to load from
  50635. */
  50636. parse(source: any, scene: Scene, rootUrl: string): void;
  50637. }
  50638. }
  50639. declare module BABYLON {
  50640. /**
  50641. * @hidden
  50642. */
  50643. export interface IMaterialBRDFDefines {
  50644. BRDF_V_HEIGHT_CORRELATED: boolean;
  50645. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50646. SPHERICAL_HARMONICS: boolean;
  50647. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50648. /** @hidden */
  50649. _areMiscDirty: boolean;
  50650. }
  50651. /**
  50652. * Define the code related to the BRDF parameters of the pbr material.
  50653. */
  50654. export class PBRBRDFConfiguration {
  50655. /**
  50656. * Default value used for the energy conservation.
  50657. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50658. */
  50659. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50660. /**
  50661. * Default value used for the Smith Visibility Height Correlated mode.
  50662. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50663. */
  50664. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50665. /**
  50666. * Default value used for the IBL diffuse part.
  50667. * This can help switching back to the polynomials mode globally which is a tiny bit
  50668. * less GPU intensive at the drawback of a lower quality.
  50669. */
  50670. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50671. /**
  50672. * Default value used for activating energy conservation for the specular workflow.
  50673. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50674. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50675. */
  50676. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50677. private _useEnergyConservation;
  50678. /**
  50679. * Defines if the material uses energy conservation.
  50680. */
  50681. useEnergyConservation: boolean;
  50682. private _useSmithVisibilityHeightCorrelated;
  50683. /**
  50684. * LEGACY Mode set to false
  50685. * Defines if the material uses height smith correlated visibility term.
  50686. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50687. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50688. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50689. * Not relying on height correlated will also disable energy conservation.
  50690. */
  50691. useSmithVisibilityHeightCorrelated: boolean;
  50692. private _useSphericalHarmonics;
  50693. /**
  50694. * LEGACY Mode set to false
  50695. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50696. * diffuse part of the IBL.
  50697. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50698. * to the ground truth.
  50699. */
  50700. useSphericalHarmonics: boolean;
  50701. private _useSpecularGlossinessInputEnergyConservation;
  50702. /**
  50703. * Defines if the material uses energy conservation, when the specular workflow is active.
  50704. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50705. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50706. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50707. */
  50708. useSpecularGlossinessInputEnergyConservation: boolean;
  50709. /** @hidden */
  50710. private _internalMarkAllSubMeshesAsMiscDirty;
  50711. /** @hidden */
  50712. _markAllSubMeshesAsMiscDirty(): void;
  50713. /**
  50714. * Instantiate a new istance of clear coat configuration.
  50715. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50716. */
  50717. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50718. /**
  50719. * Checks to see if a texture is used in the material.
  50720. * @param defines the list of "defines" to update.
  50721. */
  50722. prepareDefines(defines: IMaterialBRDFDefines): void;
  50723. /**
  50724. * Get the current class name of the texture useful for serialization or dynamic coding.
  50725. * @returns "PBRClearCoatConfiguration"
  50726. */
  50727. getClassName(): string;
  50728. /**
  50729. * Makes a duplicate of the current configuration into another one.
  50730. * @param brdfConfiguration define the config where to copy the info
  50731. */
  50732. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50733. /**
  50734. * Serializes this BRDF configuration.
  50735. * @returns - An object with the serialized config.
  50736. */
  50737. serialize(): any;
  50738. /**
  50739. * Parses a anisotropy Configuration from a serialized object.
  50740. * @param source - Serialized object.
  50741. * @param scene Defines the scene we are parsing for
  50742. * @param rootUrl Defines the rootUrl to load from
  50743. */
  50744. parse(source: any, scene: Scene, rootUrl: string): void;
  50745. }
  50746. }
  50747. declare module BABYLON {
  50748. /**
  50749. * @hidden
  50750. */
  50751. export interface IMaterialSheenDefines {
  50752. SHEEN: boolean;
  50753. SHEEN_TEXTURE: boolean;
  50754. SHEEN_TEXTUREDIRECTUV: number;
  50755. SHEEN_LINKWITHALBEDO: boolean;
  50756. SHEEN_ROUGHNESS: boolean;
  50757. SHEEN_ALBEDOSCALING: boolean;
  50758. /** @hidden */
  50759. _areTexturesDirty: boolean;
  50760. }
  50761. /**
  50762. * Define the code related to the Sheen parameters of the pbr material.
  50763. */
  50764. export class PBRSheenConfiguration {
  50765. private _isEnabled;
  50766. /**
  50767. * Defines if the material uses sheen.
  50768. */
  50769. isEnabled: boolean;
  50770. private _linkSheenWithAlbedo;
  50771. /**
  50772. * Defines if the sheen is linked to the sheen color.
  50773. */
  50774. linkSheenWithAlbedo: boolean;
  50775. /**
  50776. * Defines the sheen intensity.
  50777. */
  50778. intensity: number;
  50779. /**
  50780. * Defines the sheen color.
  50781. */
  50782. color: Color3;
  50783. private _texture;
  50784. /**
  50785. * Stores the sheen tint values in a texture.
  50786. * rgb is tint
  50787. * a is a intensity
  50788. */
  50789. texture: Nullable<BaseTexture>;
  50790. private _roughness;
  50791. /**
  50792. * Defines the sheen roughness.
  50793. * It is not taken into account if linkSheenWithAlbedo is true.
  50794. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  50795. */
  50796. roughness: Nullable<number>;
  50797. private _albedoScaling;
  50798. /**
  50799. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  50800. * It allows the strength of the sheen effect to not depend on the base color of the material,
  50801. * making it easier to setup and tweak the effect
  50802. */
  50803. albedoScaling: boolean;
  50804. /** @hidden */
  50805. private _internalMarkAllSubMeshesAsTexturesDirty;
  50806. /** @hidden */
  50807. _markAllSubMeshesAsTexturesDirty(): void;
  50808. /**
  50809. * Instantiate a new istance of clear coat configuration.
  50810. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50811. */
  50812. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50813. /**
  50814. * Specifies that the submesh is ready to be used.
  50815. * @param defines the list of "defines" to update.
  50816. * @param scene defines the scene the material belongs to.
  50817. * @returns - boolean indicating that the submesh is ready or not.
  50818. */
  50819. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50820. /**
  50821. * Checks to see if a texture is used in the material.
  50822. * @param defines the list of "defines" to update.
  50823. * @param scene defines the scene the material belongs to.
  50824. */
  50825. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50826. /**
  50827. * Binds the material data.
  50828. * @param uniformBuffer defines the Uniform buffer to fill in.
  50829. * @param scene defines the scene the material belongs to.
  50830. * @param isFrozen defines wether the material is frozen or not.
  50831. */
  50832. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50833. /**
  50834. * Checks to see if a texture is used in the material.
  50835. * @param texture - Base texture to use.
  50836. * @returns - Boolean specifying if a texture is used in the material.
  50837. */
  50838. hasTexture(texture: BaseTexture): boolean;
  50839. /**
  50840. * Returns an array of the actively used textures.
  50841. * @param activeTextures Array of BaseTextures
  50842. */
  50843. getActiveTextures(activeTextures: BaseTexture[]): void;
  50844. /**
  50845. * Returns the animatable textures.
  50846. * @param animatables Array of animatable textures.
  50847. */
  50848. getAnimatables(animatables: IAnimatable[]): void;
  50849. /**
  50850. * Disposes the resources of the material.
  50851. * @param forceDisposeTextures - Forces the disposal of all textures.
  50852. */
  50853. dispose(forceDisposeTextures?: boolean): void;
  50854. /**
  50855. * Get the current class name of the texture useful for serialization or dynamic coding.
  50856. * @returns "PBRSheenConfiguration"
  50857. */
  50858. getClassName(): string;
  50859. /**
  50860. * Add fallbacks to the effect fallbacks list.
  50861. * @param defines defines the Base texture to use.
  50862. * @param fallbacks defines the current fallback list.
  50863. * @param currentRank defines the current fallback rank.
  50864. * @returns the new fallback rank.
  50865. */
  50866. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50867. /**
  50868. * Add the required uniforms to the current list.
  50869. * @param uniforms defines the current uniform list.
  50870. */
  50871. static AddUniforms(uniforms: string[]): void;
  50872. /**
  50873. * Add the required uniforms to the current buffer.
  50874. * @param uniformBuffer defines the current uniform buffer.
  50875. */
  50876. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50877. /**
  50878. * Add the required samplers to the current list.
  50879. * @param samplers defines the current sampler list.
  50880. */
  50881. static AddSamplers(samplers: string[]): void;
  50882. /**
  50883. * Makes a duplicate of the current configuration into another one.
  50884. * @param sheenConfiguration define the config where to copy the info
  50885. */
  50886. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50887. /**
  50888. * Serializes this BRDF configuration.
  50889. * @returns - An object with the serialized config.
  50890. */
  50891. serialize(): any;
  50892. /**
  50893. * Parses a anisotropy Configuration from a serialized object.
  50894. * @param source - Serialized object.
  50895. * @param scene Defines the scene we are parsing for
  50896. * @param rootUrl Defines the rootUrl to load from
  50897. */
  50898. parse(source: any, scene: Scene, rootUrl: string): void;
  50899. }
  50900. }
  50901. declare module BABYLON {
  50902. /**
  50903. * @hidden
  50904. */
  50905. export interface IMaterialSubSurfaceDefines {
  50906. SUBSURFACE: boolean;
  50907. SS_REFRACTION: boolean;
  50908. SS_TRANSLUCENCY: boolean;
  50909. SS_SCATERRING: boolean;
  50910. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50911. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50912. SS_REFRACTIONMAP_3D: boolean;
  50913. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50914. SS_LODINREFRACTIONALPHA: boolean;
  50915. SS_GAMMAREFRACTION: boolean;
  50916. SS_RGBDREFRACTION: boolean;
  50917. SS_LINEARSPECULARREFRACTION: boolean;
  50918. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50919. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50920. /** @hidden */
  50921. _areTexturesDirty: boolean;
  50922. }
  50923. /**
  50924. * Define the code related to the sub surface parameters of the pbr material.
  50925. */
  50926. export class PBRSubSurfaceConfiguration {
  50927. private _isRefractionEnabled;
  50928. /**
  50929. * Defines if the refraction is enabled in the material.
  50930. */
  50931. isRefractionEnabled: boolean;
  50932. private _isTranslucencyEnabled;
  50933. /**
  50934. * Defines if the translucency is enabled in the material.
  50935. */
  50936. isTranslucencyEnabled: boolean;
  50937. private _isScatteringEnabled;
  50938. /**
  50939. * Defines the refraction intensity of the material.
  50940. * The refraction when enabled replaces the Diffuse part of the material.
  50941. * The intensity helps transitionning between diffuse and refraction.
  50942. */
  50943. refractionIntensity: number;
  50944. /**
  50945. * Defines the translucency intensity of the material.
  50946. * When translucency has been enabled, this defines how much of the "translucency"
  50947. * is addded to the diffuse part of the material.
  50948. */
  50949. translucencyIntensity: number;
  50950. /**
  50951. * Defines the scattering intensity of the material.
  50952. * When scattering has been enabled, this defines how much of the "scattered light"
  50953. * is addded to the diffuse part of the material.
  50954. */
  50955. scatteringIntensity: number;
  50956. private _thicknessTexture;
  50957. /**
  50958. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50959. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50960. * 0 would mean minimumThickness
  50961. * 1 would mean maximumThickness
  50962. * The other channels might be use as a mask to vary the different effects intensity.
  50963. */
  50964. thicknessTexture: Nullable<BaseTexture>;
  50965. private _refractionTexture;
  50966. /**
  50967. * Defines the texture to use for refraction.
  50968. */
  50969. refractionTexture: Nullable<BaseTexture>;
  50970. private _indexOfRefraction;
  50971. /**
  50972. * Defines the index of refraction used in the material.
  50973. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50974. */
  50975. indexOfRefraction: number;
  50976. private _invertRefractionY;
  50977. /**
  50978. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50979. */
  50980. invertRefractionY: boolean;
  50981. private _linkRefractionWithTransparency;
  50982. /**
  50983. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50984. * Materials half opaque for instance using refraction could benefit from this control.
  50985. */
  50986. linkRefractionWithTransparency: boolean;
  50987. /**
  50988. * Defines the minimum thickness stored in the thickness map.
  50989. * If no thickness map is defined, this value will be used to simulate thickness.
  50990. */
  50991. minimumThickness: number;
  50992. /**
  50993. * Defines the maximum thickness stored in the thickness map.
  50994. */
  50995. maximumThickness: number;
  50996. /**
  50997. * Defines the volume tint of the material.
  50998. * This is used for both translucency and scattering.
  50999. */
  51000. tintColor: Color3;
  51001. /**
  51002. * Defines the distance at which the tint color should be found in the media.
  51003. * This is used for refraction only.
  51004. */
  51005. tintColorAtDistance: number;
  51006. /**
  51007. * Defines how far each channel transmit through the media.
  51008. * It is defined as a color to simplify it selection.
  51009. */
  51010. diffusionDistance: Color3;
  51011. private _useMaskFromThicknessTexture;
  51012. /**
  51013. * Stores the intensity of the different subsurface effects in the thickness texture.
  51014. * * the green channel is the translucency intensity.
  51015. * * the blue channel is the scattering intensity.
  51016. * * the alpha channel is the refraction intensity.
  51017. */
  51018. useMaskFromThicknessTexture: boolean;
  51019. /** @hidden */
  51020. private _internalMarkAllSubMeshesAsTexturesDirty;
  51021. /** @hidden */
  51022. _markAllSubMeshesAsTexturesDirty(): void;
  51023. /**
  51024. * Instantiate a new istance of sub surface configuration.
  51025. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51026. */
  51027. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51028. /**
  51029. * Gets wehter the submesh is ready to be used or not.
  51030. * @param defines the list of "defines" to update.
  51031. * @param scene defines the scene the material belongs to.
  51032. * @returns - boolean indicating that the submesh is ready or not.
  51033. */
  51034. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  51035. /**
  51036. * Checks to see if a texture is used in the material.
  51037. * @param defines the list of "defines" to update.
  51038. * @param scene defines the scene to the material belongs to.
  51039. */
  51040. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  51041. /**
  51042. * Binds the material data.
  51043. * @param uniformBuffer defines the Uniform buffer to fill in.
  51044. * @param scene defines the scene the material belongs to.
  51045. * @param engine defines the engine the material belongs to.
  51046. * @param isFrozen defines wether the material is frozen or not.
  51047. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  51048. */
  51049. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  51050. /**
  51051. * Unbinds the material from the mesh.
  51052. * @param activeEffect defines the effect that should be unbound from.
  51053. * @returns true if unbound, otherwise false
  51054. */
  51055. unbind(activeEffect: Effect): boolean;
  51056. /**
  51057. * Returns the texture used for refraction or null if none is used.
  51058. * @param scene defines the scene the material belongs to.
  51059. * @returns - Refraction texture if present. If no refraction texture and refraction
  51060. * is linked with transparency, returns environment texture. Otherwise, returns null.
  51061. */
  51062. private _getRefractionTexture;
  51063. /**
  51064. * Returns true if alpha blending should be disabled.
  51065. */
  51066. get disableAlphaBlending(): boolean;
  51067. /**
  51068. * Fills the list of render target textures.
  51069. * @param renderTargets the list of render targets to update
  51070. */
  51071. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  51072. /**
  51073. * Checks to see if a texture is used in the material.
  51074. * @param texture - Base texture to use.
  51075. * @returns - Boolean specifying if a texture is used in the material.
  51076. */
  51077. hasTexture(texture: BaseTexture): boolean;
  51078. /**
  51079. * Gets a boolean indicating that current material needs to register RTT
  51080. * @returns true if this uses a render target otherwise false.
  51081. */
  51082. hasRenderTargetTextures(): boolean;
  51083. /**
  51084. * Returns an array of the actively used textures.
  51085. * @param activeTextures Array of BaseTextures
  51086. */
  51087. getActiveTextures(activeTextures: BaseTexture[]): void;
  51088. /**
  51089. * Returns the animatable textures.
  51090. * @param animatables Array of animatable textures.
  51091. */
  51092. getAnimatables(animatables: IAnimatable[]): void;
  51093. /**
  51094. * Disposes the resources of the material.
  51095. * @param forceDisposeTextures - Forces the disposal of all textures.
  51096. */
  51097. dispose(forceDisposeTextures?: boolean): void;
  51098. /**
  51099. * Get the current class name of the texture useful for serialization or dynamic coding.
  51100. * @returns "PBRSubSurfaceConfiguration"
  51101. */
  51102. getClassName(): string;
  51103. /**
  51104. * Add fallbacks to the effect fallbacks list.
  51105. * @param defines defines the Base texture to use.
  51106. * @param fallbacks defines the current fallback list.
  51107. * @param currentRank defines the current fallback rank.
  51108. * @returns the new fallback rank.
  51109. */
  51110. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51111. /**
  51112. * Add the required uniforms to the current list.
  51113. * @param uniforms defines the current uniform list.
  51114. */
  51115. static AddUniforms(uniforms: string[]): void;
  51116. /**
  51117. * Add the required samplers to the current list.
  51118. * @param samplers defines the current sampler list.
  51119. */
  51120. static AddSamplers(samplers: string[]): void;
  51121. /**
  51122. * Add the required uniforms to the current buffer.
  51123. * @param uniformBuffer defines the current uniform buffer.
  51124. */
  51125. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51126. /**
  51127. * Makes a duplicate of the current configuration into another one.
  51128. * @param configuration define the config where to copy the info
  51129. */
  51130. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  51131. /**
  51132. * Serializes this Sub Surface configuration.
  51133. * @returns - An object with the serialized config.
  51134. */
  51135. serialize(): any;
  51136. /**
  51137. * Parses a anisotropy Configuration from a serialized object.
  51138. * @param source - Serialized object.
  51139. * @param scene Defines the scene we are parsing for
  51140. * @param rootUrl Defines the rootUrl to load from
  51141. */
  51142. parse(source: any, scene: Scene, rootUrl: string): void;
  51143. }
  51144. }
  51145. declare module BABYLON {
  51146. /** @hidden */
  51147. export var pbrFragmentDeclaration: {
  51148. name: string;
  51149. shader: string;
  51150. };
  51151. }
  51152. declare module BABYLON {
  51153. /** @hidden */
  51154. export var pbrUboDeclaration: {
  51155. name: string;
  51156. shader: string;
  51157. };
  51158. }
  51159. declare module BABYLON {
  51160. /** @hidden */
  51161. export var pbrFragmentExtraDeclaration: {
  51162. name: string;
  51163. shader: string;
  51164. };
  51165. }
  51166. declare module BABYLON {
  51167. /** @hidden */
  51168. export var pbrFragmentSamplersDeclaration: {
  51169. name: string;
  51170. shader: string;
  51171. };
  51172. }
  51173. declare module BABYLON {
  51174. /** @hidden */
  51175. export var pbrHelperFunctions: {
  51176. name: string;
  51177. shader: string;
  51178. };
  51179. }
  51180. declare module BABYLON {
  51181. /** @hidden */
  51182. export var harmonicsFunctions: {
  51183. name: string;
  51184. shader: string;
  51185. };
  51186. }
  51187. declare module BABYLON {
  51188. /** @hidden */
  51189. export var pbrDirectLightingSetupFunctions: {
  51190. name: string;
  51191. shader: string;
  51192. };
  51193. }
  51194. declare module BABYLON {
  51195. /** @hidden */
  51196. export var pbrDirectLightingFalloffFunctions: {
  51197. name: string;
  51198. shader: string;
  51199. };
  51200. }
  51201. declare module BABYLON {
  51202. /** @hidden */
  51203. export var pbrBRDFFunctions: {
  51204. name: string;
  51205. shader: string;
  51206. };
  51207. }
  51208. declare module BABYLON {
  51209. /** @hidden */
  51210. export var pbrDirectLightingFunctions: {
  51211. name: string;
  51212. shader: string;
  51213. };
  51214. }
  51215. declare module BABYLON {
  51216. /** @hidden */
  51217. export var pbrIBLFunctions: {
  51218. name: string;
  51219. shader: string;
  51220. };
  51221. }
  51222. declare module BABYLON {
  51223. /** @hidden */
  51224. export var pbrBlockAlbedoOpacity: {
  51225. name: string;
  51226. shader: string;
  51227. };
  51228. }
  51229. declare module BABYLON {
  51230. /** @hidden */
  51231. export var pbrBlockReflectivity: {
  51232. name: string;
  51233. shader: string;
  51234. };
  51235. }
  51236. declare module BABYLON {
  51237. /** @hidden */
  51238. export var pbrBlockAmbientOcclusion: {
  51239. name: string;
  51240. shader: string;
  51241. };
  51242. }
  51243. declare module BABYLON {
  51244. /** @hidden */
  51245. export var pbrBlockAlphaFresnel: {
  51246. name: string;
  51247. shader: string;
  51248. };
  51249. }
  51250. declare module BABYLON {
  51251. /** @hidden */
  51252. export var pbrBlockAnisotropic: {
  51253. name: string;
  51254. shader: string;
  51255. };
  51256. }
  51257. declare module BABYLON {
  51258. /** @hidden */
  51259. export var pbrBlockReflection: {
  51260. name: string;
  51261. shader: string;
  51262. };
  51263. }
  51264. declare module BABYLON {
  51265. /** @hidden */
  51266. export var pbrBlockSheen: {
  51267. name: string;
  51268. shader: string;
  51269. };
  51270. }
  51271. declare module BABYLON {
  51272. /** @hidden */
  51273. export var pbrBlockClearcoat: {
  51274. name: string;
  51275. shader: string;
  51276. };
  51277. }
  51278. declare module BABYLON {
  51279. /** @hidden */
  51280. export var pbrBlockSubSurface: {
  51281. name: string;
  51282. shader: string;
  51283. };
  51284. }
  51285. declare module BABYLON {
  51286. /** @hidden */
  51287. export var pbrBlockNormalGeometric: {
  51288. name: string;
  51289. shader: string;
  51290. };
  51291. }
  51292. declare module BABYLON {
  51293. /** @hidden */
  51294. export var pbrBlockNormalFinal: {
  51295. name: string;
  51296. shader: string;
  51297. };
  51298. }
  51299. declare module BABYLON {
  51300. /** @hidden */
  51301. export var pbrBlockGeometryInfo: {
  51302. name: string;
  51303. shader: string;
  51304. };
  51305. }
  51306. declare module BABYLON {
  51307. /** @hidden */
  51308. export var pbrBlockReflectance0: {
  51309. name: string;
  51310. shader: string;
  51311. };
  51312. }
  51313. declare module BABYLON {
  51314. /** @hidden */
  51315. export var pbrBlockReflectance: {
  51316. name: string;
  51317. shader: string;
  51318. };
  51319. }
  51320. declare module BABYLON {
  51321. /** @hidden */
  51322. export var pbrBlockDirectLighting: {
  51323. name: string;
  51324. shader: string;
  51325. };
  51326. }
  51327. declare module BABYLON {
  51328. /** @hidden */
  51329. export var pbrBlockFinalLitComponents: {
  51330. name: string;
  51331. shader: string;
  51332. };
  51333. }
  51334. declare module BABYLON {
  51335. /** @hidden */
  51336. export var pbrBlockFinalUnlitComponents: {
  51337. name: string;
  51338. shader: string;
  51339. };
  51340. }
  51341. declare module BABYLON {
  51342. /** @hidden */
  51343. export var pbrBlockFinalColorComposition: {
  51344. name: string;
  51345. shader: string;
  51346. };
  51347. }
  51348. declare module BABYLON {
  51349. /** @hidden */
  51350. export var pbrBlockImageProcessing: {
  51351. name: string;
  51352. shader: string;
  51353. };
  51354. }
  51355. declare module BABYLON {
  51356. /** @hidden */
  51357. export var pbrDebug: {
  51358. name: string;
  51359. shader: string;
  51360. };
  51361. }
  51362. declare module BABYLON {
  51363. /** @hidden */
  51364. export var pbrPixelShader: {
  51365. name: string;
  51366. shader: string;
  51367. };
  51368. }
  51369. declare module BABYLON {
  51370. /** @hidden */
  51371. export var pbrVertexDeclaration: {
  51372. name: string;
  51373. shader: string;
  51374. };
  51375. }
  51376. declare module BABYLON {
  51377. /** @hidden */
  51378. export var pbrVertexShader: {
  51379. name: string;
  51380. shader: string;
  51381. };
  51382. }
  51383. declare module BABYLON {
  51384. /**
  51385. * Manages the defines for the PBR Material.
  51386. * @hidden
  51387. */
  51388. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  51389. PBR: boolean;
  51390. MAINUV1: boolean;
  51391. MAINUV2: boolean;
  51392. UV1: boolean;
  51393. UV2: boolean;
  51394. ALBEDO: boolean;
  51395. GAMMAALBEDO: boolean;
  51396. ALBEDODIRECTUV: number;
  51397. VERTEXCOLOR: boolean;
  51398. AMBIENT: boolean;
  51399. AMBIENTDIRECTUV: number;
  51400. AMBIENTINGRAYSCALE: boolean;
  51401. OPACITY: boolean;
  51402. VERTEXALPHA: boolean;
  51403. OPACITYDIRECTUV: number;
  51404. OPACITYRGB: boolean;
  51405. ALPHATEST: boolean;
  51406. DEPTHPREPASS: boolean;
  51407. ALPHABLEND: boolean;
  51408. ALPHAFROMALBEDO: boolean;
  51409. ALPHATESTVALUE: string;
  51410. SPECULAROVERALPHA: boolean;
  51411. RADIANCEOVERALPHA: boolean;
  51412. ALPHAFRESNEL: boolean;
  51413. LINEARALPHAFRESNEL: boolean;
  51414. PREMULTIPLYALPHA: boolean;
  51415. EMISSIVE: boolean;
  51416. EMISSIVEDIRECTUV: number;
  51417. REFLECTIVITY: boolean;
  51418. REFLECTIVITYDIRECTUV: number;
  51419. SPECULARTERM: boolean;
  51420. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  51421. MICROSURFACEAUTOMATIC: boolean;
  51422. LODBASEDMICROSFURACE: boolean;
  51423. MICROSURFACEMAP: boolean;
  51424. MICROSURFACEMAPDIRECTUV: number;
  51425. METALLICWORKFLOW: boolean;
  51426. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  51427. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  51428. METALLNESSSTOREINMETALMAPBLUE: boolean;
  51429. AOSTOREINMETALMAPRED: boolean;
  51430. METALLICF0FACTORFROMMETALLICMAP: boolean;
  51431. ENVIRONMENTBRDF: boolean;
  51432. ENVIRONMENTBRDF_RGBD: boolean;
  51433. NORMAL: boolean;
  51434. TANGENT: boolean;
  51435. BUMP: boolean;
  51436. BUMPDIRECTUV: number;
  51437. OBJECTSPACE_NORMALMAP: boolean;
  51438. PARALLAX: boolean;
  51439. PARALLAXOCCLUSION: boolean;
  51440. NORMALXYSCALE: boolean;
  51441. LIGHTMAP: boolean;
  51442. LIGHTMAPDIRECTUV: number;
  51443. USELIGHTMAPASSHADOWMAP: boolean;
  51444. GAMMALIGHTMAP: boolean;
  51445. RGBDLIGHTMAP: boolean;
  51446. REFLECTION: boolean;
  51447. REFLECTIONMAP_3D: boolean;
  51448. REFLECTIONMAP_SPHERICAL: boolean;
  51449. REFLECTIONMAP_PLANAR: boolean;
  51450. REFLECTIONMAP_CUBIC: boolean;
  51451. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  51452. REFLECTIONMAP_PROJECTION: boolean;
  51453. REFLECTIONMAP_SKYBOX: boolean;
  51454. REFLECTIONMAP_EXPLICIT: boolean;
  51455. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  51456. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  51457. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  51458. INVERTCUBICMAP: boolean;
  51459. USESPHERICALFROMREFLECTIONMAP: boolean;
  51460. USEIRRADIANCEMAP: boolean;
  51461. SPHERICAL_HARMONICS: boolean;
  51462. USESPHERICALINVERTEX: boolean;
  51463. REFLECTIONMAP_OPPOSITEZ: boolean;
  51464. LODINREFLECTIONALPHA: boolean;
  51465. GAMMAREFLECTION: boolean;
  51466. RGBDREFLECTION: boolean;
  51467. LINEARSPECULARREFLECTION: boolean;
  51468. RADIANCEOCCLUSION: boolean;
  51469. HORIZONOCCLUSION: boolean;
  51470. INSTANCES: boolean;
  51471. NUM_BONE_INFLUENCERS: number;
  51472. BonesPerMesh: number;
  51473. BONETEXTURE: boolean;
  51474. NONUNIFORMSCALING: boolean;
  51475. MORPHTARGETS: boolean;
  51476. MORPHTARGETS_NORMAL: boolean;
  51477. MORPHTARGETS_TANGENT: boolean;
  51478. MORPHTARGETS_UV: boolean;
  51479. NUM_MORPH_INFLUENCERS: number;
  51480. IMAGEPROCESSING: boolean;
  51481. VIGNETTE: boolean;
  51482. VIGNETTEBLENDMODEMULTIPLY: boolean;
  51483. VIGNETTEBLENDMODEOPAQUE: boolean;
  51484. TONEMAPPING: boolean;
  51485. TONEMAPPING_ACES: boolean;
  51486. CONTRAST: boolean;
  51487. COLORCURVES: boolean;
  51488. COLORGRADING: boolean;
  51489. COLORGRADING3D: boolean;
  51490. SAMPLER3DGREENDEPTH: boolean;
  51491. SAMPLER3DBGRMAP: boolean;
  51492. IMAGEPROCESSINGPOSTPROCESS: boolean;
  51493. EXPOSURE: boolean;
  51494. MULTIVIEW: boolean;
  51495. USEPHYSICALLIGHTFALLOFF: boolean;
  51496. USEGLTFLIGHTFALLOFF: boolean;
  51497. TWOSIDEDLIGHTING: boolean;
  51498. SHADOWFLOAT: boolean;
  51499. CLIPPLANE: boolean;
  51500. CLIPPLANE2: boolean;
  51501. CLIPPLANE3: boolean;
  51502. CLIPPLANE4: boolean;
  51503. CLIPPLANE5: boolean;
  51504. CLIPPLANE6: boolean;
  51505. POINTSIZE: boolean;
  51506. FOG: boolean;
  51507. LOGARITHMICDEPTH: boolean;
  51508. FORCENORMALFORWARD: boolean;
  51509. SPECULARAA: boolean;
  51510. CLEARCOAT: boolean;
  51511. CLEARCOAT_DEFAULTIOR: boolean;
  51512. CLEARCOAT_TEXTURE: boolean;
  51513. CLEARCOAT_TEXTUREDIRECTUV: number;
  51514. CLEARCOAT_BUMP: boolean;
  51515. CLEARCOAT_BUMPDIRECTUV: number;
  51516. CLEARCOAT_TINT: boolean;
  51517. CLEARCOAT_TINT_TEXTURE: boolean;
  51518. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51519. ANISOTROPIC: boolean;
  51520. ANISOTROPIC_TEXTURE: boolean;
  51521. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51522. BRDF_V_HEIGHT_CORRELATED: boolean;
  51523. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51524. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51525. SHEEN: boolean;
  51526. SHEEN_TEXTURE: boolean;
  51527. SHEEN_TEXTUREDIRECTUV: number;
  51528. SHEEN_LINKWITHALBEDO: boolean;
  51529. SHEEN_ROUGHNESS: boolean;
  51530. SHEEN_ALBEDOSCALING: boolean;
  51531. SUBSURFACE: boolean;
  51532. SS_REFRACTION: boolean;
  51533. SS_TRANSLUCENCY: boolean;
  51534. SS_SCATERRING: boolean;
  51535. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51536. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51537. SS_REFRACTIONMAP_3D: boolean;
  51538. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51539. SS_LODINREFRACTIONALPHA: boolean;
  51540. SS_GAMMAREFRACTION: boolean;
  51541. SS_RGBDREFRACTION: boolean;
  51542. SS_LINEARSPECULARREFRACTION: boolean;
  51543. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51544. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51545. UNLIT: boolean;
  51546. DEBUGMODE: number;
  51547. /**
  51548. * Initializes the PBR Material defines.
  51549. */
  51550. constructor();
  51551. /**
  51552. * Resets the PBR Material defines.
  51553. */
  51554. reset(): void;
  51555. }
  51556. /**
  51557. * The Physically based material base class of BJS.
  51558. *
  51559. * This offers the main features of a standard PBR material.
  51560. * For more information, please refer to the documentation :
  51561. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51562. */
  51563. export abstract class PBRBaseMaterial extends PushMaterial {
  51564. /**
  51565. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51566. */
  51567. static readonly PBRMATERIAL_OPAQUE: number;
  51568. /**
  51569. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51570. */
  51571. static readonly PBRMATERIAL_ALPHATEST: number;
  51572. /**
  51573. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51574. */
  51575. static readonly PBRMATERIAL_ALPHABLEND: number;
  51576. /**
  51577. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51578. * They are also discarded below the alpha cutoff threshold to improve performances.
  51579. */
  51580. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51581. /**
  51582. * Defines the default value of how much AO map is occluding the analytical lights
  51583. * (point spot...).
  51584. */
  51585. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51586. /**
  51587. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51588. */
  51589. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51590. /**
  51591. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51592. * to enhance interoperability with other engines.
  51593. */
  51594. static readonly LIGHTFALLOFF_GLTF: number;
  51595. /**
  51596. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51597. * to enhance interoperability with other materials.
  51598. */
  51599. static readonly LIGHTFALLOFF_STANDARD: number;
  51600. /**
  51601. * Intensity of the direct lights e.g. the four lights available in your scene.
  51602. * This impacts both the direct diffuse and specular highlights.
  51603. */
  51604. protected _directIntensity: number;
  51605. /**
  51606. * Intensity of the emissive part of the material.
  51607. * This helps controlling the emissive effect without modifying the emissive color.
  51608. */
  51609. protected _emissiveIntensity: number;
  51610. /**
  51611. * Intensity of the environment e.g. how much the environment will light the object
  51612. * either through harmonics for rough material or through the refelction for shiny ones.
  51613. */
  51614. protected _environmentIntensity: number;
  51615. /**
  51616. * This is a special control allowing the reduction of the specular highlights coming from the
  51617. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51618. */
  51619. protected _specularIntensity: number;
  51620. /**
  51621. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51622. */
  51623. private _lightingInfos;
  51624. /**
  51625. * Debug Control allowing disabling the bump map on this material.
  51626. */
  51627. protected _disableBumpMap: boolean;
  51628. /**
  51629. * AKA Diffuse Texture in standard nomenclature.
  51630. */
  51631. protected _albedoTexture: Nullable<BaseTexture>;
  51632. /**
  51633. * AKA Occlusion Texture in other nomenclature.
  51634. */
  51635. protected _ambientTexture: Nullable<BaseTexture>;
  51636. /**
  51637. * AKA Occlusion Texture Intensity in other nomenclature.
  51638. */
  51639. protected _ambientTextureStrength: number;
  51640. /**
  51641. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51642. * 1 means it completely occludes it
  51643. * 0 mean it has no impact
  51644. */
  51645. protected _ambientTextureImpactOnAnalyticalLights: number;
  51646. /**
  51647. * Stores the alpha values in a texture.
  51648. */
  51649. protected _opacityTexture: Nullable<BaseTexture>;
  51650. /**
  51651. * Stores the reflection values in a texture.
  51652. */
  51653. protected _reflectionTexture: Nullable<BaseTexture>;
  51654. /**
  51655. * Stores the emissive values in a texture.
  51656. */
  51657. protected _emissiveTexture: Nullable<BaseTexture>;
  51658. /**
  51659. * AKA Specular texture in other nomenclature.
  51660. */
  51661. protected _reflectivityTexture: Nullable<BaseTexture>;
  51662. /**
  51663. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51664. */
  51665. protected _metallicTexture: Nullable<BaseTexture>;
  51666. /**
  51667. * Specifies the metallic scalar of the metallic/roughness workflow.
  51668. * Can also be used to scale the metalness values of the metallic texture.
  51669. */
  51670. protected _metallic: Nullable<number>;
  51671. /**
  51672. * Specifies the roughness scalar of the metallic/roughness workflow.
  51673. * Can also be used to scale the roughness values of the metallic texture.
  51674. */
  51675. protected _roughness: Nullable<number>;
  51676. /**
  51677. * Specifies the an F0 factor to help configuring the material F0.
  51678. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51679. * to 0.5 the previously hard coded value stays the same.
  51680. * Can also be used to scale the F0 values of the metallic texture.
  51681. */
  51682. protected _metallicF0Factor: number;
  51683. /**
  51684. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51685. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51686. * your expectation as it multiplies with the texture data.
  51687. */
  51688. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51689. /**
  51690. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51691. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51692. */
  51693. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51694. /**
  51695. * Stores surface normal data used to displace a mesh in a texture.
  51696. */
  51697. protected _bumpTexture: Nullable<BaseTexture>;
  51698. /**
  51699. * Stores the pre-calculated light information of a mesh in a texture.
  51700. */
  51701. protected _lightmapTexture: Nullable<BaseTexture>;
  51702. /**
  51703. * The color of a material in ambient lighting.
  51704. */
  51705. protected _ambientColor: Color3;
  51706. /**
  51707. * AKA Diffuse Color in other nomenclature.
  51708. */
  51709. protected _albedoColor: Color3;
  51710. /**
  51711. * AKA Specular Color in other nomenclature.
  51712. */
  51713. protected _reflectivityColor: Color3;
  51714. /**
  51715. * The color applied when light is reflected from a material.
  51716. */
  51717. protected _reflectionColor: Color3;
  51718. /**
  51719. * The color applied when light is emitted from a material.
  51720. */
  51721. protected _emissiveColor: Color3;
  51722. /**
  51723. * AKA Glossiness in other nomenclature.
  51724. */
  51725. protected _microSurface: number;
  51726. /**
  51727. * Specifies that the material will use the light map as a show map.
  51728. */
  51729. protected _useLightmapAsShadowmap: boolean;
  51730. /**
  51731. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51732. * makes the reflect vector face the model (under horizon).
  51733. */
  51734. protected _useHorizonOcclusion: boolean;
  51735. /**
  51736. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51737. * too much the area relying on ambient texture to define their ambient occlusion.
  51738. */
  51739. protected _useRadianceOcclusion: boolean;
  51740. /**
  51741. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51742. */
  51743. protected _useAlphaFromAlbedoTexture: boolean;
  51744. /**
  51745. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51746. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51747. */
  51748. protected _useSpecularOverAlpha: boolean;
  51749. /**
  51750. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51751. */
  51752. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51753. /**
  51754. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51755. */
  51756. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51757. /**
  51758. * Specifies if the metallic texture contains the roughness information in its green channel.
  51759. */
  51760. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51761. /**
  51762. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51763. */
  51764. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51765. /**
  51766. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51767. */
  51768. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51769. /**
  51770. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51771. */
  51772. protected _useAmbientInGrayScale: boolean;
  51773. /**
  51774. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51775. * The material will try to infer what glossiness each pixel should be.
  51776. */
  51777. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51778. /**
  51779. * Defines the falloff type used in this material.
  51780. * It by default is Physical.
  51781. */
  51782. protected _lightFalloff: number;
  51783. /**
  51784. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51785. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51786. */
  51787. protected _useRadianceOverAlpha: boolean;
  51788. /**
  51789. * Allows using an object space normal map (instead of tangent space).
  51790. */
  51791. protected _useObjectSpaceNormalMap: boolean;
  51792. /**
  51793. * Allows using the bump map in parallax mode.
  51794. */
  51795. protected _useParallax: boolean;
  51796. /**
  51797. * Allows using the bump map in parallax occlusion mode.
  51798. */
  51799. protected _useParallaxOcclusion: boolean;
  51800. /**
  51801. * Controls the scale bias of the parallax mode.
  51802. */
  51803. protected _parallaxScaleBias: number;
  51804. /**
  51805. * If sets to true, disables all the lights affecting the material.
  51806. */
  51807. protected _disableLighting: boolean;
  51808. /**
  51809. * Number of Simultaneous lights allowed on the material.
  51810. */
  51811. protected _maxSimultaneousLights: number;
  51812. /**
  51813. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51814. */
  51815. protected _invertNormalMapX: boolean;
  51816. /**
  51817. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51818. */
  51819. protected _invertNormalMapY: boolean;
  51820. /**
  51821. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51822. */
  51823. protected _twoSidedLighting: boolean;
  51824. /**
  51825. * Defines the alpha limits in alpha test mode.
  51826. */
  51827. protected _alphaCutOff: number;
  51828. /**
  51829. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51830. */
  51831. protected _forceAlphaTest: boolean;
  51832. /**
  51833. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51834. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51835. */
  51836. protected _useAlphaFresnel: boolean;
  51837. /**
  51838. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51839. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51840. */
  51841. protected _useLinearAlphaFresnel: boolean;
  51842. /**
  51843. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51844. * from cos thetav and roughness:
  51845. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51846. */
  51847. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51848. /**
  51849. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51850. */
  51851. protected _forceIrradianceInFragment: boolean;
  51852. /**
  51853. * Force normal to face away from face.
  51854. */
  51855. protected _forceNormalForward: boolean;
  51856. /**
  51857. * Enables specular anti aliasing in the PBR shader.
  51858. * It will both interacts on the Geometry for analytical and IBL lighting.
  51859. * It also prefilter the roughness map based on the bump values.
  51860. */
  51861. protected _enableSpecularAntiAliasing: boolean;
  51862. /**
  51863. * Default configuration related to image processing available in the PBR Material.
  51864. */
  51865. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51866. /**
  51867. * Keep track of the image processing observer to allow dispose and replace.
  51868. */
  51869. private _imageProcessingObserver;
  51870. /**
  51871. * Attaches a new image processing configuration to the PBR Material.
  51872. * @param configuration
  51873. */
  51874. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51875. /**
  51876. * Stores the available render targets.
  51877. */
  51878. private _renderTargets;
  51879. /**
  51880. * Sets the global ambient color for the material used in lighting calculations.
  51881. */
  51882. private _globalAmbientColor;
  51883. /**
  51884. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51885. */
  51886. private _useLogarithmicDepth;
  51887. /**
  51888. * If set to true, no lighting calculations will be applied.
  51889. */
  51890. private _unlit;
  51891. private _debugMode;
  51892. /**
  51893. * @hidden
  51894. * This is reserved for the inspector.
  51895. * Defines the material debug mode.
  51896. * It helps seeing only some components of the material while troubleshooting.
  51897. */
  51898. debugMode: number;
  51899. /**
  51900. * @hidden
  51901. * This is reserved for the inspector.
  51902. * Specify from where on screen the debug mode should start.
  51903. * The value goes from -1 (full screen) to 1 (not visible)
  51904. * It helps with side by side comparison against the final render
  51905. * This defaults to -1
  51906. */
  51907. private debugLimit;
  51908. /**
  51909. * @hidden
  51910. * This is reserved for the inspector.
  51911. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51912. * You can use the factor to better multiply the final value.
  51913. */
  51914. private debugFactor;
  51915. /**
  51916. * Defines the clear coat layer parameters for the material.
  51917. */
  51918. readonly clearCoat: PBRClearCoatConfiguration;
  51919. /**
  51920. * Defines the anisotropic parameters for the material.
  51921. */
  51922. readonly anisotropy: PBRAnisotropicConfiguration;
  51923. /**
  51924. * Defines the BRDF parameters for the material.
  51925. */
  51926. readonly brdf: PBRBRDFConfiguration;
  51927. /**
  51928. * Defines the Sheen parameters for the material.
  51929. */
  51930. readonly sheen: PBRSheenConfiguration;
  51931. /**
  51932. * Defines the SubSurface parameters for the material.
  51933. */
  51934. readonly subSurface: PBRSubSurfaceConfiguration;
  51935. /**
  51936. * Custom callback helping to override the default shader used in the material.
  51937. */
  51938. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  51939. protected _rebuildInParallel: boolean;
  51940. /**
  51941. * Instantiates a new PBRMaterial instance.
  51942. *
  51943. * @param name The material name
  51944. * @param scene The scene the material will be use in.
  51945. */
  51946. constructor(name: string, scene: Scene);
  51947. /**
  51948. * Gets a boolean indicating that current material needs to register RTT
  51949. */
  51950. get hasRenderTargetTextures(): boolean;
  51951. /**
  51952. * Gets the name of the material class.
  51953. */
  51954. getClassName(): string;
  51955. /**
  51956. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51957. */
  51958. get useLogarithmicDepth(): boolean;
  51959. /**
  51960. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51961. */
  51962. set useLogarithmicDepth(value: boolean);
  51963. /**
  51964. * Returns true if alpha blending should be disabled.
  51965. */
  51966. protected get _disableAlphaBlending(): boolean;
  51967. /**
  51968. * Specifies whether or not this material should be rendered in alpha blend mode.
  51969. */
  51970. needAlphaBlending(): boolean;
  51971. /**
  51972. * Specifies whether or not this material should be rendered in alpha test mode.
  51973. */
  51974. needAlphaTesting(): boolean;
  51975. /**
  51976. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51977. */
  51978. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51979. /**
  51980. * Gets the texture used for the alpha test.
  51981. */
  51982. getAlphaTestTexture(): Nullable<BaseTexture>;
  51983. /**
  51984. * Specifies that the submesh is ready to be used.
  51985. * @param mesh - BJS mesh.
  51986. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51987. * @param useInstances - Specifies that instances should be used.
  51988. * @returns - boolean indicating that the submesh is ready or not.
  51989. */
  51990. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51991. /**
  51992. * Specifies if the material uses metallic roughness workflow.
  51993. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51994. */
  51995. isMetallicWorkflow(): boolean;
  51996. private _prepareEffect;
  51997. private _prepareDefines;
  51998. /**
  51999. * Force shader compilation
  52000. */
  52001. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  52002. /**
  52003. * Initializes the uniform buffer layout for the shader.
  52004. */
  52005. buildUniformLayout(): void;
  52006. /**
  52007. * Unbinds the material from the mesh
  52008. */
  52009. unbind(): void;
  52010. /**
  52011. * Binds the submesh data.
  52012. * @param world - The world matrix.
  52013. * @param mesh - The BJS mesh.
  52014. * @param subMesh - A submesh of the BJS mesh.
  52015. */
  52016. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52017. /**
  52018. * Returns the animatable textures.
  52019. * @returns - Array of animatable textures.
  52020. */
  52021. getAnimatables(): IAnimatable[];
  52022. /**
  52023. * Returns the texture used for reflections.
  52024. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52025. */
  52026. private _getReflectionTexture;
  52027. /**
  52028. * Returns an array of the actively used textures.
  52029. * @returns - Array of BaseTextures
  52030. */
  52031. getActiveTextures(): BaseTexture[];
  52032. /**
  52033. * Checks to see if a texture is used in the material.
  52034. * @param texture - Base texture to use.
  52035. * @returns - Boolean specifying if a texture is used in the material.
  52036. */
  52037. hasTexture(texture: BaseTexture): boolean;
  52038. /**
  52039. * Disposes the resources of the material.
  52040. * @param forceDisposeEffect - Forces the disposal of effects.
  52041. * @param forceDisposeTextures - Forces the disposal of all textures.
  52042. */
  52043. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  52044. }
  52045. }
  52046. declare module BABYLON {
  52047. /**
  52048. * The Physically based material of BJS.
  52049. *
  52050. * This offers the main features of a standard PBR material.
  52051. * For more information, please refer to the documentation :
  52052. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52053. */
  52054. export class PBRMaterial extends PBRBaseMaterial {
  52055. /**
  52056. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52057. */
  52058. static readonly PBRMATERIAL_OPAQUE: number;
  52059. /**
  52060. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52061. */
  52062. static readonly PBRMATERIAL_ALPHATEST: number;
  52063. /**
  52064. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52065. */
  52066. static readonly PBRMATERIAL_ALPHABLEND: number;
  52067. /**
  52068. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52069. * They are also discarded below the alpha cutoff threshold to improve performances.
  52070. */
  52071. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52072. /**
  52073. * Defines the default value of how much AO map is occluding the analytical lights
  52074. * (point spot...).
  52075. */
  52076. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52077. /**
  52078. * Intensity of the direct lights e.g. the four lights available in your scene.
  52079. * This impacts both the direct diffuse and specular highlights.
  52080. */
  52081. directIntensity: number;
  52082. /**
  52083. * Intensity of the emissive part of the material.
  52084. * This helps controlling the emissive effect without modifying the emissive color.
  52085. */
  52086. emissiveIntensity: number;
  52087. /**
  52088. * Intensity of the environment e.g. how much the environment will light the object
  52089. * either through harmonics for rough material or through the refelction for shiny ones.
  52090. */
  52091. environmentIntensity: number;
  52092. /**
  52093. * This is a special control allowing the reduction of the specular highlights coming from the
  52094. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52095. */
  52096. specularIntensity: number;
  52097. /**
  52098. * Debug Control allowing disabling the bump map on this material.
  52099. */
  52100. disableBumpMap: boolean;
  52101. /**
  52102. * AKA Diffuse Texture in standard nomenclature.
  52103. */
  52104. albedoTexture: BaseTexture;
  52105. /**
  52106. * AKA Occlusion Texture in other nomenclature.
  52107. */
  52108. ambientTexture: BaseTexture;
  52109. /**
  52110. * AKA Occlusion Texture Intensity in other nomenclature.
  52111. */
  52112. ambientTextureStrength: number;
  52113. /**
  52114. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52115. * 1 means it completely occludes it
  52116. * 0 mean it has no impact
  52117. */
  52118. ambientTextureImpactOnAnalyticalLights: number;
  52119. /**
  52120. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  52121. */
  52122. opacityTexture: BaseTexture;
  52123. /**
  52124. * Stores the reflection values in a texture.
  52125. */
  52126. reflectionTexture: Nullable<BaseTexture>;
  52127. /**
  52128. * Stores the emissive values in a texture.
  52129. */
  52130. emissiveTexture: BaseTexture;
  52131. /**
  52132. * AKA Specular texture in other nomenclature.
  52133. */
  52134. reflectivityTexture: BaseTexture;
  52135. /**
  52136. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52137. */
  52138. metallicTexture: BaseTexture;
  52139. /**
  52140. * Specifies the metallic scalar of the metallic/roughness workflow.
  52141. * Can also be used to scale the metalness values of the metallic texture.
  52142. */
  52143. metallic: Nullable<number>;
  52144. /**
  52145. * Specifies the roughness scalar of the metallic/roughness workflow.
  52146. * Can also be used to scale the roughness values of the metallic texture.
  52147. */
  52148. roughness: Nullable<number>;
  52149. /**
  52150. * Specifies the an F0 factor to help configuring the material F0.
  52151. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52152. * to 0.5 the previously hard coded value stays the same.
  52153. * Can also be used to scale the F0 values of the metallic texture.
  52154. */
  52155. metallicF0Factor: number;
  52156. /**
  52157. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52158. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52159. * your expectation as it multiplies with the texture data.
  52160. */
  52161. useMetallicF0FactorFromMetallicTexture: boolean;
  52162. /**
  52163. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52164. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52165. */
  52166. microSurfaceTexture: BaseTexture;
  52167. /**
  52168. * Stores surface normal data used to displace a mesh in a texture.
  52169. */
  52170. bumpTexture: BaseTexture;
  52171. /**
  52172. * Stores the pre-calculated light information of a mesh in a texture.
  52173. */
  52174. lightmapTexture: BaseTexture;
  52175. /**
  52176. * Stores the refracted light information in a texture.
  52177. */
  52178. get refractionTexture(): Nullable<BaseTexture>;
  52179. set refractionTexture(value: Nullable<BaseTexture>);
  52180. /**
  52181. * The color of a material in ambient lighting.
  52182. */
  52183. ambientColor: Color3;
  52184. /**
  52185. * AKA Diffuse Color in other nomenclature.
  52186. */
  52187. albedoColor: Color3;
  52188. /**
  52189. * AKA Specular Color in other nomenclature.
  52190. */
  52191. reflectivityColor: Color3;
  52192. /**
  52193. * The color reflected from the material.
  52194. */
  52195. reflectionColor: Color3;
  52196. /**
  52197. * The color emitted from the material.
  52198. */
  52199. emissiveColor: Color3;
  52200. /**
  52201. * AKA Glossiness in other nomenclature.
  52202. */
  52203. microSurface: number;
  52204. /**
  52205. * source material index of refraction (IOR)' / 'destination material IOR.
  52206. */
  52207. get indexOfRefraction(): number;
  52208. set indexOfRefraction(value: number);
  52209. /**
  52210. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52211. */
  52212. get invertRefractionY(): boolean;
  52213. set invertRefractionY(value: boolean);
  52214. /**
  52215. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52216. * Materials half opaque for instance using refraction could benefit from this control.
  52217. */
  52218. get linkRefractionWithTransparency(): boolean;
  52219. set linkRefractionWithTransparency(value: boolean);
  52220. /**
  52221. * If true, the light map contains occlusion information instead of lighting info.
  52222. */
  52223. useLightmapAsShadowmap: boolean;
  52224. /**
  52225. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52226. */
  52227. useAlphaFromAlbedoTexture: boolean;
  52228. /**
  52229. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52230. */
  52231. forceAlphaTest: boolean;
  52232. /**
  52233. * Defines the alpha limits in alpha test mode.
  52234. */
  52235. alphaCutOff: number;
  52236. /**
  52237. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52238. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52239. */
  52240. useSpecularOverAlpha: boolean;
  52241. /**
  52242. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52243. */
  52244. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  52245. /**
  52246. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52247. */
  52248. useRoughnessFromMetallicTextureAlpha: boolean;
  52249. /**
  52250. * Specifies if the metallic texture contains the roughness information in its green channel.
  52251. */
  52252. useRoughnessFromMetallicTextureGreen: boolean;
  52253. /**
  52254. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52255. */
  52256. useMetallnessFromMetallicTextureBlue: boolean;
  52257. /**
  52258. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52259. */
  52260. useAmbientOcclusionFromMetallicTextureRed: boolean;
  52261. /**
  52262. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52263. */
  52264. useAmbientInGrayScale: boolean;
  52265. /**
  52266. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52267. * The material will try to infer what glossiness each pixel should be.
  52268. */
  52269. useAutoMicroSurfaceFromReflectivityMap: boolean;
  52270. /**
  52271. * BJS is using an harcoded light falloff based on a manually sets up range.
  52272. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52273. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52274. */
  52275. get usePhysicalLightFalloff(): boolean;
  52276. /**
  52277. * BJS is using an harcoded light falloff based on a manually sets up range.
  52278. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52279. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52280. */
  52281. set usePhysicalLightFalloff(value: boolean);
  52282. /**
  52283. * In order to support the falloff compatibility with gltf, a special mode has been added
  52284. * to reproduce the gltf light falloff.
  52285. */
  52286. get useGLTFLightFalloff(): boolean;
  52287. /**
  52288. * In order to support the falloff compatibility with gltf, a special mode has been added
  52289. * to reproduce the gltf light falloff.
  52290. */
  52291. set useGLTFLightFalloff(value: boolean);
  52292. /**
  52293. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52294. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52295. */
  52296. useRadianceOverAlpha: boolean;
  52297. /**
  52298. * Allows using an object space normal map (instead of tangent space).
  52299. */
  52300. useObjectSpaceNormalMap: boolean;
  52301. /**
  52302. * Allows using the bump map in parallax mode.
  52303. */
  52304. useParallax: boolean;
  52305. /**
  52306. * Allows using the bump map in parallax occlusion mode.
  52307. */
  52308. useParallaxOcclusion: boolean;
  52309. /**
  52310. * Controls the scale bias of the parallax mode.
  52311. */
  52312. parallaxScaleBias: number;
  52313. /**
  52314. * If sets to true, disables all the lights affecting the material.
  52315. */
  52316. disableLighting: boolean;
  52317. /**
  52318. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52319. */
  52320. forceIrradianceInFragment: boolean;
  52321. /**
  52322. * Number of Simultaneous lights allowed on the material.
  52323. */
  52324. maxSimultaneousLights: number;
  52325. /**
  52326. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52327. */
  52328. invertNormalMapX: boolean;
  52329. /**
  52330. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52331. */
  52332. invertNormalMapY: boolean;
  52333. /**
  52334. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52335. */
  52336. twoSidedLighting: boolean;
  52337. /**
  52338. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52339. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52340. */
  52341. useAlphaFresnel: boolean;
  52342. /**
  52343. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52344. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52345. */
  52346. useLinearAlphaFresnel: boolean;
  52347. /**
  52348. * Let user defines the brdf lookup texture used for IBL.
  52349. * A default 8bit version is embedded but you could point at :
  52350. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  52351. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  52352. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  52353. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  52354. */
  52355. environmentBRDFTexture: Nullable<BaseTexture>;
  52356. /**
  52357. * Force normal to face away from face.
  52358. */
  52359. forceNormalForward: boolean;
  52360. /**
  52361. * Enables specular anti aliasing in the PBR shader.
  52362. * It will both interacts on the Geometry for analytical and IBL lighting.
  52363. * It also prefilter the roughness map based on the bump values.
  52364. */
  52365. enableSpecularAntiAliasing: boolean;
  52366. /**
  52367. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52368. * makes the reflect vector face the model (under horizon).
  52369. */
  52370. useHorizonOcclusion: boolean;
  52371. /**
  52372. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52373. * too much the area relying on ambient texture to define their ambient occlusion.
  52374. */
  52375. useRadianceOcclusion: boolean;
  52376. /**
  52377. * If set to true, no lighting calculations will be applied.
  52378. */
  52379. unlit: boolean;
  52380. /**
  52381. * Gets the image processing configuration used either in this material.
  52382. */
  52383. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  52384. /**
  52385. * Sets the Default image processing configuration used either in the this material.
  52386. *
  52387. * If sets to null, the scene one is in use.
  52388. */
  52389. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  52390. /**
  52391. * Gets wether the color curves effect is enabled.
  52392. */
  52393. get cameraColorCurvesEnabled(): boolean;
  52394. /**
  52395. * Sets wether the color curves effect is enabled.
  52396. */
  52397. set cameraColorCurvesEnabled(value: boolean);
  52398. /**
  52399. * Gets wether the color grading effect is enabled.
  52400. */
  52401. get cameraColorGradingEnabled(): boolean;
  52402. /**
  52403. * Gets wether the color grading effect is enabled.
  52404. */
  52405. set cameraColorGradingEnabled(value: boolean);
  52406. /**
  52407. * Gets wether tonemapping is enabled or not.
  52408. */
  52409. get cameraToneMappingEnabled(): boolean;
  52410. /**
  52411. * Sets wether tonemapping is enabled or not
  52412. */
  52413. set cameraToneMappingEnabled(value: boolean);
  52414. /**
  52415. * The camera exposure used on this material.
  52416. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52417. * This corresponds to a photographic exposure.
  52418. */
  52419. get cameraExposure(): number;
  52420. /**
  52421. * The camera exposure used on this material.
  52422. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  52423. * This corresponds to a photographic exposure.
  52424. */
  52425. set cameraExposure(value: number);
  52426. /**
  52427. * Gets The camera contrast used on this material.
  52428. */
  52429. get cameraContrast(): number;
  52430. /**
  52431. * Sets The camera contrast used on this material.
  52432. */
  52433. set cameraContrast(value: number);
  52434. /**
  52435. * Gets the Color Grading 2D Lookup Texture.
  52436. */
  52437. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  52438. /**
  52439. * Sets the Color Grading 2D Lookup Texture.
  52440. */
  52441. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  52442. /**
  52443. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52444. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52445. * 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;
  52446. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52447. */
  52448. get cameraColorCurves(): Nullable<ColorCurves>;
  52449. /**
  52450. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  52451. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  52452. * 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;
  52453. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  52454. */
  52455. set cameraColorCurves(value: Nullable<ColorCurves>);
  52456. /**
  52457. * Instantiates a new PBRMaterial instance.
  52458. *
  52459. * @param name The material name
  52460. * @param scene The scene the material will be use in.
  52461. */
  52462. constructor(name: string, scene: Scene);
  52463. /**
  52464. * Returns the name of this material class.
  52465. */
  52466. getClassName(): string;
  52467. /**
  52468. * Makes a duplicate of the current material.
  52469. * @param name - name to use for the new material.
  52470. */
  52471. clone(name: string): PBRMaterial;
  52472. /**
  52473. * Serializes this PBR Material.
  52474. * @returns - An object with the serialized material.
  52475. */
  52476. serialize(): any;
  52477. /**
  52478. * Parses a PBR Material from a serialized object.
  52479. * @param source - Serialized object.
  52480. * @param scene - BJS scene instance.
  52481. * @param rootUrl - url for the scene object
  52482. * @returns - PBRMaterial
  52483. */
  52484. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  52485. }
  52486. }
  52487. declare module BABYLON {
  52488. /**
  52489. * Direct draw surface info
  52490. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  52491. */
  52492. export interface DDSInfo {
  52493. /**
  52494. * Width of the texture
  52495. */
  52496. width: number;
  52497. /**
  52498. * Width of the texture
  52499. */
  52500. height: number;
  52501. /**
  52502. * Number of Mipmaps for the texture
  52503. * @see https://en.wikipedia.org/wiki/Mipmap
  52504. */
  52505. mipmapCount: number;
  52506. /**
  52507. * If the textures format is a known fourCC format
  52508. * @see https://www.fourcc.org/
  52509. */
  52510. isFourCC: boolean;
  52511. /**
  52512. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52513. */
  52514. isRGB: boolean;
  52515. /**
  52516. * If the texture is a lumincance format
  52517. */
  52518. isLuminance: boolean;
  52519. /**
  52520. * If this is a cube texture
  52521. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52522. */
  52523. isCube: boolean;
  52524. /**
  52525. * If the texture is a compressed format eg. FOURCC_DXT1
  52526. */
  52527. isCompressed: boolean;
  52528. /**
  52529. * The dxgiFormat of the texture
  52530. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52531. */
  52532. dxgiFormat: number;
  52533. /**
  52534. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52535. */
  52536. textureType: number;
  52537. /**
  52538. * Sphericle polynomial created for the dds texture
  52539. */
  52540. sphericalPolynomial?: SphericalPolynomial;
  52541. }
  52542. /**
  52543. * Class used to provide DDS decompression tools
  52544. */
  52545. export class DDSTools {
  52546. /**
  52547. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52548. */
  52549. static StoreLODInAlphaChannel: boolean;
  52550. /**
  52551. * Gets DDS information from an array buffer
  52552. * @param data defines the array buffer view to read data from
  52553. * @returns the DDS information
  52554. */
  52555. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  52556. private static _FloatView;
  52557. private static _Int32View;
  52558. private static _ToHalfFloat;
  52559. private static _FromHalfFloat;
  52560. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52561. private static _GetHalfFloatRGBAArrayBuffer;
  52562. private static _GetFloatRGBAArrayBuffer;
  52563. private static _GetFloatAsUIntRGBAArrayBuffer;
  52564. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52565. private static _GetRGBAArrayBuffer;
  52566. private static _ExtractLongWordOrder;
  52567. private static _GetRGBArrayBuffer;
  52568. private static _GetLuminanceArrayBuffer;
  52569. /**
  52570. * Uploads DDS Levels to a Babylon Texture
  52571. * @hidden
  52572. */
  52573. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52574. }
  52575. interface ThinEngine {
  52576. /**
  52577. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52578. * @param rootUrl defines the url where the file to load is located
  52579. * @param scene defines the current scene
  52580. * @param lodScale defines scale to apply to the mip map selection
  52581. * @param lodOffset defines offset to apply to the mip map selection
  52582. * @param onLoad defines an optional callback raised when the texture is loaded
  52583. * @param onError defines an optional callback raised if there is an issue to load the texture
  52584. * @param format defines the format of the data
  52585. * @param forcedExtension defines the extension to use to pick the right loader
  52586. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52587. * @returns the cube texture as an InternalTexture
  52588. */
  52589. 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;
  52590. }
  52591. }
  52592. declare module BABYLON {
  52593. /**
  52594. * Implementation of the DDS Texture Loader.
  52595. * @hidden
  52596. */
  52597. export class _DDSTextureLoader implements IInternalTextureLoader {
  52598. /**
  52599. * Defines wether the loader supports cascade loading the different faces.
  52600. */
  52601. readonly supportCascades: boolean;
  52602. /**
  52603. * This returns if the loader support the current file information.
  52604. * @param extension defines the file extension of the file being loaded
  52605. * @returns true if the loader can load the specified file
  52606. */
  52607. canLoad(extension: string): boolean;
  52608. /**
  52609. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52610. * @param data contains the texture data
  52611. * @param texture defines the BabylonJS internal texture
  52612. * @param createPolynomials will be true if polynomials have been requested
  52613. * @param onLoad defines the callback to trigger once the texture is ready
  52614. * @param onError defines the callback to trigger in case of error
  52615. */
  52616. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52617. /**
  52618. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52619. * @param data contains the texture data
  52620. * @param texture defines the BabylonJS internal texture
  52621. * @param callback defines the method to call once ready to upload
  52622. */
  52623. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52624. }
  52625. }
  52626. declare module BABYLON {
  52627. /**
  52628. * Implementation of the ENV Texture Loader.
  52629. * @hidden
  52630. */
  52631. export class _ENVTextureLoader implements IInternalTextureLoader {
  52632. /**
  52633. * Defines wether the loader supports cascade loading the different faces.
  52634. */
  52635. readonly supportCascades: boolean;
  52636. /**
  52637. * This returns if the loader support the current file information.
  52638. * @param extension defines the file extension of the file being loaded
  52639. * @returns true if the loader can load the specified file
  52640. */
  52641. canLoad(extension: string): boolean;
  52642. /**
  52643. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52644. * @param data contains the texture data
  52645. * @param texture defines the BabylonJS internal texture
  52646. * @param createPolynomials will be true if polynomials have been requested
  52647. * @param onLoad defines the callback to trigger once the texture is ready
  52648. * @param onError defines the callback to trigger in case of error
  52649. */
  52650. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52651. /**
  52652. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52653. * @param data contains the texture data
  52654. * @param texture defines the BabylonJS internal texture
  52655. * @param callback defines the method to call once ready to upload
  52656. */
  52657. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52658. }
  52659. }
  52660. declare module BABYLON {
  52661. /**
  52662. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52663. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52664. */
  52665. export class KhronosTextureContainer {
  52666. /** contents of the KTX container file */
  52667. data: ArrayBufferView;
  52668. private static HEADER_LEN;
  52669. private static COMPRESSED_2D;
  52670. private static COMPRESSED_3D;
  52671. private static TEX_2D;
  52672. private static TEX_3D;
  52673. /**
  52674. * Gets the openGL type
  52675. */
  52676. glType: number;
  52677. /**
  52678. * Gets the openGL type size
  52679. */
  52680. glTypeSize: number;
  52681. /**
  52682. * Gets the openGL format
  52683. */
  52684. glFormat: number;
  52685. /**
  52686. * Gets the openGL internal format
  52687. */
  52688. glInternalFormat: number;
  52689. /**
  52690. * Gets the base internal format
  52691. */
  52692. glBaseInternalFormat: number;
  52693. /**
  52694. * Gets image width in pixel
  52695. */
  52696. pixelWidth: number;
  52697. /**
  52698. * Gets image height in pixel
  52699. */
  52700. pixelHeight: number;
  52701. /**
  52702. * Gets image depth in pixels
  52703. */
  52704. pixelDepth: number;
  52705. /**
  52706. * Gets the number of array elements
  52707. */
  52708. numberOfArrayElements: number;
  52709. /**
  52710. * Gets the number of faces
  52711. */
  52712. numberOfFaces: number;
  52713. /**
  52714. * Gets the number of mipmap levels
  52715. */
  52716. numberOfMipmapLevels: number;
  52717. /**
  52718. * Gets the bytes of key value data
  52719. */
  52720. bytesOfKeyValueData: number;
  52721. /**
  52722. * Gets the load type
  52723. */
  52724. loadType: number;
  52725. /**
  52726. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52727. */
  52728. isInvalid: boolean;
  52729. /**
  52730. * Creates a new KhronosTextureContainer
  52731. * @param data contents of the KTX container file
  52732. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52733. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52734. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52735. */
  52736. constructor(
  52737. /** contents of the KTX container file */
  52738. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52739. /**
  52740. * Uploads KTX content to a Babylon Texture.
  52741. * It is assumed that the texture has already been created & is currently bound
  52742. * @hidden
  52743. */
  52744. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52745. private _upload2DCompressedLevels;
  52746. /**
  52747. * Checks if the given data starts with a KTX file identifier.
  52748. * @param data the data to check
  52749. * @returns true if the data is a KTX file or false otherwise
  52750. */
  52751. static IsValid(data: ArrayBufferView): boolean;
  52752. }
  52753. }
  52754. declare module BABYLON {
  52755. /**
  52756. * Class for loading KTX2 files
  52757. * !!! Experimental Extension Subject to Changes !!!
  52758. * @hidden
  52759. */
  52760. export class KhronosTextureContainer2 {
  52761. private static _ModulePromise;
  52762. private static _TranscodeFormat;
  52763. constructor(engine: ThinEngine);
  52764. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  52765. private _determineTranscodeFormat;
  52766. /**
  52767. * Checks if the given data starts with a KTX2 file identifier.
  52768. * @param data the data to check
  52769. * @returns true if the data is a KTX2 file or false otherwise
  52770. */
  52771. static IsValid(data: ArrayBufferView): boolean;
  52772. }
  52773. }
  52774. declare module BABYLON {
  52775. /**
  52776. * Implementation of the KTX Texture Loader.
  52777. * @hidden
  52778. */
  52779. export class _KTXTextureLoader implements IInternalTextureLoader {
  52780. /**
  52781. * Defines wether the loader supports cascade loading the different faces.
  52782. */
  52783. readonly supportCascades: boolean;
  52784. /**
  52785. * This returns if the loader support the current file information.
  52786. * @param extension defines the file extension of the file being loaded
  52787. * @returns true if the loader can load the specified file
  52788. */
  52789. canLoad(extension: string): boolean;
  52790. /**
  52791. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  52792. * @param data contains the texture data
  52793. * @param texture defines the BabylonJS internal texture
  52794. * @param createPolynomials will be true if polynomials have been requested
  52795. * @param onLoad defines the callback to trigger once the texture is ready
  52796. * @param onError defines the callback to trigger in case of error
  52797. */
  52798. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52799. /**
  52800. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  52801. * @param data contains the texture data
  52802. * @param texture defines the BabylonJS internal texture
  52803. * @param callback defines the method to call once ready to upload
  52804. */
  52805. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52806. }
  52807. }
  52808. declare module BABYLON {
  52809. /** @hidden */
  52810. export var _forceSceneHelpersToBundle: boolean;
  52811. interface Scene {
  52812. /**
  52813. * Creates a default light for the scene.
  52814. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52815. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52816. */
  52817. createDefaultLight(replace?: boolean): void;
  52818. /**
  52819. * Creates a default camera for the scene.
  52820. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52821. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52822. * @param replace has default false, when true replaces the active camera in the scene
  52823. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52824. */
  52825. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52826. /**
  52827. * Creates a default camera and a default light.
  52828. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52829. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52830. * @param replace has the default false, when true replaces the active camera/light in the scene
  52831. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52832. */
  52833. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52834. /**
  52835. * Creates a new sky box
  52836. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52837. * @param environmentTexture defines the texture to use as environment texture
  52838. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52839. * @param scale defines the overall scale of the skybox
  52840. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52841. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52842. * @returns a new mesh holding the sky box
  52843. */
  52844. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52845. /**
  52846. * Creates a new environment
  52847. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52848. * @param options defines the options you can use to configure the environment
  52849. * @returns the new EnvironmentHelper
  52850. */
  52851. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52852. /**
  52853. * Creates a new VREXperienceHelper
  52854. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52855. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52856. * @returns a new VREXperienceHelper
  52857. */
  52858. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52859. /**
  52860. * Creates a new WebXRDefaultExperience
  52861. * @see http://doc.babylonjs.com/how_to/webxr
  52862. * @param options experience options
  52863. * @returns a promise for a new WebXRDefaultExperience
  52864. */
  52865. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52866. }
  52867. }
  52868. declare module BABYLON {
  52869. /**
  52870. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52871. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52872. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52873. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52874. */
  52875. export class VideoDome extends TransformNode {
  52876. /**
  52877. * Define the video source as a Monoscopic panoramic 360 video.
  52878. */
  52879. static readonly MODE_MONOSCOPIC: number;
  52880. /**
  52881. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52882. */
  52883. static readonly MODE_TOPBOTTOM: number;
  52884. /**
  52885. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52886. */
  52887. static readonly MODE_SIDEBYSIDE: number;
  52888. private _halfDome;
  52889. private _useDirectMapping;
  52890. /**
  52891. * The video texture being displayed on the sphere
  52892. */
  52893. protected _videoTexture: VideoTexture;
  52894. /**
  52895. * Gets the video texture being displayed on the sphere
  52896. */
  52897. get videoTexture(): VideoTexture;
  52898. /**
  52899. * The skybox material
  52900. */
  52901. protected _material: BackgroundMaterial;
  52902. /**
  52903. * The surface used for the skybox
  52904. */
  52905. protected _mesh: Mesh;
  52906. /**
  52907. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52908. */
  52909. private _halfDomeMask;
  52910. /**
  52911. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52912. * Also see the options.resolution property.
  52913. */
  52914. get fovMultiplier(): number;
  52915. set fovMultiplier(value: number);
  52916. private _videoMode;
  52917. /**
  52918. * Gets or set the current video mode for the video. It can be:
  52919. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52920. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52921. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52922. */
  52923. get videoMode(): number;
  52924. set videoMode(value: number);
  52925. /**
  52926. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52927. *
  52928. */
  52929. get halfDome(): boolean;
  52930. /**
  52931. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52932. */
  52933. set halfDome(enabled: boolean);
  52934. /**
  52935. * Oberserver used in Stereoscopic VR Mode.
  52936. */
  52937. private _onBeforeCameraRenderObserver;
  52938. /**
  52939. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52940. * @param name Element's name, child elements will append suffixes for their own names.
  52941. * @param urlsOrVideo defines the url(s) or the video element to use
  52942. * @param options An object containing optional or exposed sub element properties
  52943. */
  52944. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52945. resolution?: number;
  52946. clickToPlay?: boolean;
  52947. autoPlay?: boolean;
  52948. loop?: boolean;
  52949. size?: number;
  52950. poster?: string;
  52951. faceForward?: boolean;
  52952. useDirectMapping?: boolean;
  52953. halfDomeMode?: boolean;
  52954. }, scene: Scene);
  52955. private _changeVideoMode;
  52956. /**
  52957. * Releases resources associated with this node.
  52958. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52959. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52960. */
  52961. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52962. }
  52963. }
  52964. declare module BABYLON {
  52965. /**
  52966. * This class can be used to get instrumentation data from a Babylon engine
  52967. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52968. */
  52969. export class EngineInstrumentation implements IDisposable {
  52970. /**
  52971. * Define the instrumented engine.
  52972. */
  52973. engine: Engine;
  52974. private _captureGPUFrameTime;
  52975. private _gpuFrameTimeToken;
  52976. private _gpuFrameTime;
  52977. private _captureShaderCompilationTime;
  52978. private _shaderCompilationTime;
  52979. private _onBeginFrameObserver;
  52980. private _onEndFrameObserver;
  52981. private _onBeforeShaderCompilationObserver;
  52982. private _onAfterShaderCompilationObserver;
  52983. /**
  52984. * Gets the perf counter used for GPU frame time
  52985. */
  52986. get gpuFrameTimeCounter(): PerfCounter;
  52987. /**
  52988. * Gets the GPU frame time capture status
  52989. */
  52990. get captureGPUFrameTime(): boolean;
  52991. /**
  52992. * Enable or disable the GPU frame time capture
  52993. */
  52994. set captureGPUFrameTime(value: boolean);
  52995. /**
  52996. * Gets the perf counter used for shader compilation time
  52997. */
  52998. get shaderCompilationTimeCounter(): PerfCounter;
  52999. /**
  53000. * Gets the shader compilation time capture status
  53001. */
  53002. get captureShaderCompilationTime(): boolean;
  53003. /**
  53004. * Enable or disable the shader compilation time capture
  53005. */
  53006. set captureShaderCompilationTime(value: boolean);
  53007. /**
  53008. * Instantiates a new engine instrumentation.
  53009. * This class can be used to get instrumentation data from a Babylon engine
  53010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  53011. * @param engine Defines the engine to instrument
  53012. */
  53013. constructor(
  53014. /**
  53015. * Define the instrumented engine.
  53016. */
  53017. engine: Engine);
  53018. /**
  53019. * Dispose and release associated resources.
  53020. */
  53021. dispose(): void;
  53022. }
  53023. }
  53024. declare module BABYLON {
  53025. /**
  53026. * This class can be used to get instrumentation data from a Babylon engine
  53027. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53028. */
  53029. export class SceneInstrumentation implements IDisposable {
  53030. /**
  53031. * Defines the scene to instrument
  53032. */
  53033. scene: Scene;
  53034. private _captureActiveMeshesEvaluationTime;
  53035. private _activeMeshesEvaluationTime;
  53036. private _captureRenderTargetsRenderTime;
  53037. private _renderTargetsRenderTime;
  53038. private _captureFrameTime;
  53039. private _frameTime;
  53040. private _captureRenderTime;
  53041. private _renderTime;
  53042. private _captureInterFrameTime;
  53043. private _interFrameTime;
  53044. private _captureParticlesRenderTime;
  53045. private _particlesRenderTime;
  53046. private _captureSpritesRenderTime;
  53047. private _spritesRenderTime;
  53048. private _capturePhysicsTime;
  53049. private _physicsTime;
  53050. private _captureAnimationsTime;
  53051. private _animationsTime;
  53052. private _captureCameraRenderTime;
  53053. private _cameraRenderTime;
  53054. private _onBeforeActiveMeshesEvaluationObserver;
  53055. private _onAfterActiveMeshesEvaluationObserver;
  53056. private _onBeforeRenderTargetsRenderObserver;
  53057. private _onAfterRenderTargetsRenderObserver;
  53058. private _onAfterRenderObserver;
  53059. private _onBeforeDrawPhaseObserver;
  53060. private _onAfterDrawPhaseObserver;
  53061. private _onBeforeAnimationsObserver;
  53062. private _onBeforeParticlesRenderingObserver;
  53063. private _onAfterParticlesRenderingObserver;
  53064. private _onBeforeSpritesRenderingObserver;
  53065. private _onAfterSpritesRenderingObserver;
  53066. private _onBeforePhysicsObserver;
  53067. private _onAfterPhysicsObserver;
  53068. private _onAfterAnimationsObserver;
  53069. private _onBeforeCameraRenderObserver;
  53070. private _onAfterCameraRenderObserver;
  53071. /**
  53072. * Gets the perf counter used for active meshes evaluation time
  53073. */
  53074. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  53075. /**
  53076. * Gets the active meshes evaluation time capture status
  53077. */
  53078. get captureActiveMeshesEvaluationTime(): boolean;
  53079. /**
  53080. * Enable or disable the active meshes evaluation time capture
  53081. */
  53082. set captureActiveMeshesEvaluationTime(value: boolean);
  53083. /**
  53084. * Gets the perf counter used for render targets render time
  53085. */
  53086. get renderTargetsRenderTimeCounter(): PerfCounter;
  53087. /**
  53088. * Gets the render targets render time capture status
  53089. */
  53090. get captureRenderTargetsRenderTime(): boolean;
  53091. /**
  53092. * Enable or disable the render targets render time capture
  53093. */
  53094. set captureRenderTargetsRenderTime(value: boolean);
  53095. /**
  53096. * Gets the perf counter used for particles render time
  53097. */
  53098. get particlesRenderTimeCounter(): PerfCounter;
  53099. /**
  53100. * Gets the particles render time capture status
  53101. */
  53102. get captureParticlesRenderTime(): boolean;
  53103. /**
  53104. * Enable or disable the particles render time capture
  53105. */
  53106. set captureParticlesRenderTime(value: boolean);
  53107. /**
  53108. * Gets the perf counter used for sprites render time
  53109. */
  53110. get spritesRenderTimeCounter(): PerfCounter;
  53111. /**
  53112. * Gets the sprites render time capture status
  53113. */
  53114. get captureSpritesRenderTime(): boolean;
  53115. /**
  53116. * Enable or disable the sprites render time capture
  53117. */
  53118. set captureSpritesRenderTime(value: boolean);
  53119. /**
  53120. * Gets the perf counter used for physics time
  53121. */
  53122. get physicsTimeCounter(): PerfCounter;
  53123. /**
  53124. * Gets the physics time capture status
  53125. */
  53126. get capturePhysicsTime(): boolean;
  53127. /**
  53128. * Enable or disable the physics time capture
  53129. */
  53130. set capturePhysicsTime(value: boolean);
  53131. /**
  53132. * Gets the perf counter used for animations time
  53133. */
  53134. get animationsTimeCounter(): PerfCounter;
  53135. /**
  53136. * Gets the animations time capture status
  53137. */
  53138. get captureAnimationsTime(): boolean;
  53139. /**
  53140. * Enable or disable the animations time capture
  53141. */
  53142. set captureAnimationsTime(value: boolean);
  53143. /**
  53144. * Gets the perf counter used for frame time capture
  53145. */
  53146. get frameTimeCounter(): PerfCounter;
  53147. /**
  53148. * Gets the frame time capture status
  53149. */
  53150. get captureFrameTime(): boolean;
  53151. /**
  53152. * Enable or disable the frame time capture
  53153. */
  53154. set captureFrameTime(value: boolean);
  53155. /**
  53156. * Gets the perf counter used for inter-frames time capture
  53157. */
  53158. get interFrameTimeCounter(): PerfCounter;
  53159. /**
  53160. * Gets the inter-frames time capture status
  53161. */
  53162. get captureInterFrameTime(): boolean;
  53163. /**
  53164. * Enable or disable the inter-frames time capture
  53165. */
  53166. set captureInterFrameTime(value: boolean);
  53167. /**
  53168. * Gets the perf counter used for render time capture
  53169. */
  53170. get renderTimeCounter(): PerfCounter;
  53171. /**
  53172. * Gets the render time capture status
  53173. */
  53174. get captureRenderTime(): boolean;
  53175. /**
  53176. * Enable or disable the render time capture
  53177. */
  53178. set captureRenderTime(value: boolean);
  53179. /**
  53180. * Gets the perf counter used for camera render time capture
  53181. */
  53182. get cameraRenderTimeCounter(): PerfCounter;
  53183. /**
  53184. * Gets the camera render time capture status
  53185. */
  53186. get captureCameraRenderTime(): boolean;
  53187. /**
  53188. * Enable or disable the camera render time capture
  53189. */
  53190. set captureCameraRenderTime(value: boolean);
  53191. /**
  53192. * Gets the perf counter used for draw calls
  53193. */
  53194. get drawCallsCounter(): PerfCounter;
  53195. /**
  53196. * Instantiates a new scene instrumentation.
  53197. * This class can be used to get instrumentation data from a Babylon engine
  53198. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  53199. * @param scene Defines the scene to instrument
  53200. */
  53201. constructor(
  53202. /**
  53203. * Defines the scene to instrument
  53204. */
  53205. scene: Scene);
  53206. /**
  53207. * Dispose and release associated resources.
  53208. */
  53209. dispose(): void;
  53210. }
  53211. }
  53212. declare module BABYLON {
  53213. /** @hidden */
  53214. export var glowMapGenerationPixelShader: {
  53215. name: string;
  53216. shader: string;
  53217. };
  53218. }
  53219. declare module BABYLON {
  53220. /** @hidden */
  53221. export var glowMapGenerationVertexShader: {
  53222. name: string;
  53223. shader: string;
  53224. };
  53225. }
  53226. declare module BABYLON {
  53227. /**
  53228. * Effect layer options. This helps customizing the behaviour
  53229. * of the effect layer.
  53230. */
  53231. export interface IEffectLayerOptions {
  53232. /**
  53233. * Multiplication factor apply to the canvas size to compute the render target size
  53234. * used to generated the objects (the smaller the faster).
  53235. */
  53236. mainTextureRatio: number;
  53237. /**
  53238. * Enforces a fixed size texture to ensure effect stability across devices.
  53239. */
  53240. mainTextureFixedSize?: number;
  53241. /**
  53242. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  53243. */
  53244. alphaBlendingMode: number;
  53245. /**
  53246. * The camera attached to the layer.
  53247. */
  53248. camera: Nullable<Camera>;
  53249. /**
  53250. * The rendering group to draw the layer in.
  53251. */
  53252. renderingGroupId: number;
  53253. }
  53254. /**
  53255. * The effect layer Helps adding post process effect blended with the main pass.
  53256. *
  53257. * This can be for instance use to generate glow or higlight effects on the scene.
  53258. *
  53259. * The effect layer class can not be used directly and is intented to inherited from to be
  53260. * customized per effects.
  53261. */
  53262. export abstract class EffectLayer {
  53263. private _vertexBuffers;
  53264. private _indexBuffer;
  53265. private _cachedDefines;
  53266. private _effectLayerMapGenerationEffect;
  53267. private _effectLayerOptions;
  53268. private _mergeEffect;
  53269. protected _scene: Scene;
  53270. protected _engine: Engine;
  53271. protected _maxSize: number;
  53272. protected _mainTextureDesiredSize: ISize;
  53273. protected _mainTexture: RenderTargetTexture;
  53274. protected _shouldRender: boolean;
  53275. protected _postProcesses: PostProcess[];
  53276. protected _textures: BaseTexture[];
  53277. protected _emissiveTextureAndColor: {
  53278. texture: Nullable<BaseTexture>;
  53279. color: Color4;
  53280. };
  53281. /**
  53282. * The name of the layer
  53283. */
  53284. name: string;
  53285. /**
  53286. * The clear color of the texture used to generate the glow map.
  53287. */
  53288. neutralColor: Color4;
  53289. /**
  53290. * Specifies whether the highlight layer is enabled or not.
  53291. */
  53292. isEnabled: boolean;
  53293. /**
  53294. * Gets the camera attached to the layer.
  53295. */
  53296. get camera(): Nullable<Camera>;
  53297. /**
  53298. * Gets the rendering group id the layer should render in.
  53299. */
  53300. get renderingGroupId(): number;
  53301. set renderingGroupId(renderingGroupId: number);
  53302. /**
  53303. * An event triggered when the effect layer has been disposed.
  53304. */
  53305. onDisposeObservable: Observable<EffectLayer>;
  53306. /**
  53307. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  53308. */
  53309. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  53310. /**
  53311. * An event triggered when the generated texture is being merged in the scene.
  53312. */
  53313. onBeforeComposeObservable: Observable<EffectLayer>;
  53314. /**
  53315. * An event triggered when the mesh is rendered into the effect render target.
  53316. */
  53317. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  53318. /**
  53319. * An event triggered after the mesh has been rendered into the effect render target.
  53320. */
  53321. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  53322. /**
  53323. * An event triggered when the generated texture has been merged in the scene.
  53324. */
  53325. onAfterComposeObservable: Observable<EffectLayer>;
  53326. /**
  53327. * An event triggered when the efffect layer changes its size.
  53328. */
  53329. onSizeChangedObservable: Observable<EffectLayer>;
  53330. /** @hidden */
  53331. static _SceneComponentInitialization: (scene: Scene) => void;
  53332. /**
  53333. * Instantiates a new effect Layer and references it in the scene.
  53334. * @param name The name of the layer
  53335. * @param scene The scene to use the layer in
  53336. */
  53337. constructor(
  53338. /** The Friendly of the effect in the scene */
  53339. name: string, scene: Scene);
  53340. /**
  53341. * Get the effect name of the layer.
  53342. * @return The effect name
  53343. */
  53344. abstract getEffectName(): string;
  53345. /**
  53346. * Checks for the readiness of the element composing the layer.
  53347. * @param subMesh the mesh to check for
  53348. * @param useInstances specify whether or not to use instances to render the mesh
  53349. * @return true if ready otherwise, false
  53350. */
  53351. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53352. /**
  53353. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53354. * @returns true if the effect requires stencil during the main canvas render pass.
  53355. */
  53356. abstract needStencil(): boolean;
  53357. /**
  53358. * Create the merge effect. This is the shader use to blit the information back
  53359. * to the main canvas at the end of the scene rendering.
  53360. * @returns The effect containing the shader used to merge the effect on the main canvas
  53361. */
  53362. protected abstract _createMergeEffect(): Effect;
  53363. /**
  53364. * Creates the render target textures and post processes used in the effect layer.
  53365. */
  53366. protected abstract _createTextureAndPostProcesses(): void;
  53367. /**
  53368. * Implementation specific of rendering the generating effect on the main canvas.
  53369. * @param effect The effect used to render through
  53370. */
  53371. protected abstract _internalRender(effect: Effect): void;
  53372. /**
  53373. * Sets the required values for both the emissive texture and and the main color.
  53374. */
  53375. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53376. /**
  53377. * Free any resources and references associated to a mesh.
  53378. * Internal use
  53379. * @param mesh The mesh to free.
  53380. */
  53381. abstract _disposeMesh(mesh: Mesh): void;
  53382. /**
  53383. * Serializes this layer (Glow or Highlight for example)
  53384. * @returns a serialized layer object
  53385. */
  53386. abstract serialize?(): any;
  53387. /**
  53388. * Initializes the effect layer with the required options.
  53389. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  53390. */
  53391. protected _init(options: Partial<IEffectLayerOptions>): void;
  53392. /**
  53393. * Generates the index buffer of the full screen quad blending to the main canvas.
  53394. */
  53395. private _generateIndexBuffer;
  53396. /**
  53397. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  53398. */
  53399. private _generateVertexBuffer;
  53400. /**
  53401. * Sets the main texture desired size which is the closest power of two
  53402. * of the engine canvas size.
  53403. */
  53404. private _setMainTextureSize;
  53405. /**
  53406. * Creates the main texture for the effect layer.
  53407. */
  53408. protected _createMainTexture(): void;
  53409. /**
  53410. * Adds specific effects defines.
  53411. * @param defines The defines to add specifics to.
  53412. */
  53413. protected _addCustomEffectDefines(defines: string[]): void;
  53414. /**
  53415. * Checks for the readiness of the element composing the layer.
  53416. * @param subMesh the mesh to check for
  53417. * @param useInstances specify whether or not to use instances to render the mesh
  53418. * @param emissiveTexture the associated emissive texture used to generate the glow
  53419. * @return true if ready otherwise, false
  53420. */
  53421. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  53422. /**
  53423. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  53424. */
  53425. render(): void;
  53426. /**
  53427. * Determine if a given mesh will be used in the current effect.
  53428. * @param mesh mesh to test
  53429. * @returns true if the mesh will be used
  53430. */
  53431. hasMesh(mesh: AbstractMesh): boolean;
  53432. /**
  53433. * Returns true if the layer contains information to display, otherwise false.
  53434. * @returns true if the glow layer should be rendered
  53435. */
  53436. shouldRender(): boolean;
  53437. /**
  53438. * Returns true if the mesh should render, otherwise false.
  53439. * @param mesh The mesh to render
  53440. * @returns true if it should render otherwise false
  53441. */
  53442. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  53443. /**
  53444. * Returns true if the mesh can be rendered, otherwise false.
  53445. * @param mesh The mesh to render
  53446. * @param material The material used on the mesh
  53447. * @returns true if it can be rendered otherwise false
  53448. */
  53449. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53450. /**
  53451. * Returns true if the mesh should render, otherwise false.
  53452. * @param mesh The mesh to render
  53453. * @returns true if it should render otherwise false
  53454. */
  53455. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  53456. /**
  53457. * Renders the submesh passed in parameter to the generation map.
  53458. */
  53459. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  53460. /**
  53461. * Defines whether the current material of the mesh should be use to render the effect.
  53462. * @param mesh defines the current mesh to render
  53463. */
  53464. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53465. /**
  53466. * Rebuild the required buffers.
  53467. * @hidden Internal use only.
  53468. */
  53469. _rebuild(): void;
  53470. /**
  53471. * Dispose only the render target textures and post process.
  53472. */
  53473. private _disposeTextureAndPostProcesses;
  53474. /**
  53475. * Dispose the highlight layer and free resources.
  53476. */
  53477. dispose(): void;
  53478. /**
  53479. * Gets the class name of the effect layer
  53480. * @returns the string with the class name of the effect layer
  53481. */
  53482. getClassName(): string;
  53483. /**
  53484. * Creates an effect layer from parsed effect layer data
  53485. * @param parsedEffectLayer defines effect layer data
  53486. * @param scene defines the current scene
  53487. * @param rootUrl defines the root URL containing the effect layer information
  53488. * @returns a parsed effect Layer
  53489. */
  53490. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53491. }
  53492. }
  53493. declare module BABYLON {
  53494. interface AbstractScene {
  53495. /**
  53496. * The list of effect layers (highlights/glow) added to the scene
  53497. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53498. * @see http://doc.babylonjs.com/how_to/glow_layer
  53499. */
  53500. effectLayers: Array<EffectLayer>;
  53501. /**
  53502. * Removes the given effect layer from this scene.
  53503. * @param toRemove defines the effect layer to remove
  53504. * @returns the index of the removed effect layer
  53505. */
  53506. removeEffectLayer(toRemove: EffectLayer): number;
  53507. /**
  53508. * Adds the given effect layer to this scene
  53509. * @param newEffectLayer defines the effect layer to add
  53510. */
  53511. addEffectLayer(newEffectLayer: EffectLayer): void;
  53512. }
  53513. /**
  53514. * Defines the layer scene component responsible to manage any effect layers
  53515. * in a given scene.
  53516. */
  53517. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53518. /**
  53519. * The component name helpfull to identify the component in the list of scene components.
  53520. */
  53521. readonly name: string;
  53522. /**
  53523. * The scene the component belongs to.
  53524. */
  53525. scene: Scene;
  53526. private _engine;
  53527. private _renderEffects;
  53528. private _needStencil;
  53529. private _previousStencilState;
  53530. /**
  53531. * Creates a new instance of the component for the given scene
  53532. * @param scene Defines the scene to register the component in
  53533. */
  53534. constructor(scene: Scene);
  53535. /**
  53536. * Registers the component in a given scene
  53537. */
  53538. register(): void;
  53539. /**
  53540. * Rebuilds the elements related to this component in case of
  53541. * context lost for instance.
  53542. */
  53543. rebuild(): void;
  53544. /**
  53545. * Serializes the component data to the specified json object
  53546. * @param serializationObject The object to serialize to
  53547. */
  53548. serialize(serializationObject: any): void;
  53549. /**
  53550. * Adds all the elements from the container to the scene
  53551. * @param container the container holding the elements
  53552. */
  53553. addFromContainer(container: AbstractScene): void;
  53554. /**
  53555. * Removes all the elements in the container from the scene
  53556. * @param container contains the elements to remove
  53557. * @param dispose if the removed element should be disposed (default: false)
  53558. */
  53559. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53560. /**
  53561. * Disposes the component and the associated ressources.
  53562. */
  53563. dispose(): void;
  53564. private _isReadyForMesh;
  53565. private _renderMainTexture;
  53566. private _setStencil;
  53567. private _setStencilBack;
  53568. private _draw;
  53569. private _drawCamera;
  53570. private _drawRenderingGroup;
  53571. }
  53572. }
  53573. declare module BABYLON {
  53574. /** @hidden */
  53575. export var glowMapMergePixelShader: {
  53576. name: string;
  53577. shader: string;
  53578. };
  53579. }
  53580. declare module BABYLON {
  53581. /** @hidden */
  53582. export var glowMapMergeVertexShader: {
  53583. name: string;
  53584. shader: string;
  53585. };
  53586. }
  53587. declare module BABYLON {
  53588. interface AbstractScene {
  53589. /**
  53590. * Return a the first highlight layer of the scene with a given name.
  53591. * @param name The name of the highlight layer to look for.
  53592. * @return The highlight layer if found otherwise null.
  53593. */
  53594. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53595. }
  53596. /**
  53597. * Glow layer options. This helps customizing the behaviour
  53598. * of the glow layer.
  53599. */
  53600. export interface IGlowLayerOptions {
  53601. /**
  53602. * Multiplication factor apply to the canvas size to compute the render target size
  53603. * used to generated the glowing objects (the smaller the faster).
  53604. */
  53605. mainTextureRatio: number;
  53606. /**
  53607. * Enforces a fixed size texture to ensure resize independant blur.
  53608. */
  53609. mainTextureFixedSize?: number;
  53610. /**
  53611. * How big is the kernel of the blur texture.
  53612. */
  53613. blurKernelSize: number;
  53614. /**
  53615. * The camera attached to the layer.
  53616. */
  53617. camera: Nullable<Camera>;
  53618. /**
  53619. * Enable MSAA by chosing the number of samples.
  53620. */
  53621. mainTextureSamples?: number;
  53622. /**
  53623. * The rendering group to draw the layer in.
  53624. */
  53625. renderingGroupId: number;
  53626. }
  53627. /**
  53628. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53629. *
  53630. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53631. *
  53632. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53633. */
  53634. export class GlowLayer extends EffectLayer {
  53635. /**
  53636. * Effect Name of the layer.
  53637. */
  53638. static readonly EffectName: string;
  53639. /**
  53640. * The default blur kernel size used for the glow.
  53641. */
  53642. static DefaultBlurKernelSize: number;
  53643. /**
  53644. * The default texture size ratio used for the glow.
  53645. */
  53646. static DefaultTextureRatio: number;
  53647. /**
  53648. * Sets the kernel size of the blur.
  53649. */
  53650. set blurKernelSize(value: number);
  53651. /**
  53652. * Gets the kernel size of the blur.
  53653. */
  53654. get blurKernelSize(): number;
  53655. /**
  53656. * Sets the glow intensity.
  53657. */
  53658. set intensity(value: number);
  53659. /**
  53660. * Gets the glow intensity.
  53661. */
  53662. get intensity(): number;
  53663. private _options;
  53664. private _intensity;
  53665. private _horizontalBlurPostprocess1;
  53666. private _verticalBlurPostprocess1;
  53667. private _horizontalBlurPostprocess2;
  53668. private _verticalBlurPostprocess2;
  53669. private _blurTexture1;
  53670. private _blurTexture2;
  53671. private _postProcesses1;
  53672. private _postProcesses2;
  53673. private _includedOnlyMeshes;
  53674. private _excludedMeshes;
  53675. private _meshesUsingTheirOwnMaterials;
  53676. /**
  53677. * Callback used to let the user override the color selection on a per mesh basis
  53678. */
  53679. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53680. /**
  53681. * Callback used to let the user override the texture selection on a per mesh basis
  53682. */
  53683. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53684. /**
  53685. * Instantiates a new glow Layer and references it to the scene.
  53686. * @param name The name of the layer
  53687. * @param scene The scene to use the layer in
  53688. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53689. */
  53690. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53691. /**
  53692. * Get the effect name of the layer.
  53693. * @return The effect name
  53694. */
  53695. getEffectName(): string;
  53696. /**
  53697. * Create the merge effect. This is the shader use to blit the information back
  53698. * to the main canvas at the end of the scene rendering.
  53699. */
  53700. protected _createMergeEffect(): Effect;
  53701. /**
  53702. * Creates the render target textures and post processes used in the glow layer.
  53703. */
  53704. protected _createTextureAndPostProcesses(): void;
  53705. /**
  53706. * Checks for the readiness of the element composing the layer.
  53707. * @param subMesh the mesh to check for
  53708. * @param useInstances specify wether or not to use instances to render the mesh
  53709. * @param emissiveTexture the associated emissive texture used to generate the glow
  53710. * @return true if ready otherwise, false
  53711. */
  53712. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53713. /**
  53714. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53715. */
  53716. needStencil(): boolean;
  53717. /**
  53718. * Returns true if the mesh can be rendered, otherwise false.
  53719. * @param mesh The mesh to render
  53720. * @param material The material used on the mesh
  53721. * @returns true if it can be rendered otherwise false
  53722. */
  53723. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53724. /**
  53725. * Implementation specific of rendering the generating effect on the main canvas.
  53726. * @param effect The effect used to render through
  53727. */
  53728. protected _internalRender(effect: Effect): void;
  53729. /**
  53730. * Sets the required values for both the emissive texture and and the main color.
  53731. */
  53732. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53733. /**
  53734. * Returns true if the mesh should render, otherwise false.
  53735. * @param mesh The mesh to render
  53736. * @returns true if it should render otherwise false
  53737. */
  53738. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53739. /**
  53740. * Adds specific effects defines.
  53741. * @param defines The defines to add specifics to.
  53742. */
  53743. protected _addCustomEffectDefines(defines: string[]): void;
  53744. /**
  53745. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53746. * @param mesh The mesh to exclude from the glow layer
  53747. */
  53748. addExcludedMesh(mesh: Mesh): void;
  53749. /**
  53750. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53751. * @param mesh The mesh to remove
  53752. */
  53753. removeExcludedMesh(mesh: Mesh): void;
  53754. /**
  53755. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53756. * @param mesh The mesh to include in the glow layer
  53757. */
  53758. addIncludedOnlyMesh(mesh: Mesh): void;
  53759. /**
  53760. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53761. * @param mesh The mesh to remove
  53762. */
  53763. removeIncludedOnlyMesh(mesh: Mesh): void;
  53764. /**
  53765. * Determine if a given mesh will be used in the glow layer
  53766. * @param mesh The mesh to test
  53767. * @returns true if the mesh will be highlighted by the current glow layer
  53768. */
  53769. hasMesh(mesh: AbstractMesh): boolean;
  53770. /**
  53771. * Defines whether the current material of the mesh should be use to render the effect.
  53772. * @param mesh defines the current mesh to render
  53773. */
  53774. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53775. /**
  53776. * Add a mesh to be rendered through its own material and not with emissive only.
  53777. * @param mesh The mesh for which we need to use its material
  53778. */
  53779. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53780. /**
  53781. * Remove a mesh from being rendered through its own material and not with emissive only.
  53782. * @param mesh The mesh for which we need to not use its material
  53783. */
  53784. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53785. /**
  53786. * Free any resources and references associated to a mesh.
  53787. * Internal use
  53788. * @param mesh The mesh to free.
  53789. * @hidden
  53790. */
  53791. _disposeMesh(mesh: Mesh): void;
  53792. /**
  53793. * Gets the class name of the effect layer
  53794. * @returns the string with the class name of the effect layer
  53795. */
  53796. getClassName(): string;
  53797. /**
  53798. * Serializes this glow layer
  53799. * @returns a serialized glow layer object
  53800. */
  53801. serialize(): any;
  53802. /**
  53803. * Creates a Glow Layer from parsed glow layer data
  53804. * @param parsedGlowLayer defines glow layer data
  53805. * @param scene defines the current scene
  53806. * @param rootUrl defines the root URL containing the glow layer information
  53807. * @returns a parsed Glow Layer
  53808. */
  53809. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53810. }
  53811. }
  53812. declare module BABYLON {
  53813. /** @hidden */
  53814. export var glowBlurPostProcessPixelShader: {
  53815. name: string;
  53816. shader: string;
  53817. };
  53818. }
  53819. declare module BABYLON {
  53820. interface AbstractScene {
  53821. /**
  53822. * Return a the first highlight layer of the scene with a given name.
  53823. * @param name The name of the highlight layer to look for.
  53824. * @return The highlight layer if found otherwise null.
  53825. */
  53826. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53827. }
  53828. /**
  53829. * Highlight layer options. This helps customizing the behaviour
  53830. * of the highlight layer.
  53831. */
  53832. export interface IHighlightLayerOptions {
  53833. /**
  53834. * Multiplication factor apply to the canvas size to compute the render target size
  53835. * used to generated the glowing objects (the smaller the faster).
  53836. */
  53837. mainTextureRatio: number;
  53838. /**
  53839. * Enforces a fixed size texture to ensure resize independant blur.
  53840. */
  53841. mainTextureFixedSize?: number;
  53842. /**
  53843. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53844. * of the picture to blur (the smaller the faster).
  53845. */
  53846. blurTextureSizeRatio: number;
  53847. /**
  53848. * How big in texel of the blur texture is the vertical blur.
  53849. */
  53850. blurVerticalSize: number;
  53851. /**
  53852. * How big in texel of the blur texture is the horizontal blur.
  53853. */
  53854. blurHorizontalSize: number;
  53855. /**
  53856. * Alpha blending mode used to apply the blur. Default is combine.
  53857. */
  53858. alphaBlendingMode: number;
  53859. /**
  53860. * The camera attached to the layer.
  53861. */
  53862. camera: Nullable<Camera>;
  53863. /**
  53864. * Should we display highlight as a solid stroke?
  53865. */
  53866. isStroke?: boolean;
  53867. /**
  53868. * The rendering group to draw the layer in.
  53869. */
  53870. renderingGroupId: number;
  53871. }
  53872. /**
  53873. * The highlight layer Helps adding a glow effect around a mesh.
  53874. *
  53875. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53876. * glowy meshes to your scene.
  53877. *
  53878. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53879. */
  53880. export class HighlightLayer extends EffectLayer {
  53881. name: string;
  53882. /**
  53883. * Effect Name of the highlight layer.
  53884. */
  53885. static readonly EffectName: string;
  53886. /**
  53887. * The neutral color used during the preparation of the glow effect.
  53888. * This is black by default as the blend operation is a blend operation.
  53889. */
  53890. static NeutralColor: Color4;
  53891. /**
  53892. * Stencil value used for glowing meshes.
  53893. */
  53894. static GlowingMeshStencilReference: number;
  53895. /**
  53896. * Stencil value used for the other meshes in the scene.
  53897. */
  53898. static NormalMeshStencilReference: number;
  53899. /**
  53900. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53901. */
  53902. innerGlow: boolean;
  53903. /**
  53904. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53905. */
  53906. outerGlow: boolean;
  53907. /**
  53908. * Specifies the horizontal size of the blur.
  53909. */
  53910. set blurHorizontalSize(value: number);
  53911. /**
  53912. * Specifies the vertical size of the blur.
  53913. */
  53914. set blurVerticalSize(value: number);
  53915. /**
  53916. * Gets the horizontal size of the blur.
  53917. */
  53918. get blurHorizontalSize(): number;
  53919. /**
  53920. * Gets the vertical size of the blur.
  53921. */
  53922. get blurVerticalSize(): number;
  53923. /**
  53924. * An event triggered when the highlight layer is being blurred.
  53925. */
  53926. onBeforeBlurObservable: Observable<HighlightLayer>;
  53927. /**
  53928. * An event triggered when the highlight layer has been blurred.
  53929. */
  53930. onAfterBlurObservable: Observable<HighlightLayer>;
  53931. private _instanceGlowingMeshStencilReference;
  53932. private _options;
  53933. private _downSamplePostprocess;
  53934. private _horizontalBlurPostprocess;
  53935. private _verticalBlurPostprocess;
  53936. private _blurTexture;
  53937. private _meshes;
  53938. private _excludedMeshes;
  53939. /**
  53940. * Instantiates a new highlight Layer and references it to the scene..
  53941. * @param name The name of the layer
  53942. * @param scene The scene to use the layer in
  53943. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53944. */
  53945. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53946. /**
  53947. * Get the effect name of the layer.
  53948. * @return The effect name
  53949. */
  53950. getEffectName(): string;
  53951. /**
  53952. * Create the merge effect. This is the shader use to blit the information back
  53953. * to the main canvas at the end of the scene rendering.
  53954. */
  53955. protected _createMergeEffect(): Effect;
  53956. /**
  53957. * Creates the render target textures and post processes used in the highlight layer.
  53958. */
  53959. protected _createTextureAndPostProcesses(): void;
  53960. /**
  53961. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53962. */
  53963. needStencil(): boolean;
  53964. /**
  53965. * Checks for the readiness of the element composing the layer.
  53966. * @param subMesh the mesh to check for
  53967. * @param useInstances specify wether or not to use instances to render the mesh
  53968. * @param emissiveTexture the associated emissive texture used to generate the glow
  53969. * @return true if ready otherwise, false
  53970. */
  53971. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53972. /**
  53973. * Implementation specific of rendering the generating effect on the main canvas.
  53974. * @param effect The effect used to render through
  53975. */
  53976. protected _internalRender(effect: Effect): void;
  53977. /**
  53978. * Returns true if the layer contains information to display, otherwise false.
  53979. */
  53980. shouldRender(): boolean;
  53981. /**
  53982. * Returns true if the mesh should render, otherwise false.
  53983. * @param mesh The mesh to render
  53984. * @returns true if it should render otherwise false
  53985. */
  53986. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53987. /**
  53988. * Adds specific effects defines.
  53989. * @param defines The defines to add specifics to.
  53990. */
  53991. protected _addCustomEffectDefines(defines: string[]): void;
  53992. /**
  53993. * Sets the required values for both the emissive texture and and the main color.
  53994. */
  53995. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53996. /**
  53997. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53998. * @param mesh The mesh to exclude from the highlight layer
  53999. */
  54000. addExcludedMesh(mesh: Mesh): void;
  54001. /**
  54002. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  54003. * @param mesh The mesh to highlight
  54004. */
  54005. removeExcludedMesh(mesh: Mesh): void;
  54006. /**
  54007. * Determine if a given mesh will be highlighted by the current HighlightLayer
  54008. * @param mesh mesh to test
  54009. * @returns true if the mesh will be highlighted by the current HighlightLayer
  54010. */
  54011. hasMesh(mesh: AbstractMesh): boolean;
  54012. /**
  54013. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  54014. * @param mesh The mesh to highlight
  54015. * @param color The color of the highlight
  54016. * @param glowEmissiveOnly Extract the glow from the emissive texture
  54017. */
  54018. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  54019. /**
  54020. * Remove a mesh from the highlight layer in order to make it stop glowing.
  54021. * @param mesh The mesh to highlight
  54022. */
  54023. removeMesh(mesh: Mesh): void;
  54024. /**
  54025. * Remove all the meshes currently referenced in the highlight layer
  54026. */
  54027. removeAllMeshes(): void;
  54028. /**
  54029. * Force the stencil to the normal expected value for none glowing parts
  54030. */
  54031. private _defaultStencilReference;
  54032. /**
  54033. * Free any resources and references associated to a mesh.
  54034. * Internal use
  54035. * @param mesh The mesh to free.
  54036. * @hidden
  54037. */
  54038. _disposeMesh(mesh: Mesh): void;
  54039. /**
  54040. * Dispose the highlight layer and free resources.
  54041. */
  54042. dispose(): void;
  54043. /**
  54044. * Gets the class name of the effect layer
  54045. * @returns the string with the class name of the effect layer
  54046. */
  54047. getClassName(): string;
  54048. /**
  54049. * Serializes this Highlight layer
  54050. * @returns a serialized Highlight layer object
  54051. */
  54052. serialize(): any;
  54053. /**
  54054. * Creates a Highlight layer from parsed Highlight layer data
  54055. * @param parsedHightlightLayer defines the Highlight layer data
  54056. * @param scene defines the current scene
  54057. * @param rootUrl defines the root URL containing the Highlight layer information
  54058. * @returns a parsed Highlight layer
  54059. */
  54060. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  54061. }
  54062. }
  54063. declare module BABYLON {
  54064. interface AbstractScene {
  54065. /**
  54066. * The list of layers (background and foreground) of the scene
  54067. */
  54068. layers: Array<Layer>;
  54069. }
  54070. /**
  54071. * Defines the layer scene component responsible to manage any layers
  54072. * in a given scene.
  54073. */
  54074. export class LayerSceneComponent implements ISceneComponent {
  54075. /**
  54076. * The component name helpfull to identify the component in the list of scene components.
  54077. */
  54078. readonly name: string;
  54079. /**
  54080. * The scene the component belongs to.
  54081. */
  54082. scene: Scene;
  54083. private _engine;
  54084. /**
  54085. * Creates a new instance of the component for the given scene
  54086. * @param scene Defines the scene to register the component in
  54087. */
  54088. constructor(scene: Scene);
  54089. /**
  54090. * Registers the component in a given scene
  54091. */
  54092. register(): void;
  54093. /**
  54094. * Rebuilds the elements related to this component in case of
  54095. * context lost for instance.
  54096. */
  54097. rebuild(): void;
  54098. /**
  54099. * Disposes the component and the associated ressources.
  54100. */
  54101. dispose(): void;
  54102. private _draw;
  54103. private _drawCameraPredicate;
  54104. private _drawCameraBackground;
  54105. private _drawCameraForeground;
  54106. private _drawRenderTargetPredicate;
  54107. private _drawRenderTargetBackground;
  54108. private _drawRenderTargetForeground;
  54109. /**
  54110. * Adds all the elements from the container to the scene
  54111. * @param container the container holding the elements
  54112. */
  54113. addFromContainer(container: AbstractScene): void;
  54114. /**
  54115. * Removes all the elements in the container from the scene
  54116. * @param container contains the elements to remove
  54117. * @param dispose if the removed element should be disposed (default: false)
  54118. */
  54119. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54120. }
  54121. }
  54122. declare module BABYLON {
  54123. /** @hidden */
  54124. export var layerPixelShader: {
  54125. name: string;
  54126. shader: string;
  54127. };
  54128. }
  54129. declare module BABYLON {
  54130. /** @hidden */
  54131. export var layerVertexShader: {
  54132. name: string;
  54133. shader: string;
  54134. };
  54135. }
  54136. declare module BABYLON {
  54137. /**
  54138. * This represents a full screen 2d layer.
  54139. * This can be useful to display a picture in the background of your scene for instance.
  54140. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54141. */
  54142. export class Layer {
  54143. /**
  54144. * Define the name of the layer.
  54145. */
  54146. name: string;
  54147. /**
  54148. * Define the texture the layer should display.
  54149. */
  54150. texture: Nullable<Texture>;
  54151. /**
  54152. * Is the layer in background or foreground.
  54153. */
  54154. isBackground: boolean;
  54155. /**
  54156. * Define the color of the layer (instead of texture).
  54157. */
  54158. color: Color4;
  54159. /**
  54160. * Define the scale of the layer in order to zoom in out of the texture.
  54161. */
  54162. scale: Vector2;
  54163. /**
  54164. * Define an offset for the layer in order to shift the texture.
  54165. */
  54166. offset: Vector2;
  54167. /**
  54168. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  54169. */
  54170. alphaBlendingMode: number;
  54171. /**
  54172. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  54173. * Alpha test will not mix with the background color in case of transparency.
  54174. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  54175. */
  54176. alphaTest: boolean;
  54177. /**
  54178. * Define a mask to restrict the layer to only some of the scene cameras.
  54179. */
  54180. layerMask: number;
  54181. /**
  54182. * Define the list of render target the layer is visible into.
  54183. */
  54184. renderTargetTextures: RenderTargetTexture[];
  54185. /**
  54186. * Define if the layer is only used in renderTarget or if it also
  54187. * renders in the main frame buffer of the canvas.
  54188. */
  54189. renderOnlyInRenderTargetTextures: boolean;
  54190. private _scene;
  54191. private _vertexBuffers;
  54192. private _indexBuffer;
  54193. private _effect;
  54194. private _previousDefines;
  54195. /**
  54196. * An event triggered when the layer is disposed.
  54197. */
  54198. onDisposeObservable: Observable<Layer>;
  54199. private _onDisposeObserver;
  54200. /**
  54201. * Back compatibility with callback before the onDisposeObservable existed.
  54202. * The set callback will be triggered when the layer has been disposed.
  54203. */
  54204. set onDispose(callback: () => void);
  54205. /**
  54206. * An event triggered before rendering the scene
  54207. */
  54208. onBeforeRenderObservable: Observable<Layer>;
  54209. private _onBeforeRenderObserver;
  54210. /**
  54211. * Back compatibility with callback before the onBeforeRenderObservable existed.
  54212. * The set callback will be triggered just before rendering the layer.
  54213. */
  54214. set onBeforeRender(callback: () => void);
  54215. /**
  54216. * An event triggered after rendering the scene
  54217. */
  54218. onAfterRenderObservable: Observable<Layer>;
  54219. private _onAfterRenderObserver;
  54220. /**
  54221. * Back compatibility with callback before the onAfterRenderObservable existed.
  54222. * The set callback will be triggered just after rendering the layer.
  54223. */
  54224. set onAfterRender(callback: () => void);
  54225. /**
  54226. * Instantiates a new layer.
  54227. * This represents a full screen 2d layer.
  54228. * This can be useful to display a picture in the background of your scene for instance.
  54229. * @see https://www.babylonjs-playground.com/#08A2BS#1
  54230. * @param name Define the name of the layer in the scene
  54231. * @param imgUrl Define the url of the texture to display in the layer
  54232. * @param scene Define the scene the layer belongs to
  54233. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  54234. * @param color Defines a color for the layer
  54235. */
  54236. constructor(
  54237. /**
  54238. * Define the name of the layer.
  54239. */
  54240. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  54241. private _createIndexBuffer;
  54242. /** @hidden */
  54243. _rebuild(): void;
  54244. /**
  54245. * Renders the layer in the scene.
  54246. */
  54247. render(): void;
  54248. /**
  54249. * Disposes and releases the associated ressources.
  54250. */
  54251. dispose(): void;
  54252. }
  54253. }
  54254. declare module BABYLON {
  54255. /** @hidden */
  54256. export var lensFlarePixelShader: {
  54257. name: string;
  54258. shader: string;
  54259. };
  54260. }
  54261. declare module BABYLON {
  54262. /** @hidden */
  54263. export var lensFlareVertexShader: {
  54264. name: string;
  54265. shader: string;
  54266. };
  54267. }
  54268. declare module BABYLON {
  54269. /**
  54270. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54271. * It is usually composed of several `lensFlare`.
  54272. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54273. */
  54274. export class LensFlareSystem {
  54275. /**
  54276. * Define the name of the lens flare system
  54277. */
  54278. name: string;
  54279. /**
  54280. * List of lens flares used in this system.
  54281. */
  54282. lensFlares: LensFlare[];
  54283. /**
  54284. * Define a limit from the border the lens flare can be visible.
  54285. */
  54286. borderLimit: number;
  54287. /**
  54288. * Define a viewport border we do not want to see the lens flare in.
  54289. */
  54290. viewportBorder: number;
  54291. /**
  54292. * Define a predicate which could limit the list of meshes able to occlude the effect.
  54293. */
  54294. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  54295. /**
  54296. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  54297. */
  54298. layerMask: number;
  54299. /**
  54300. * Define the id of the lens flare system in the scene.
  54301. * (equal to name by default)
  54302. */
  54303. id: string;
  54304. private _scene;
  54305. private _emitter;
  54306. private _vertexBuffers;
  54307. private _indexBuffer;
  54308. private _effect;
  54309. private _positionX;
  54310. private _positionY;
  54311. private _isEnabled;
  54312. /** @hidden */
  54313. static _SceneComponentInitialization: (scene: Scene) => void;
  54314. /**
  54315. * Instantiates a lens flare system.
  54316. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  54317. * It is usually composed of several `lensFlare`.
  54318. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54319. * @param name Define the name of the lens flare system in the scene
  54320. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  54321. * @param scene Define the scene the lens flare system belongs to
  54322. */
  54323. constructor(
  54324. /**
  54325. * Define the name of the lens flare system
  54326. */
  54327. name: string, emitter: any, scene: Scene);
  54328. /**
  54329. * Define if the lens flare system is enabled.
  54330. */
  54331. get isEnabled(): boolean;
  54332. set isEnabled(value: boolean);
  54333. /**
  54334. * Get the scene the effects belongs to.
  54335. * @returns the scene holding the lens flare system
  54336. */
  54337. getScene(): Scene;
  54338. /**
  54339. * Get the emitter of the lens flare system.
  54340. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54341. * @returns the emitter of the lens flare system
  54342. */
  54343. getEmitter(): any;
  54344. /**
  54345. * Set the emitter of the lens flare system.
  54346. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  54347. * @param newEmitter Define the new emitter of the system
  54348. */
  54349. setEmitter(newEmitter: any): void;
  54350. /**
  54351. * Get the lens flare system emitter position.
  54352. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  54353. * @returns the position
  54354. */
  54355. getEmitterPosition(): Vector3;
  54356. /**
  54357. * @hidden
  54358. */
  54359. computeEffectivePosition(globalViewport: Viewport): boolean;
  54360. /** @hidden */
  54361. _isVisible(): boolean;
  54362. /**
  54363. * @hidden
  54364. */
  54365. render(): boolean;
  54366. /**
  54367. * Dispose and release the lens flare with its associated resources.
  54368. */
  54369. dispose(): void;
  54370. /**
  54371. * Parse a lens flare system from a JSON repressentation
  54372. * @param parsedLensFlareSystem Define the JSON to parse
  54373. * @param scene Define the scene the parsed system should be instantiated in
  54374. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  54375. * @returns the parsed system
  54376. */
  54377. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  54378. /**
  54379. * Serialize the current Lens Flare System into a JSON representation.
  54380. * @returns the serialized JSON
  54381. */
  54382. serialize(): any;
  54383. }
  54384. }
  54385. declare module BABYLON {
  54386. /**
  54387. * This represents one of the lens effect in a `lensFlareSystem`.
  54388. * It controls one of the indiviual texture used in the effect.
  54389. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54390. */
  54391. export class LensFlare {
  54392. /**
  54393. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54394. */
  54395. size: number;
  54396. /**
  54397. * 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.
  54398. */
  54399. position: number;
  54400. /**
  54401. * Define the lens color.
  54402. */
  54403. color: Color3;
  54404. /**
  54405. * Define the lens texture.
  54406. */
  54407. texture: Nullable<Texture>;
  54408. /**
  54409. * Define the alpha mode to render this particular lens.
  54410. */
  54411. alphaMode: number;
  54412. private _system;
  54413. /**
  54414. * Creates a new Lens Flare.
  54415. * This represents one of the lens effect in a `lensFlareSystem`.
  54416. * It controls one of the indiviual texture used in the effect.
  54417. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54418. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  54419. * @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.
  54420. * @param color Define the lens color
  54421. * @param imgUrl Define the lens texture url
  54422. * @param system Define the `lensFlareSystem` this flare is part of
  54423. * @returns The newly created Lens Flare
  54424. */
  54425. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  54426. /**
  54427. * Instantiates a new Lens Flare.
  54428. * This represents one of the lens effect in a `lensFlareSystem`.
  54429. * It controls one of the indiviual texture used in the effect.
  54430. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54431. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  54432. * @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.
  54433. * @param color Define the lens color
  54434. * @param imgUrl Define the lens texture url
  54435. * @param system Define the `lensFlareSystem` this flare is part of
  54436. */
  54437. constructor(
  54438. /**
  54439. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  54440. */
  54441. size: number,
  54442. /**
  54443. * 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.
  54444. */
  54445. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  54446. /**
  54447. * Dispose and release the lens flare with its associated resources.
  54448. */
  54449. dispose(): void;
  54450. }
  54451. }
  54452. declare module BABYLON {
  54453. interface AbstractScene {
  54454. /**
  54455. * The list of lens flare system added to the scene
  54456. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  54457. */
  54458. lensFlareSystems: Array<LensFlareSystem>;
  54459. /**
  54460. * Removes the given lens flare system from this scene.
  54461. * @param toRemove The lens flare system to remove
  54462. * @returns The index of the removed lens flare system
  54463. */
  54464. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  54465. /**
  54466. * Adds the given lens flare system to this scene
  54467. * @param newLensFlareSystem The lens flare system to add
  54468. */
  54469. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  54470. /**
  54471. * Gets a lens flare system using its name
  54472. * @param name defines the name to look for
  54473. * @returns the lens flare system or null if not found
  54474. */
  54475. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  54476. /**
  54477. * Gets a lens flare system using its id
  54478. * @param id defines the id to look for
  54479. * @returns the lens flare system or null if not found
  54480. */
  54481. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54482. }
  54483. /**
  54484. * Defines the lens flare scene component responsible to manage any lens flares
  54485. * in a given scene.
  54486. */
  54487. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54488. /**
  54489. * The component name helpfull to identify the component in the list of scene components.
  54490. */
  54491. readonly name: string;
  54492. /**
  54493. * The scene the component belongs to.
  54494. */
  54495. scene: Scene;
  54496. /**
  54497. * Creates a new instance of the component for the given scene
  54498. * @param scene Defines the scene to register the component in
  54499. */
  54500. constructor(scene: Scene);
  54501. /**
  54502. * Registers the component in a given scene
  54503. */
  54504. register(): void;
  54505. /**
  54506. * Rebuilds the elements related to this component in case of
  54507. * context lost for instance.
  54508. */
  54509. rebuild(): void;
  54510. /**
  54511. * Adds all the elements from the container to the scene
  54512. * @param container the container holding the elements
  54513. */
  54514. addFromContainer(container: AbstractScene): void;
  54515. /**
  54516. * Removes all the elements in the container from the scene
  54517. * @param container contains the elements to remove
  54518. * @param dispose if the removed element should be disposed (default: false)
  54519. */
  54520. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54521. /**
  54522. * Serializes the component data to the specified json object
  54523. * @param serializationObject The object to serialize to
  54524. */
  54525. serialize(serializationObject: any): void;
  54526. /**
  54527. * Disposes the component and the associated ressources.
  54528. */
  54529. dispose(): void;
  54530. private _draw;
  54531. }
  54532. }
  54533. declare module BABYLON {
  54534. /** @hidden */
  54535. export var depthPixelShader: {
  54536. name: string;
  54537. shader: string;
  54538. };
  54539. }
  54540. declare module BABYLON {
  54541. /** @hidden */
  54542. export var depthVertexShader: {
  54543. name: string;
  54544. shader: string;
  54545. };
  54546. }
  54547. declare module BABYLON {
  54548. /**
  54549. * This represents a depth renderer in Babylon.
  54550. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54551. */
  54552. export class DepthRenderer {
  54553. private _scene;
  54554. private _depthMap;
  54555. private _effect;
  54556. private readonly _storeNonLinearDepth;
  54557. private readonly _clearColor;
  54558. /** Get if the depth renderer is using packed depth or not */
  54559. readonly isPacked: boolean;
  54560. private _cachedDefines;
  54561. private _camera;
  54562. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54563. enabled: boolean;
  54564. /**
  54565. * Specifiess that the depth renderer will only be used within
  54566. * the camera it is created for.
  54567. * This can help forcing its rendering during the camera processing.
  54568. */
  54569. useOnlyInActiveCamera: boolean;
  54570. /** @hidden */
  54571. static _SceneComponentInitialization: (scene: Scene) => void;
  54572. /**
  54573. * Instantiates a depth renderer
  54574. * @param scene The scene the renderer belongs to
  54575. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54576. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54577. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54578. */
  54579. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54580. /**
  54581. * Creates the depth rendering effect and checks if the effect is ready.
  54582. * @param subMesh The submesh to be used to render the depth map of
  54583. * @param useInstances If multiple world instances should be used
  54584. * @returns if the depth renderer is ready to render the depth map
  54585. */
  54586. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54587. /**
  54588. * Gets the texture which the depth map will be written to.
  54589. * @returns The depth map texture
  54590. */
  54591. getDepthMap(): RenderTargetTexture;
  54592. /**
  54593. * Disposes of the depth renderer.
  54594. */
  54595. dispose(): void;
  54596. }
  54597. }
  54598. declare module BABYLON {
  54599. /** @hidden */
  54600. export var minmaxReduxPixelShader: {
  54601. name: string;
  54602. shader: string;
  54603. };
  54604. }
  54605. declare module BABYLON {
  54606. /**
  54607. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54608. * and maximum values from all values of the texture.
  54609. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54610. * The source values are read from the red channel of the texture.
  54611. */
  54612. export class MinMaxReducer {
  54613. /**
  54614. * Observable triggered when the computation has been performed
  54615. */
  54616. onAfterReductionPerformed: Observable<{
  54617. min: number;
  54618. max: number;
  54619. }>;
  54620. protected _camera: Camera;
  54621. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54622. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54623. protected _postProcessManager: PostProcessManager;
  54624. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54625. protected _forceFullscreenViewport: boolean;
  54626. /**
  54627. * Creates a min/max reducer
  54628. * @param camera The camera to use for the post processes
  54629. */
  54630. constructor(camera: Camera);
  54631. /**
  54632. * Gets the texture used to read the values from.
  54633. */
  54634. get sourceTexture(): Nullable<RenderTargetTexture>;
  54635. /**
  54636. * Sets the source texture to read the values from.
  54637. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54638. * because in such textures '1' value must not be taken into account to compute the maximum
  54639. * as this value is used to clear the texture.
  54640. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54641. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54642. * @param depthRedux Indicates if the texture is a depth texture or not
  54643. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54644. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54645. */
  54646. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54647. /**
  54648. * Defines the refresh rate of the computation.
  54649. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54650. */
  54651. get refreshRate(): number;
  54652. set refreshRate(value: number);
  54653. protected _activated: boolean;
  54654. /**
  54655. * Gets the activation status of the reducer
  54656. */
  54657. get activated(): boolean;
  54658. /**
  54659. * Activates the reduction computation.
  54660. * When activated, the observers registered in onAfterReductionPerformed are
  54661. * called after the compuation is performed
  54662. */
  54663. activate(): void;
  54664. /**
  54665. * Deactivates the reduction computation.
  54666. */
  54667. deactivate(): void;
  54668. /**
  54669. * Disposes the min/max reducer
  54670. * @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.
  54671. */
  54672. dispose(disposeAll?: boolean): void;
  54673. }
  54674. }
  54675. declare module BABYLON {
  54676. /**
  54677. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54678. */
  54679. export class DepthReducer extends MinMaxReducer {
  54680. private _depthRenderer;
  54681. private _depthRendererId;
  54682. /**
  54683. * Gets the depth renderer used for the computation.
  54684. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54685. */
  54686. get depthRenderer(): Nullable<DepthRenderer>;
  54687. /**
  54688. * Creates a depth reducer
  54689. * @param camera The camera used to render the depth texture
  54690. */
  54691. constructor(camera: Camera);
  54692. /**
  54693. * Sets the depth renderer to use to generate the depth map
  54694. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54695. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54696. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54697. */
  54698. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54699. /** @hidden */
  54700. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54701. /**
  54702. * Activates the reduction computation.
  54703. * When activated, the observers registered in onAfterReductionPerformed are
  54704. * called after the compuation is performed
  54705. */
  54706. activate(): void;
  54707. /**
  54708. * Deactivates the reduction computation.
  54709. */
  54710. deactivate(): void;
  54711. /**
  54712. * Disposes the depth reducer
  54713. * @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.
  54714. */
  54715. dispose(disposeAll?: boolean): void;
  54716. }
  54717. }
  54718. declare module BABYLON {
  54719. /**
  54720. * A CSM implementation allowing casting shadows on large scenes.
  54721. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54722. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54723. */
  54724. export class CascadedShadowGenerator extends ShadowGenerator {
  54725. private static readonly frustumCornersNDCSpace;
  54726. /**
  54727. * Name of the CSM class
  54728. */
  54729. static CLASSNAME: string;
  54730. /**
  54731. * Defines the default number of cascades used by the CSM.
  54732. */
  54733. static readonly DEFAULT_CASCADES_COUNT: number;
  54734. /**
  54735. * Defines the minimum number of cascades used by the CSM.
  54736. */
  54737. static readonly MIN_CASCADES_COUNT: number;
  54738. /**
  54739. * Defines the maximum number of cascades used by the CSM.
  54740. */
  54741. static readonly MAX_CASCADES_COUNT: number;
  54742. protected _validateFilter(filter: number): number;
  54743. /**
  54744. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54745. */
  54746. penumbraDarkness: number;
  54747. private _numCascades;
  54748. /**
  54749. * Gets or set the number of cascades used by the CSM.
  54750. */
  54751. get numCascades(): number;
  54752. set numCascades(value: number);
  54753. /**
  54754. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54755. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54756. */
  54757. stabilizeCascades: boolean;
  54758. private _freezeShadowCastersBoundingInfo;
  54759. private _freezeShadowCastersBoundingInfoObservable;
  54760. /**
  54761. * Enables or disables the shadow casters bounding info computation.
  54762. * If your shadow casters don't move, you can disable this feature.
  54763. * If it is enabled, the bounding box computation is done every frame.
  54764. */
  54765. get freezeShadowCastersBoundingInfo(): boolean;
  54766. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54767. private _scbiMin;
  54768. private _scbiMax;
  54769. protected _computeShadowCastersBoundingInfo(): void;
  54770. protected _shadowCastersBoundingInfo: BoundingInfo;
  54771. /**
  54772. * Gets or sets the shadow casters bounding info.
  54773. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54774. * so that the system won't overwrite the bounds you provide
  54775. */
  54776. get shadowCastersBoundingInfo(): BoundingInfo;
  54777. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54778. protected _breaksAreDirty: boolean;
  54779. protected _minDistance: number;
  54780. protected _maxDistance: number;
  54781. /**
  54782. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54783. *
  54784. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54785. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54786. * @param min minimal distance for the breaks (default to 0.)
  54787. * @param max maximal distance for the breaks (default to 1.)
  54788. */
  54789. setMinMaxDistance(min: number, max: number): void;
  54790. /** Gets the minimal distance used in the cascade break computation */
  54791. get minDistance(): number;
  54792. /** Gets the maximal distance used in the cascade break computation */
  54793. get maxDistance(): number;
  54794. /**
  54795. * Gets the class name of that object
  54796. * @returns "CascadedShadowGenerator"
  54797. */
  54798. getClassName(): string;
  54799. private _cascadeMinExtents;
  54800. private _cascadeMaxExtents;
  54801. /**
  54802. * Gets a cascade minimum extents
  54803. * @param cascadeIndex index of the cascade
  54804. * @returns the minimum cascade extents
  54805. */
  54806. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54807. /**
  54808. * Gets a cascade maximum extents
  54809. * @param cascadeIndex index of the cascade
  54810. * @returns the maximum cascade extents
  54811. */
  54812. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54813. private _cascades;
  54814. private _currentLayer;
  54815. private _viewSpaceFrustumsZ;
  54816. private _viewMatrices;
  54817. private _projectionMatrices;
  54818. private _transformMatrices;
  54819. private _transformMatricesAsArray;
  54820. private _frustumLengths;
  54821. private _lightSizeUVCorrection;
  54822. private _depthCorrection;
  54823. private _frustumCornersWorldSpace;
  54824. private _frustumCenter;
  54825. private _shadowCameraPos;
  54826. private _shadowMaxZ;
  54827. /**
  54828. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54829. * It defaults to camera.maxZ
  54830. */
  54831. get shadowMaxZ(): number;
  54832. /**
  54833. * Sets the shadow max z distance.
  54834. */
  54835. set shadowMaxZ(value: number);
  54836. protected _debug: boolean;
  54837. /**
  54838. * Gets or sets the debug flag.
  54839. * When enabled, the cascades are materialized by different colors on the screen.
  54840. */
  54841. get debug(): boolean;
  54842. set debug(dbg: boolean);
  54843. private _depthClamp;
  54844. /**
  54845. * Gets or sets the depth clamping value.
  54846. *
  54847. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54848. * to account for the shadow casters far away.
  54849. *
  54850. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54851. */
  54852. get depthClamp(): boolean;
  54853. set depthClamp(value: boolean);
  54854. private _cascadeBlendPercentage;
  54855. /**
  54856. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54857. * It defaults to 0.1 (10% blending).
  54858. */
  54859. get cascadeBlendPercentage(): number;
  54860. set cascadeBlendPercentage(value: number);
  54861. private _lambda;
  54862. /**
  54863. * Gets or set the lambda parameter.
  54864. * This parameter is used to split the camera frustum and create the cascades.
  54865. * 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.
  54866. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54867. */
  54868. get lambda(): number;
  54869. set lambda(value: number);
  54870. /**
  54871. * Gets the view matrix corresponding to a given cascade
  54872. * @param cascadeNum cascade to retrieve the view matrix from
  54873. * @returns the cascade view matrix
  54874. */
  54875. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54876. /**
  54877. * Gets the projection matrix corresponding to a given cascade
  54878. * @param cascadeNum cascade to retrieve the projection matrix from
  54879. * @returns the cascade projection matrix
  54880. */
  54881. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54882. /**
  54883. * Gets the transformation matrix corresponding to a given cascade
  54884. * @param cascadeNum cascade to retrieve the transformation matrix from
  54885. * @returns the cascade transformation matrix
  54886. */
  54887. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54888. private _depthRenderer;
  54889. /**
  54890. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54891. *
  54892. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54893. *
  54894. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54895. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54896. * @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
  54897. */
  54898. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54899. private _depthReducer;
  54900. private _autoCalcDepthBounds;
  54901. /**
  54902. * Gets or sets the autoCalcDepthBounds property.
  54903. *
  54904. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54905. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54906. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54907. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54908. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54909. */
  54910. get autoCalcDepthBounds(): boolean;
  54911. set autoCalcDepthBounds(value: boolean);
  54912. /**
  54913. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54914. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54915. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54916. * for setting the refresh rate on the renderer yourself!
  54917. */
  54918. get autoCalcDepthBoundsRefreshRate(): number;
  54919. set autoCalcDepthBoundsRefreshRate(value: number);
  54920. /**
  54921. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54922. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54923. * you change the camera near/far planes!
  54924. */
  54925. splitFrustum(): void;
  54926. private _splitFrustum;
  54927. private _computeMatrices;
  54928. private _computeFrustumInWorldSpace;
  54929. private _computeCascadeFrustum;
  54930. /**
  54931. * Support test.
  54932. */
  54933. static get IsSupported(): boolean;
  54934. /** @hidden */
  54935. static _SceneComponentInitialization: (scene: Scene) => void;
  54936. /**
  54937. * Creates a Cascaded Shadow Generator object.
  54938. * A ShadowGenerator is the required tool to use the shadows.
  54939. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54940. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54941. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54942. * @param light The directional light object generating the shadows.
  54943. * @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.
  54944. */
  54945. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54946. protected _initializeGenerator(): void;
  54947. protected _createTargetRenderTexture(): void;
  54948. protected _initializeShadowMap(): void;
  54949. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54950. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54951. /**
  54952. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54953. * @param defines Defines of the material we want to update
  54954. * @param lightIndex Index of the light in the enabled light list of the material
  54955. */
  54956. prepareDefines(defines: any, lightIndex: number): void;
  54957. /**
  54958. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54959. * defined in the generator but impacting the effect).
  54960. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54961. * @param effect The effect we are binfing the information for
  54962. */
  54963. bindShadowLight(lightIndex: string, effect: Effect): void;
  54964. /**
  54965. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54966. * (eq to view projection * shadow projection matrices)
  54967. * @returns The transform matrix used to create the shadow map
  54968. */
  54969. getTransformMatrix(): Matrix;
  54970. /**
  54971. * Disposes the ShadowGenerator.
  54972. * Returns nothing.
  54973. */
  54974. dispose(): void;
  54975. /**
  54976. * Serializes the shadow generator setup to a json object.
  54977. * @returns The serialized JSON object
  54978. */
  54979. serialize(): any;
  54980. /**
  54981. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54982. * @param parsedShadowGenerator The JSON object to parse
  54983. * @param scene The scene to create the shadow map for
  54984. * @returns The parsed shadow generator
  54985. */
  54986. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54987. }
  54988. }
  54989. declare module BABYLON {
  54990. /**
  54991. * Defines the shadow generator component responsible to manage any shadow generators
  54992. * in a given scene.
  54993. */
  54994. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54995. /**
  54996. * The component name helpfull to identify the component in the list of scene components.
  54997. */
  54998. readonly name: string;
  54999. /**
  55000. * The scene the component belongs to.
  55001. */
  55002. scene: Scene;
  55003. /**
  55004. * Creates a new instance of the component for the given scene
  55005. * @param scene Defines the scene to register the component in
  55006. */
  55007. constructor(scene: Scene);
  55008. /**
  55009. * Registers the component in a given scene
  55010. */
  55011. register(): void;
  55012. /**
  55013. * Rebuilds the elements related to this component in case of
  55014. * context lost for instance.
  55015. */
  55016. rebuild(): void;
  55017. /**
  55018. * Serializes the component data to the specified json object
  55019. * @param serializationObject The object to serialize to
  55020. */
  55021. serialize(serializationObject: any): void;
  55022. /**
  55023. * Adds all the elements from the container to the scene
  55024. * @param container the container holding the elements
  55025. */
  55026. addFromContainer(container: AbstractScene): void;
  55027. /**
  55028. * Removes all the elements in the container from the scene
  55029. * @param container contains the elements to remove
  55030. * @param dispose if the removed element should be disposed (default: false)
  55031. */
  55032. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55033. /**
  55034. * Rebuilds the elements related to this component in case of
  55035. * context lost for instance.
  55036. */
  55037. dispose(): void;
  55038. private _gatherRenderTargets;
  55039. }
  55040. }
  55041. declare module BABYLON {
  55042. /**
  55043. * A point light is a light defined by an unique point in world space.
  55044. * The light is emitted in every direction from this point.
  55045. * A good example of a point light is a standard light bulb.
  55046. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55047. */
  55048. export class PointLight extends ShadowLight {
  55049. private _shadowAngle;
  55050. /**
  55051. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55052. * This specifies what angle the shadow will use to be created.
  55053. *
  55054. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55055. */
  55056. get shadowAngle(): number;
  55057. /**
  55058. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55059. * This specifies what angle the shadow will use to be created.
  55060. *
  55061. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  55062. */
  55063. set shadowAngle(value: number);
  55064. /**
  55065. * Gets the direction if it has been set.
  55066. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55067. */
  55068. get direction(): Vector3;
  55069. /**
  55070. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  55071. */
  55072. set direction(value: Vector3);
  55073. /**
  55074. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  55075. * A PointLight emits the light in every direction.
  55076. * It can cast shadows.
  55077. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  55078. * ```javascript
  55079. * var pointLight = new PointLight("pl", camera.position, scene);
  55080. * ```
  55081. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55082. * @param name The light friendly name
  55083. * @param position The position of the point light in the scene
  55084. * @param scene The scene the lights belongs to
  55085. */
  55086. constructor(name: string, position: Vector3, scene: Scene);
  55087. /**
  55088. * Returns the string "PointLight"
  55089. * @returns the class name
  55090. */
  55091. getClassName(): string;
  55092. /**
  55093. * Returns the integer 0.
  55094. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55095. */
  55096. getTypeID(): number;
  55097. /**
  55098. * Specifies wether or not the shadowmap should be a cube texture.
  55099. * @returns true if the shadowmap needs to be a cube texture.
  55100. */
  55101. needCube(): boolean;
  55102. /**
  55103. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  55104. * @param faceIndex The index of the face we are computed the direction to generate shadow
  55105. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  55106. */
  55107. getShadowDirection(faceIndex?: number): Vector3;
  55108. /**
  55109. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  55110. * - fov = PI / 2
  55111. * - aspect ratio : 1.0
  55112. * - z-near and far equal to the active camera minZ and maxZ.
  55113. * Returns the PointLight.
  55114. */
  55115. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55116. protected _buildUniformLayout(): void;
  55117. /**
  55118. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  55119. * @param effect The effect to update
  55120. * @param lightIndex The index of the light in the effect to update
  55121. * @returns The point light
  55122. */
  55123. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  55124. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55125. /**
  55126. * Prepares the list of defines specific to the light type.
  55127. * @param defines the list of defines
  55128. * @param lightIndex defines the index of the light for the effect
  55129. */
  55130. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55131. }
  55132. }
  55133. declare module BABYLON {
  55134. /**
  55135. * Header information of HDR texture files.
  55136. */
  55137. export interface HDRInfo {
  55138. /**
  55139. * The height of the texture in pixels.
  55140. */
  55141. height: number;
  55142. /**
  55143. * The width of the texture in pixels.
  55144. */
  55145. width: number;
  55146. /**
  55147. * The index of the beginning of the data in the binary file.
  55148. */
  55149. dataPosition: number;
  55150. }
  55151. /**
  55152. * This groups tools to convert HDR texture to native colors array.
  55153. */
  55154. export class HDRTools {
  55155. private static Ldexp;
  55156. private static Rgbe2float;
  55157. private static readStringLine;
  55158. /**
  55159. * Reads header information from an RGBE texture stored in a native array.
  55160. * More information on this format are available here:
  55161. * https://en.wikipedia.org/wiki/RGBE_image_format
  55162. *
  55163. * @param uint8array The binary file stored in native array.
  55164. * @return The header information.
  55165. */
  55166. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  55167. /**
  55168. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  55169. * This RGBE texture needs to store the information as a panorama.
  55170. *
  55171. * More information on this format are available here:
  55172. * https://en.wikipedia.org/wiki/RGBE_image_format
  55173. *
  55174. * @param buffer The binary file stored in an array buffer.
  55175. * @param size The expected size of the extracted cubemap.
  55176. * @return The Cube Map information.
  55177. */
  55178. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  55179. /**
  55180. * Returns the pixels data extracted from an RGBE texture.
  55181. * This pixels will be stored left to right up to down in the R G B order in one array.
  55182. *
  55183. * More information on this format are available here:
  55184. * https://en.wikipedia.org/wiki/RGBE_image_format
  55185. *
  55186. * @param uint8array The binary file stored in an array buffer.
  55187. * @param hdrInfo The header information of the file.
  55188. * @return The pixels data in RGB right to left up to down order.
  55189. */
  55190. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  55191. private static RGBE_ReadPixels_RLE;
  55192. }
  55193. }
  55194. declare module BABYLON {
  55195. /**
  55196. * This represents a texture coming from an HDR input.
  55197. *
  55198. * The only supported format is currently panorama picture stored in RGBE format.
  55199. * Example of such files can be found on HDRLib: http://hdrlib.com/
  55200. */
  55201. export class HDRCubeTexture extends BaseTexture {
  55202. private static _facesMapping;
  55203. private _generateHarmonics;
  55204. private _noMipmap;
  55205. private _textureMatrix;
  55206. private _size;
  55207. private _onLoad;
  55208. private _onError;
  55209. /**
  55210. * The texture URL.
  55211. */
  55212. url: string;
  55213. /**
  55214. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  55215. */
  55216. coordinatesMode: number;
  55217. protected _isBlocking: boolean;
  55218. /**
  55219. * Sets wether or not the texture is blocking during loading.
  55220. */
  55221. set isBlocking(value: boolean);
  55222. /**
  55223. * Gets wether or not the texture is blocking during loading.
  55224. */
  55225. get isBlocking(): boolean;
  55226. protected _rotationY: number;
  55227. /**
  55228. * Sets texture matrix rotation angle around Y axis in radians.
  55229. */
  55230. set rotationY(value: number);
  55231. /**
  55232. * Gets texture matrix rotation angle around Y axis radians.
  55233. */
  55234. get rotationY(): number;
  55235. /**
  55236. * Gets or sets the center of the bounding box associated with the cube texture
  55237. * It must define where the camera used to render the texture was set
  55238. */
  55239. boundingBoxPosition: Vector3;
  55240. private _boundingBoxSize;
  55241. /**
  55242. * Gets or sets the size of the bounding box associated with the cube texture
  55243. * When defined, the cubemap will switch to local mode
  55244. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  55245. * @example https://www.babylonjs-playground.com/#RNASML
  55246. */
  55247. set boundingBoxSize(value: Vector3);
  55248. get boundingBoxSize(): Vector3;
  55249. /**
  55250. * Instantiates an HDRTexture from the following parameters.
  55251. *
  55252. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  55253. * @param scene The scene the texture will be used in
  55254. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55255. * @param noMipmap Forces to not generate the mipmap if true
  55256. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55257. * @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)
  55258. * @param reserved Reserved flag for internal use.
  55259. */
  55260. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55261. /**
  55262. * Get the current class name of the texture useful for serialization or dynamic coding.
  55263. * @returns "HDRCubeTexture"
  55264. */
  55265. getClassName(): string;
  55266. /**
  55267. * Occurs when the file is raw .hdr file.
  55268. */
  55269. private loadTexture;
  55270. clone(): HDRCubeTexture;
  55271. delayLoad(): void;
  55272. /**
  55273. * Get the texture reflection matrix used to rotate/transform the reflection.
  55274. * @returns the reflection matrix
  55275. */
  55276. getReflectionTextureMatrix(): Matrix;
  55277. /**
  55278. * Set the texture reflection matrix used to rotate/transform the reflection.
  55279. * @param value Define the reflection matrix to set
  55280. */
  55281. setReflectionTextureMatrix(value: Matrix): void;
  55282. /**
  55283. * Parses a JSON representation of an HDR Texture in order to create the texture
  55284. * @param parsedTexture Define the JSON representation
  55285. * @param scene Define the scene the texture should be created in
  55286. * @param rootUrl Define the root url in case we need to load relative dependencies
  55287. * @returns the newly created texture after parsing
  55288. */
  55289. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55290. serialize(): any;
  55291. }
  55292. }
  55293. declare module BABYLON {
  55294. /**
  55295. * Class used to control physics engine
  55296. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55297. */
  55298. export class PhysicsEngine implements IPhysicsEngine {
  55299. private _physicsPlugin;
  55300. /**
  55301. * Global value used to control the smallest number supported by the simulation
  55302. */
  55303. static Epsilon: number;
  55304. private _impostors;
  55305. private _joints;
  55306. private _subTimeStep;
  55307. /**
  55308. * Gets the gravity vector used by the simulation
  55309. */
  55310. gravity: Vector3;
  55311. /**
  55312. * Factory used to create the default physics plugin.
  55313. * @returns The default physics plugin
  55314. */
  55315. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55316. /**
  55317. * Creates a new Physics Engine
  55318. * @param gravity defines the gravity vector used by the simulation
  55319. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55320. */
  55321. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55322. /**
  55323. * Sets the gravity vector used by the simulation
  55324. * @param gravity defines the gravity vector to use
  55325. */
  55326. setGravity(gravity: Vector3): void;
  55327. /**
  55328. * Set the time step of the physics engine.
  55329. * Default is 1/60.
  55330. * To slow it down, enter 1/600 for example.
  55331. * To speed it up, 1/30
  55332. * @param newTimeStep defines the new timestep to apply to this world.
  55333. */
  55334. setTimeStep(newTimeStep?: number): void;
  55335. /**
  55336. * Get the time step of the physics engine.
  55337. * @returns the current time step
  55338. */
  55339. getTimeStep(): number;
  55340. /**
  55341. * Set the sub time step of the physics engine.
  55342. * Default is 0 meaning there is no sub steps
  55343. * To increase physics resolution precision, set a small value (like 1 ms)
  55344. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55345. */
  55346. setSubTimeStep(subTimeStep?: number): void;
  55347. /**
  55348. * Get the sub time step of the physics engine.
  55349. * @returns the current sub time step
  55350. */
  55351. getSubTimeStep(): number;
  55352. /**
  55353. * Release all resources
  55354. */
  55355. dispose(): void;
  55356. /**
  55357. * Gets the name of the current physics plugin
  55358. * @returns the name of the plugin
  55359. */
  55360. getPhysicsPluginName(): string;
  55361. /**
  55362. * Adding a new impostor for the impostor tracking.
  55363. * This will be done by the impostor itself.
  55364. * @param impostor the impostor to add
  55365. */
  55366. addImpostor(impostor: PhysicsImpostor): void;
  55367. /**
  55368. * Remove an impostor from the engine.
  55369. * This impostor and its mesh will not longer be updated by the physics engine.
  55370. * @param impostor the impostor to remove
  55371. */
  55372. removeImpostor(impostor: PhysicsImpostor): void;
  55373. /**
  55374. * Add a joint to the physics engine
  55375. * @param mainImpostor defines the main impostor to which the joint is added.
  55376. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55377. * @param joint defines the joint that will connect both impostors.
  55378. */
  55379. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55380. /**
  55381. * Removes a joint from the simulation
  55382. * @param mainImpostor defines the impostor used with the joint
  55383. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55384. * @param joint defines the joint to remove
  55385. */
  55386. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55387. /**
  55388. * Called by the scene. No need to call it.
  55389. * @param delta defines the timespam between frames
  55390. */
  55391. _step(delta: number): void;
  55392. /**
  55393. * Gets the current plugin used to run the simulation
  55394. * @returns current plugin
  55395. */
  55396. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55397. /**
  55398. * Gets the list of physic impostors
  55399. * @returns an array of PhysicsImpostor
  55400. */
  55401. getImpostors(): Array<PhysicsImpostor>;
  55402. /**
  55403. * Gets the impostor for a physics enabled object
  55404. * @param object defines the object impersonated by the impostor
  55405. * @returns the PhysicsImpostor or null if not found
  55406. */
  55407. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55408. /**
  55409. * Gets the impostor for a physics body object
  55410. * @param body defines physics body used by the impostor
  55411. * @returns the PhysicsImpostor or null if not found
  55412. */
  55413. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55414. /**
  55415. * Does a raycast in the physics world
  55416. * @param from when should the ray start?
  55417. * @param to when should the ray end?
  55418. * @returns PhysicsRaycastResult
  55419. */
  55420. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55421. }
  55422. }
  55423. declare module BABYLON {
  55424. /** @hidden */
  55425. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55426. private _useDeltaForWorldStep;
  55427. world: any;
  55428. name: string;
  55429. private _physicsMaterials;
  55430. private _fixedTimeStep;
  55431. private _cannonRaycastResult;
  55432. private _raycastResult;
  55433. private _physicsBodysToRemoveAfterStep;
  55434. BJSCANNON: any;
  55435. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55436. setGravity(gravity: Vector3): void;
  55437. setTimeStep(timeStep: number): void;
  55438. getTimeStep(): number;
  55439. executeStep(delta: number): void;
  55440. private _removeMarkedPhysicsBodiesFromWorld;
  55441. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55442. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55443. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55444. private _processChildMeshes;
  55445. removePhysicsBody(impostor: PhysicsImpostor): void;
  55446. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55447. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55448. private _addMaterial;
  55449. private _checkWithEpsilon;
  55450. private _createShape;
  55451. private _createHeightmap;
  55452. private _minus90X;
  55453. private _plus90X;
  55454. private _tmpPosition;
  55455. private _tmpDeltaPosition;
  55456. private _tmpUnityRotation;
  55457. private _updatePhysicsBodyTransformation;
  55458. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55459. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55460. isSupported(): boolean;
  55461. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55462. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55463. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55464. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55465. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55466. getBodyMass(impostor: PhysicsImpostor): number;
  55467. getBodyFriction(impostor: PhysicsImpostor): number;
  55468. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55469. getBodyRestitution(impostor: PhysicsImpostor): number;
  55470. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55471. sleepBody(impostor: PhysicsImpostor): void;
  55472. wakeUpBody(impostor: PhysicsImpostor): void;
  55473. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55474. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55475. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55476. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55477. getRadius(impostor: PhysicsImpostor): number;
  55478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55479. dispose(): void;
  55480. private _extendNamespace;
  55481. /**
  55482. * Does a raycast in the physics world
  55483. * @param from when should the ray start?
  55484. * @param to when should the ray end?
  55485. * @returns PhysicsRaycastResult
  55486. */
  55487. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55488. }
  55489. }
  55490. declare module BABYLON {
  55491. /** @hidden */
  55492. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55493. world: any;
  55494. name: string;
  55495. BJSOIMO: any;
  55496. private _raycastResult;
  55497. constructor(iterations?: number, oimoInjection?: any);
  55498. setGravity(gravity: Vector3): void;
  55499. setTimeStep(timeStep: number): void;
  55500. getTimeStep(): number;
  55501. private _tmpImpostorsArray;
  55502. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55503. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55504. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55505. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55506. private _tmpPositionVector;
  55507. removePhysicsBody(impostor: PhysicsImpostor): void;
  55508. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55509. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55510. isSupported(): boolean;
  55511. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55512. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55513. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55514. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55515. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55516. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55517. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55518. getBodyMass(impostor: PhysicsImpostor): number;
  55519. getBodyFriction(impostor: PhysicsImpostor): number;
  55520. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55521. getBodyRestitution(impostor: PhysicsImpostor): number;
  55522. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55523. sleepBody(impostor: PhysicsImpostor): void;
  55524. wakeUpBody(impostor: PhysicsImpostor): void;
  55525. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55526. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55527. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55528. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55529. getRadius(impostor: PhysicsImpostor): number;
  55530. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55531. dispose(): void;
  55532. /**
  55533. * Does a raycast in the physics world
  55534. * @param from when should the ray start?
  55535. * @param to when should the ray end?
  55536. * @returns PhysicsRaycastResult
  55537. */
  55538. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55539. }
  55540. }
  55541. declare module BABYLON {
  55542. /**
  55543. * Class containing static functions to help procedurally build meshes
  55544. */
  55545. export class RibbonBuilder {
  55546. /**
  55547. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55548. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55549. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55550. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55551. * * 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
  55552. * * 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
  55553. * * 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
  55554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55555. * * 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
  55556. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55557. * * 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
  55558. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55559. * * 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
  55560. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55562. * @param name defines the name of the mesh
  55563. * @param options defines the options used to create the mesh
  55564. * @param scene defines the hosting scene
  55565. * @returns the ribbon mesh
  55566. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55567. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55568. */
  55569. static CreateRibbon(name: string, options: {
  55570. pathArray: Vector3[][];
  55571. closeArray?: boolean;
  55572. closePath?: boolean;
  55573. offset?: number;
  55574. updatable?: boolean;
  55575. sideOrientation?: number;
  55576. frontUVs?: Vector4;
  55577. backUVs?: Vector4;
  55578. instance?: Mesh;
  55579. invertUV?: boolean;
  55580. uvs?: Vector2[];
  55581. colors?: Color4[];
  55582. }, scene?: Nullable<Scene>): Mesh;
  55583. }
  55584. }
  55585. declare module BABYLON {
  55586. /**
  55587. * Class containing static functions to help procedurally build meshes
  55588. */
  55589. export class ShapeBuilder {
  55590. /**
  55591. * 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.
  55592. * * 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.
  55593. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55594. * * 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.
  55595. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55596. * * 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
  55597. * * 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
  55598. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55599. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55600. * * 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
  55601. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55603. * @param name defines the name of the mesh
  55604. * @param options defines the options used to create the mesh
  55605. * @param scene defines the hosting scene
  55606. * @returns the extruded shape mesh
  55607. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55609. */
  55610. static ExtrudeShape(name: string, options: {
  55611. shape: Vector3[];
  55612. path: Vector3[];
  55613. scale?: number;
  55614. rotation?: number;
  55615. cap?: number;
  55616. updatable?: boolean;
  55617. sideOrientation?: number;
  55618. frontUVs?: Vector4;
  55619. backUVs?: Vector4;
  55620. instance?: Mesh;
  55621. invertUV?: boolean;
  55622. }, scene?: Nullable<Scene>): Mesh;
  55623. /**
  55624. * Creates an custom extruded shape mesh.
  55625. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55626. * * 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.
  55627. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55628. * * 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
  55629. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55630. * * 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
  55631. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55632. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55633. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55634. * * 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
  55635. * * 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
  55636. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55638. * * 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
  55639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55641. * @param name defines the name of the mesh
  55642. * @param options defines the options used to create the mesh
  55643. * @param scene defines the hosting scene
  55644. * @returns the custom extruded shape mesh
  55645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55647. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55648. */
  55649. static ExtrudeShapeCustom(name: string, options: {
  55650. shape: Vector3[];
  55651. path: Vector3[];
  55652. scaleFunction?: any;
  55653. rotationFunction?: any;
  55654. ribbonCloseArray?: boolean;
  55655. ribbonClosePath?: boolean;
  55656. cap?: number;
  55657. updatable?: boolean;
  55658. sideOrientation?: number;
  55659. frontUVs?: Vector4;
  55660. backUVs?: Vector4;
  55661. instance?: Mesh;
  55662. invertUV?: boolean;
  55663. }, scene?: Nullable<Scene>): Mesh;
  55664. private static _ExtrudeShapeGeneric;
  55665. }
  55666. }
  55667. declare module BABYLON {
  55668. /**
  55669. * AmmoJS Physics plugin
  55670. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55671. * @see https://github.com/kripken/ammo.js/
  55672. */
  55673. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55674. private _useDeltaForWorldStep;
  55675. /**
  55676. * Reference to the Ammo library
  55677. */
  55678. bjsAMMO: any;
  55679. /**
  55680. * Created ammoJS world which physics bodies are added to
  55681. */
  55682. world: any;
  55683. /**
  55684. * Name of the plugin
  55685. */
  55686. name: string;
  55687. private _timeStep;
  55688. private _fixedTimeStep;
  55689. private _maxSteps;
  55690. private _tmpQuaternion;
  55691. private _tmpAmmoTransform;
  55692. private _tmpAmmoQuaternion;
  55693. private _tmpAmmoConcreteContactResultCallback;
  55694. private _collisionConfiguration;
  55695. private _dispatcher;
  55696. private _overlappingPairCache;
  55697. private _solver;
  55698. private _softBodySolver;
  55699. private _tmpAmmoVectorA;
  55700. private _tmpAmmoVectorB;
  55701. private _tmpAmmoVectorC;
  55702. private _tmpAmmoVectorD;
  55703. private _tmpContactCallbackResult;
  55704. private _tmpAmmoVectorRCA;
  55705. private _tmpAmmoVectorRCB;
  55706. private _raycastResult;
  55707. private static readonly DISABLE_COLLISION_FLAG;
  55708. private static readonly KINEMATIC_FLAG;
  55709. private static readonly DISABLE_DEACTIVATION_FLAG;
  55710. /**
  55711. * Initializes the ammoJS plugin
  55712. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55713. * @param ammoInjection can be used to inject your own ammo reference
  55714. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55715. */
  55716. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55717. /**
  55718. * Sets the gravity of the physics world (m/(s^2))
  55719. * @param gravity Gravity to set
  55720. */
  55721. setGravity(gravity: Vector3): void;
  55722. /**
  55723. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55724. * @param timeStep timestep to use in seconds
  55725. */
  55726. setTimeStep(timeStep: number): void;
  55727. /**
  55728. * 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)
  55729. * @param fixedTimeStep fixedTimeStep to use in seconds
  55730. */
  55731. setFixedTimeStep(fixedTimeStep: number): void;
  55732. /**
  55733. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55734. * @param maxSteps the maximum number of steps by the physics engine per frame
  55735. */
  55736. setMaxSteps(maxSteps: number): void;
  55737. /**
  55738. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55739. * @returns the current timestep in seconds
  55740. */
  55741. getTimeStep(): number;
  55742. /**
  55743. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55744. */
  55745. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55746. private _isImpostorInContact;
  55747. private _isImpostorPairInContact;
  55748. private _stepSimulation;
  55749. /**
  55750. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55751. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55752. * After the step the babylon meshes are set to the position of the physics imposters
  55753. * @param delta amount of time to step forward
  55754. * @param impostors array of imposters to update before/after the step
  55755. */
  55756. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55757. /**
  55758. * Update babylon mesh to match physics world object
  55759. * @param impostor imposter to match
  55760. */
  55761. private _afterSoftStep;
  55762. /**
  55763. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55764. * @param impostor imposter to match
  55765. */
  55766. private _ropeStep;
  55767. /**
  55768. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55769. * @param impostor imposter to match
  55770. */
  55771. private _softbodyOrClothStep;
  55772. private _tmpMatrix;
  55773. /**
  55774. * Applies an impulse on the imposter
  55775. * @param impostor imposter to apply impulse to
  55776. * @param force amount of force to be applied to the imposter
  55777. * @param contactPoint the location to apply the impulse on the imposter
  55778. */
  55779. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55780. /**
  55781. * Applies a force on the imposter
  55782. * @param impostor imposter to apply force
  55783. * @param force amount of force to be applied to the imposter
  55784. * @param contactPoint the location to apply the force on the imposter
  55785. */
  55786. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55787. /**
  55788. * Creates a physics body using the plugin
  55789. * @param impostor the imposter to create the physics body on
  55790. */
  55791. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55792. /**
  55793. * Removes the physics body from the imposter and disposes of the body's memory
  55794. * @param impostor imposter to remove the physics body from
  55795. */
  55796. removePhysicsBody(impostor: PhysicsImpostor): void;
  55797. /**
  55798. * Generates a joint
  55799. * @param impostorJoint the imposter joint to create the joint with
  55800. */
  55801. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55802. /**
  55803. * Removes a joint
  55804. * @param impostorJoint the imposter joint to remove the joint from
  55805. */
  55806. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55807. private _addMeshVerts;
  55808. /**
  55809. * Initialise the soft body vertices to match its object's (mesh) vertices
  55810. * Softbody vertices (nodes) are in world space and to match this
  55811. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55812. * @param impostor to create the softbody for
  55813. */
  55814. private _softVertexData;
  55815. /**
  55816. * Create an impostor's soft body
  55817. * @param impostor to create the softbody for
  55818. */
  55819. private _createSoftbody;
  55820. /**
  55821. * Create cloth for an impostor
  55822. * @param impostor to create the softbody for
  55823. */
  55824. private _createCloth;
  55825. /**
  55826. * Create rope for an impostor
  55827. * @param impostor to create the softbody for
  55828. */
  55829. private _createRope;
  55830. /**
  55831. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55832. * @param impostor to create the custom physics shape for
  55833. */
  55834. private _createCustom;
  55835. private _addHullVerts;
  55836. private _createShape;
  55837. /**
  55838. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55839. * @param impostor imposter containing the physics body and babylon object
  55840. */
  55841. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55842. /**
  55843. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55844. * @param impostor imposter containing the physics body and babylon object
  55845. * @param newPosition new position
  55846. * @param newRotation new rotation
  55847. */
  55848. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55849. /**
  55850. * If this plugin is supported
  55851. * @returns true if its supported
  55852. */
  55853. isSupported(): boolean;
  55854. /**
  55855. * Sets the linear velocity of the physics body
  55856. * @param impostor imposter to set the velocity on
  55857. * @param velocity velocity to set
  55858. */
  55859. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55860. /**
  55861. * Sets the angular velocity of the physics body
  55862. * @param impostor imposter to set the velocity on
  55863. * @param velocity velocity to set
  55864. */
  55865. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55866. /**
  55867. * gets the linear velocity
  55868. * @param impostor imposter to get linear velocity from
  55869. * @returns linear velocity
  55870. */
  55871. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55872. /**
  55873. * gets the angular velocity
  55874. * @param impostor imposter to get angular velocity from
  55875. * @returns angular velocity
  55876. */
  55877. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55878. /**
  55879. * Sets the mass of physics body
  55880. * @param impostor imposter to set the mass on
  55881. * @param mass mass to set
  55882. */
  55883. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55884. /**
  55885. * Gets the mass of the physics body
  55886. * @param impostor imposter to get the mass from
  55887. * @returns mass
  55888. */
  55889. getBodyMass(impostor: PhysicsImpostor): number;
  55890. /**
  55891. * Gets friction of the impostor
  55892. * @param impostor impostor to get friction from
  55893. * @returns friction value
  55894. */
  55895. getBodyFriction(impostor: PhysicsImpostor): number;
  55896. /**
  55897. * Sets friction of the impostor
  55898. * @param impostor impostor to set friction on
  55899. * @param friction friction value
  55900. */
  55901. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55902. /**
  55903. * Gets restitution of the impostor
  55904. * @param impostor impostor to get restitution from
  55905. * @returns restitution value
  55906. */
  55907. getBodyRestitution(impostor: PhysicsImpostor): number;
  55908. /**
  55909. * Sets resitution of the impostor
  55910. * @param impostor impostor to set resitution on
  55911. * @param restitution resitution value
  55912. */
  55913. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55914. /**
  55915. * Gets pressure inside the impostor
  55916. * @param impostor impostor to get pressure from
  55917. * @returns pressure value
  55918. */
  55919. getBodyPressure(impostor: PhysicsImpostor): number;
  55920. /**
  55921. * Sets pressure inside a soft body impostor
  55922. * Cloth and rope must remain 0 pressure
  55923. * @param impostor impostor to set pressure on
  55924. * @param pressure pressure value
  55925. */
  55926. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55927. /**
  55928. * Gets stiffness of the impostor
  55929. * @param impostor impostor to get stiffness from
  55930. * @returns pressure value
  55931. */
  55932. getBodyStiffness(impostor: PhysicsImpostor): number;
  55933. /**
  55934. * Sets stiffness of the impostor
  55935. * @param impostor impostor to set stiffness on
  55936. * @param stiffness stiffness value from 0 to 1
  55937. */
  55938. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55939. /**
  55940. * Gets velocityIterations of the impostor
  55941. * @param impostor impostor to get velocity iterations from
  55942. * @returns velocityIterations value
  55943. */
  55944. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55945. /**
  55946. * Sets velocityIterations of the impostor
  55947. * @param impostor impostor to set velocity iterations on
  55948. * @param velocityIterations velocityIterations value
  55949. */
  55950. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55951. /**
  55952. * Gets positionIterations of the impostor
  55953. * @param impostor impostor to get position iterations from
  55954. * @returns positionIterations value
  55955. */
  55956. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55957. /**
  55958. * Sets positionIterations of the impostor
  55959. * @param impostor impostor to set position on
  55960. * @param positionIterations positionIterations value
  55961. */
  55962. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55963. /**
  55964. * Append an anchor to a cloth object
  55965. * @param impostor is the cloth impostor to add anchor to
  55966. * @param otherImpostor is the rigid impostor to anchor to
  55967. * @param width ratio across width from 0 to 1
  55968. * @param height ratio up height from 0 to 1
  55969. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55970. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55971. */
  55972. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55973. /**
  55974. * Append an hook to a rope object
  55975. * @param impostor is the rope impostor to add hook to
  55976. * @param otherImpostor is the rigid impostor to hook to
  55977. * @param length ratio along the rope from 0 to 1
  55978. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55979. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55980. */
  55981. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55982. /**
  55983. * Sleeps the physics body and stops it from being active
  55984. * @param impostor impostor to sleep
  55985. */
  55986. sleepBody(impostor: PhysicsImpostor): void;
  55987. /**
  55988. * Activates the physics body
  55989. * @param impostor impostor to activate
  55990. */
  55991. wakeUpBody(impostor: PhysicsImpostor): void;
  55992. /**
  55993. * Updates the distance parameters of the joint
  55994. * @param joint joint to update
  55995. * @param maxDistance maximum distance of the joint
  55996. * @param minDistance minimum distance of the joint
  55997. */
  55998. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55999. /**
  56000. * Sets a motor on the joint
  56001. * @param joint joint to set motor on
  56002. * @param speed speed of the motor
  56003. * @param maxForce maximum force of the motor
  56004. * @param motorIndex index of the motor
  56005. */
  56006. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56007. /**
  56008. * Sets the motors limit
  56009. * @param joint joint to set limit on
  56010. * @param upperLimit upper limit
  56011. * @param lowerLimit lower limit
  56012. */
  56013. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56014. /**
  56015. * Syncs the position and rotation of a mesh with the impostor
  56016. * @param mesh mesh to sync
  56017. * @param impostor impostor to update the mesh with
  56018. */
  56019. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56020. /**
  56021. * Gets the radius of the impostor
  56022. * @param impostor impostor to get radius from
  56023. * @returns the radius
  56024. */
  56025. getRadius(impostor: PhysicsImpostor): number;
  56026. /**
  56027. * Gets the box size of the impostor
  56028. * @param impostor impostor to get box size from
  56029. * @param result the resulting box size
  56030. */
  56031. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56032. /**
  56033. * Disposes of the impostor
  56034. */
  56035. dispose(): void;
  56036. /**
  56037. * Does a raycast in the physics world
  56038. * @param from when should the ray start?
  56039. * @param to when should the ray end?
  56040. * @returns PhysicsRaycastResult
  56041. */
  56042. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56043. }
  56044. }
  56045. declare module BABYLON {
  56046. interface AbstractScene {
  56047. /**
  56048. * The list of reflection probes added to the scene
  56049. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56050. */
  56051. reflectionProbes: Array<ReflectionProbe>;
  56052. /**
  56053. * Removes the given reflection probe from this scene.
  56054. * @param toRemove The reflection probe to remove
  56055. * @returns The index of the removed reflection probe
  56056. */
  56057. removeReflectionProbe(toRemove: ReflectionProbe): number;
  56058. /**
  56059. * Adds the given reflection probe to this scene.
  56060. * @param newReflectionProbe The reflection probe to add
  56061. */
  56062. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  56063. }
  56064. /**
  56065. * Class used to generate realtime reflection / refraction cube textures
  56066. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  56067. */
  56068. export class ReflectionProbe {
  56069. /** defines the name of the probe */
  56070. name: string;
  56071. private _scene;
  56072. private _renderTargetTexture;
  56073. private _projectionMatrix;
  56074. private _viewMatrix;
  56075. private _target;
  56076. private _add;
  56077. private _attachedMesh;
  56078. private _invertYAxis;
  56079. /** Gets or sets probe position (center of the cube map) */
  56080. position: Vector3;
  56081. /**
  56082. * Creates a new reflection probe
  56083. * @param name defines the name of the probe
  56084. * @param size defines the texture resolution (for each face)
  56085. * @param scene defines the hosting scene
  56086. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  56087. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  56088. */
  56089. constructor(
  56090. /** defines the name of the probe */
  56091. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  56092. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  56093. get samples(): number;
  56094. set samples(value: number);
  56095. /** Gets or sets the refresh rate to use (on every frame by default) */
  56096. get refreshRate(): number;
  56097. set refreshRate(value: number);
  56098. /**
  56099. * Gets the hosting scene
  56100. * @returns a Scene
  56101. */
  56102. getScene(): Scene;
  56103. /** Gets the internal CubeTexture used to render to */
  56104. get cubeTexture(): RenderTargetTexture;
  56105. /** Gets the list of meshes to render */
  56106. get renderList(): Nullable<AbstractMesh[]>;
  56107. /**
  56108. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  56109. * @param mesh defines the mesh to attach to
  56110. */
  56111. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56112. /**
  56113. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  56114. * @param renderingGroupId The rendering group id corresponding to its index
  56115. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  56116. */
  56117. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  56118. /**
  56119. * Clean all associated resources
  56120. */
  56121. dispose(): void;
  56122. /**
  56123. * Converts the reflection probe information to a readable string for debug purpose.
  56124. * @param fullDetails Supports for multiple levels of logging within scene loading
  56125. * @returns the human readable reflection probe info
  56126. */
  56127. toString(fullDetails?: boolean): string;
  56128. /**
  56129. * Get the class name of the relfection probe.
  56130. * @returns "ReflectionProbe"
  56131. */
  56132. getClassName(): string;
  56133. /**
  56134. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  56135. * @returns The JSON representation of the texture
  56136. */
  56137. serialize(): any;
  56138. /**
  56139. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  56140. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  56141. * @param scene Define the scene the parsed reflection probe should be instantiated in
  56142. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  56143. * @returns The parsed reflection probe if successful
  56144. */
  56145. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  56146. }
  56147. }
  56148. declare module BABYLON {
  56149. /** @hidden */
  56150. export var _BabylonLoaderRegistered: boolean;
  56151. /**
  56152. * Helps setting up some configuration for the babylon file loader.
  56153. */
  56154. export class BabylonFileLoaderConfiguration {
  56155. /**
  56156. * The loader does not allow injecting custom physix engine into the plugins.
  56157. * Unfortunately in ES6, we need to manually inject them into the plugin.
  56158. * So you could set this variable to your engine import to make it work.
  56159. */
  56160. static LoaderInjectedPhysicsEngine: any;
  56161. }
  56162. }
  56163. declare module BABYLON {
  56164. /**
  56165. * The Physically based simple base material of BJS.
  56166. *
  56167. * This enables better naming and convention enforcements on top of the pbrMaterial.
  56168. * It is used as the base class for both the specGloss and metalRough conventions.
  56169. */
  56170. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  56171. /**
  56172. * Number of Simultaneous lights allowed on the material.
  56173. */
  56174. maxSimultaneousLights: number;
  56175. /**
  56176. * If sets to true, disables all the lights affecting the material.
  56177. */
  56178. disableLighting: boolean;
  56179. /**
  56180. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  56181. */
  56182. environmentTexture: BaseTexture;
  56183. /**
  56184. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56185. */
  56186. invertNormalMapX: boolean;
  56187. /**
  56188. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56189. */
  56190. invertNormalMapY: boolean;
  56191. /**
  56192. * Normal map used in the model.
  56193. */
  56194. normalTexture: BaseTexture;
  56195. /**
  56196. * Emissivie color used to self-illuminate the model.
  56197. */
  56198. emissiveColor: Color3;
  56199. /**
  56200. * Emissivie texture used to self-illuminate the model.
  56201. */
  56202. emissiveTexture: BaseTexture;
  56203. /**
  56204. * Occlusion Channel Strenght.
  56205. */
  56206. occlusionStrength: number;
  56207. /**
  56208. * Occlusion Texture of the material (adding extra occlusion effects).
  56209. */
  56210. occlusionTexture: BaseTexture;
  56211. /**
  56212. * Defines the alpha limits in alpha test mode.
  56213. */
  56214. alphaCutOff: number;
  56215. /**
  56216. * Gets the current double sided mode.
  56217. */
  56218. get doubleSided(): boolean;
  56219. /**
  56220. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56221. */
  56222. set doubleSided(value: boolean);
  56223. /**
  56224. * Stores the pre-calculated light information of a mesh in a texture.
  56225. */
  56226. lightmapTexture: BaseTexture;
  56227. /**
  56228. * If true, the light map contains occlusion information instead of lighting info.
  56229. */
  56230. useLightmapAsShadowmap: boolean;
  56231. /**
  56232. * Instantiates a new PBRMaterial instance.
  56233. *
  56234. * @param name The material name
  56235. * @param scene The scene the material will be use in.
  56236. */
  56237. constructor(name: string, scene: Scene);
  56238. getClassName(): string;
  56239. }
  56240. }
  56241. declare module BABYLON {
  56242. /**
  56243. * The PBR material of BJS following the metal roughness convention.
  56244. *
  56245. * This fits to the PBR convention in the GLTF definition:
  56246. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  56247. */
  56248. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  56249. /**
  56250. * The base color has two different interpretations depending on the value of metalness.
  56251. * When the material is a metal, the base color is the specific measured reflectance value
  56252. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  56253. * of the material.
  56254. */
  56255. baseColor: Color3;
  56256. /**
  56257. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56258. * well as opacity information in the alpha channel.
  56259. */
  56260. baseTexture: BaseTexture;
  56261. /**
  56262. * Specifies the metallic scalar value of the material.
  56263. * Can also be used to scale the metalness values of the metallic texture.
  56264. */
  56265. metallic: number;
  56266. /**
  56267. * Specifies the roughness scalar value of the material.
  56268. * Can also be used to scale the roughness values of the metallic texture.
  56269. */
  56270. roughness: number;
  56271. /**
  56272. * Texture containing both the metallic value in the B channel and the
  56273. * roughness value in the G channel to keep better precision.
  56274. */
  56275. metallicRoughnessTexture: BaseTexture;
  56276. /**
  56277. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56278. *
  56279. * @param name The material name
  56280. * @param scene The scene the material will be use in.
  56281. */
  56282. constructor(name: string, scene: Scene);
  56283. /**
  56284. * Return the currrent class name of the material.
  56285. */
  56286. getClassName(): string;
  56287. /**
  56288. * Makes a duplicate of the current material.
  56289. * @param name - name to use for the new material.
  56290. */
  56291. clone(name: string): PBRMetallicRoughnessMaterial;
  56292. /**
  56293. * Serialize the material to a parsable JSON object.
  56294. */
  56295. serialize(): any;
  56296. /**
  56297. * Parses a JSON object correponding to the serialize function.
  56298. */
  56299. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56300. }
  56301. }
  56302. declare module BABYLON {
  56303. /**
  56304. * The PBR material of BJS following the specular glossiness convention.
  56305. *
  56306. * This fits to the PBR convention in the GLTF definition:
  56307. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56308. */
  56309. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56310. /**
  56311. * Specifies the diffuse color of the material.
  56312. */
  56313. diffuseColor: Color3;
  56314. /**
  56315. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56316. * channel.
  56317. */
  56318. diffuseTexture: BaseTexture;
  56319. /**
  56320. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56321. */
  56322. specularColor: Color3;
  56323. /**
  56324. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56325. */
  56326. glossiness: number;
  56327. /**
  56328. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56329. */
  56330. specularGlossinessTexture: BaseTexture;
  56331. /**
  56332. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56333. *
  56334. * @param name The material name
  56335. * @param scene The scene the material will be use in.
  56336. */
  56337. constructor(name: string, scene: Scene);
  56338. /**
  56339. * Return the currrent class name of the material.
  56340. */
  56341. getClassName(): string;
  56342. /**
  56343. * Makes a duplicate of the current material.
  56344. * @param name - name to use for the new material.
  56345. */
  56346. clone(name: string): PBRSpecularGlossinessMaterial;
  56347. /**
  56348. * Serialize the material to a parsable JSON object.
  56349. */
  56350. serialize(): any;
  56351. /**
  56352. * Parses a JSON object correponding to the serialize function.
  56353. */
  56354. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56355. }
  56356. }
  56357. declare module BABYLON {
  56358. /**
  56359. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56360. * It can help converting any input color in a desired output one. This can then be used to create effects
  56361. * from sepia, black and white to sixties or futuristic rendering...
  56362. *
  56363. * The only supported format is currently 3dl.
  56364. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56365. */
  56366. export class ColorGradingTexture extends BaseTexture {
  56367. /**
  56368. * The current texture matrix. (will always be identity in color grading texture)
  56369. */
  56370. private _textureMatrix;
  56371. /**
  56372. * The texture URL.
  56373. */
  56374. url: string;
  56375. /**
  56376. * Empty line regex stored for GC.
  56377. */
  56378. private static _noneEmptyLineRegex;
  56379. private _engine;
  56380. /**
  56381. * Instantiates a ColorGradingTexture from the following parameters.
  56382. *
  56383. * @param url The location of the color gradind data (currently only supporting 3dl)
  56384. * @param scene The scene the texture will be used in
  56385. */
  56386. constructor(url: string, scene: Scene);
  56387. /**
  56388. * Returns the texture matrix used in most of the material.
  56389. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56390. */
  56391. getTextureMatrix(): Matrix;
  56392. /**
  56393. * Occurs when the file being loaded is a .3dl LUT file.
  56394. */
  56395. private load3dlTexture;
  56396. /**
  56397. * Starts the loading process of the texture.
  56398. */
  56399. private loadTexture;
  56400. /**
  56401. * Clones the color gradind texture.
  56402. */
  56403. clone(): ColorGradingTexture;
  56404. /**
  56405. * Called during delayed load for textures.
  56406. */
  56407. delayLoad(): void;
  56408. /**
  56409. * Parses a color grading texture serialized by Babylon.
  56410. * @param parsedTexture The texture information being parsedTexture
  56411. * @param scene The scene to load the texture in
  56412. * @param rootUrl The root url of the data assets to load
  56413. * @return A color gradind texture
  56414. */
  56415. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56416. /**
  56417. * Serializes the LUT texture to json format.
  56418. */
  56419. serialize(): any;
  56420. }
  56421. }
  56422. declare module BABYLON {
  56423. /**
  56424. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56425. */
  56426. export class EquiRectangularCubeTexture extends BaseTexture {
  56427. /** The six faces of the cube. */
  56428. private static _FacesMapping;
  56429. private _noMipmap;
  56430. private _onLoad;
  56431. private _onError;
  56432. /** The size of the cubemap. */
  56433. private _size;
  56434. /** The buffer of the image. */
  56435. private _buffer;
  56436. /** The width of the input image. */
  56437. private _width;
  56438. /** The height of the input image. */
  56439. private _height;
  56440. /** The URL to the image. */
  56441. url: string;
  56442. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56443. coordinatesMode: number;
  56444. /**
  56445. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56446. * @param url The location of the image
  56447. * @param scene The scene the texture will be used in
  56448. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56449. * @param noMipmap Forces to not generate the mipmap if true
  56450. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56451. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56452. * @param onLoad — defines a callback called when texture is loaded
  56453. * @param onError — defines a callback called if there is an error
  56454. */
  56455. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56456. /**
  56457. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56458. */
  56459. private loadImage;
  56460. /**
  56461. * Convert the image buffer into a cubemap and create a CubeTexture.
  56462. */
  56463. private loadTexture;
  56464. /**
  56465. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56466. * @param buffer The ArrayBuffer that should be converted.
  56467. * @returns The buffer as Float32Array.
  56468. */
  56469. private getFloat32ArrayFromArrayBuffer;
  56470. /**
  56471. * Get the current class name of the texture useful for serialization or dynamic coding.
  56472. * @returns "EquiRectangularCubeTexture"
  56473. */
  56474. getClassName(): string;
  56475. /**
  56476. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56477. * @returns A clone of the current EquiRectangularCubeTexture.
  56478. */
  56479. clone(): EquiRectangularCubeTexture;
  56480. }
  56481. }
  56482. declare module BABYLON {
  56483. /**
  56484. * Based on jsTGALoader - Javascript loader for TGA file
  56485. * By Vincent Thibault
  56486. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56487. */
  56488. export class TGATools {
  56489. private static _TYPE_INDEXED;
  56490. private static _TYPE_RGB;
  56491. private static _TYPE_GREY;
  56492. private static _TYPE_RLE_INDEXED;
  56493. private static _TYPE_RLE_RGB;
  56494. private static _TYPE_RLE_GREY;
  56495. private static _ORIGIN_MASK;
  56496. private static _ORIGIN_SHIFT;
  56497. private static _ORIGIN_BL;
  56498. private static _ORIGIN_BR;
  56499. private static _ORIGIN_UL;
  56500. private static _ORIGIN_UR;
  56501. /**
  56502. * Gets the header of a TGA file
  56503. * @param data defines the TGA data
  56504. * @returns the header
  56505. */
  56506. static GetTGAHeader(data: Uint8Array): any;
  56507. /**
  56508. * Uploads TGA content to a Babylon Texture
  56509. * @hidden
  56510. */
  56511. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56512. /** @hidden */
  56513. 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;
  56514. /** @hidden */
  56515. 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;
  56516. /** @hidden */
  56517. 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;
  56518. /** @hidden */
  56519. 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;
  56520. /** @hidden */
  56521. 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;
  56522. /** @hidden */
  56523. 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;
  56524. }
  56525. }
  56526. declare module BABYLON {
  56527. /**
  56528. * Implementation of the TGA Texture Loader.
  56529. * @hidden
  56530. */
  56531. export class _TGATextureLoader implements IInternalTextureLoader {
  56532. /**
  56533. * Defines wether the loader supports cascade loading the different faces.
  56534. */
  56535. readonly supportCascades: boolean;
  56536. /**
  56537. * This returns if the loader support the current file information.
  56538. * @param extension defines the file extension of the file being loaded
  56539. * @returns true if the loader can load the specified file
  56540. */
  56541. canLoad(extension: string): boolean;
  56542. /**
  56543. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56544. * @param data contains the texture data
  56545. * @param texture defines the BabylonJS internal texture
  56546. * @param createPolynomials will be true if polynomials have been requested
  56547. * @param onLoad defines the callback to trigger once the texture is ready
  56548. * @param onError defines the callback to trigger in case of error
  56549. */
  56550. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56551. /**
  56552. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56553. * @param data contains the texture data
  56554. * @param texture defines the BabylonJS internal texture
  56555. * @param callback defines the method to call once ready to upload
  56556. */
  56557. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56558. }
  56559. }
  56560. declare module BABYLON {
  56561. /**
  56562. * Info about the .basis files
  56563. */
  56564. class BasisFileInfo {
  56565. /**
  56566. * If the file has alpha
  56567. */
  56568. hasAlpha: boolean;
  56569. /**
  56570. * Info about each image of the basis file
  56571. */
  56572. images: Array<{
  56573. levels: Array<{
  56574. width: number;
  56575. height: number;
  56576. transcodedPixels: ArrayBufferView;
  56577. }>;
  56578. }>;
  56579. }
  56580. /**
  56581. * Result of transcoding a basis file
  56582. */
  56583. class TranscodeResult {
  56584. /**
  56585. * Info about the .basis file
  56586. */
  56587. fileInfo: BasisFileInfo;
  56588. /**
  56589. * Format to use when loading the file
  56590. */
  56591. format: number;
  56592. }
  56593. /**
  56594. * Configuration options for the Basis transcoder
  56595. */
  56596. export class BasisTranscodeConfiguration {
  56597. /**
  56598. * Supported compression formats used to determine the supported output format of the transcoder
  56599. */
  56600. supportedCompressionFormats?: {
  56601. /**
  56602. * etc1 compression format
  56603. */
  56604. etc1?: boolean;
  56605. /**
  56606. * s3tc compression format
  56607. */
  56608. s3tc?: boolean;
  56609. /**
  56610. * pvrtc compression format
  56611. */
  56612. pvrtc?: boolean;
  56613. /**
  56614. * etc2 compression format
  56615. */
  56616. etc2?: boolean;
  56617. };
  56618. /**
  56619. * If mipmap levels should be loaded for transcoded images (Default: true)
  56620. */
  56621. loadMipmapLevels?: boolean;
  56622. /**
  56623. * Index of a single image to load (Default: all images)
  56624. */
  56625. loadSingleImage?: number;
  56626. }
  56627. /**
  56628. * Used to load .Basis files
  56629. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56630. */
  56631. export class BasisTools {
  56632. private static _IgnoreSupportedFormats;
  56633. /**
  56634. * URL to use when loading the basis transcoder
  56635. */
  56636. static JSModuleURL: string;
  56637. /**
  56638. * URL to use when loading the wasm module for the transcoder
  56639. */
  56640. static WasmModuleURL: string;
  56641. /**
  56642. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56643. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56644. * @returns internal format corresponding to the Basis format
  56645. */
  56646. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56647. private static _WorkerPromise;
  56648. private static _Worker;
  56649. private static _actionId;
  56650. private static _CreateWorkerAsync;
  56651. /**
  56652. * Transcodes a loaded image file to compressed pixel data
  56653. * @param data image data to transcode
  56654. * @param config configuration options for the transcoding
  56655. * @returns a promise resulting in the transcoded image
  56656. */
  56657. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56658. /**
  56659. * Loads a texture from the transcode result
  56660. * @param texture texture load to
  56661. * @param transcodeResult the result of transcoding the basis file to load from
  56662. */
  56663. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56664. }
  56665. }
  56666. declare module BABYLON {
  56667. /**
  56668. * Loader for .basis file format
  56669. */
  56670. export class _BasisTextureLoader implements IInternalTextureLoader {
  56671. /**
  56672. * Defines whether the loader supports cascade loading the different faces.
  56673. */
  56674. readonly supportCascades: boolean;
  56675. /**
  56676. * This returns if the loader support the current file information.
  56677. * @param extension defines the file extension of the file being loaded
  56678. * @returns true if the loader can load the specified file
  56679. */
  56680. canLoad(extension: string): boolean;
  56681. /**
  56682. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56683. * @param data contains the texture data
  56684. * @param texture defines the BabylonJS internal texture
  56685. * @param createPolynomials will be true if polynomials have been requested
  56686. * @param onLoad defines the callback to trigger once the texture is ready
  56687. * @param onError defines the callback to trigger in case of error
  56688. */
  56689. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56690. /**
  56691. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56692. * @param data contains the texture data
  56693. * @param texture defines the BabylonJS internal texture
  56694. * @param callback defines the method to call once ready to upload
  56695. */
  56696. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56697. }
  56698. }
  56699. declare module BABYLON {
  56700. /**
  56701. * 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.
  56702. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56703. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56704. */
  56705. export class CustomProceduralTexture extends ProceduralTexture {
  56706. private _animate;
  56707. private _time;
  56708. private _config;
  56709. private _texturePath;
  56710. /**
  56711. * Instantiates a new Custom Procedural Texture.
  56712. * 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.
  56713. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56714. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56715. * @param name Define the name of the texture
  56716. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56717. * @param size Define the size of the texture to create
  56718. * @param scene Define the scene the texture belongs to
  56719. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56720. * @param generateMipMaps Define if the texture should creates mip maps or not
  56721. */
  56722. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56723. private _loadJson;
  56724. /**
  56725. * Is the texture ready to be used ? (rendered at least once)
  56726. * @returns true if ready, otherwise, false.
  56727. */
  56728. isReady(): boolean;
  56729. /**
  56730. * Render the texture to its associated render target.
  56731. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56732. */
  56733. render(useCameraPostProcess?: boolean): void;
  56734. /**
  56735. * Update the list of dependant textures samplers in the shader.
  56736. */
  56737. updateTextures(): void;
  56738. /**
  56739. * Update the uniform values of the procedural texture in the shader.
  56740. */
  56741. updateShaderUniforms(): void;
  56742. /**
  56743. * Define if the texture animates or not.
  56744. */
  56745. get animate(): boolean;
  56746. set animate(value: boolean);
  56747. }
  56748. }
  56749. declare module BABYLON {
  56750. /** @hidden */
  56751. export var noisePixelShader: {
  56752. name: string;
  56753. shader: string;
  56754. };
  56755. }
  56756. declare module BABYLON {
  56757. /**
  56758. * Class used to generate noise procedural textures
  56759. */
  56760. export class NoiseProceduralTexture extends ProceduralTexture {
  56761. private _time;
  56762. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56763. brightness: number;
  56764. /** Defines the number of octaves to process */
  56765. octaves: number;
  56766. /** Defines the level of persistence (0.8 by default) */
  56767. persistence: number;
  56768. /** Gets or sets animation speed factor (default is 1) */
  56769. animationSpeedFactor: number;
  56770. /**
  56771. * Creates a new NoiseProceduralTexture
  56772. * @param name defines the name fo the texture
  56773. * @param size defines the size of the texture (default is 256)
  56774. * @param scene defines the hosting scene
  56775. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56776. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56777. */
  56778. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56779. private _updateShaderUniforms;
  56780. protected _getDefines(): string;
  56781. /** Generate the current state of the procedural texture */
  56782. render(useCameraPostProcess?: boolean): void;
  56783. /**
  56784. * Serializes this noise procedural texture
  56785. * @returns a serialized noise procedural texture object
  56786. */
  56787. serialize(): any;
  56788. /**
  56789. * Clone the texture.
  56790. * @returns the cloned texture
  56791. */
  56792. clone(): NoiseProceduralTexture;
  56793. /**
  56794. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56795. * @param parsedTexture defines parsed texture data
  56796. * @param scene defines the current scene
  56797. * @param rootUrl defines the root URL containing noise procedural texture information
  56798. * @returns a parsed NoiseProceduralTexture
  56799. */
  56800. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56801. }
  56802. }
  56803. declare module BABYLON {
  56804. /**
  56805. * Raw cube texture where the raw buffers are passed in
  56806. */
  56807. export class RawCubeTexture extends CubeTexture {
  56808. /**
  56809. * Creates a cube texture where the raw buffers are passed in.
  56810. * @param scene defines the scene the texture is attached to
  56811. * @param data defines the array of data to use to create each face
  56812. * @param size defines the size of the textures
  56813. * @param format defines the format of the data
  56814. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56815. * @param generateMipMaps defines if the engine should generate the mip levels
  56816. * @param invertY defines if data must be stored with Y axis inverted
  56817. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56818. * @param compression defines the compression used (null by default)
  56819. */
  56820. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56821. /**
  56822. * Updates the raw cube texture.
  56823. * @param data defines the data to store
  56824. * @param format defines the data format
  56825. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56826. * @param invertY defines if data must be stored with Y axis inverted
  56827. * @param compression defines the compression used (null by default)
  56828. * @param level defines which level of the texture to update
  56829. */
  56830. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56831. /**
  56832. * Updates a raw cube texture with RGBD encoded data.
  56833. * @param data defines the array of data [mipmap][face] to use to create each face
  56834. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56835. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56836. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56837. * @returns a promsie that resolves when the operation is complete
  56838. */
  56839. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56840. /**
  56841. * Clones the raw cube texture.
  56842. * @return a new cube texture
  56843. */
  56844. clone(): CubeTexture;
  56845. /** @hidden */
  56846. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56847. }
  56848. }
  56849. declare module BABYLON {
  56850. /**
  56851. * Class used to store 3D textures containing user data
  56852. */
  56853. export class RawTexture3D extends Texture {
  56854. /** Gets or sets the texture format to use */
  56855. format: number;
  56856. private _engine;
  56857. /**
  56858. * Create a new RawTexture3D
  56859. * @param data defines the data of the texture
  56860. * @param width defines the width of the texture
  56861. * @param height defines the height of the texture
  56862. * @param depth defines the depth of the texture
  56863. * @param format defines the texture format to use
  56864. * @param scene defines the hosting scene
  56865. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56866. * @param invertY defines if texture must be stored with Y axis inverted
  56867. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56868. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56869. */
  56870. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56871. /** Gets or sets the texture format to use */
  56872. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56873. /**
  56874. * Update the texture with new data
  56875. * @param data defines the data to store in the texture
  56876. */
  56877. update(data: ArrayBufferView): void;
  56878. }
  56879. }
  56880. declare module BABYLON {
  56881. /**
  56882. * Class used to store 2D array textures containing user data
  56883. */
  56884. export class RawTexture2DArray extends Texture {
  56885. /** Gets or sets the texture format to use */
  56886. format: number;
  56887. private _engine;
  56888. /**
  56889. * Create a new RawTexture2DArray
  56890. * @param data defines the data of the texture
  56891. * @param width defines the width of the texture
  56892. * @param height defines the height of the texture
  56893. * @param depth defines the number of layers of the texture
  56894. * @param format defines the texture format to use
  56895. * @param scene defines the hosting scene
  56896. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56897. * @param invertY defines if texture must be stored with Y axis inverted
  56898. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56899. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56900. */
  56901. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56902. /** Gets or sets the texture format to use */
  56903. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56904. /**
  56905. * Update the texture with new data
  56906. * @param data defines the data to store in the texture
  56907. */
  56908. update(data: ArrayBufferView): void;
  56909. }
  56910. }
  56911. declare module BABYLON {
  56912. /**
  56913. * Creates a refraction texture used by refraction channel of the standard material.
  56914. * It is like a mirror but to see through a material.
  56915. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56916. */
  56917. export class RefractionTexture extends RenderTargetTexture {
  56918. /**
  56919. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56920. * 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.
  56921. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56922. */
  56923. refractionPlane: Plane;
  56924. /**
  56925. * Define how deep under the surface we should see.
  56926. */
  56927. depth: number;
  56928. /**
  56929. * Creates a refraction texture used by refraction channel of the standard material.
  56930. * It is like a mirror but to see through a material.
  56931. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56932. * @param name Define the texture name
  56933. * @param size Define the size of the underlying texture
  56934. * @param scene Define the scene the refraction belongs to
  56935. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56936. */
  56937. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56938. /**
  56939. * Clone the refraction texture.
  56940. * @returns the cloned texture
  56941. */
  56942. clone(): RefractionTexture;
  56943. /**
  56944. * Serialize the texture to a JSON representation you could use in Parse later on
  56945. * @returns the serialized JSON representation
  56946. */
  56947. serialize(): any;
  56948. }
  56949. }
  56950. declare module BABYLON {
  56951. /**
  56952. * Defines the options related to the creation of an HtmlElementTexture
  56953. */
  56954. export interface IHtmlElementTextureOptions {
  56955. /**
  56956. * Defines wether mip maps should be created or not.
  56957. */
  56958. generateMipMaps?: boolean;
  56959. /**
  56960. * Defines the sampling mode of the texture.
  56961. */
  56962. samplingMode?: number;
  56963. /**
  56964. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56965. */
  56966. engine: Nullable<ThinEngine>;
  56967. /**
  56968. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56969. */
  56970. scene: Nullable<Scene>;
  56971. }
  56972. /**
  56973. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56974. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56975. * is automatically managed.
  56976. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56977. * in your application.
  56978. *
  56979. * As the update is not automatic, you need to call them manually.
  56980. */
  56981. export class HtmlElementTexture extends BaseTexture {
  56982. /**
  56983. * The texture URL.
  56984. */
  56985. element: HTMLVideoElement | HTMLCanvasElement;
  56986. private static readonly DefaultOptions;
  56987. private _textureMatrix;
  56988. private _engine;
  56989. private _isVideo;
  56990. private _generateMipMaps;
  56991. private _samplingMode;
  56992. /**
  56993. * Instantiates a HtmlElementTexture from the following parameters.
  56994. *
  56995. * @param name Defines the name of the texture
  56996. * @param element Defines the video or canvas the texture is filled with
  56997. * @param options Defines the other none mandatory texture creation options
  56998. */
  56999. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  57000. private _createInternalTexture;
  57001. /**
  57002. * Returns the texture matrix used in most of the material.
  57003. */
  57004. getTextureMatrix(): Matrix;
  57005. /**
  57006. * Updates the content of the texture.
  57007. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  57008. */
  57009. update(invertY?: Nullable<boolean>): void;
  57010. }
  57011. }
  57012. declare module BABYLON {
  57013. /**
  57014. * Defines the basic options interface of a TexturePacker Frame
  57015. */
  57016. export interface ITexturePackerFrame {
  57017. /**
  57018. * The frame ID
  57019. */
  57020. id: number;
  57021. /**
  57022. * The frames Scale
  57023. */
  57024. scale: Vector2;
  57025. /**
  57026. * The Frames offset
  57027. */
  57028. offset: Vector2;
  57029. }
  57030. /**
  57031. * This is a support class for frame Data on texture packer sets.
  57032. */
  57033. export class TexturePackerFrame implements ITexturePackerFrame {
  57034. /**
  57035. * The frame ID
  57036. */
  57037. id: number;
  57038. /**
  57039. * The frames Scale
  57040. */
  57041. scale: Vector2;
  57042. /**
  57043. * The Frames offset
  57044. */
  57045. offset: Vector2;
  57046. /**
  57047. * Initializes a texture package frame.
  57048. * @param id The numerical frame identifier
  57049. * @param scale Scalar Vector2 for UV frame
  57050. * @param offset Vector2 for the frame position in UV units.
  57051. * @returns TexturePackerFrame
  57052. */
  57053. constructor(id: number, scale: Vector2, offset: Vector2);
  57054. }
  57055. }
  57056. declare module BABYLON {
  57057. /**
  57058. * Defines the basic options interface of a TexturePacker
  57059. */
  57060. export interface ITexturePackerOptions {
  57061. /**
  57062. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  57063. */
  57064. map?: string[];
  57065. /**
  57066. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57067. */
  57068. uvsIn?: string;
  57069. /**
  57070. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  57071. */
  57072. uvsOut?: string;
  57073. /**
  57074. * number representing the layout style. Defaults to LAYOUT_STRIP
  57075. */
  57076. layout?: number;
  57077. /**
  57078. * number of columns if using custom column count layout(2). This defaults to 4.
  57079. */
  57080. colnum?: number;
  57081. /**
  57082. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  57083. */
  57084. updateInputMeshes?: boolean;
  57085. /**
  57086. * boolean flag to dispose all the source textures. Defaults to true.
  57087. */
  57088. disposeSources?: boolean;
  57089. /**
  57090. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  57091. */
  57092. fillBlanks?: boolean;
  57093. /**
  57094. * string value representing the context fill style color. Defaults to 'black'.
  57095. */
  57096. customFillColor?: string;
  57097. /**
  57098. * Width and Height Value of each Frame in the TexturePacker Sets
  57099. */
  57100. frameSize?: number;
  57101. /**
  57102. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  57103. */
  57104. paddingRatio?: number;
  57105. /**
  57106. * Number that declares the fill method for the padding gutter.
  57107. */
  57108. paddingMode?: number;
  57109. /**
  57110. * If in SUBUV_COLOR padding mode what color to use.
  57111. */
  57112. paddingColor?: Color3 | Color4;
  57113. }
  57114. /**
  57115. * Defines the basic interface of a TexturePacker JSON File
  57116. */
  57117. export interface ITexturePackerJSON {
  57118. /**
  57119. * The frame ID
  57120. */
  57121. name: string;
  57122. /**
  57123. * The base64 channel data
  57124. */
  57125. sets: any;
  57126. /**
  57127. * The options of the Packer
  57128. */
  57129. options: ITexturePackerOptions;
  57130. /**
  57131. * The frame data of the Packer
  57132. */
  57133. frames: Array<number>;
  57134. }
  57135. /**
  57136. * This is a support class that generates a series of packed texture sets.
  57137. * @see https://doc.babylonjs.com/babylon101/materials
  57138. */
  57139. export class TexturePacker {
  57140. /** Packer Layout Constant 0 */
  57141. static readonly LAYOUT_STRIP: number;
  57142. /** Packer Layout Constant 1 */
  57143. static readonly LAYOUT_POWER2: number;
  57144. /** Packer Layout Constant 2 */
  57145. static readonly LAYOUT_COLNUM: number;
  57146. /** Packer Layout Constant 0 */
  57147. static readonly SUBUV_WRAP: number;
  57148. /** Packer Layout Constant 1 */
  57149. static readonly SUBUV_EXTEND: number;
  57150. /** Packer Layout Constant 2 */
  57151. static readonly SUBUV_COLOR: number;
  57152. /** The Name of the Texture Package */
  57153. name: string;
  57154. /** The scene scope of the TexturePacker */
  57155. scene: Scene;
  57156. /** The Meshes to target */
  57157. meshes: AbstractMesh[];
  57158. /** Arguments passed with the Constructor */
  57159. options: ITexturePackerOptions;
  57160. /** The promise that is started upon initialization */
  57161. promise: Nullable<Promise<TexturePacker | string>>;
  57162. /** The Container object for the channel sets that are generated */
  57163. sets: object;
  57164. /** The Container array for the frames that are generated */
  57165. frames: TexturePackerFrame[];
  57166. /** The expected number of textures the system is parsing. */
  57167. private _expecting;
  57168. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  57169. private _paddingValue;
  57170. /**
  57171. * Initializes a texture package series from an array of meshes or a single mesh.
  57172. * @param name The name of the package
  57173. * @param meshes The target meshes to compose the package from
  57174. * @param options The arguments that texture packer should follow while building.
  57175. * @param scene The scene which the textures are scoped to.
  57176. * @returns TexturePacker
  57177. */
  57178. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  57179. /**
  57180. * Starts the package process
  57181. * @param resolve The promises resolution function
  57182. * @returns TexturePacker
  57183. */
  57184. private _createFrames;
  57185. /**
  57186. * Calculates the Size of the Channel Sets
  57187. * @returns Vector2
  57188. */
  57189. private _calculateSize;
  57190. /**
  57191. * Calculates the UV data for the frames.
  57192. * @param baseSize the base frameSize
  57193. * @param padding the base frame padding
  57194. * @param dtSize size of the Dynamic Texture for that channel
  57195. * @param dtUnits is 1/dtSize
  57196. * @param update flag to update the input meshes
  57197. */
  57198. private _calculateMeshUVFrames;
  57199. /**
  57200. * Calculates the frames Offset.
  57201. * @param index of the frame
  57202. * @returns Vector2
  57203. */
  57204. private _getFrameOffset;
  57205. /**
  57206. * Updates a Mesh to the frame data
  57207. * @param mesh that is the target
  57208. * @param frameID or the frame index
  57209. */
  57210. private _updateMeshUV;
  57211. /**
  57212. * Updates a Meshes materials to use the texture packer channels
  57213. * @param m is the mesh to target
  57214. * @param force all channels on the packer to be set.
  57215. */
  57216. private _updateTextureReferences;
  57217. /**
  57218. * Public method to set a Mesh to a frame
  57219. * @param m that is the target
  57220. * @param frameID or the frame index
  57221. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  57222. */
  57223. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  57224. /**
  57225. * Starts the async promise to compile the texture packer.
  57226. * @returns Promise<void>
  57227. */
  57228. processAsync(): Promise<void>;
  57229. /**
  57230. * Disposes all textures associated with this packer
  57231. */
  57232. dispose(): void;
  57233. /**
  57234. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  57235. * @param imageType is the image type to use.
  57236. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  57237. */
  57238. download(imageType?: string, quality?: number): void;
  57239. /**
  57240. * Public method to load a texturePacker JSON file.
  57241. * @param data of the JSON file in string format.
  57242. */
  57243. updateFromJSON(data: string): void;
  57244. }
  57245. }
  57246. declare module BABYLON {
  57247. /**
  57248. * Enum used to define the target of a block
  57249. */
  57250. export enum NodeMaterialBlockTargets {
  57251. /** Vertex shader */
  57252. Vertex = 1,
  57253. /** Fragment shader */
  57254. Fragment = 2,
  57255. /** Neutral */
  57256. Neutral = 4,
  57257. /** Vertex and Fragment */
  57258. VertexAndFragment = 3
  57259. }
  57260. }
  57261. declare module BABYLON {
  57262. /**
  57263. * Defines the kind of connection point for node based material
  57264. */
  57265. export enum NodeMaterialBlockConnectionPointTypes {
  57266. /** Float */
  57267. Float = 1,
  57268. /** Int */
  57269. Int = 2,
  57270. /** Vector2 */
  57271. Vector2 = 4,
  57272. /** Vector3 */
  57273. Vector3 = 8,
  57274. /** Vector4 */
  57275. Vector4 = 16,
  57276. /** Color3 */
  57277. Color3 = 32,
  57278. /** Color4 */
  57279. Color4 = 64,
  57280. /** Matrix */
  57281. Matrix = 128,
  57282. /** Detect type based on connection */
  57283. AutoDetect = 1024,
  57284. /** Output type that will be defined by input type */
  57285. BasedOnInput = 2048
  57286. }
  57287. }
  57288. declare module BABYLON {
  57289. /**
  57290. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  57291. */
  57292. export enum NodeMaterialBlockConnectionPointMode {
  57293. /** Value is an uniform */
  57294. Uniform = 0,
  57295. /** Value is a mesh attribute */
  57296. Attribute = 1,
  57297. /** Value is a varying between vertex and fragment shaders */
  57298. Varying = 2,
  57299. /** Mode is undefined */
  57300. Undefined = 3
  57301. }
  57302. }
  57303. declare module BABYLON {
  57304. /**
  57305. * Enum used to define system values e.g. values automatically provided by the system
  57306. */
  57307. export enum NodeMaterialSystemValues {
  57308. /** World */
  57309. World = 1,
  57310. /** View */
  57311. View = 2,
  57312. /** Projection */
  57313. Projection = 3,
  57314. /** ViewProjection */
  57315. ViewProjection = 4,
  57316. /** WorldView */
  57317. WorldView = 5,
  57318. /** WorldViewProjection */
  57319. WorldViewProjection = 6,
  57320. /** CameraPosition */
  57321. CameraPosition = 7,
  57322. /** Fog Color */
  57323. FogColor = 8,
  57324. /** Delta time */
  57325. DeltaTime = 9
  57326. }
  57327. }
  57328. declare module BABYLON {
  57329. /**
  57330. * Root class for all node material optimizers
  57331. */
  57332. export class NodeMaterialOptimizer {
  57333. /**
  57334. * Function used to optimize a NodeMaterial graph
  57335. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  57336. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  57337. */
  57338. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  57339. }
  57340. }
  57341. declare module BABYLON {
  57342. /**
  57343. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  57344. */
  57345. export class TransformBlock extends NodeMaterialBlock {
  57346. /**
  57347. * Defines the value to use to complement W value to transform it to a Vector4
  57348. */
  57349. complementW: number;
  57350. /**
  57351. * Defines the value to use to complement z value to transform it to a Vector4
  57352. */
  57353. complementZ: number;
  57354. /**
  57355. * Creates a new TransformBlock
  57356. * @param name defines the block name
  57357. */
  57358. constructor(name: string);
  57359. /**
  57360. * Gets the current class name
  57361. * @returns the class name
  57362. */
  57363. getClassName(): string;
  57364. /**
  57365. * Gets the vector input
  57366. */
  57367. get vector(): NodeMaterialConnectionPoint;
  57368. /**
  57369. * Gets the output component
  57370. */
  57371. get output(): NodeMaterialConnectionPoint;
  57372. /**
  57373. * Gets the xyz output component
  57374. */
  57375. get xyz(): NodeMaterialConnectionPoint;
  57376. /**
  57377. * Gets the matrix transform input
  57378. */
  57379. get transform(): NodeMaterialConnectionPoint;
  57380. protected _buildBlock(state: NodeMaterialBuildState): this;
  57381. serialize(): any;
  57382. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57383. protected _dumpPropertiesCode(): string;
  57384. }
  57385. }
  57386. declare module BABYLON {
  57387. /**
  57388. * Block used to output the vertex position
  57389. */
  57390. export class VertexOutputBlock extends NodeMaterialBlock {
  57391. /**
  57392. * Creates a new VertexOutputBlock
  57393. * @param name defines the block name
  57394. */
  57395. constructor(name: string);
  57396. /**
  57397. * Gets the current class name
  57398. * @returns the class name
  57399. */
  57400. getClassName(): string;
  57401. /**
  57402. * Gets the vector input component
  57403. */
  57404. get vector(): NodeMaterialConnectionPoint;
  57405. protected _buildBlock(state: NodeMaterialBuildState): this;
  57406. }
  57407. }
  57408. declare module BABYLON {
  57409. /**
  57410. * Block used to output the final color
  57411. */
  57412. export class FragmentOutputBlock extends NodeMaterialBlock {
  57413. /**
  57414. * Create a new FragmentOutputBlock
  57415. * @param name defines the block name
  57416. */
  57417. constructor(name: string);
  57418. /**
  57419. * Gets the current class name
  57420. * @returns the class name
  57421. */
  57422. getClassName(): string;
  57423. /**
  57424. * Gets the rgba input component
  57425. */
  57426. get rgba(): NodeMaterialConnectionPoint;
  57427. /**
  57428. * Gets the rgb input component
  57429. */
  57430. get rgb(): NodeMaterialConnectionPoint;
  57431. /**
  57432. * Gets the a input component
  57433. */
  57434. get a(): NodeMaterialConnectionPoint;
  57435. protected _buildBlock(state: NodeMaterialBuildState): this;
  57436. }
  57437. }
  57438. declare module BABYLON {
  57439. /**
  57440. * Block used to read a reflection texture from a sampler
  57441. */
  57442. export class ReflectionTextureBlock extends NodeMaterialBlock {
  57443. private _define3DName;
  57444. private _defineCubicName;
  57445. private _defineExplicitName;
  57446. private _defineProjectionName;
  57447. private _defineLocalCubicName;
  57448. private _defineSphericalName;
  57449. private _definePlanarName;
  57450. private _defineEquirectangularName;
  57451. private _defineMirroredEquirectangularFixedName;
  57452. private _defineEquirectangularFixedName;
  57453. private _defineSkyboxName;
  57454. private _cubeSamplerName;
  57455. private _2DSamplerName;
  57456. private _positionUVWName;
  57457. private _directionWName;
  57458. private _reflectionCoordsName;
  57459. private _reflection2DCoordsName;
  57460. private _reflectionColorName;
  57461. private _reflectionMatrixName;
  57462. /**
  57463. * Gets or sets the texture associated with the node
  57464. */
  57465. texture: Nullable<BaseTexture>;
  57466. /**
  57467. * Create a new TextureBlock
  57468. * @param name defines the block name
  57469. */
  57470. constructor(name: string);
  57471. /**
  57472. * Gets the current class name
  57473. * @returns the class name
  57474. */
  57475. getClassName(): string;
  57476. /**
  57477. * Gets the world position input component
  57478. */
  57479. get position(): NodeMaterialConnectionPoint;
  57480. /**
  57481. * Gets the world position input component
  57482. */
  57483. get worldPosition(): NodeMaterialConnectionPoint;
  57484. /**
  57485. * Gets the world normal input component
  57486. */
  57487. get worldNormal(): NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the world input component
  57490. */
  57491. get world(): NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the camera (or eye) position component
  57494. */
  57495. get cameraPosition(): NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the view input component
  57498. */
  57499. get view(): NodeMaterialConnectionPoint;
  57500. /**
  57501. * Gets the rgb output component
  57502. */
  57503. get rgb(): NodeMaterialConnectionPoint;
  57504. /**
  57505. * Gets the r output component
  57506. */
  57507. get r(): NodeMaterialConnectionPoint;
  57508. /**
  57509. * Gets the g output component
  57510. */
  57511. get g(): NodeMaterialConnectionPoint;
  57512. /**
  57513. * Gets the b output component
  57514. */
  57515. get b(): NodeMaterialConnectionPoint;
  57516. autoConfigure(material: NodeMaterial): void;
  57517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57518. isReady(): boolean;
  57519. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57520. private _injectVertexCode;
  57521. private _writeOutput;
  57522. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57523. protected _dumpPropertiesCode(): string;
  57524. serialize(): any;
  57525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57526. }
  57527. }
  57528. declare module BABYLON {
  57529. /**
  57530. * Interface used to configure the node material editor
  57531. */
  57532. export interface INodeMaterialEditorOptions {
  57533. /** Define the URl to load node editor script */
  57534. editorURL?: string;
  57535. }
  57536. /** @hidden */
  57537. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57538. NORMAL: boolean;
  57539. TANGENT: boolean;
  57540. UV1: boolean;
  57541. /** BONES */
  57542. NUM_BONE_INFLUENCERS: number;
  57543. BonesPerMesh: number;
  57544. BONETEXTURE: boolean;
  57545. /** MORPH TARGETS */
  57546. MORPHTARGETS: boolean;
  57547. MORPHTARGETS_NORMAL: boolean;
  57548. MORPHTARGETS_TANGENT: boolean;
  57549. MORPHTARGETS_UV: boolean;
  57550. NUM_MORPH_INFLUENCERS: number;
  57551. /** IMAGE PROCESSING */
  57552. IMAGEPROCESSING: boolean;
  57553. VIGNETTE: boolean;
  57554. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57555. VIGNETTEBLENDMODEOPAQUE: boolean;
  57556. TONEMAPPING: boolean;
  57557. TONEMAPPING_ACES: boolean;
  57558. CONTRAST: boolean;
  57559. EXPOSURE: boolean;
  57560. COLORCURVES: boolean;
  57561. COLORGRADING: boolean;
  57562. COLORGRADING3D: boolean;
  57563. SAMPLER3DGREENDEPTH: boolean;
  57564. SAMPLER3DBGRMAP: boolean;
  57565. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57566. /** MISC. */
  57567. BUMPDIRECTUV: number;
  57568. constructor();
  57569. setValue(name: string, value: boolean): void;
  57570. }
  57571. /**
  57572. * Class used to configure NodeMaterial
  57573. */
  57574. export interface INodeMaterialOptions {
  57575. /**
  57576. * Defines if blocks should emit comments
  57577. */
  57578. emitComments: boolean;
  57579. }
  57580. /**
  57581. * Class used to create a node based material built by assembling shader blocks
  57582. */
  57583. export class NodeMaterial extends PushMaterial {
  57584. private static _BuildIdGenerator;
  57585. private _options;
  57586. private _vertexCompilationState;
  57587. private _fragmentCompilationState;
  57588. private _sharedData;
  57589. private _buildId;
  57590. private _buildWasSuccessful;
  57591. private _cachedWorldViewMatrix;
  57592. private _cachedWorldViewProjectionMatrix;
  57593. private _optimizers;
  57594. private _animationFrame;
  57595. /** Define the Url to load node editor script */
  57596. static EditorURL: string;
  57597. /** Define the Url to load snippets */
  57598. static SnippetUrl: string;
  57599. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  57600. static IgnoreTexturesAtLoadTime: boolean;
  57601. private BJSNODEMATERIALEDITOR;
  57602. /** Get the inspector from bundle or global */
  57603. private _getGlobalNodeMaterialEditor;
  57604. /**
  57605. * Snippet ID if the material was created from the snippet server
  57606. */
  57607. snippetId: string;
  57608. /**
  57609. * Gets or sets data used by visual editor
  57610. * @see https://nme.babylonjs.com
  57611. */
  57612. editorData: any;
  57613. /**
  57614. * 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)
  57615. */
  57616. ignoreAlpha: boolean;
  57617. /**
  57618. * Defines the maximum number of lights that can be used in the material
  57619. */
  57620. maxSimultaneousLights: number;
  57621. /**
  57622. * Observable raised when the material is built
  57623. */
  57624. onBuildObservable: Observable<NodeMaterial>;
  57625. /**
  57626. * Gets or sets the root nodes of the material vertex shader
  57627. */
  57628. _vertexOutputNodes: NodeMaterialBlock[];
  57629. /**
  57630. * Gets or sets the root nodes of the material fragment (pixel) shader
  57631. */
  57632. _fragmentOutputNodes: NodeMaterialBlock[];
  57633. /** Gets or sets options to control the node material overall behavior */
  57634. get options(): INodeMaterialOptions;
  57635. set options(options: INodeMaterialOptions);
  57636. /**
  57637. * Default configuration related to image processing available in the standard Material.
  57638. */
  57639. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57640. /**
  57641. * Gets the image processing configuration used either in this material.
  57642. */
  57643. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57644. /**
  57645. * Sets the Default image processing configuration used either in the this material.
  57646. *
  57647. * If sets to null, the scene one is in use.
  57648. */
  57649. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57650. /**
  57651. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57652. */
  57653. attachedBlocks: NodeMaterialBlock[];
  57654. /**
  57655. * Create a new node based material
  57656. * @param name defines the material name
  57657. * @param scene defines the hosting scene
  57658. * @param options defines creation option
  57659. */
  57660. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57661. /**
  57662. * Gets the current class name of the material e.g. "NodeMaterial"
  57663. * @returns the class name
  57664. */
  57665. getClassName(): string;
  57666. /**
  57667. * Keep track of the image processing observer to allow dispose and replace.
  57668. */
  57669. private _imageProcessingObserver;
  57670. /**
  57671. * Attaches a new image processing configuration to the Standard Material.
  57672. * @param configuration
  57673. */
  57674. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57675. /**
  57676. * Get a block by its name
  57677. * @param name defines the name of the block to retrieve
  57678. * @returns the required block or null if not found
  57679. */
  57680. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57681. /**
  57682. * Get a block by its name
  57683. * @param predicate defines the predicate used to find the good candidate
  57684. * @returns the required block or null if not found
  57685. */
  57686. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57687. /**
  57688. * Get an input block by its name
  57689. * @param predicate defines the predicate used to find the good candidate
  57690. * @returns the required input block or null if not found
  57691. */
  57692. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57693. /**
  57694. * Gets the list of input blocks attached to this material
  57695. * @returns an array of InputBlocks
  57696. */
  57697. getInputBlocks(): InputBlock[];
  57698. /**
  57699. * Adds a new optimizer to the list of optimizers
  57700. * @param optimizer defines the optimizers to add
  57701. * @returns the current material
  57702. */
  57703. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57704. /**
  57705. * Remove an optimizer from the list of optimizers
  57706. * @param optimizer defines the optimizers to remove
  57707. * @returns the current material
  57708. */
  57709. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57710. /**
  57711. * Add a new block to the list of output nodes
  57712. * @param node defines the node to add
  57713. * @returns the current material
  57714. */
  57715. addOutputNode(node: NodeMaterialBlock): this;
  57716. /**
  57717. * Remove a block from the list of root nodes
  57718. * @param node defines the node to remove
  57719. * @returns the current material
  57720. */
  57721. removeOutputNode(node: NodeMaterialBlock): this;
  57722. private _addVertexOutputNode;
  57723. private _removeVertexOutputNode;
  57724. private _addFragmentOutputNode;
  57725. private _removeFragmentOutputNode;
  57726. /**
  57727. * Specifies if the material will require alpha blending
  57728. * @returns a boolean specifying if alpha blending is needed
  57729. */
  57730. needAlphaBlending(): boolean;
  57731. /**
  57732. * Specifies if this material should be rendered in alpha test mode
  57733. * @returns a boolean specifying if an alpha test is needed.
  57734. */
  57735. needAlphaTesting(): boolean;
  57736. private _initializeBlock;
  57737. private _resetDualBlocks;
  57738. /**
  57739. * Remove a block from the current node material
  57740. * @param block defines the block to remove
  57741. */
  57742. removeBlock(block: NodeMaterialBlock): void;
  57743. /**
  57744. * Build the material and generates the inner effect
  57745. * @param verbose defines if the build should log activity
  57746. */
  57747. build(verbose?: boolean): void;
  57748. /**
  57749. * Runs an otpimization phase to try to improve the shader code
  57750. */
  57751. optimize(): void;
  57752. private _prepareDefinesForAttributes;
  57753. /**
  57754. * Get if the submesh is ready to be used and all its information available.
  57755. * Child classes can use it to update shaders
  57756. * @param mesh defines the mesh to check
  57757. * @param subMesh defines which submesh to check
  57758. * @param useInstances specifies that instances should be used
  57759. * @returns a boolean indicating that the submesh is ready or not
  57760. */
  57761. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57762. /**
  57763. * Get a string representing the shaders built by the current node graph
  57764. */
  57765. get compiledShaders(): string;
  57766. /**
  57767. * Binds the world matrix to the material
  57768. * @param world defines the world transformation matrix
  57769. */
  57770. bindOnlyWorldMatrix(world: Matrix): void;
  57771. /**
  57772. * Binds the submesh to this material by preparing the effect and shader to draw
  57773. * @param world defines the world transformation matrix
  57774. * @param mesh defines the mesh containing the submesh
  57775. * @param subMesh defines the submesh to bind the material to
  57776. */
  57777. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57778. /**
  57779. * Gets the active textures from the material
  57780. * @returns an array of textures
  57781. */
  57782. getActiveTextures(): BaseTexture[];
  57783. /**
  57784. * Gets the list of texture blocks
  57785. * @returns an array of texture blocks
  57786. */
  57787. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57788. /**
  57789. * Specifies if the material uses a texture
  57790. * @param texture defines the texture to check against the material
  57791. * @returns a boolean specifying if the material uses the texture
  57792. */
  57793. hasTexture(texture: BaseTexture): boolean;
  57794. /**
  57795. * Disposes the material
  57796. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57797. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57798. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57799. */
  57800. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57801. /** Creates the node editor window. */
  57802. private _createNodeEditor;
  57803. /**
  57804. * Launch the node material editor
  57805. * @param config Define the configuration of the editor
  57806. * @return a promise fulfilled when the node editor is visible
  57807. */
  57808. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57809. /**
  57810. * Clear the current material
  57811. */
  57812. clear(): void;
  57813. /**
  57814. * Clear the current material and set it to a default state
  57815. */
  57816. setToDefault(): void;
  57817. /**
  57818. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57819. * @param url defines the url to load from
  57820. * @returns a promise that will fullfil when the material is fully loaded
  57821. */
  57822. loadAsync(url: string): Promise<void>;
  57823. private _gatherBlocks;
  57824. /**
  57825. * Generate a string containing the code declaration required to create an equivalent of this material
  57826. * @returns a string
  57827. */
  57828. generateCode(): string;
  57829. /**
  57830. * Serializes this material in a JSON representation
  57831. * @returns the serialized material object
  57832. */
  57833. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57834. private _restoreConnections;
  57835. /**
  57836. * Clear the current graph and load a new one from a serialization object
  57837. * @param source defines the JSON representation of the material
  57838. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57839. */
  57840. loadFromSerialization(source: any, rootUrl?: string): void;
  57841. /**
  57842. * Makes a duplicate of the current material.
  57843. * @param name - name to use for the new material.
  57844. */
  57845. clone(name: string): NodeMaterial;
  57846. /**
  57847. * Creates a node material from parsed material data
  57848. * @param source defines the JSON representation of the material
  57849. * @param scene defines the hosting scene
  57850. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57851. * @returns a new node material
  57852. */
  57853. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57854. /**
  57855. * Creates a node material from a snippet saved in a remote file
  57856. * @param name defines the name of the material to create
  57857. * @param url defines the url to load from
  57858. * @param scene defines the hosting scene
  57859. * @returns a promise that will resolve to the new node material
  57860. */
  57861. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57862. /**
  57863. * Creates a node material from a snippet saved by the node material editor
  57864. * @param snippetId defines the snippet to load
  57865. * @param scene defines the hosting scene
  57866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57867. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  57868. * @returns a promise that will resolve to the new node material
  57869. */
  57870. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  57871. /**
  57872. * Creates a new node material set to default basic configuration
  57873. * @param name defines the name of the material
  57874. * @param scene defines the hosting scene
  57875. * @returns a new NodeMaterial
  57876. */
  57877. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57878. }
  57879. }
  57880. declare module BABYLON {
  57881. /**
  57882. * Block used to read a texture from a sampler
  57883. */
  57884. export class TextureBlock extends NodeMaterialBlock {
  57885. private _defineName;
  57886. private _linearDefineName;
  57887. private _tempTextureRead;
  57888. private _samplerName;
  57889. private _transformedUVName;
  57890. private _textureTransformName;
  57891. private _textureInfoName;
  57892. private _mainUVName;
  57893. private _mainUVDefineName;
  57894. /**
  57895. * Gets or sets the texture associated with the node
  57896. */
  57897. texture: Nullable<Texture>;
  57898. /**
  57899. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57900. */
  57901. convertToGammaSpace: boolean;
  57902. /**
  57903. * Create a new TextureBlock
  57904. * @param name defines the block name
  57905. */
  57906. constructor(name: string);
  57907. /**
  57908. * Gets the current class name
  57909. * @returns the class name
  57910. */
  57911. getClassName(): string;
  57912. /**
  57913. * Gets the uv input component
  57914. */
  57915. get uv(): NodeMaterialConnectionPoint;
  57916. /**
  57917. * Gets the rgba output component
  57918. */
  57919. get rgba(): NodeMaterialConnectionPoint;
  57920. /**
  57921. * Gets the rgb output component
  57922. */
  57923. get rgb(): NodeMaterialConnectionPoint;
  57924. /**
  57925. * Gets the r output component
  57926. */
  57927. get r(): NodeMaterialConnectionPoint;
  57928. /**
  57929. * Gets the g output component
  57930. */
  57931. get g(): NodeMaterialConnectionPoint;
  57932. /**
  57933. * Gets the b output component
  57934. */
  57935. get b(): NodeMaterialConnectionPoint;
  57936. /**
  57937. * Gets the a output component
  57938. */
  57939. get a(): NodeMaterialConnectionPoint;
  57940. get target(): NodeMaterialBlockTargets;
  57941. autoConfigure(material: NodeMaterial): void;
  57942. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57943. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57944. isReady(): boolean;
  57945. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57946. private get _isMixed();
  57947. private _injectVertexCode;
  57948. private _writeTextureRead;
  57949. private _writeOutput;
  57950. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57951. protected _dumpPropertiesCode(): string;
  57952. serialize(): any;
  57953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57954. }
  57955. }
  57956. declare module BABYLON {
  57957. /**
  57958. * Class used to store shared data between 2 NodeMaterialBuildState
  57959. */
  57960. export class NodeMaterialBuildStateSharedData {
  57961. /**
  57962. * Gets the list of emitted varyings
  57963. */
  57964. temps: string[];
  57965. /**
  57966. * Gets the list of emitted varyings
  57967. */
  57968. varyings: string[];
  57969. /**
  57970. * Gets the varying declaration string
  57971. */
  57972. varyingDeclaration: string;
  57973. /**
  57974. * Input blocks
  57975. */
  57976. inputBlocks: InputBlock[];
  57977. /**
  57978. * Input blocks
  57979. */
  57980. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57981. /**
  57982. * Bindable blocks (Blocks that need to set data to the effect)
  57983. */
  57984. bindableBlocks: NodeMaterialBlock[];
  57985. /**
  57986. * List of blocks that can provide a compilation fallback
  57987. */
  57988. blocksWithFallbacks: NodeMaterialBlock[];
  57989. /**
  57990. * List of blocks that can provide a define update
  57991. */
  57992. blocksWithDefines: NodeMaterialBlock[];
  57993. /**
  57994. * List of blocks that can provide a repeatable content
  57995. */
  57996. repeatableContentBlocks: NodeMaterialBlock[];
  57997. /**
  57998. * List of blocks that can provide a dynamic list of uniforms
  57999. */
  58000. dynamicUniformBlocks: NodeMaterialBlock[];
  58001. /**
  58002. * List of blocks that can block the isReady function for the material
  58003. */
  58004. blockingBlocks: NodeMaterialBlock[];
  58005. /**
  58006. * Gets the list of animated inputs
  58007. */
  58008. animatedInputs: InputBlock[];
  58009. /**
  58010. * Build Id used to avoid multiple recompilations
  58011. */
  58012. buildId: number;
  58013. /** List of emitted variables */
  58014. variableNames: {
  58015. [key: string]: number;
  58016. };
  58017. /** List of emitted defines */
  58018. defineNames: {
  58019. [key: string]: number;
  58020. };
  58021. /** Should emit comments? */
  58022. emitComments: boolean;
  58023. /** Emit build activity */
  58024. verbose: boolean;
  58025. /** Gets or sets the hosting scene */
  58026. scene: Scene;
  58027. /**
  58028. * Gets the compilation hints emitted at compilation time
  58029. */
  58030. hints: {
  58031. needWorldViewMatrix: boolean;
  58032. needWorldViewProjectionMatrix: boolean;
  58033. needAlphaBlending: boolean;
  58034. needAlphaTesting: boolean;
  58035. };
  58036. /**
  58037. * List of compilation checks
  58038. */
  58039. checks: {
  58040. emitVertex: boolean;
  58041. emitFragment: boolean;
  58042. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  58043. };
  58044. /** Creates a new shared data */
  58045. constructor();
  58046. /**
  58047. * Emits console errors and exceptions if there is a failing check
  58048. */
  58049. emitErrors(): void;
  58050. }
  58051. }
  58052. declare module BABYLON {
  58053. /**
  58054. * Class used to store node based material build state
  58055. */
  58056. export class NodeMaterialBuildState {
  58057. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  58058. supportUniformBuffers: boolean;
  58059. /**
  58060. * Gets the list of emitted attributes
  58061. */
  58062. attributes: string[];
  58063. /**
  58064. * Gets the list of emitted uniforms
  58065. */
  58066. uniforms: string[];
  58067. /**
  58068. * Gets the list of emitted constants
  58069. */
  58070. constants: string[];
  58071. /**
  58072. * Gets the list of emitted samplers
  58073. */
  58074. samplers: string[];
  58075. /**
  58076. * Gets the list of emitted functions
  58077. */
  58078. functions: {
  58079. [key: string]: string;
  58080. };
  58081. /**
  58082. * Gets the list of emitted extensions
  58083. */
  58084. extensions: {
  58085. [key: string]: string;
  58086. };
  58087. /**
  58088. * Gets the target of the compilation state
  58089. */
  58090. target: NodeMaterialBlockTargets;
  58091. /**
  58092. * Gets the list of emitted counters
  58093. */
  58094. counters: {
  58095. [key: string]: number;
  58096. };
  58097. /**
  58098. * Shared data between multiple NodeMaterialBuildState instances
  58099. */
  58100. sharedData: NodeMaterialBuildStateSharedData;
  58101. /** @hidden */
  58102. _vertexState: NodeMaterialBuildState;
  58103. /** @hidden */
  58104. _attributeDeclaration: string;
  58105. /** @hidden */
  58106. _uniformDeclaration: string;
  58107. /** @hidden */
  58108. _constantDeclaration: string;
  58109. /** @hidden */
  58110. _samplerDeclaration: string;
  58111. /** @hidden */
  58112. _varyingTransfer: string;
  58113. private _repeatableContentAnchorIndex;
  58114. /** @hidden */
  58115. _builtCompilationString: string;
  58116. /**
  58117. * Gets the emitted compilation strings
  58118. */
  58119. compilationString: string;
  58120. /**
  58121. * Finalize the compilation strings
  58122. * @param state defines the current compilation state
  58123. */
  58124. finalize(state: NodeMaterialBuildState): void;
  58125. /** @hidden */
  58126. get _repeatableContentAnchor(): string;
  58127. /** @hidden */
  58128. _getFreeVariableName(prefix: string): string;
  58129. /** @hidden */
  58130. _getFreeDefineName(prefix: string): string;
  58131. /** @hidden */
  58132. _excludeVariableName(name: string): void;
  58133. /** @hidden */
  58134. _emit2DSampler(name: string): void;
  58135. /** @hidden */
  58136. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  58137. /** @hidden */
  58138. _emitExtension(name: string, extension: string): void;
  58139. /** @hidden */
  58140. _emitFunction(name: string, code: string, comments: string): void;
  58141. /** @hidden */
  58142. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  58143. replaceStrings?: {
  58144. search: RegExp;
  58145. replace: string;
  58146. }[];
  58147. repeatKey?: string;
  58148. }): string;
  58149. /** @hidden */
  58150. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  58151. repeatKey?: string;
  58152. removeAttributes?: boolean;
  58153. removeUniforms?: boolean;
  58154. removeVaryings?: boolean;
  58155. removeIfDef?: boolean;
  58156. replaceStrings?: {
  58157. search: RegExp;
  58158. replace: string;
  58159. }[];
  58160. }, storeKey?: string): void;
  58161. /** @hidden */
  58162. _registerTempVariable(name: string): boolean;
  58163. /** @hidden */
  58164. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  58165. /** @hidden */
  58166. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  58167. /** @hidden */
  58168. _emitFloat(value: number): string;
  58169. }
  58170. }
  58171. declare module BABYLON {
  58172. /**
  58173. * Defines a block that can be used inside a node based material
  58174. */
  58175. export class NodeMaterialBlock {
  58176. private _buildId;
  58177. private _buildTarget;
  58178. private _target;
  58179. private _isFinalMerger;
  58180. private _isInput;
  58181. protected _isUnique: boolean;
  58182. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  58183. inputsAreExclusive: boolean;
  58184. /** @hidden */
  58185. _codeVariableName: string;
  58186. /** @hidden */
  58187. _inputs: NodeMaterialConnectionPoint[];
  58188. /** @hidden */
  58189. _outputs: NodeMaterialConnectionPoint[];
  58190. /** @hidden */
  58191. _preparationId: number;
  58192. /**
  58193. * Gets or sets the name of the block
  58194. */
  58195. name: string;
  58196. /**
  58197. * Gets or sets the unique id of the node
  58198. */
  58199. uniqueId: number;
  58200. /**
  58201. * Gets or sets the comments associated with this block
  58202. */
  58203. comments: string;
  58204. /**
  58205. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  58206. */
  58207. get isUnique(): boolean;
  58208. /**
  58209. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  58210. */
  58211. get isFinalMerger(): boolean;
  58212. /**
  58213. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  58214. */
  58215. get isInput(): boolean;
  58216. /**
  58217. * Gets or sets the build Id
  58218. */
  58219. get buildId(): number;
  58220. set buildId(value: number);
  58221. /**
  58222. * Gets or sets the target of the block
  58223. */
  58224. get target(): NodeMaterialBlockTargets;
  58225. set target(value: NodeMaterialBlockTargets);
  58226. /**
  58227. * Gets the list of input points
  58228. */
  58229. get inputs(): NodeMaterialConnectionPoint[];
  58230. /** Gets the list of output points */
  58231. get outputs(): NodeMaterialConnectionPoint[];
  58232. /**
  58233. * Find an input by its name
  58234. * @param name defines the name of the input to look for
  58235. * @returns the input or null if not found
  58236. */
  58237. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58238. /**
  58239. * Find an output by its name
  58240. * @param name defines the name of the outputto look for
  58241. * @returns the output or null if not found
  58242. */
  58243. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  58244. /**
  58245. * Creates a new NodeMaterialBlock
  58246. * @param name defines the block name
  58247. * @param target defines the target of that block (Vertex by default)
  58248. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  58249. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  58250. */
  58251. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  58252. /**
  58253. * Initialize the block and prepare the context for build
  58254. * @param state defines the state that will be used for the build
  58255. */
  58256. initialize(state: NodeMaterialBuildState): void;
  58257. /**
  58258. * Bind data to effect. Will only be called for blocks with isBindable === true
  58259. * @param effect defines the effect to bind data to
  58260. * @param nodeMaterial defines the hosting NodeMaterial
  58261. * @param mesh defines the mesh that will be rendered
  58262. */
  58263. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58264. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  58265. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  58266. protected _writeFloat(value: number): string;
  58267. /**
  58268. * Gets the current class name e.g. "NodeMaterialBlock"
  58269. * @returns the class name
  58270. */
  58271. getClassName(): string;
  58272. /**
  58273. * Register a new input. Must be called inside a block constructor
  58274. * @param name defines the connection point name
  58275. * @param type defines the connection point type
  58276. * @param isOptional defines a boolean indicating that this input can be omitted
  58277. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58278. * @returns the current block
  58279. */
  58280. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  58281. /**
  58282. * Register a new output. Must be called inside a block constructor
  58283. * @param name defines the connection point name
  58284. * @param type defines the connection point type
  58285. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  58286. * @returns the current block
  58287. */
  58288. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  58289. /**
  58290. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  58291. * @param forOutput defines an optional connection point to check compatibility with
  58292. * @returns the first available input or null
  58293. */
  58294. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  58295. /**
  58296. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  58297. * @param forBlock defines an optional block to check compatibility with
  58298. * @returns the first available input or null
  58299. */
  58300. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  58301. /**
  58302. * Gets the sibling of the given output
  58303. * @param current defines the current output
  58304. * @returns the next output in the list or null
  58305. */
  58306. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  58307. /**
  58308. * Connect current block with another block
  58309. * @param other defines the block to connect with
  58310. * @param options define the various options to help pick the right connections
  58311. * @returns the current block
  58312. */
  58313. connectTo(other: NodeMaterialBlock, options?: {
  58314. input?: string;
  58315. output?: string;
  58316. outputSwizzle?: string;
  58317. }): this | undefined;
  58318. protected _buildBlock(state: NodeMaterialBuildState): void;
  58319. /**
  58320. * Add uniforms, samplers and uniform buffers at compilation time
  58321. * @param state defines the state to update
  58322. * @param nodeMaterial defines the node material requesting the update
  58323. * @param defines defines the material defines to update
  58324. * @param uniformBuffers defines the list of uniform buffer names
  58325. */
  58326. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58327. /**
  58328. * Add potential fallbacks if shader compilation fails
  58329. * @param mesh defines the mesh to be rendered
  58330. * @param fallbacks defines the current prioritized list of fallbacks
  58331. */
  58332. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58333. /**
  58334. * Initialize defines for shader compilation
  58335. * @param mesh defines the mesh to be rendered
  58336. * @param nodeMaterial defines the node material requesting the update
  58337. * @param defines defines the material defines to update
  58338. * @param useInstances specifies that instances should be used
  58339. */
  58340. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58341. /**
  58342. * Update defines for shader compilation
  58343. * @param mesh defines the mesh to be rendered
  58344. * @param nodeMaterial defines the node material requesting the update
  58345. * @param defines defines the material defines to update
  58346. * @param useInstances specifies that instances should be used
  58347. */
  58348. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58349. /**
  58350. * Lets the block try to connect some inputs automatically
  58351. * @param material defines the hosting NodeMaterial
  58352. */
  58353. autoConfigure(material: NodeMaterial): void;
  58354. /**
  58355. * Function called when a block is declared as repeatable content generator
  58356. * @param vertexShaderState defines the current compilation state for the vertex shader
  58357. * @param fragmentShaderState defines the current compilation state for the fragment shader
  58358. * @param mesh defines the mesh to be rendered
  58359. * @param defines defines the material defines to update
  58360. */
  58361. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58362. /**
  58363. * Checks if the block is ready
  58364. * @param mesh defines the mesh to be rendered
  58365. * @param nodeMaterial defines the node material requesting the update
  58366. * @param defines defines the material defines to update
  58367. * @param useInstances specifies that instances should be used
  58368. * @returns true if the block is ready
  58369. */
  58370. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  58371. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  58372. private _processBuild;
  58373. /**
  58374. * Compile the current node and generate the shader code
  58375. * @param state defines the current compilation state (uniforms, samplers, current string)
  58376. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  58377. * @returns true if already built
  58378. */
  58379. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  58380. protected _inputRename(name: string): string;
  58381. protected _outputRename(name: string): string;
  58382. protected _dumpPropertiesCode(): string;
  58383. /** @hidden */
  58384. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  58385. /** @hidden */
  58386. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  58387. /**
  58388. * Clone the current block to a new identical block
  58389. * @param scene defines the hosting scene
  58390. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58391. * @returns a copy of the current block
  58392. */
  58393. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  58394. /**
  58395. * Serializes this block in a JSON representation
  58396. * @returns the serialized block object
  58397. */
  58398. serialize(): any;
  58399. /** @hidden */
  58400. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58401. /**
  58402. * Release resources
  58403. */
  58404. dispose(): void;
  58405. }
  58406. }
  58407. declare module BABYLON {
  58408. /**
  58409. * Enum defining the type of animations supported by InputBlock
  58410. */
  58411. export enum AnimatedInputBlockTypes {
  58412. /** No animation */
  58413. None = 0,
  58414. /** Time based animation. Will only work for floats */
  58415. Time = 1
  58416. }
  58417. }
  58418. declare module BABYLON {
  58419. /**
  58420. * Block used to expose an input value
  58421. */
  58422. export class InputBlock extends NodeMaterialBlock {
  58423. private _mode;
  58424. private _associatedVariableName;
  58425. private _storedValue;
  58426. private _valueCallback;
  58427. private _type;
  58428. private _animationType;
  58429. /** Gets or set a value used to limit the range of float values */
  58430. min: number;
  58431. /** Gets or set a value used to limit the range of float values */
  58432. max: number;
  58433. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  58434. isBoolean: boolean;
  58435. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  58436. matrixMode: number;
  58437. /** @hidden */
  58438. _systemValue: Nullable<NodeMaterialSystemValues>;
  58439. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  58440. visibleInInspector: boolean;
  58441. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  58442. isConstant: boolean;
  58443. /** Gets or sets the group to use to display this block in the Inspector */
  58444. groupInInspector: string;
  58445. /** Gets an observable raised when the value is changed */
  58446. onValueChangedObservable: Observable<InputBlock>;
  58447. /**
  58448. * Gets or sets the connection point type (default is float)
  58449. */
  58450. get type(): NodeMaterialBlockConnectionPointTypes;
  58451. /**
  58452. * Creates a new InputBlock
  58453. * @param name defines the block name
  58454. * @param target defines the target of that block (Vertex by default)
  58455. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  58456. */
  58457. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  58458. /**
  58459. * Gets the output component
  58460. */
  58461. get output(): NodeMaterialConnectionPoint;
  58462. /**
  58463. * Set the source of this connection point to a vertex attribute
  58464. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  58465. * @returns the current connection point
  58466. */
  58467. setAsAttribute(attributeName?: string): InputBlock;
  58468. /**
  58469. * Set the source of this connection point to a system value
  58470. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  58471. * @returns the current connection point
  58472. */
  58473. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  58474. /**
  58475. * Gets or sets the value of that point.
  58476. * Please note that this value will be ignored if valueCallback is defined
  58477. */
  58478. get value(): any;
  58479. set value(value: any);
  58480. /**
  58481. * Gets or sets a callback used to get the value of that point.
  58482. * Please note that setting this value will force the connection point to ignore the value property
  58483. */
  58484. get valueCallback(): () => any;
  58485. set valueCallback(value: () => any);
  58486. /**
  58487. * Gets or sets the associated variable name in the shader
  58488. */
  58489. get associatedVariableName(): string;
  58490. set associatedVariableName(value: string);
  58491. /** Gets or sets the type of animation applied to the input */
  58492. get animationType(): AnimatedInputBlockTypes;
  58493. set animationType(value: AnimatedInputBlockTypes);
  58494. /**
  58495. * Gets a boolean indicating that this connection point not defined yet
  58496. */
  58497. get isUndefined(): boolean;
  58498. /**
  58499. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  58500. * In this case the connection point name must be the name of the uniform to use.
  58501. * Can only be set on inputs
  58502. */
  58503. get isUniform(): boolean;
  58504. set isUniform(value: boolean);
  58505. /**
  58506. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58507. * In this case the connection point name must be the name of the attribute to use
  58508. * Can only be set on inputs
  58509. */
  58510. get isAttribute(): boolean;
  58511. set isAttribute(value: boolean);
  58512. /**
  58513. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58514. * Can only be set on exit points
  58515. */
  58516. get isVarying(): boolean;
  58517. set isVarying(value: boolean);
  58518. /**
  58519. * Gets a boolean indicating that the current connection point is a system value
  58520. */
  58521. get isSystemValue(): boolean;
  58522. /**
  58523. * Gets or sets the current well known value or null if not defined as a system value
  58524. */
  58525. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58526. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58527. /**
  58528. * Gets the current class name
  58529. * @returns the class name
  58530. */
  58531. getClassName(): string;
  58532. /**
  58533. * Animate the input if animationType !== None
  58534. * @param scene defines the rendering scene
  58535. */
  58536. animate(scene: Scene): void;
  58537. private _emitDefine;
  58538. initialize(state: NodeMaterialBuildState): void;
  58539. /**
  58540. * Set the input block to its default value (based on its type)
  58541. */
  58542. setDefaultValue(): void;
  58543. private _emitConstant;
  58544. private _emit;
  58545. /** @hidden */
  58546. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58547. /** @hidden */
  58548. _transmit(effect: Effect, scene: Scene): void;
  58549. protected _buildBlock(state: NodeMaterialBuildState): void;
  58550. protected _dumpPropertiesCode(): string;
  58551. dispose(): void;
  58552. serialize(): any;
  58553. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58554. }
  58555. }
  58556. declare module BABYLON {
  58557. /**
  58558. * Enum used to define the compatibility state between two connection points
  58559. */
  58560. export enum NodeMaterialConnectionPointCompatibilityStates {
  58561. /** Points are compatibles */
  58562. Compatible = 0,
  58563. /** Points are incompatible because of their types */
  58564. TypeIncompatible = 1,
  58565. /** Points are incompatible because of their targets (vertex vs fragment) */
  58566. TargetIncompatible = 2
  58567. }
  58568. /**
  58569. * Defines the direction of a connection point
  58570. */
  58571. export enum NodeMaterialConnectionPointDirection {
  58572. /** Input */
  58573. Input = 0,
  58574. /** Output */
  58575. Output = 1
  58576. }
  58577. /**
  58578. * Defines a connection point for a block
  58579. */
  58580. export class NodeMaterialConnectionPoint {
  58581. /** @hidden */
  58582. _ownerBlock: NodeMaterialBlock;
  58583. /** @hidden */
  58584. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58585. private _endpoints;
  58586. private _associatedVariableName;
  58587. private _direction;
  58588. /** @hidden */
  58589. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58590. /** @hidden */
  58591. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58592. private _type;
  58593. /** @hidden */
  58594. _enforceAssociatedVariableName: boolean;
  58595. /** Gets the direction of the point */
  58596. get direction(): NodeMaterialConnectionPointDirection;
  58597. /**
  58598. * Gets or sets the additional types supported by this connection point
  58599. */
  58600. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58601. /**
  58602. * Gets or sets the additional types excluded by this connection point
  58603. */
  58604. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58605. /**
  58606. * Observable triggered when this point is connected
  58607. */
  58608. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58609. /**
  58610. * Gets or sets the associated variable name in the shader
  58611. */
  58612. get associatedVariableName(): string;
  58613. set associatedVariableName(value: string);
  58614. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  58615. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58616. /**
  58617. * Gets or sets the connection point type (default is float)
  58618. */
  58619. get type(): NodeMaterialBlockConnectionPointTypes;
  58620. set type(value: NodeMaterialBlockConnectionPointTypes);
  58621. /**
  58622. * Gets or sets the connection point name
  58623. */
  58624. name: string;
  58625. /**
  58626. * Gets or sets a boolean indicating that this connection point can be omitted
  58627. */
  58628. isOptional: boolean;
  58629. /**
  58630. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58631. */
  58632. define: string;
  58633. /** @hidden */
  58634. _prioritizeVertex: boolean;
  58635. private _target;
  58636. /** Gets or sets the target of that connection point */
  58637. get target(): NodeMaterialBlockTargets;
  58638. set target(value: NodeMaterialBlockTargets);
  58639. /**
  58640. * Gets a boolean indicating that the current point is connected
  58641. */
  58642. get isConnected(): boolean;
  58643. /**
  58644. * Gets a boolean indicating that the current point is connected to an input block
  58645. */
  58646. get isConnectedToInputBlock(): boolean;
  58647. /**
  58648. * Gets a the connected input block (if any)
  58649. */
  58650. get connectInputBlock(): Nullable<InputBlock>;
  58651. /** Get the other side of the connection (if any) */
  58652. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58653. /** Get the block that owns this connection point */
  58654. get ownerBlock(): NodeMaterialBlock;
  58655. /** Get the block connected on the other side of this connection (if any) */
  58656. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58657. /** Get the block connected on the endpoints of this connection (if any) */
  58658. get connectedBlocks(): Array<NodeMaterialBlock>;
  58659. /** Gets the list of connected endpoints */
  58660. get endpoints(): NodeMaterialConnectionPoint[];
  58661. /** Gets a boolean indicating if that output point is connected to at least one input */
  58662. get hasEndpoints(): boolean;
  58663. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58664. get isConnectedInVertexShader(): boolean;
  58665. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58666. get isConnectedInFragmentShader(): boolean;
  58667. /**
  58668. * Creates a new connection point
  58669. * @param name defines the connection point name
  58670. * @param ownerBlock defines the block hosting this connection point
  58671. * @param direction defines the direction of the connection point
  58672. */
  58673. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58674. /**
  58675. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58676. * @returns the class name
  58677. */
  58678. getClassName(): string;
  58679. /**
  58680. * Gets a boolean indicating if the current point can be connected to another point
  58681. * @param connectionPoint defines the other connection point
  58682. * @returns a boolean
  58683. */
  58684. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58685. /**
  58686. * Gets a number indicating if the current point can be connected to another point
  58687. * @param connectionPoint defines the other connection point
  58688. * @returns a number defining the compatibility state
  58689. */
  58690. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58691. /**
  58692. * Connect this point to another connection point
  58693. * @param connectionPoint defines the other connection point
  58694. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58695. * @returns the current connection point
  58696. */
  58697. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58698. /**
  58699. * Disconnect this point from one of his endpoint
  58700. * @param endpoint defines the other connection point
  58701. * @returns the current connection point
  58702. */
  58703. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58704. /**
  58705. * Serializes this point in a JSON representation
  58706. * @returns the serialized point object
  58707. */
  58708. serialize(): any;
  58709. /**
  58710. * Release resources
  58711. */
  58712. dispose(): void;
  58713. }
  58714. }
  58715. declare module BABYLON {
  58716. /**
  58717. * Block used to add support for vertex skinning (bones)
  58718. */
  58719. export class BonesBlock extends NodeMaterialBlock {
  58720. /**
  58721. * Creates a new BonesBlock
  58722. * @param name defines the block name
  58723. */
  58724. constructor(name: string);
  58725. /**
  58726. * Initialize the block and prepare the context for build
  58727. * @param state defines the state that will be used for the build
  58728. */
  58729. initialize(state: NodeMaterialBuildState): void;
  58730. /**
  58731. * Gets the current class name
  58732. * @returns the class name
  58733. */
  58734. getClassName(): string;
  58735. /**
  58736. * Gets the matrix indices input component
  58737. */
  58738. get matricesIndices(): NodeMaterialConnectionPoint;
  58739. /**
  58740. * Gets the matrix weights input component
  58741. */
  58742. get matricesWeights(): NodeMaterialConnectionPoint;
  58743. /**
  58744. * Gets the extra matrix indices input component
  58745. */
  58746. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58747. /**
  58748. * Gets the extra matrix weights input component
  58749. */
  58750. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58751. /**
  58752. * Gets the world input component
  58753. */
  58754. get world(): NodeMaterialConnectionPoint;
  58755. /**
  58756. * Gets the output component
  58757. */
  58758. get output(): NodeMaterialConnectionPoint;
  58759. autoConfigure(material: NodeMaterial): void;
  58760. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58761. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58763. protected _buildBlock(state: NodeMaterialBuildState): this;
  58764. }
  58765. }
  58766. declare module BABYLON {
  58767. /**
  58768. * Block used to add support for instances
  58769. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58770. */
  58771. export class InstancesBlock extends NodeMaterialBlock {
  58772. /**
  58773. * Creates a new InstancesBlock
  58774. * @param name defines the block name
  58775. */
  58776. constructor(name: string);
  58777. /**
  58778. * Gets the current class name
  58779. * @returns the class name
  58780. */
  58781. getClassName(): string;
  58782. /**
  58783. * Gets the first world row input component
  58784. */
  58785. get world0(): NodeMaterialConnectionPoint;
  58786. /**
  58787. * Gets the second world row input component
  58788. */
  58789. get world1(): NodeMaterialConnectionPoint;
  58790. /**
  58791. * Gets the third world row input component
  58792. */
  58793. get world2(): NodeMaterialConnectionPoint;
  58794. /**
  58795. * Gets the forth world row input component
  58796. */
  58797. get world3(): NodeMaterialConnectionPoint;
  58798. /**
  58799. * Gets the world input component
  58800. */
  58801. get world(): NodeMaterialConnectionPoint;
  58802. /**
  58803. * Gets the output component
  58804. */
  58805. get output(): NodeMaterialConnectionPoint;
  58806. /**
  58807. * Gets the isntanceID component
  58808. */
  58809. get instanceID(): NodeMaterialConnectionPoint;
  58810. autoConfigure(material: NodeMaterial): void;
  58811. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58812. protected _buildBlock(state: NodeMaterialBuildState): this;
  58813. }
  58814. }
  58815. declare module BABYLON {
  58816. /**
  58817. * Block used to add morph targets support to vertex shader
  58818. */
  58819. export class MorphTargetsBlock extends NodeMaterialBlock {
  58820. private _repeatableContentAnchor;
  58821. /**
  58822. * Create a new MorphTargetsBlock
  58823. * @param name defines the block name
  58824. */
  58825. constructor(name: string);
  58826. /**
  58827. * Gets the current class name
  58828. * @returns the class name
  58829. */
  58830. getClassName(): string;
  58831. /**
  58832. * Gets the position input component
  58833. */
  58834. get position(): NodeMaterialConnectionPoint;
  58835. /**
  58836. * Gets the normal input component
  58837. */
  58838. get normal(): NodeMaterialConnectionPoint;
  58839. /**
  58840. * Gets the tangent input component
  58841. */
  58842. get tangent(): NodeMaterialConnectionPoint;
  58843. /**
  58844. * Gets the tangent input component
  58845. */
  58846. get uv(): NodeMaterialConnectionPoint;
  58847. /**
  58848. * Gets the position output component
  58849. */
  58850. get positionOutput(): NodeMaterialConnectionPoint;
  58851. /**
  58852. * Gets the normal output component
  58853. */
  58854. get normalOutput(): NodeMaterialConnectionPoint;
  58855. /**
  58856. * Gets the tangent output component
  58857. */
  58858. get tangentOutput(): NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the tangent output component
  58861. */
  58862. get uvOutput(): NodeMaterialConnectionPoint;
  58863. initialize(state: NodeMaterialBuildState): void;
  58864. autoConfigure(material: NodeMaterial): void;
  58865. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58866. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58867. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58868. protected _buildBlock(state: NodeMaterialBuildState): this;
  58869. }
  58870. }
  58871. declare module BABYLON {
  58872. /**
  58873. * Block used to get data information from a light
  58874. */
  58875. export class LightInformationBlock extends NodeMaterialBlock {
  58876. private _lightDataUniformName;
  58877. private _lightColorUniformName;
  58878. private _lightTypeDefineName;
  58879. /**
  58880. * Gets or sets the light associated with this block
  58881. */
  58882. light: Nullable<Light>;
  58883. /**
  58884. * Creates a new LightInformationBlock
  58885. * @param name defines the block name
  58886. */
  58887. constructor(name: string);
  58888. /**
  58889. * Gets the current class name
  58890. * @returns the class name
  58891. */
  58892. getClassName(): string;
  58893. /**
  58894. * Gets the world position input component
  58895. */
  58896. get worldPosition(): NodeMaterialConnectionPoint;
  58897. /**
  58898. * Gets the direction output component
  58899. */
  58900. get direction(): NodeMaterialConnectionPoint;
  58901. /**
  58902. * Gets the direction output component
  58903. */
  58904. get color(): NodeMaterialConnectionPoint;
  58905. /**
  58906. * Gets the direction output component
  58907. */
  58908. get intensity(): NodeMaterialConnectionPoint;
  58909. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58911. protected _buildBlock(state: NodeMaterialBuildState): this;
  58912. serialize(): any;
  58913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58914. }
  58915. }
  58916. declare module BABYLON {
  58917. /**
  58918. * Block used to add image processing support to fragment shader
  58919. */
  58920. export class ImageProcessingBlock extends NodeMaterialBlock {
  58921. /**
  58922. * Create a new ImageProcessingBlock
  58923. * @param name defines the block name
  58924. */
  58925. constructor(name: string);
  58926. /**
  58927. * Gets the current class name
  58928. * @returns the class name
  58929. */
  58930. getClassName(): string;
  58931. /**
  58932. * Gets the color input component
  58933. */
  58934. get color(): NodeMaterialConnectionPoint;
  58935. /**
  58936. * Gets the output component
  58937. */
  58938. get output(): NodeMaterialConnectionPoint;
  58939. /**
  58940. * Initialize the block and prepare the context for build
  58941. * @param state defines the state that will be used for the build
  58942. */
  58943. initialize(state: NodeMaterialBuildState): void;
  58944. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58945. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58946. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58947. protected _buildBlock(state: NodeMaterialBuildState): this;
  58948. }
  58949. }
  58950. declare module BABYLON {
  58951. /**
  58952. * Block used to pertub normals based on a normal map
  58953. */
  58954. export class PerturbNormalBlock extends NodeMaterialBlock {
  58955. private _tangentSpaceParameterName;
  58956. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58957. invertX: boolean;
  58958. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58959. invertY: boolean;
  58960. /**
  58961. * Create a new PerturbNormalBlock
  58962. * @param name defines the block name
  58963. */
  58964. constructor(name: string);
  58965. /**
  58966. * Gets the current class name
  58967. * @returns the class name
  58968. */
  58969. getClassName(): string;
  58970. /**
  58971. * Gets the world position input component
  58972. */
  58973. get worldPosition(): NodeMaterialConnectionPoint;
  58974. /**
  58975. * Gets the world normal input component
  58976. */
  58977. get worldNormal(): NodeMaterialConnectionPoint;
  58978. /**
  58979. * Gets the world tangent input component
  58980. */
  58981. get worldTangent(): NodeMaterialConnectionPoint;
  58982. /**
  58983. * Gets the uv input component
  58984. */
  58985. get uv(): NodeMaterialConnectionPoint;
  58986. /**
  58987. * Gets the normal map color input component
  58988. */
  58989. get normalMapColor(): NodeMaterialConnectionPoint;
  58990. /**
  58991. * Gets the strength input component
  58992. */
  58993. get strength(): NodeMaterialConnectionPoint;
  58994. /**
  58995. * Gets the output component
  58996. */
  58997. get output(): NodeMaterialConnectionPoint;
  58998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59000. autoConfigure(material: NodeMaterial): void;
  59001. protected _buildBlock(state: NodeMaterialBuildState): this;
  59002. protected _dumpPropertiesCode(): string;
  59003. serialize(): any;
  59004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59005. }
  59006. }
  59007. declare module BABYLON {
  59008. /**
  59009. * Block used to discard a pixel if a value is smaller than a cutoff
  59010. */
  59011. export class DiscardBlock extends NodeMaterialBlock {
  59012. /**
  59013. * Create a new DiscardBlock
  59014. * @param name defines the block name
  59015. */
  59016. constructor(name: string);
  59017. /**
  59018. * Gets the current class name
  59019. * @returns the class name
  59020. */
  59021. getClassName(): string;
  59022. /**
  59023. * Gets the color input component
  59024. */
  59025. get value(): NodeMaterialConnectionPoint;
  59026. /**
  59027. * Gets the cutoff input component
  59028. */
  59029. get cutoff(): NodeMaterialConnectionPoint;
  59030. protected _buildBlock(state: NodeMaterialBuildState): this;
  59031. }
  59032. }
  59033. declare module BABYLON {
  59034. /**
  59035. * Block used to test if the fragment shader is front facing
  59036. */
  59037. export class FrontFacingBlock extends NodeMaterialBlock {
  59038. /**
  59039. * Creates a new FrontFacingBlock
  59040. * @param name defines the block name
  59041. */
  59042. constructor(name: string);
  59043. /**
  59044. * Gets the current class name
  59045. * @returns the class name
  59046. */
  59047. getClassName(): string;
  59048. /**
  59049. * Gets the output component
  59050. */
  59051. get output(): NodeMaterialConnectionPoint;
  59052. protected _buildBlock(state: NodeMaterialBuildState): this;
  59053. }
  59054. }
  59055. declare module BABYLON {
  59056. /**
  59057. * Block used to get the derivative value on x and y of a given input
  59058. */
  59059. export class DerivativeBlock extends NodeMaterialBlock {
  59060. /**
  59061. * Create a new DerivativeBlock
  59062. * @param name defines the block name
  59063. */
  59064. constructor(name: string);
  59065. /**
  59066. * Gets the current class name
  59067. * @returns the class name
  59068. */
  59069. getClassName(): string;
  59070. /**
  59071. * Gets the input component
  59072. */
  59073. get input(): NodeMaterialConnectionPoint;
  59074. /**
  59075. * Gets the derivative output on x
  59076. */
  59077. get dx(): NodeMaterialConnectionPoint;
  59078. /**
  59079. * Gets the derivative output on y
  59080. */
  59081. get dy(): NodeMaterialConnectionPoint;
  59082. protected _buildBlock(state: NodeMaterialBuildState): this;
  59083. }
  59084. }
  59085. declare module BABYLON {
  59086. /**
  59087. * Block used to add support for scene fog
  59088. */
  59089. export class FogBlock extends NodeMaterialBlock {
  59090. private _fogDistanceName;
  59091. private _fogParameters;
  59092. /**
  59093. * Create a new FogBlock
  59094. * @param name defines the block name
  59095. */
  59096. constructor(name: string);
  59097. /**
  59098. * Gets the current class name
  59099. * @returns the class name
  59100. */
  59101. getClassName(): string;
  59102. /**
  59103. * Gets the world position input component
  59104. */
  59105. get worldPosition(): NodeMaterialConnectionPoint;
  59106. /**
  59107. * Gets the view input component
  59108. */
  59109. get view(): NodeMaterialConnectionPoint;
  59110. /**
  59111. * Gets the color input component
  59112. */
  59113. get input(): NodeMaterialConnectionPoint;
  59114. /**
  59115. * Gets the fog color input component
  59116. */
  59117. get fogColor(): NodeMaterialConnectionPoint;
  59118. /**
  59119. * Gets the output component
  59120. */
  59121. get output(): NodeMaterialConnectionPoint;
  59122. autoConfigure(material: NodeMaterial): void;
  59123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59125. protected _buildBlock(state: NodeMaterialBuildState): this;
  59126. }
  59127. }
  59128. declare module BABYLON {
  59129. /**
  59130. * Block used to add light in the fragment shader
  59131. */
  59132. export class LightBlock extends NodeMaterialBlock {
  59133. private _lightId;
  59134. /**
  59135. * Gets or sets the light associated with this block
  59136. */
  59137. light: Nullable<Light>;
  59138. /**
  59139. * Create a new LightBlock
  59140. * @param name defines the block name
  59141. */
  59142. constructor(name: string);
  59143. /**
  59144. * Gets the current class name
  59145. * @returns the class name
  59146. */
  59147. getClassName(): string;
  59148. /**
  59149. * Gets the world position input component
  59150. */
  59151. get worldPosition(): NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the world normal input component
  59154. */
  59155. get worldNormal(): NodeMaterialConnectionPoint;
  59156. /**
  59157. * Gets the camera (or eye) position component
  59158. */
  59159. get cameraPosition(): NodeMaterialConnectionPoint;
  59160. /**
  59161. * Gets the glossiness component
  59162. */
  59163. get glossiness(): NodeMaterialConnectionPoint;
  59164. /**
  59165. * Gets the glossinness power component
  59166. */
  59167. get glossPower(): NodeMaterialConnectionPoint;
  59168. /**
  59169. * Gets the diffuse color component
  59170. */
  59171. get diffuseColor(): NodeMaterialConnectionPoint;
  59172. /**
  59173. * Gets the specular color component
  59174. */
  59175. get specularColor(): NodeMaterialConnectionPoint;
  59176. /**
  59177. * Gets the diffuse output component
  59178. */
  59179. get diffuseOutput(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the specular output component
  59182. */
  59183. get specularOutput(): NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the shadow output component
  59186. */
  59187. get shadow(): NodeMaterialConnectionPoint;
  59188. autoConfigure(material: NodeMaterial): void;
  59189. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59190. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59191. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59192. private _injectVertexCode;
  59193. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59194. serialize(): any;
  59195. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59196. }
  59197. }
  59198. declare module BABYLON {
  59199. /**
  59200. * Block used to multiply 2 values
  59201. */
  59202. export class MultiplyBlock extends NodeMaterialBlock {
  59203. /**
  59204. * Creates a new MultiplyBlock
  59205. * @param name defines the block name
  59206. */
  59207. constructor(name: string);
  59208. /**
  59209. * Gets the current class name
  59210. * @returns the class name
  59211. */
  59212. getClassName(): string;
  59213. /**
  59214. * Gets the left operand input component
  59215. */
  59216. get left(): NodeMaterialConnectionPoint;
  59217. /**
  59218. * Gets the right operand input component
  59219. */
  59220. get right(): NodeMaterialConnectionPoint;
  59221. /**
  59222. * Gets the output component
  59223. */
  59224. get output(): NodeMaterialConnectionPoint;
  59225. protected _buildBlock(state: NodeMaterialBuildState): this;
  59226. }
  59227. }
  59228. declare module BABYLON {
  59229. /**
  59230. * Block used to add 2 vectors
  59231. */
  59232. export class AddBlock extends NodeMaterialBlock {
  59233. /**
  59234. * Creates a new AddBlock
  59235. * @param name defines the block name
  59236. */
  59237. constructor(name: string);
  59238. /**
  59239. * Gets the current class name
  59240. * @returns the class name
  59241. */
  59242. getClassName(): string;
  59243. /**
  59244. * Gets the left operand input component
  59245. */
  59246. get left(): NodeMaterialConnectionPoint;
  59247. /**
  59248. * Gets the right operand input component
  59249. */
  59250. get right(): NodeMaterialConnectionPoint;
  59251. /**
  59252. * Gets the output component
  59253. */
  59254. get output(): NodeMaterialConnectionPoint;
  59255. protected _buildBlock(state: NodeMaterialBuildState): this;
  59256. }
  59257. }
  59258. declare module BABYLON {
  59259. /**
  59260. * Block used to scale a vector by a float
  59261. */
  59262. export class ScaleBlock extends NodeMaterialBlock {
  59263. /**
  59264. * Creates a new ScaleBlock
  59265. * @param name defines the block name
  59266. */
  59267. constructor(name: string);
  59268. /**
  59269. * Gets the current class name
  59270. * @returns the class name
  59271. */
  59272. getClassName(): string;
  59273. /**
  59274. * Gets the input component
  59275. */
  59276. get input(): NodeMaterialConnectionPoint;
  59277. /**
  59278. * Gets the factor input component
  59279. */
  59280. get factor(): NodeMaterialConnectionPoint;
  59281. /**
  59282. * Gets the output component
  59283. */
  59284. get output(): NodeMaterialConnectionPoint;
  59285. protected _buildBlock(state: NodeMaterialBuildState): this;
  59286. }
  59287. }
  59288. declare module BABYLON {
  59289. /**
  59290. * Block used to clamp a float
  59291. */
  59292. export class ClampBlock extends NodeMaterialBlock {
  59293. /** Gets or sets the minimum range */
  59294. minimum: number;
  59295. /** Gets or sets the maximum range */
  59296. maximum: number;
  59297. /**
  59298. * Creates a new ClampBlock
  59299. * @param name defines the block name
  59300. */
  59301. constructor(name: string);
  59302. /**
  59303. * Gets the current class name
  59304. * @returns the class name
  59305. */
  59306. getClassName(): string;
  59307. /**
  59308. * Gets the value input component
  59309. */
  59310. get value(): NodeMaterialConnectionPoint;
  59311. /**
  59312. * Gets the output component
  59313. */
  59314. get output(): NodeMaterialConnectionPoint;
  59315. protected _buildBlock(state: NodeMaterialBuildState): this;
  59316. protected _dumpPropertiesCode(): string;
  59317. serialize(): any;
  59318. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59319. }
  59320. }
  59321. declare module BABYLON {
  59322. /**
  59323. * Block used to apply a cross product between 2 vectors
  59324. */
  59325. export class CrossBlock extends NodeMaterialBlock {
  59326. /**
  59327. * Creates a new CrossBlock
  59328. * @param name defines the block name
  59329. */
  59330. constructor(name: string);
  59331. /**
  59332. * Gets the current class name
  59333. * @returns the class name
  59334. */
  59335. getClassName(): string;
  59336. /**
  59337. * Gets the left operand input component
  59338. */
  59339. get left(): NodeMaterialConnectionPoint;
  59340. /**
  59341. * Gets the right operand input component
  59342. */
  59343. get right(): NodeMaterialConnectionPoint;
  59344. /**
  59345. * Gets the output component
  59346. */
  59347. get output(): NodeMaterialConnectionPoint;
  59348. protected _buildBlock(state: NodeMaterialBuildState): this;
  59349. }
  59350. }
  59351. declare module BABYLON {
  59352. /**
  59353. * Block used to apply a dot product between 2 vectors
  59354. */
  59355. export class DotBlock extends NodeMaterialBlock {
  59356. /**
  59357. * Creates a new DotBlock
  59358. * @param name defines the block name
  59359. */
  59360. constructor(name: string);
  59361. /**
  59362. * Gets the current class name
  59363. * @returns the class name
  59364. */
  59365. getClassName(): string;
  59366. /**
  59367. * Gets the left operand input component
  59368. */
  59369. get left(): NodeMaterialConnectionPoint;
  59370. /**
  59371. * Gets the right operand input component
  59372. */
  59373. get right(): NodeMaterialConnectionPoint;
  59374. /**
  59375. * Gets the output component
  59376. */
  59377. get output(): NodeMaterialConnectionPoint;
  59378. protected _buildBlock(state: NodeMaterialBuildState): this;
  59379. }
  59380. }
  59381. declare module BABYLON {
  59382. /**
  59383. * Block used to remap a float from a range to a new one
  59384. */
  59385. export class RemapBlock extends NodeMaterialBlock {
  59386. /**
  59387. * Gets or sets the source range
  59388. */
  59389. sourceRange: Vector2;
  59390. /**
  59391. * Gets or sets the target range
  59392. */
  59393. targetRange: Vector2;
  59394. /**
  59395. * Creates a new RemapBlock
  59396. * @param name defines the block name
  59397. */
  59398. constructor(name: string);
  59399. /**
  59400. * Gets the current class name
  59401. * @returns the class name
  59402. */
  59403. getClassName(): string;
  59404. /**
  59405. * Gets the input component
  59406. */
  59407. get input(): NodeMaterialConnectionPoint;
  59408. /**
  59409. * Gets the source min input component
  59410. */
  59411. get sourceMin(): NodeMaterialConnectionPoint;
  59412. /**
  59413. * Gets the source max input component
  59414. */
  59415. get sourceMax(): NodeMaterialConnectionPoint;
  59416. /**
  59417. * Gets the target min input component
  59418. */
  59419. get targetMin(): NodeMaterialConnectionPoint;
  59420. /**
  59421. * Gets the target max input component
  59422. */
  59423. get targetMax(): NodeMaterialConnectionPoint;
  59424. /**
  59425. * Gets the output component
  59426. */
  59427. get output(): NodeMaterialConnectionPoint;
  59428. protected _buildBlock(state: NodeMaterialBuildState): this;
  59429. protected _dumpPropertiesCode(): string;
  59430. serialize(): any;
  59431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59432. }
  59433. }
  59434. declare module BABYLON {
  59435. /**
  59436. * Block used to normalize a vector
  59437. */
  59438. export class NormalizeBlock extends NodeMaterialBlock {
  59439. /**
  59440. * Creates a new NormalizeBlock
  59441. * @param name defines the block name
  59442. */
  59443. constructor(name: string);
  59444. /**
  59445. * Gets the current class name
  59446. * @returns the class name
  59447. */
  59448. getClassName(): string;
  59449. /**
  59450. * Gets the input component
  59451. */
  59452. get input(): NodeMaterialConnectionPoint;
  59453. /**
  59454. * Gets the output component
  59455. */
  59456. get output(): NodeMaterialConnectionPoint;
  59457. protected _buildBlock(state: NodeMaterialBuildState): this;
  59458. }
  59459. }
  59460. declare module BABYLON {
  59461. /**
  59462. * Operations supported by the Trigonometry block
  59463. */
  59464. export enum TrigonometryBlockOperations {
  59465. /** Cos */
  59466. Cos = 0,
  59467. /** Sin */
  59468. Sin = 1,
  59469. /** Abs */
  59470. Abs = 2,
  59471. /** Exp */
  59472. Exp = 3,
  59473. /** Exp2 */
  59474. Exp2 = 4,
  59475. /** Round */
  59476. Round = 5,
  59477. /** Floor */
  59478. Floor = 6,
  59479. /** Ceiling */
  59480. Ceiling = 7,
  59481. /** Square root */
  59482. Sqrt = 8,
  59483. /** Log */
  59484. Log = 9,
  59485. /** Tangent */
  59486. Tan = 10,
  59487. /** Arc tangent */
  59488. ArcTan = 11,
  59489. /** Arc cosinus */
  59490. ArcCos = 12,
  59491. /** Arc sinus */
  59492. ArcSin = 13,
  59493. /** Fraction */
  59494. Fract = 14,
  59495. /** Sign */
  59496. Sign = 15,
  59497. /** To radians (from degrees) */
  59498. Radians = 16,
  59499. /** To degrees (from radians) */
  59500. Degrees = 17
  59501. }
  59502. /**
  59503. * Block used to apply trigonometry operation to floats
  59504. */
  59505. export class TrigonometryBlock extends NodeMaterialBlock {
  59506. /**
  59507. * Gets or sets the operation applied by the block
  59508. */
  59509. operation: TrigonometryBlockOperations;
  59510. /**
  59511. * Creates a new TrigonometryBlock
  59512. * @param name defines the block name
  59513. */
  59514. constructor(name: string);
  59515. /**
  59516. * Gets the current class name
  59517. * @returns the class name
  59518. */
  59519. getClassName(): string;
  59520. /**
  59521. * Gets the input component
  59522. */
  59523. get input(): NodeMaterialConnectionPoint;
  59524. /**
  59525. * Gets the output component
  59526. */
  59527. get output(): NodeMaterialConnectionPoint;
  59528. protected _buildBlock(state: NodeMaterialBuildState): this;
  59529. serialize(): any;
  59530. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59531. protected _dumpPropertiesCode(): string;
  59532. }
  59533. }
  59534. declare module BABYLON {
  59535. /**
  59536. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59537. */
  59538. export class ColorMergerBlock extends NodeMaterialBlock {
  59539. /**
  59540. * Create a new ColorMergerBlock
  59541. * @param name defines the block name
  59542. */
  59543. constructor(name: string);
  59544. /**
  59545. * Gets the current class name
  59546. * @returns the class name
  59547. */
  59548. getClassName(): string;
  59549. /**
  59550. * Gets the rgb component (input)
  59551. */
  59552. get rgbIn(): NodeMaterialConnectionPoint;
  59553. /**
  59554. * Gets the r component (input)
  59555. */
  59556. get r(): NodeMaterialConnectionPoint;
  59557. /**
  59558. * Gets the g component (input)
  59559. */
  59560. get g(): NodeMaterialConnectionPoint;
  59561. /**
  59562. * Gets the b component (input)
  59563. */
  59564. get b(): NodeMaterialConnectionPoint;
  59565. /**
  59566. * Gets the a component (input)
  59567. */
  59568. get a(): NodeMaterialConnectionPoint;
  59569. /**
  59570. * Gets the rgba component (output)
  59571. */
  59572. get rgba(): NodeMaterialConnectionPoint;
  59573. /**
  59574. * Gets the rgb component (output)
  59575. */
  59576. get rgbOut(): NodeMaterialConnectionPoint;
  59577. /**
  59578. * Gets the rgb component (output)
  59579. * @deprecated Please use rgbOut instead.
  59580. */
  59581. get rgb(): NodeMaterialConnectionPoint;
  59582. protected _buildBlock(state: NodeMaterialBuildState): this;
  59583. }
  59584. }
  59585. declare module BABYLON {
  59586. /**
  59587. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59588. */
  59589. export class VectorMergerBlock extends NodeMaterialBlock {
  59590. /**
  59591. * Create a new VectorMergerBlock
  59592. * @param name defines the block name
  59593. */
  59594. constructor(name: string);
  59595. /**
  59596. * Gets the current class name
  59597. * @returns the class name
  59598. */
  59599. getClassName(): string;
  59600. /**
  59601. * Gets the xyz component (input)
  59602. */
  59603. get xyzIn(): NodeMaterialConnectionPoint;
  59604. /**
  59605. * Gets the xy component (input)
  59606. */
  59607. get xyIn(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the x component (input)
  59610. */
  59611. get x(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the y component (input)
  59614. */
  59615. get y(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the z component (input)
  59618. */
  59619. get z(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the w component (input)
  59622. */
  59623. get w(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the xyzw component (output)
  59626. */
  59627. get xyzw(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the xyz component (output)
  59630. */
  59631. get xyzOut(): NodeMaterialConnectionPoint;
  59632. /**
  59633. * Gets the xy component (output)
  59634. */
  59635. get xyOut(): NodeMaterialConnectionPoint;
  59636. /**
  59637. * Gets the xy component (output)
  59638. * @deprecated Please use xyOut instead.
  59639. */
  59640. get xy(): NodeMaterialConnectionPoint;
  59641. /**
  59642. * Gets the xyz component (output)
  59643. * @deprecated Please use xyzOut instead.
  59644. */
  59645. get xyz(): NodeMaterialConnectionPoint;
  59646. protected _buildBlock(state: NodeMaterialBuildState): this;
  59647. }
  59648. }
  59649. declare module BABYLON {
  59650. /**
  59651. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59652. */
  59653. export class ColorSplitterBlock extends NodeMaterialBlock {
  59654. /**
  59655. * Create a new ColorSplitterBlock
  59656. * @param name defines the block name
  59657. */
  59658. constructor(name: string);
  59659. /**
  59660. * Gets the current class name
  59661. * @returns the class name
  59662. */
  59663. getClassName(): string;
  59664. /**
  59665. * Gets the rgba component (input)
  59666. */
  59667. get rgba(): NodeMaterialConnectionPoint;
  59668. /**
  59669. * Gets the rgb component (input)
  59670. */
  59671. get rgbIn(): NodeMaterialConnectionPoint;
  59672. /**
  59673. * Gets the rgb component (output)
  59674. */
  59675. get rgbOut(): NodeMaterialConnectionPoint;
  59676. /**
  59677. * Gets the r component (output)
  59678. */
  59679. get r(): NodeMaterialConnectionPoint;
  59680. /**
  59681. * Gets the g component (output)
  59682. */
  59683. get g(): NodeMaterialConnectionPoint;
  59684. /**
  59685. * Gets the b component (output)
  59686. */
  59687. get b(): NodeMaterialConnectionPoint;
  59688. /**
  59689. * Gets the a component (output)
  59690. */
  59691. get a(): NodeMaterialConnectionPoint;
  59692. protected _inputRename(name: string): string;
  59693. protected _outputRename(name: string): string;
  59694. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59695. }
  59696. }
  59697. declare module BABYLON {
  59698. /**
  59699. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59700. */
  59701. export class VectorSplitterBlock extends NodeMaterialBlock {
  59702. /**
  59703. * Create a new VectorSplitterBlock
  59704. * @param name defines the block name
  59705. */
  59706. constructor(name: string);
  59707. /**
  59708. * Gets the current class name
  59709. * @returns the class name
  59710. */
  59711. getClassName(): string;
  59712. /**
  59713. * Gets the xyzw component (input)
  59714. */
  59715. get xyzw(): NodeMaterialConnectionPoint;
  59716. /**
  59717. * Gets the xyz component (input)
  59718. */
  59719. get xyzIn(): NodeMaterialConnectionPoint;
  59720. /**
  59721. * Gets the xy component (input)
  59722. */
  59723. get xyIn(): NodeMaterialConnectionPoint;
  59724. /**
  59725. * Gets the xyz component (output)
  59726. */
  59727. get xyzOut(): NodeMaterialConnectionPoint;
  59728. /**
  59729. * Gets the xy component (output)
  59730. */
  59731. get xyOut(): NodeMaterialConnectionPoint;
  59732. /**
  59733. * Gets the x component (output)
  59734. */
  59735. get x(): NodeMaterialConnectionPoint;
  59736. /**
  59737. * Gets the y component (output)
  59738. */
  59739. get y(): NodeMaterialConnectionPoint;
  59740. /**
  59741. * Gets the z component (output)
  59742. */
  59743. get z(): NodeMaterialConnectionPoint;
  59744. /**
  59745. * Gets the w component (output)
  59746. */
  59747. get w(): NodeMaterialConnectionPoint;
  59748. protected _inputRename(name: string): string;
  59749. protected _outputRename(name: string): string;
  59750. protected _buildBlock(state: NodeMaterialBuildState): this;
  59751. }
  59752. }
  59753. declare module BABYLON {
  59754. /**
  59755. * Block used to lerp between 2 values
  59756. */
  59757. export class LerpBlock extends NodeMaterialBlock {
  59758. /**
  59759. * Creates a new LerpBlock
  59760. * @param name defines the block name
  59761. */
  59762. constructor(name: string);
  59763. /**
  59764. * Gets the current class name
  59765. * @returns the class name
  59766. */
  59767. getClassName(): string;
  59768. /**
  59769. * Gets the left operand input component
  59770. */
  59771. get left(): NodeMaterialConnectionPoint;
  59772. /**
  59773. * Gets the right operand input component
  59774. */
  59775. get right(): NodeMaterialConnectionPoint;
  59776. /**
  59777. * Gets the gradient operand input component
  59778. */
  59779. get gradient(): NodeMaterialConnectionPoint;
  59780. /**
  59781. * Gets the output component
  59782. */
  59783. get output(): NodeMaterialConnectionPoint;
  59784. protected _buildBlock(state: NodeMaterialBuildState): this;
  59785. }
  59786. }
  59787. declare module BABYLON {
  59788. /**
  59789. * Block used to divide 2 vectors
  59790. */
  59791. export class DivideBlock extends NodeMaterialBlock {
  59792. /**
  59793. * Creates a new DivideBlock
  59794. * @param name defines the block name
  59795. */
  59796. constructor(name: string);
  59797. /**
  59798. * Gets the current class name
  59799. * @returns the class name
  59800. */
  59801. getClassName(): string;
  59802. /**
  59803. * Gets the left operand input component
  59804. */
  59805. get left(): NodeMaterialConnectionPoint;
  59806. /**
  59807. * Gets the right operand input component
  59808. */
  59809. get right(): NodeMaterialConnectionPoint;
  59810. /**
  59811. * Gets the output component
  59812. */
  59813. get output(): NodeMaterialConnectionPoint;
  59814. protected _buildBlock(state: NodeMaterialBuildState): this;
  59815. }
  59816. }
  59817. declare module BABYLON {
  59818. /**
  59819. * Block used to subtract 2 vectors
  59820. */
  59821. export class SubtractBlock extends NodeMaterialBlock {
  59822. /**
  59823. * Creates a new SubtractBlock
  59824. * @param name defines the block name
  59825. */
  59826. constructor(name: string);
  59827. /**
  59828. * Gets the current class name
  59829. * @returns the class name
  59830. */
  59831. getClassName(): string;
  59832. /**
  59833. * Gets the left operand input component
  59834. */
  59835. get left(): NodeMaterialConnectionPoint;
  59836. /**
  59837. * Gets the right operand input component
  59838. */
  59839. get right(): NodeMaterialConnectionPoint;
  59840. /**
  59841. * Gets the output component
  59842. */
  59843. get output(): NodeMaterialConnectionPoint;
  59844. protected _buildBlock(state: NodeMaterialBuildState): this;
  59845. }
  59846. }
  59847. declare module BABYLON {
  59848. /**
  59849. * Block used to step a value
  59850. */
  59851. export class StepBlock extends NodeMaterialBlock {
  59852. /**
  59853. * Creates a new StepBlock
  59854. * @param name defines the block name
  59855. */
  59856. constructor(name: string);
  59857. /**
  59858. * Gets the current class name
  59859. * @returns the class name
  59860. */
  59861. getClassName(): string;
  59862. /**
  59863. * Gets the value operand input component
  59864. */
  59865. get value(): NodeMaterialConnectionPoint;
  59866. /**
  59867. * Gets the edge operand input component
  59868. */
  59869. get edge(): NodeMaterialConnectionPoint;
  59870. /**
  59871. * Gets the output component
  59872. */
  59873. get output(): NodeMaterialConnectionPoint;
  59874. protected _buildBlock(state: NodeMaterialBuildState): this;
  59875. }
  59876. }
  59877. declare module BABYLON {
  59878. /**
  59879. * Block used to get the opposite (1 - x) of a value
  59880. */
  59881. export class OneMinusBlock extends NodeMaterialBlock {
  59882. /**
  59883. * Creates a new OneMinusBlock
  59884. * @param name defines the block name
  59885. */
  59886. constructor(name: string);
  59887. /**
  59888. * Gets the current class name
  59889. * @returns the class name
  59890. */
  59891. getClassName(): string;
  59892. /**
  59893. * Gets the input component
  59894. */
  59895. get input(): NodeMaterialConnectionPoint;
  59896. /**
  59897. * Gets the output component
  59898. */
  59899. get output(): NodeMaterialConnectionPoint;
  59900. protected _buildBlock(state: NodeMaterialBuildState): this;
  59901. }
  59902. }
  59903. declare module BABYLON {
  59904. /**
  59905. * Block used to get the view direction
  59906. */
  59907. export class ViewDirectionBlock extends NodeMaterialBlock {
  59908. /**
  59909. * Creates a new ViewDirectionBlock
  59910. * @param name defines the block name
  59911. */
  59912. constructor(name: string);
  59913. /**
  59914. * Gets the current class name
  59915. * @returns the class name
  59916. */
  59917. getClassName(): string;
  59918. /**
  59919. * Gets the world position component
  59920. */
  59921. get worldPosition(): NodeMaterialConnectionPoint;
  59922. /**
  59923. * Gets the camera position component
  59924. */
  59925. get cameraPosition(): NodeMaterialConnectionPoint;
  59926. /**
  59927. * Gets the output component
  59928. */
  59929. get output(): NodeMaterialConnectionPoint;
  59930. autoConfigure(material: NodeMaterial): void;
  59931. protected _buildBlock(state: NodeMaterialBuildState): this;
  59932. }
  59933. }
  59934. declare module BABYLON {
  59935. /**
  59936. * Block used to compute fresnel value
  59937. */
  59938. export class FresnelBlock extends NodeMaterialBlock {
  59939. /**
  59940. * Create a new FresnelBlock
  59941. * @param name defines the block name
  59942. */
  59943. constructor(name: string);
  59944. /**
  59945. * Gets the current class name
  59946. * @returns the class name
  59947. */
  59948. getClassName(): string;
  59949. /**
  59950. * Gets the world normal input component
  59951. */
  59952. get worldNormal(): NodeMaterialConnectionPoint;
  59953. /**
  59954. * Gets the view direction input component
  59955. */
  59956. get viewDirection(): NodeMaterialConnectionPoint;
  59957. /**
  59958. * Gets the bias input component
  59959. */
  59960. get bias(): NodeMaterialConnectionPoint;
  59961. /**
  59962. * Gets the camera (or eye) position component
  59963. */
  59964. get power(): NodeMaterialConnectionPoint;
  59965. /**
  59966. * Gets the fresnel output component
  59967. */
  59968. get fresnel(): NodeMaterialConnectionPoint;
  59969. autoConfigure(material: NodeMaterial): void;
  59970. protected _buildBlock(state: NodeMaterialBuildState): this;
  59971. }
  59972. }
  59973. declare module BABYLON {
  59974. /**
  59975. * Block used to get the max of 2 values
  59976. */
  59977. export class MaxBlock extends NodeMaterialBlock {
  59978. /**
  59979. * Creates a new MaxBlock
  59980. * @param name defines the block name
  59981. */
  59982. constructor(name: string);
  59983. /**
  59984. * Gets the current class name
  59985. * @returns the class name
  59986. */
  59987. getClassName(): string;
  59988. /**
  59989. * Gets the left operand input component
  59990. */
  59991. get left(): NodeMaterialConnectionPoint;
  59992. /**
  59993. * Gets the right operand input component
  59994. */
  59995. get right(): NodeMaterialConnectionPoint;
  59996. /**
  59997. * Gets the output component
  59998. */
  59999. get output(): NodeMaterialConnectionPoint;
  60000. protected _buildBlock(state: NodeMaterialBuildState): this;
  60001. }
  60002. }
  60003. declare module BABYLON {
  60004. /**
  60005. * Block used to get the min of 2 values
  60006. */
  60007. export class MinBlock extends NodeMaterialBlock {
  60008. /**
  60009. * Creates a new MinBlock
  60010. * @param name defines the block name
  60011. */
  60012. constructor(name: string);
  60013. /**
  60014. * Gets the current class name
  60015. * @returns the class name
  60016. */
  60017. getClassName(): string;
  60018. /**
  60019. * Gets the left operand input component
  60020. */
  60021. get left(): NodeMaterialConnectionPoint;
  60022. /**
  60023. * Gets the right operand input component
  60024. */
  60025. get right(): NodeMaterialConnectionPoint;
  60026. /**
  60027. * Gets the output component
  60028. */
  60029. get output(): NodeMaterialConnectionPoint;
  60030. protected _buildBlock(state: NodeMaterialBuildState): this;
  60031. }
  60032. }
  60033. declare module BABYLON {
  60034. /**
  60035. * Block used to get the distance between 2 values
  60036. */
  60037. export class DistanceBlock extends NodeMaterialBlock {
  60038. /**
  60039. * Creates a new DistanceBlock
  60040. * @param name defines the block name
  60041. */
  60042. constructor(name: string);
  60043. /**
  60044. * Gets the current class name
  60045. * @returns the class name
  60046. */
  60047. getClassName(): string;
  60048. /**
  60049. * Gets the left operand input component
  60050. */
  60051. get left(): NodeMaterialConnectionPoint;
  60052. /**
  60053. * Gets the right operand input component
  60054. */
  60055. get right(): NodeMaterialConnectionPoint;
  60056. /**
  60057. * Gets the output component
  60058. */
  60059. get output(): NodeMaterialConnectionPoint;
  60060. protected _buildBlock(state: NodeMaterialBuildState): this;
  60061. }
  60062. }
  60063. declare module BABYLON {
  60064. /**
  60065. * Block used to get the length of a vector
  60066. */
  60067. export class LengthBlock extends NodeMaterialBlock {
  60068. /**
  60069. * Creates a new LengthBlock
  60070. * @param name defines the block name
  60071. */
  60072. constructor(name: string);
  60073. /**
  60074. * Gets the current class name
  60075. * @returns the class name
  60076. */
  60077. getClassName(): string;
  60078. /**
  60079. * Gets the value input component
  60080. */
  60081. get value(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the output component
  60084. */
  60085. get output(): NodeMaterialConnectionPoint;
  60086. protected _buildBlock(state: NodeMaterialBuildState): this;
  60087. }
  60088. }
  60089. declare module BABYLON {
  60090. /**
  60091. * Block used to get negative version of a value (i.e. x * -1)
  60092. */
  60093. export class NegateBlock extends NodeMaterialBlock {
  60094. /**
  60095. * Creates a new NegateBlock
  60096. * @param name defines the block name
  60097. */
  60098. constructor(name: string);
  60099. /**
  60100. * Gets the current class name
  60101. * @returns the class name
  60102. */
  60103. getClassName(): string;
  60104. /**
  60105. * Gets the value input component
  60106. */
  60107. get value(): NodeMaterialConnectionPoint;
  60108. /**
  60109. * Gets the output component
  60110. */
  60111. get output(): NodeMaterialConnectionPoint;
  60112. protected _buildBlock(state: NodeMaterialBuildState): this;
  60113. }
  60114. }
  60115. declare module BABYLON {
  60116. /**
  60117. * Block used to get the value of the first parameter raised to the power of the second
  60118. */
  60119. export class PowBlock extends NodeMaterialBlock {
  60120. /**
  60121. * Creates a new PowBlock
  60122. * @param name defines the block name
  60123. */
  60124. constructor(name: string);
  60125. /**
  60126. * Gets the current class name
  60127. * @returns the class name
  60128. */
  60129. getClassName(): string;
  60130. /**
  60131. * Gets the value operand input component
  60132. */
  60133. get value(): NodeMaterialConnectionPoint;
  60134. /**
  60135. * Gets the power operand input component
  60136. */
  60137. get power(): NodeMaterialConnectionPoint;
  60138. /**
  60139. * Gets the output component
  60140. */
  60141. get output(): NodeMaterialConnectionPoint;
  60142. protected _buildBlock(state: NodeMaterialBuildState): this;
  60143. }
  60144. }
  60145. declare module BABYLON {
  60146. /**
  60147. * Block used to get a random number
  60148. */
  60149. export class RandomNumberBlock extends NodeMaterialBlock {
  60150. /**
  60151. * Creates a new RandomNumberBlock
  60152. * @param name defines the block name
  60153. */
  60154. constructor(name: string);
  60155. /**
  60156. * Gets the current class name
  60157. * @returns the class name
  60158. */
  60159. getClassName(): string;
  60160. /**
  60161. * Gets the seed input component
  60162. */
  60163. get seed(): NodeMaterialConnectionPoint;
  60164. /**
  60165. * Gets the output component
  60166. */
  60167. get output(): NodeMaterialConnectionPoint;
  60168. protected _buildBlock(state: NodeMaterialBuildState): this;
  60169. }
  60170. }
  60171. declare module BABYLON {
  60172. /**
  60173. * Block used to compute arc tangent of 2 values
  60174. */
  60175. export class ArcTan2Block extends NodeMaterialBlock {
  60176. /**
  60177. * Creates a new ArcTan2Block
  60178. * @param name defines the block name
  60179. */
  60180. constructor(name: string);
  60181. /**
  60182. * Gets the current class name
  60183. * @returns the class name
  60184. */
  60185. getClassName(): string;
  60186. /**
  60187. * Gets the x operand input component
  60188. */
  60189. get x(): NodeMaterialConnectionPoint;
  60190. /**
  60191. * Gets the y operand input component
  60192. */
  60193. get y(): NodeMaterialConnectionPoint;
  60194. /**
  60195. * Gets the output component
  60196. */
  60197. get output(): NodeMaterialConnectionPoint;
  60198. protected _buildBlock(state: NodeMaterialBuildState): this;
  60199. }
  60200. }
  60201. declare module BABYLON {
  60202. /**
  60203. * Block used to smooth step a value
  60204. */
  60205. export class SmoothStepBlock extends NodeMaterialBlock {
  60206. /**
  60207. * Creates a new SmoothStepBlock
  60208. * @param name defines the block name
  60209. */
  60210. constructor(name: string);
  60211. /**
  60212. * Gets the current class name
  60213. * @returns the class name
  60214. */
  60215. getClassName(): string;
  60216. /**
  60217. * Gets the value operand input component
  60218. */
  60219. get value(): NodeMaterialConnectionPoint;
  60220. /**
  60221. * Gets the first edge operand input component
  60222. */
  60223. get edge0(): NodeMaterialConnectionPoint;
  60224. /**
  60225. * Gets the second edge operand input component
  60226. */
  60227. get edge1(): NodeMaterialConnectionPoint;
  60228. /**
  60229. * Gets the output component
  60230. */
  60231. get output(): NodeMaterialConnectionPoint;
  60232. protected _buildBlock(state: NodeMaterialBuildState): this;
  60233. }
  60234. }
  60235. declare module BABYLON {
  60236. /**
  60237. * Block used to get the reciprocal (1 / x) of a value
  60238. */
  60239. export class ReciprocalBlock extends NodeMaterialBlock {
  60240. /**
  60241. * Creates a new ReciprocalBlock
  60242. * @param name defines the block name
  60243. */
  60244. constructor(name: string);
  60245. /**
  60246. * Gets the current class name
  60247. * @returns the class name
  60248. */
  60249. getClassName(): string;
  60250. /**
  60251. * Gets the input component
  60252. */
  60253. get input(): NodeMaterialConnectionPoint;
  60254. /**
  60255. * Gets the output component
  60256. */
  60257. get output(): NodeMaterialConnectionPoint;
  60258. protected _buildBlock(state: NodeMaterialBuildState): this;
  60259. }
  60260. }
  60261. declare module BABYLON {
  60262. /**
  60263. * Block used to replace a color by another one
  60264. */
  60265. export class ReplaceColorBlock extends NodeMaterialBlock {
  60266. /**
  60267. * Creates a new ReplaceColorBlock
  60268. * @param name defines the block name
  60269. */
  60270. constructor(name: string);
  60271. /**
  60272. * Gets the current class name
  60273. * @returns the class name
  60274. */
  60275. getClassName(): string;
  60276. /**
  60277. * Gets the value input component
  60278. */
  60279. get value(): NodeMaterialConnectionPoint;
  60280. /**
  60281. * Gets the reference input component
  60282. */
  60283. get reference(): NodeMaterialConnectionPoint;
  60284. /**
  60285. * Gets the distance input component
  60286. */
  60287. get distance(): NodeMaterialConnectionPoint;
  60288. /**
  60289. * Gets the replacement input component
  60290. */
  60291. get replacement(): NodeMaterialConnectionPoint;
  60292. /**
  60293. * Gets the output component
  60294. */
  60295. get output(): NodeMaterialConnectionPoint;
  60296. protected _buildBlock(state: NodeMaterialBuildState): this;
  60297. }
  60298. }
  60299. declare module BABYLON {
  60300. /**
  60301. * Block used to posterize a value
  60302. * @see https://en.wikipedia.org/wiki/Posterization
  60303. */
  60304. export class PosterizeBlock extends NodeMaterialBlock {
  60305. /**
  60306. * Creates a new PosterizeBlock
  60307. * @param name defines the block name
  60308. */
  60309. constructor(name: string);
  60310. /**
  60311. * Gets the current class name
  60312. * @returns the class name
  60313. */
  60314. getClassName(): string;
  60315. /**
  60316. * Gets the value input component
  60317. */
  60318. get value(): NodeMaterialConnectionPoint;
  60319. /**
  60320. * Gets the steps input component
  60321. */
  60322. get steps(): NodeMaterialConnectionPoint;
  60323. /**
  60324. * Gets the output component
  60325. */
  60326. get output(): NodeMaterialConnectionPoint;
  60327. protected _buildBlock(state: NodeMaterialBuildState): this;
  60328. }
  60329. }
  60330. declare module BABYLON {
  60331. /**
  60332. * Operations supported by the Wave block
  60333. */
  60334. export enum WaveBlockKind {
  60335. /** SawTooth */
  60336. SawTooth = 0,
  60337. /** Square */
  60338. Square = 1,
  60339. /** Triangle */
  60340. Triangle = 2
  60341. }
  60342. /**
  60343. * Block used to apply wave operation to floats
  60344. */
  60345. export class WaveBlock extends NodeMaterialBlock {
  60346. /**
  60347. * Gets or sets the kibnd of wave to be applied by the block
  60348. */
  60349. kind: WaveBlockKind;
  60350. /**
  60351. * Creates a new WaveBlock
  60352. * @param name defines the block name
  60353. */
  60354. constructor(name: string);
  60355. /**
  60356. * Gets the current class name
  60357. * @returns the class name
  60358. */
  60359. getClassName(): string;
  60360. /**
  60361. * Gets the input component
  60362. */
  60363. get input(): NodeMaterialConnectionPoint;
  60364. /**
  60365. * Gets the output component
  60366. */
  60367. get output(): NodeMaterialConnectionPoint;
  60368. protected _buildBlock(state: NodeMaterialBuildState): this;
  60369. serialize(): any;
  60370. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60371. }
  60372. }
  60373. declare module BABYLON {
  60374. /**
  60375. * Class used to store a color step for the GradientBlock
  60376. */
  60377. export class GradientBlockColorStep {
  60378. /**
  60379. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60380. */
  60381. step: number;
  60382. /**
  60383. * Gets or sets the color associated with this step
  60384. */
  60385. color: Color3;
  60386. /**
  60387. * Creates a new GradientBlockColorStep
  60388. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  60389. * @param color defines the color associated with this step
  60390. */
  60391. constructor(
  60392. /**
  60393. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  60394. */
  60395. step: number,
  60396. /**
  60397. * Gets or sets the color associated with this step
  60398. */
  60399. color: Color3);
  60400. }
  60401. /**
  60402. * Block used to return a color from a gradient based on an input value between 0 and 1
  60403. */
  60404. export class GradientBlock extends NodeMaterialBlock {
  60405. /**
  60406. * Gets or sets the list of color steps
  60407. */
  60408. colorSteps: GradientBlockColorStep[];
  60409. /**
  60410. * Creates a new GradientBlock
  60411. * @param name defines the block name
  60412. */
  60413. constructor(name: string);
  60414. /**
  60415. * Gets the current class name
  60416. * @returns the class name
  60417. */
  60418. getClassName(): string;
  60419. /**
  60420. * Gets the gradient input component
  60421. */
  60422. get gradient(): NodeMaterialConnectionPoint;
  60423. /**
  60424. * Gets the output component
  60425. */
  60426. get output(): NodeMaterialConnectionPoint;
  60427. private _writeColorConstant;
  60428. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60429. serialize(): any;
  60430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60431. protected _dumpPropertiesCode(): string;
  60432. }
  60433. }
  60434. declare module BABYLON {
  60435. /**
  60436. * Block used to normalize lerp between 2 values
  60437. */
  60438. export class NLerpBlock extends NodeMaterialBlock {
  60439. /**
  60440. * Creates a new NLerpBlock
  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 left operand input component
  60451. */
  60452. get left(): NodeMaterialConnectionPoint;
  60453. /**
  60454. * Gets the right operand input component
  60455. */
  60456. get right(): NodeMaterialConnectionPoint;
  60457. /**
  60458. * Gets the gradient operand input component
  60459. */
  60460. get gradient(): NodeMaterialConnectionPoint;
  60461. /**
  60462. * Gets the output component
  60463. */
  60464. get output(): NodeMaterialConnectionPoint;
  60465. protected _buildBlock(state: NodeMaterialBuildState): this;
  60466. }
  60467. }
  60468. declare module BABYLON {
  60469. /**
  60470. * block used to Generate a Worley Noise 3D Noise Pattern
  60471. */
  60472. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  60473. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60474. manhattanDistance: boolean;
  60475. /**
  60476. * Creates a new WorleyNoise3DBlock
  60477. * @param name defines the block name
  60478. */
  60479. constructor(name: string);
  60480. /**
  60481. * Gets the current class name
  60482. * @returns the class name
  60483. */
  60484. getClassName(): string;
  60485. /**
  60486. * Gets the seed input component
  60487. */
  60488. get seed(): NodeMaterialConnectionPoint;
  60489. /**
  60490. * Gets the jitter input component
  60491. */
  60492. get jitter(): NodeMaterialConnectionPoint;
  60493. /**
  60494. * Gets the output component
  60495. */
  60496. get output(): NodeMaterialConnectionPoint;
  60497. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60498. /**
  60499. * Exposes the properties to the UI?
  60500. */
  60501. protected _dumpPropertiesCode(): string;
  60502. /**
  60503. * Exposes the properties to the Seralize?
  60504. */
  60505. serialize(): any;
  60506. /**
  60507. * Exposes the properties to the deseralize?
  60508. */
  60509. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60510. }
  60511. }
  60512. declare module BABYLON {
  60513. /**
  60514. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60515. */
  60516. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60517. /**
  60518. * Creates a new SimplexPerlin3DBlock
  60519. * @param name defines the block name
  60520. */
  60521. constructor(name: string);
  60522. /**
  60523. * Gets the current class name
  60524. * @returns the class name
  60525. */
  60526. getClassName(): string;
  60527. /**
  60528. * Gets the seed operand input component
  60529. */
  60530. get seed(): NodeMaterialConnectionPoint;
  60531. /**
  60532. * Gets the output component
  60533. */
  60534. get output(): NodeMaterialConnectionPoint;
  60535. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60536. }
  60537. }
  60538. declare module BABYLON {
  60539. /**
  60540. * Block used to blend normals
  60541. */
  60542. export class NormalBlendBlock extends NodeMaterialBlock {
  60543. /**
  60544. * Creates a new NormalBlendBlock
  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 first input component
  60555. */
  60556. get normalMap0(): NodeMaterialConnectionPoint;
  60557. /**
  60558. * Gets the second input component
  60559. */
  60560. get normalMap1(): NodeMaterialConnectionPoint;
  60561. /**
  60562. * Gets the output component
  60563. */
  60564. get output(): NodeMaterialConnectionPoint;
  60565. protected _buildBlock(state: NodeMaterialBuildState): this;
  60566. }
  60567. }
  60568. declare module BABYLON {
  60569. /**
  60570. * Block used to rotate a 2d vector by a given angle
  60571. */
  60572. export class Rotate2dBlock extends NodeMaterialBlock {
  60573. /**
  60574. * Creates a new Rotate2dBlock
  60575. * @param name defines the block name
  60576. */
  60577. constructor(name: string);
  60578. /**
  60579. * Gets the current class name
  60580. * @returns the class name
  60581. */
  60582. getClassName(): string;
  60583. /**
  60584. * Gets the input vector
  60585. */
  60586. get input(): NodeMaterialConnectionPoint;
  60587. /**
  60588. * Gets the input angle
  60589. */
  60590. get angle(): NodeMaterialConnectionPoint;
  60591. /**
  60592. * Gets the output component
  60593. */
  60594. get output(): NodeMaterialConnectionPoint;
  60595. autoConfigure(material: NodeMaterial): void;
  60596. protected _buildBlock(state: NodeMaterialBuildState): this;
  60597. }
  60598. }
  60599. declare module BABYLON {
  60600. /**
  60601. * Block used to get the reflected vector from a direction and a normal
  60602. */
  60603. export class ReflectBlock extends NodeMaterialBlock {
  60604. /**
  60605. * Creates a new ReflectBlock
  60606. * @param name defines the block name
  60607. */
  60608. constructor(name: string);
  60609. /**
  60610. * Gets the current class name
  60611. * @returns the class name
  60612. */
  60613. getClassName(): string;
  60614. /**
  60615. * Gets the incident component
  60616. */
  60617. get incident(): NodeMaterialConnectionPoint;
  60618. /**
  60619. * Gets the normal component
  60620. */
  60621. get normal(): NodeMaterialConnectionPoint;
  60622. /**
  60623. * Gets the output component
  60624. */
  60625. get output(): NodeMaterialConnectionPoint;
  60626. protected _buildBlock(state: NodeMaterialBuildState): this;
  60627. }
  60628. }
  60629. declare module BABYLON {
  60630. /**
  60631. * Block used to get the refracted vector from a direction and a normal
  60632. */
  60633. export class RefractBlock extends NodeMaterialBlock {
  60634. /**
  60635. * Creates a new RefractBlock
  60636. * @param name defines the block name
  60637. */
  60638. constructor(name: string);
  60639. /**
  60640. * Gets the current class name
  60641. * @returns the class name
  60642. */
  60643. getClassName(): string;
  60644. /**
  60645. * Gets the incident component
  60646. */
  60647. get incident(): NodeMaterialConnectionPoint;
  60648. /**
  60649. * Gets the normal component
  60650. */
  60651. get normal(): NodeMaterialConnectionPoint;
  60652. /**
  60653. * Gets the index of refraction component
  60654. */
  60655. get ior(): NodeMaterialConnectionPoint;
  60656. /**
  60657. * Gets the output component
  60658. */
  60659. get output(): NodeMaterialConnectionPoint;
  60660. protected _buildBlock(state: NodeMaterialBuildState): this;
  60661. }
  60662. }
  60663. declare module BABYLON {
  60664. /**
  60665. * Block used to desaturate a color
  60666. */
  60667. export class DesaturateBlock extends NodeMaterialBlock {
  60668. /**
  60669. * Creates a new DesaturateBlock
  60670. * @param name defines the block name
  60671. */
  60672. constructor(name: string);
  60673. /**
  60674. * Gets the current class name
  60675. * @returns the class name
  60676. */
  60677. getClassName(): string;
  60678. /**
  60679. * Gets the color operand input component
  60680. */
  60681. get color(): NodeMaterialConnectionPoint;
  60682. /**
  60683. * Gets the level operand input component
  60684. */
  60685. get level(): NodeMaterialConnectionPoint;
  60686. /**
  60687. * Gets the output component
  60688. */
  60689. get output(): NodeMaterialConnectionPoint;
  60690. protected _buildBlock(state: NodeMaterialBuildState): this;
  60691. }
  60692. }
  60693. declare module BABYLON {
  60694. /**
  60695. * Effect Render Options
  60696. */
  60697. export interface IEffectRendererOptions {
  60698. /**
  60699. * Defines the vertices positions.
  60700. */
  60701. positions?: number[];
  60702. /**
  60703. * Defines the indices.
  60704. */
  60705. indices?: number[];
  60706. }
  60707. /**
  60708. * Helper class to render one or more effects.
  60709. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60710. */
  60711. export class EffectRenderer {
  60712. private engine;
  60713. private static _DefaultOptions;
  60714. private _vertexBuffers;
  60715. private _indexBuffer;
  60716. private _fullscreenViewport;
  60717. /**
  60718. * Creates an effect renderer
  60719. * @param engine the engine to use for rendering
  60720. * @param options defines the options of the effect renderer
  60721. */
  60722. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60723. /**
  60724. * Sets the current viewport in normalized coordinates 0-1
  60725. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60726. */
  60727. setViewport(viewport?: Viewport): void;
  60728. /**
  60729. * Binds the embedded attributes buffer to the effect.
  60730. * @param effect Defines the effect to bind the attributes for
  60731. */
  60732. bindBuffers(effect: Effect): void;
  60733. /**
  60734. * Sets the current effect wrapper to use during draw.
  60735. * The effect needs to be ready before calling this api.
  60736. * This also sets the default full screen position attribute.
  60737. * @param effectWrapper Defines the effect to draw with
  60738. */
  60739. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60740. /**
  60741. * Draws a full screen quad.
  60742. */
  60743. draw(): void;
  60744. private isRenderTargetTexture;
  60745. /**
  60746. * renders one or more effects to a specified texture
  60747. * @param effectWrapper the effect to renderer
  60748. * @param outputTexture texture to draw to, if null it will render to the screen.
  60749. */
  60750. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60751. /**
  60752. * Disposes of the effect renderer
  60753. */
  60754. dispose(): void;
  60755. }
  60756. /**
  60757. * Options to create an EffectWrapper
  60758. */
  60759. interface EffectWrapperCreationOptions {
  60760. /**
  60761. * Engine to use to create the effect
  60762. */
  60763. engine: ThinEngine;
  60764. /**
  60765. * Fragment shader for the effect
  60766. */
  60767. fragmentShader: string;
  60768. /**
  60769. * Vertex shader for the effect
  60770. */
  60771. vertexShader?: string;
  60772. /**
  60773. * Attributes to use in the shader
  60774. */
  60775. attributeNames?: Array<string>;
  60776. /**
  60777. * Uniforms to use in the shader
  60778. */
  60779. uniformNames?: Array<string>;
  60780. /**
  60781. * Texture sampler names to use in the shader
  60782. */
  60783. samplerNames?: Array<string>;
  60784. /**
  60785. * The friendly name of the effect displayed in Spector.
  60786. */
  60787. name?: string;
  60788. }
  60789. /**
  60790. * Wraps an effect to be used for rendering
  60791. */
  60792. export class EffectWrapper {
  60793. /**
  60794. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60795. */
  60796. onApplyObservable: Observable<{}>;
  60797. /**
  60798. * The underlying effect
  60799. */
  60800. effect: Effect;
  60801. /**
  60802. * Creates an effect to be renderer
  60803. * @param creationOptions options to create the effect
  60804. */
  60805. constructor(creationOptions: EffectWrapperCreationOptions);
  60806. /**
  60807. * Disposes of the effect wrapper
  60808. */
  60809. dispose(): void;
  60810. }
  60811. }
  60812. declare module BABYLON {
  60813. /**
  60814. * Helper class to push actions to a pool of workers.
  60815. */
  60816. export class WorkerPool implements IDisposable {
  60817. private _workerInfos;
  60818. private _pendingActions;
  60819. /**
  60820. * Constructor
  60821. * @param workers Array of workers to use for actions
  60822. */
  60823. constructor(workers: Array<Worker>);
  60824. /**
  60825. * Terminates all workers and clears any pending actions.
  60826. */
  60827. dispose(): void;
  60828. /**
  60829. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60830. * pended until a worker has completed its action.
  60831. * @param action The action to perform. Call onComplete when the action is complete.
  60832. */
  60833. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60834. private _execute;
  60835. }
  60836. }
  60837. declare module BABYLON {
  60838. /**
  60839. * Configuration for Draco compression
  60840. */
  60841. export interface IDracoCompressionConfiguration {
  60842. /**
  60843. * Configuration for the decoder.
  60844. */
  60845. decoder: {
  60846. /**
  60847. * The url to the WebAssembly module.
  60848. */
  60849. wasmUrl?: string;
  60850. /**
  60851. * The url to the WebAssembly binary.
  60852. */
  60853. wasmBinaryUrl?: string;
  60854. /**
  60855. * The url to the fallback JavaScript module.
  60856. */
  60857. fallbackUrl?: string;
  60858. };
  60859. }
  60860. /**
  60861. * Draco compression (https://google.github.io/draco/)
  60862. *
  60863. * This class wraps the Draco module.
  60864. *
  60865. * **Encoder**
  60866. *
  60867. * The encoder is not currently implemented.
  60868. *
  60869. * **Decoder**
  60870. *
  60871. * 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.
  60872. *
  60873. * To update the configuration, use the following code:
  60874. * ```javascript
  60875. * DracoCompression.Configuration = {
  60876. * decoder: {
  60877. * wasmUrl: "<url to the WebAssembly library>",
  60878. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60879. * fallbackUrl: "<url to the fallback JavaScript library>",
  60880. * }
  60881. * };
  60882. * ```
  60883. *
  60884. * 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.
  60885. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60886. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60887. *
  60888. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60889. * ```javascript
  60890. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60891. * ```
  60892. *
  60893. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60894. */
  60895. export class DracoCompression implements IDisposable {
  60896. private _workerPoolPromise?;
  60897. private _decoderModulePromise?;
  60898. /**
  60899. * The configuration. Defaults to the following urls:
  60900. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60901. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60902. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60903. */
  60904. static Configuration: IDracoCompressionConfiguration;
  60905. /**
  60906. * Returns true if the decoder configuration is available.
  60907. */
  60908. static get DecoderAvailable(): boolean;
  60909. /**
  60910. * Default number of workers to create when creating the draco compression object.
  60911. */
  60912. static DefaultNumWorkers: number;
  60913. private static GetDefaultNumWorkers;
  60914. private static _Default;
  60915. /**
  60916. * Default instance for the draco compression object.
  60917. */
  60918. static get Default(): DracoCompression;
  60919. /**
  60920. * Constructor
  60921. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60922. */
  60923. constructor(numWorkers?: number);
  60924. /**
  60925. * Stop all async operations and release resources.
  60926. */
  60927. dispose(): void;
  60928. /**
  60929. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60930. * @returns a promise that resolves when ready
  60931. */
  60932. whenReadyAsync(): Promise<void>;
  60933. /**
  60934. * Decode Draco compressed mesh data to vertex data.
  60935. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60936. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60937. * @returns A promise that resolves with the decoded vertex data
  60938. */
  60939. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60940. [kind: string]: number;
  60941. }): Promise<VertexData>;
  60942. }
  60943. }
  60944. declare module BABYLON {
  60945. /**
  60946. * Class for building Constructive Solid Geometry
  60947. */
  60948. export class CSG {
  60949. private polygons;
  60950. /**
  60951. * The world matrix
  60952. */
  60953. matrix: Matrix;
  60954. /**
  60955. * Stores the position
  60956. */
  60957. position: Vector3;
  60958. /**
  60959. * Stores the rotation
  60960. */
  60961. rotation: Vector3;
  60962. /**
  60963. * Stores the rotation quaternion
  60964. */
  60965. rotationQuaternion: Nullable<Quaternion>;
  60966. /**
  60967. * Stores the scaling vector
  60968. */
  60969. scaling: Vector3;
  60970. /**
  60971. * Convert the Mesh to CSG
  60972. * @param mesh The Mesh to convert to CSG
  60973. * @returns A new CSG from the Mesh
  60974. */
  60975. static FromMesh(mesh: Mesh): CSG;
  60976. /**
  60977. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60978. * @param polygons Polygons used to construct a CSG solid
  60979. */
  60980. private static FromPolygons;
  60981. /**
  60982. * Clones, or makes a deep copy, of the CSG
  60983. * @returns A new CSG
  60984. */
  60985. clone(): CSG;
  60986. /**
  60987. * Unions this CSG with another CSG
  60988. * @param csg The CSG to union against this CSG
  60989. * @returns The unioned CSG
  60990. */
  60991. union(csg: CSG): CSG;
  60992. /**
  60993. * Unions this CSG with another CSG in place
  60994. * @param csg The CSG to union against this CSG
  60995. */
  60996. unionInPlace(csg: CSG): void;
  60997. /**
  60998. * Subtracts this CSG with another CSG
  60999. * @param csg The CSG to subtract against this CSG
  61000. * @returns A new CSG
  61001. */
  61002. subtract(csg: CSG): CSG;
  61003. /**
  61004. * Subtracts this CSG with another CSG in place
  61005. * @param csg The CSG to subtact against this CSG
  61006. */
  61007. subtractInPlace(csg: CSG): void;
  61008. /**
  61009. * Intersect this CSG with another CSG
  61010. * @param csg The CSG to intersect against this CSG
  61011. * @returns A new CSG
  61012. */
  61013. intersect(csg: CSG): CSG;
  61014. /**
  61015. * Intersects this CSG with another CSG in place
  61016. * @param csg The CSG to intersect against this CSG
  61017. */
  61018. intersectInPlace(csg: CSG): void;
  61019. /**
  61020. * Return a new CSG solid with solid and empty space switched. This solid is
  61021. * not modified.
  61022. * @returns A new CSG solid with solid and empty space switched
  61023. */
  61024. inverse(): CSG;
  61025. /**
  61026. * Inverses the CSG in place
  61027. */
  61028. inverseInPlace(): void;
  61029. /**
  61030. * This is used to keep meshes transformations so they can be restored
  61031. * when we build back a Babylon Mesh
  61032. * NB : All CSG operations are performed in world coordinates
  61033. * @param csg The CSG to copy the transform attributes from
  61034. * @returns This CSG
  61035. */
  61036. copyTransformAttributes(csg: CSG): CSG;
  61037. /**
  61038. * Build Raw mesh from CSG
  61039. * Coordinates here are in world space
  61040. * @param name The name of the mesh geometry
  61041. * @param scene The Scene
  61042. * @param keepSubMeshes Specifies if the submeshes should be kept
  61043. * @returns A new Mesh
  61044. */
  61045. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61046. /**
  61047. * Build Mesh from CSG taking material and transforms into account
  61048. * @param name The name of the Mesh
  61049. * @param material The material of the Mesh
  61050. * @param scene The Scene
  61051. * @param keepSubMeshes Specifies if submeshes should be kept
  61052. * @returns The new Mesh
  61053. */
  61054. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  61055. }
  61056. }
  61057. declare module BABYLON {
  61058. /**
  61059. * Class used to create a trail following a mesh
  61060. */
  61061. export class TrailMesh extends Mesh {
  61062. private _generator;
  61063. private _autoStart;
  61064. private _running;
  61065. private _diameter;
  61066. private _length;
  61067. private _sectionPolygonPointsCount;
  61068. private _sectionVectors;
  61069. private _sectionNormalVectors;
  61070. private _beforeRenderObserver;
  61071. /**
  61072. * @constructor
  61073. * @param name The value used by scene.getMeshByName() to do a lookup.
  61074. * @param generator The mesh or transform node to generate a trail.
  61075. * @param scene The scene to add this mesh to.
  61076. * @param diameter Diameter of trailing mesh. Default is 1.
  61077. * @param length Length of trailing mesh. Default is 60.
  61078. * @param autoStart Automatically start trailing mesh. Default true.
  61079. */
  61080. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  61081. /**
  61082. * "TrailMesh"
  61083. * @returns "TrailMesh"
  61084. */
  61085. getClassName(): string;
  61086. private _createMesh;
  61087. /**
  61088. * Start trailing mesh.
  61089. */
  61090. start(): void;
  61091. /**
  61092. * Stop trailing mesh.
  61093. */
  61094. stop(): void;
  61095. /**
  61096. * Update trailing mesh geometry.
  61097. */
  61098. update(): void;
  61099. /**
  61100. * Returns a new TrailMesh object.
  61101. * @param name is a string, the name given to the new mesh
  61102. * @param newGenerator use new generator object for cloned trail mesh
  61103. * @returns a new mesh
  61104. */
  61105. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  61106. /**
  61107. * Serializes this trail mesh
  61108. * @param serializationObject object to write serialization to
  61109. */
  61110. serialize(serializationObject: any): void;
  61111. /**
  61112. * Parses a serialized trail mesh
  61113. * @param parsedMesh the serialized mesh
  61114. * @param scene the scene to create the trail mesh in
  61115. * @returns the created trail mesh
  61116. */
  61117. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  61118. }
  61119. }
  61120. declare module BABYLON {
  61121. /**
  61122. * Class containing static functions to help procedurally build meshes
  61123. */
  61124. export class TiledBoxBuilder {
  61125. /**
  61126. * Creates a box mesh
  61127. * 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)
  61128. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61130. * * 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
  61131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61132. * @param name defines the name of the mesh
  61133. * @param options defines the options used to create the mesh
  61134. * @param scene defines the hosting scene
  61135. * @returns the box mesh
  61136. */
  61137. static CreateTiledBox(name: string, options: {
  61138. pattern?: number;
  61139. width?: number;
  61140. height?: number;
  61141. depth?: number;
  61142. tileSize?: number;
  61143. tileWidth?: number;
  61144. tileHeight?: number;
  61145. alignHorizontal?: number;
  61146. alignVertical?: number;
  61147. faceUV?: Vector4[];
  61148. faceColors?: Color4[];
  61149. sideOrientation?: number;
  61150. updatable?: boolean;
  61151. }, scene?: Nullable<Scene>): Mesh;
  61152. }
  61153. }
  61154. declare module BABYLON {
  61155. /**
  61156. * Class containing static functions to help procedurally build meshes
  61157. */
  61158. export class TorusKnotBuilder {
  61159. /**
  61160. * Creates a torus knot mesh
  61161. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61162. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61163. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61164. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61166. * * 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
  61167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61168. * @param name defines the name of the mesh
  61169. * @param options defines the options used to create the mesh
  61170. * @param scene defines the hosting scene
  61171. * @returns the torus knot mesh
  61172. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61173. */
  61174. static CreateTorusKnot(name: string, options: {
  61175. radius?: number;
  61176. tube?: number;
  61177. radialSegments?: number;
  61178. tubularSegments?: number;
  61179. p?: number;
  61180. q?: number;
  61181. updatable?: boolean;
  61182. sideOrientation?: number;
  61183. frontUVs?: Vector4;
  61184. backUVs?: Vector4;
  61185. }, scene: any): Mesh;
  61186. }
  61187. }
  61188. declare module BABYLON {
  61189. /**
  61190. * Polygon
  61191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  61192. */
  61193. export class Polygon {
  61194. /**
  61195. * Creates a rectangle
  61196. * @param xmin bottom X coord
  61197. * @param ymin bottom Y coord
  61198. * @param xmax top X coord
  61199. * @param ymax top Y coord
  61200. * @returns points that make the resulting rectation
  61201. */
  61202. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  61203. /**
  61204. * Creates a circle
  61205. * @param radius radius of circle
  61206. * @param cx scale in x
  61207. * @param cy scale in y
  61208. * @param numberOfSides number of sides that make up the circle
  61209. * @returns points that make the resulting circle
  61210. */
  61211. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  61212. /**
  61213. * Creates a polygon from input string
  61214. * @param input Input polygon data
  61215. * @returns the parsed points
  61216. */
  61217. static Parse(input: string): Vector2[];
  61218. /**
  61219. * Starts building a polygon from x and y coordinates
  61220. * @param x x coordinate
  61221. * @param y y coordinate
  61222. * @returns the started path2
  61223. */
  61224. static StartingAt(x: number, y: number): Path2;
  61225. }
  61226. /**
  61227. * Builds a polygon
  61228. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  61229. */
  61230. export class PolygonMeshBuilder {
  61231. private _points;
  61232. private _outlinepoints;
  61233. private _holes;
  61234. private _name;
  61235. private _scene;
  61236. private _epoints;
  61237. private _eholes;
  61238. private _addToepoint;
  61239. /**
  61240. * Babylon reference to the earcut plugin.
  61241. */
  61242. bjsEarcut: any;
  61243. /**
  61244. * Creates a PolygonMeshBuilder
  61245. * @param name name of the builder
  61246. * @param contours Path of the polygon
  61247. * @param scene scene to add to when creating the mesh
  61248. * @param earcutInjection can be used to inject your own earcut reference
  61249. */
  61250. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  61251. /**
  61252. * Adds a whole within the polygon
  61253. * @param hole Array of points defining the hole
  61254. * @returns this
  61255. */
  61256. addHole(hole: Vector2[]): PolygonMeshBuilder;
  61257. /**
  61258. * Creates the polygon
  61259. * @param updatable If the mesh should be updatable
  61260. * @param depth The depth of the mesh created
  61261. * @returns the created mesh
  61262. */
  61263. build(updatable?: boolean, depth?: number): Mesh;
  61264. /**
  61265. * Creates the polygon
  61266. * @param depth The depth of the mesh created
  61267. * @returns the created VertexData
  61268. */
  61269. buildVertexData(depth?: number): VertexData;
  61270. /**
  61271. * Adds a side to the polygon
  61272. * @param positions points that make the polygon
  61273. * @param normals normals of the polygon
  61274. * @param uvs uvs of the polygon
  61275. * @param indices indices of the polygon
  61276. * @param bounds bounds of the polygon
  61277. * @param points points of the polygon
  61278. * @param depth depth of the polygon
  61279. * @param flip flip of the polygon
  61280. */
  61281. private addSide;
  61282. }
  61283. }
  61284. declare module BABYLON {
  61285. /**
  61286. * Class containing static functions to help procedurally build meshes
  61287. */
  61288. export class PolygonBuilder {
  61289. /**
  61290. * Creates a polygon mesh
  61291. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61292. * * 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
  61293. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61295. * * 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)
  61296. * * Remember you can only change the shape positions, not their number when updating a polygon
  61297. * @param name defines the name of the mesh
  61298. * @param options defines the options used to create the mesh
  61299. * @param scene defines the hosting scene
  61300. * @param earcutInjection can be used to inject your own earcut reference
  61301. * @returns the polygon mesh
  61302. */
  61303. static CreatePolygon(name: string, options: {
  61304. shape: Vector3[];
  61305. holes?: Vector3[][];
  61306. depth?: number;
  61307. faceUV?: Vector4[];
  61308. faceColors?: Color4[];
  61309. updatable?: boolean;
  61310. sideOrientation?: number;
  61311. frontUVs?: Vector4;
  61312. backUVs?: Vector4;
  61313. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61314. /**
  61315. * Creates an extruded polygon mesh, with depth in the Y direction.
  61316. * * 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)
  61317. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61318. * @param name defines the name of the mesh
  61319. * @param options defines the options used to create the mesh
  61320. * @param scene defines the hosting scene
  61321. * @param earcutInjection can be used to inject your own earcut reference
  61322. * @returns the polygon mesh
  61323. */
  61324. static ExtrudePolygon(name: string, options: {
  61325. shape: Vector3[];
  61326. holes?: Vector3[][];
  61327. depth?: number;
  61328. faceUV?: Vector4[];
  61329. faceColors?: Color4[];
  61330. updatable?: boolean;
  61331. sideOrientation?: number;
  61332. frontUVs?: Vector4;
  61333. backUVs?: Vector4;
  61334. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61335. }
  61336. }
  61337. declare module BABYLON {
  61338. /**
  61339. * Class containing static functions to help procedurally build meshes
  61340. */
  61341. export class LatheBuilder {
  61342. /**
  61343. * Creates lathe mesh.
  61344. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61345. * * 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
  61346. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61347. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61348. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61349. * * 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
  61350. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61351. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  61352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61353. * * 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
  61354. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61356. * @param name defines the name of the mesh
  61357. * @param options defines the options used to create the mesh
  61358. * @param scene defines the hosting scene
  61359. * @returns the lathe mesh
  61360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61361. */
  61362. static CreateLathe(name: string, options: {
  61363. shape: Vector3[];
  61364. radius?: number;
  61365. tessellation?: number;
  61366. clip?: number;
  61367. arc?: number;
  61368. closed?: boolean;
  61369. updatable?: boolean;
  61370. sideOrientation?: number;
  61371. frontUVs?: Vector4;
  61372. backUVs?: Vector4;
  61373. cap?: number;
  61374. invertUV?: boolean;
  61375. }, scene?: Nullable<Scene>): Mesh;
  61376. }
  61377. }
  61378. declare module BABYLON {
  61379. /**
  61380. * Class containing static functions to help procedurally build meshes
  61381. */
  61382. export class TiledPlaneBuilder {
  61383. /**
  61384. * Creates a tiled plane mesh
  61385. * * The parameter `pattern` will, depending on value, do nothing or
  61386. * * * flip (reflect about central vertical) alternate tiles across and up
  61387. * * * flip every tile on alternate rows
  61388. * * * rotate (180 degs) alternate tiles across and up
  61389. * * * rotate every tile on alternate rows
  61390. * * * flip and rotate alternate tiles across and up
  61391. * * * flip and rotate every tile on alternate rows
  61392. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  61393. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  61394. * * 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
  61395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61396. * * 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)
  61397. * * 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)
  61398. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61399. * @param name defines the name of the mesh
  61400. * @param options defines the options used to create the mesh
  61401. * @param scene defines the hosting scene
  61402. * @returns the box mesh
  61403. */
  61404. static CreateTiledPlane(name: string, options: {
  61405. pattern?: number;
  61406. tileSize?: number;
  61407. tileWidth?: number;
  61408. tileHeight?: number;
  61409. size?: number;
  61410. width?: number;
  61411. height?: number;
  61412. alignHorizontal?: number;
  61413. alignVertical?: number;
  61414. sideOrientation?: number;
  61415. frontUVs?: Vector4;
  61416. backUVs?: Vector4;
  61417. updatable?: boolean;
  61418. }, scene?: Nullable<Scene>): Mesh;
  61419. }
  61420. }
  61421. declare module BABYLON {
  61422. /**
  61423. * Class containing static functions to help procedurally build meshes
  61424. */
  61425. export class TubeBuilder {
  61426. /**
  61427. * Creates a tube mesh.
  61428. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61429. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61430. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61431. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61432. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61433. * * 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)
  61434. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61435. * * 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
  61436. * * 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
  61437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61438. * * 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
  61439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61441. * @param name defines the name of the mesh
  61442. * @param options defines the options used to create the mesh
  61443. * @param scene defines the hosting scene
  61444. * @returns the tube mesh
  61445. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61446. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61447. */
  61448. static CreateTube(name: string, options: {
  61449. path: Vector3[];
  61450. radius?: number;
  61451. tessellation?: number;
  61452. radiusFunction?: {
  61453. (i: number, distance: number): number;
  61454. };
  61455. cap?: number;
  61456. arc?: number;
  61457. updatable?: boolean;
  61458. sideOrientation?: number;
  61459. frontUVs?: Vector4;
  61460. backUVs?: Vector4;
  61461. instance?: Mesh;
  61462. invertUV?: boolean;
  61463. }, scene?: Nullable<Scene>): Mesh;
  61464. }
  61465. }
  61466. declare module BABYLON {
  61467. /**
  61468. * Class containing static functions to help procedurally build meshes
  61469. */
  61470. export class IcoSphereBuilder {
  61471. /**
  61472. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61473. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61474. * * 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`)
  61475. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61476. * * 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
  61477. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61478. * * 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
  61479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61480. * @param name defines the name of the mesh
  61481. * @param options defines the options used to create the mesh
  61482. * @param scene defines the hosting scene
  61483. * @returns the icosahedron mesh
  61484. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61485. */
  61486. static CreateIcoSphere(name: string, options: {
  61487. radius?: number;
  61488. radiusX?: number;
  61489. radiusY?: number;
  61490. radiusZ?: number;
  61491. flat?: boolean;
  61492. subdivisions?: number;
  61493. sideOrientation?: number;
  61494. frontUVs?: Vector4;
  61495. backUVs?: Vector4;
  61496. updatable?: boolean;
  61497. }, scene?: Nullable<Scene>): Mesh;
  61498. }
  61499. }
  61500. declare module BABYLON {
  61501. /**
  61502. * Class containing static functions to help procedurally build meshes
  61503. */
  61504. export class DecalBuilder {
  61505. /**
  61506. * Creates a decal mesh.
  61507. * 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
  61508. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61509. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61510. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61511. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61512. * @param name defines the name of the mesh
  61513. * @param sourceMesh defines the mesh where the decal must be applied
  61514. * @param options defines the options used to create the mesh
  61515. * @param scene defines the hosting scene
  61516. * @returns the decal mesh
  61517. * @see https://doc.babylonjs.com/how_to/decals
  61518. */
  61519. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61520. position?: Vector3;
  61521. normal?: Vector3;
  61522. size?: Vector3;
  61523. angle?: number;
  61524. }): Mesh;
  61525. }
  61526. }
  61527. declare module BABYLON {
  61528. /**
  61529. * Class containing static functions to help procedurally build meshes
  61530. */
  61531. export class MeshBuilder {
  61532. /**
  61533. * Creates a box mesh
  61534. * * The parameter `size` sets the size (float) of each box side (default 1)
  61535. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61536. * * 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)
  61537. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61539. * * 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
  61540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61541. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61542. * @param name defines the name of the mesh
  61543. * @param options defines the options used to create the mesh
  61544. * @param scene defines the hosting scene
  61545. * @returns the box mesh
  61546. */
  61547. static CreateBox(name: string, options: {
  61548. size?: number;
  61549. width?: number;
  61550. height?: number;
  61551. depth?: number;
  61552. faceUV?: Vector4[];
  61553. faceColors?: Color4[];
  61554. sideOrientation?: number;
  61555. frontUVs?: Vector4;
  61556. backUVs?: Vector4;
  61557. wrap?: boolean;
  61558. topBaseAt?: number;
  61559. bottomBaseAt?: number;
  61560. updatable?: boolean;
  61561. }, scene?: Nullable<Scene>): Mesh;
  61562. /**
  61563. * Creates a tiled box mesh
  61564. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61566. * @param name defines the name of the mesh
  61567. * @param options defines the options used to create the mesh
  61568. * @param scene defines the hosting scene
  61569. * @returns the tiled box mesh
  61570. */
  61571. static CreateTiledBox(name: string, options: {
  61572. pattern?: number;
  61573. size?: number;
  61574. width?: number;
  61575. height?: number;
  61576. depth: number;
  61577. tileSize?: number;
  61578. tileWidth?: number;
  61579. tileHeight?: number;
  61580. faceUV?: Vector4[];
  61581. faceColors?: Color4[];
  61582. alignHorizontal?: number;
  61583. alignVertical?: number;
  61584. sideOrientation?: number;
  61585. updatable?: boolean;
  61586. }, scene?: Nullable<Scene>): Mesh;
  61587. /**
  61588. * Creates a sphere mesh
  61589. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61590. * * 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`)
  61591. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61592. * * 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
  61593. * * 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)
  61594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61595. * * 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
  61596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61597. * @param name defines the name of the mesh
  61598. * @param options defines the options used to create the mesh
  61599. * @param scene defines the hosting scene
  61600. * @returns the sphere mesh
  61601. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61602. */
  61603. static CreateSphere(name: string, options: {
  61604. segments?: number;
  61605. diameter?: number;
  61606. diameterX?: number;
  61607. diameterY?: number;
  61608. diameterZ?: number;
  61609. arc?: number;
  61610. slice?: number;
  61611. sideOrientation?: number;
  61612. frontUVs?: Vector4;
  61613. backUVs?: Vector4;
  61614. updatable?: boolean;
  61615. }, scene?: Nullable<Scene>): Mesh;
  61616. /**
  61617. * Creates a plane polygonal mesh. By default, this is a disc
  61618. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61619. * * 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
  61620. * * 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
  61621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61622. * * 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
  61623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61624. * @param name defines the name of the mesh
  61625. * @param options defines the options used to create the mesh
  61626. * @param scene defines the hosting scene
  61627. * @returns the plane polygonal mesh
  61628. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61629. */
  61630. static CreateDisc(name: string, options: {
  61631. radius?: number;
  61632. tessellation?: number;
  61633. arc?: number;
  61634. updatable?: boolean;
  61635. sideOrientation?: number;
  61636. frontUVs?: Vector4;
  61637. backUVs?: Vector4;
  61638. }, scene?: Nullable<Scene>): Mesh;
  61639. /**
  61640. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61641. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61642. * * 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`)
  61643. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61644. * * 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
  61645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61646. * * 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
  61647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61648. * @param name defines the name of the mesh
  61649. * @param options defines the options used to create the mesh
  61650. * @param scene defines the hosting scene
  61651. * @returns the icosahedron mesh
  61652. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61653. */
  61654. static CreateIcoSphere(name: string, options: {
  61655. radius?: number;
  61656. radiusX?: number;
  61657. radiusY?: number;
  61658. radiusZ?: number;
  61659. flat?: boolean;
  61660. subdivisions?: number;
  61661. sideOrientation?: number;
  61662. frontUVs?: Vector4;
  61663. backUVs?: Vector4;
  61664. updatable?: boolean;
  61665. }, scene?: Nullable<Scene>): Mesh;
  61666. /**
  61667. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61668. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61669. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61670. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61671. * * 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
  61672. * * 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
  61673. * * 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
  61674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61675. * * 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
  61676. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61677. * * 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
  61678. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61679. * * 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
  61680. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61682. * @param name defines the name of the mesh
  61683. * @param options defines the options used to create the mesh
  61684. * @param scene defines the hosting scene
  61685. * @returns the ribbon mesh
  61686. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61687. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61688. */
  61689. static CreateRibbon(name: string, options: {
  61690. pathArray: Vector3[][];
  61691. closeArray?: boolean;
  61692. closePath?: boolean;
  61693. offset?: number;
  61694. updatable?: boolean;
  61695. sideOrientation?: number;
  61696. frontUVs?: Vector4;
  61697. backUVs?: Vector4;
  61698. instance?: Mesh;
  61699. invertUV?: boolean;
  61700. uvs?: Vector2[];
  61701. colors?: Color4[];
  61702. }, scene?: Nullable<Scene>): Mesh;
  61703. /**
  61704. * Creates a cylinder or a cone mesh
  61705. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61706. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61707. * * 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.
  61708. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61709. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61710. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61711. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61712. * * 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).
  61713. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61714. * * 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).
  61715. * * 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
  61716. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61717. * * 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
  61718. * * 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.
  61719. * * If `enclose` is false, a ring surface is one element.
  61720. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61721. * * 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
  61722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61723. * * 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
  61724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61725. * @param name defines the name of the mesh
  61726. * @param options defines the options used to create the mesh
  61727. * @param scene defines the hosting scene
  61728. * @returns the cylinder mesh
  61729. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61730. */
  61731. static CreateCylinder(name: string, options: {
  61732. height?: number;
  61733. diameterTop?: number;
  61734. diameterBottom?: number;
  61735. diameter?: number;
  61736. tessellation?: number;
  61737. subdivisions?: number;
  61738. arc?: number;
  61739. faceColors?: Color4[];
  61740. faceUV?: Vector4[];
  61741. updatable?: boolean;
  61742. hasRings?: boolean;
  61743. enclose?: boolean;
  61744. cap?: number;
  61745. sideOrientation?: number;
  61746. frontUVs?: Vector4;
  61747. backUVs?: Vector4;
  61748. }, scene?: Nullable<Scene>): Mesh;
  61749. /**
  61750. * Creates a torus mesh
  61751. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61752. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61753. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61755. * * 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
  61756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61757. * @param name defines the name of the mesh
  61758. * @param options defines the options used to create the mesh
  61759. * @param scene defines the hosting scene
  61760. * @returns the torus mesh
  61761. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61762. */
  61763. static CreateTorus(name: string, options: {
  61764. diameter?: number;
  61765. thickness?: number;
  61766. tessellation?: number;
  61767. updatable?: boolean;
  61768. sideOrientation?: number;
  61769. frontUVs?: Vector4;
  61770. backUVs?: Vector4;
  61771. }, scene?: Nullable<Scene>): Mesh;
  61772. /**
  61773. * Creates a torus knot mesh
  61774. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61775. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61776. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61777. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61778. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61779. * * 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
  61780. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61781. * @param name defines the name of the mesh
  61782. * @param options defines the options used to create the mesh
  61783. * @param scene defines the hosting scene
  61784. * @returns the torus knot mesh
  61785. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61786. */
  61787. static CreateTorusKnot(name: string, options: {
  61788. radius?: number;
  61789. tube?: number;
  61790. radialSegments?: number;
  61791. tubularSegments?: number;
  61792. p?: number;
  61793. q?: number;
  61794. updatable?: boolean;
  61795. sideOrientation?: number;
  61796. frontUVs?: Vector4;
  61797. backUVs?: Vector4;
  61798. }, scene?: Nullable<Scene>): Mesh;
  61799. /**
  61800. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61801. * * 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
  61802. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61803. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61804. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61805. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61806. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61807. * * 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
  61808. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61811. * @param name defines the name of the new line system
  61812. * @param options defines the options used to create the line system
  61813. * @param scene defines the hosting scene
  61814. * @returns a new line system mesh
  61815. */
  61816. static CreateLineSystem(name: string, options: {
  61817. lines: Vector3[][];
  61818. updatable?: boolean;
  61819. instance?: Nullable<LinesMesh>;
  61820. colors?: Nullable<Color4[][]>;
  61821. useVertexAlpha?: boolean;
  61822. }, scene: Nullable<Scene>): LinesMesh;
  61823. /**
  61824. * Creates a line mesh
  61825. * 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
  61826. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61827. * * The parameter `points` is an array successive Vector3
  61828. * * 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
  61829. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61830. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61831. * * When updating an instance, remember that only point positions can change, not the number of points
  61832. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61834. * @param name defines the name of the new line system
  61835. * @param options defines the options used to create the line system
  61836. * @param scene defines the hosting scene
  61837. * @returns a new line mesh
  61838. */
  61839. static CreateLines(name: string, options: {
  61840. points: Vector3[];
  61841. updatable?: boolean;
  61842. instance?: Nullable<LinesMesh>;
  61843. colors?: Color4[];
  61844. useVertexAlpha?: boolean;
  61845. }, scene?: Nullable<Scene>): LinesMesh;
  61846. /**
  61847. * Creates a dashed line mesh
  61848. * * 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
  61849. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61850. * * The parameter `points` is an array successive Vector3
  61851. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61852. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61853. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61854. * * 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
  61855. * * When updating an instance, remember that only point positions can change, not the number of points
  61856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61857. * @param name defines the name of the mesh
  61858. * @param options defines the options used to create the mesh
  61859. * @param scene defines the hosting scene
  61860. * @returns the dashed line mesh
  61861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61862. */
  61863. static CreateDashedLines(name: string, options: {
  61864. points: Vector3[];
  61865. dashSize?: number;
  61866. gapSize?: number;
  61867. dashNb?: number;
  61868. updatable?: boolean;
  61869. instance?: LinesMesh;
  61870. }, scene?: Nullable<Scene>): LinesMesh;
  61871. /**
  61872. * 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.
  61873. * * 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.
  61874. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61875. * * 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.
  61876. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61877. * * 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
  61878. * * 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
  61879. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61880. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61881. * * 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
  61882. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61884. * @param name defines the name of the mesh
  61885. * @param options defines the options used to create the mesh
  61886. * @param scene defines the hosting scene
  61887. * @returns the extruded shape mesh
  61888. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61890. */
  61891. static ExtrudeShape(name: string, options: {
  61892. shape: Vector3[];
  61893. path: Vector3[];
  61894. scale?: number;
  61895. rotation?: number;
  61896. cap?: number;
  61897. updatable?: boolean;
  61898. sideOrientation?: number;
  61899. frontUVs?: Vector4;
  61900. backUVs?: Vector4;
  61901. instance?: Mesh;
  61902. invertUV?: boolean;
  61903. }, scene?: Nullable<Scene>): Mesh;
  61904. /**
  61905. * Creates an custom extruded shape mesh.
  61906. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61907. * * 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.
  61908. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61909. * * 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
  61910. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61911. * * 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
  61912. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61913. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61914. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61915. * * 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
  61916. * * 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
  61917. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61919. * * 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
  61920. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61922. * @param name defines the name of the mesh
  61923. * @param options defines the options used to create the mesh
  61924. * @param scene defines the hosting scene
  61925. * @returns the custom extruded shape mesh
  61926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61927. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61928. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61929. */
  61930. static ExtrudeShapeCustom(name: string, options: {
  61931. shape: Vector3[];
  61932. path: Vector3[];
  61933. scaleFunction?: any;
  61934. rotationFunction?: any;
  61935. ribbonCloseArray?: boolean;
  61936. ribbonClosePath?: boolean;
  61937. cap?: number;
  61938. updatable?: boolean;
  61939. sideOrientation?: number;
  61940. frontUVs?: Vector4;
  61941. backUVs?: Vector4;
  61942. instance?: Mesh;
  61943. invertUV?: boolean;
  61944. }, scene?: Nullable<Scene>): Mesh;
  61945. /**
  61946. * Creates lathe mesh.
  61947. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61948. * * 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
  61949. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61950. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61951. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61952. * * 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
  61953. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61954. * * 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
  61955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61956. * * 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
  61957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61959. * @param name defines the name of the mesh
  61960. * @param options defines the options used to create the mesh
  61961. * @param scene defines the hosting scene
  61962. * @returns the lathe mesh
  61963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61964. */
  61965. static CreateLathe(name: string, options: {
  61966. shape: Vector3[];
  61967. radius?: number;
  61968. tessellation?: number;
  61969. clip?: number;
  61970. arc?: number;
  61971. closed?: boolean;
  61972. updatable?: boolean;
  61973. sideOrientation?: number;
  61974. frontUVs?: Vector4;
  61975. backUVs?: Vector4;
  61976. cap?: number;
  61977. invertUV?: boolean;
  61978. }, scene?: Nullable<Scene>): Mesh;
  61979. /**
  61980. * Creates a tiled plane mesh
  61981. * * You can set a limited pattern arrangement with the tiles
  61982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61983. * * 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
  61984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61985. * @param name defines the name of the mesh
  61986. * @param options defines the options used to create the mesh
  61987. * @param scene defines the hosting scene
  61988. * @returns the plane mesh
  61989. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61990. */
  61991. static CreateTiledPlane(name: string, options: {
  61992. pattern?: number;
  61993. tileSize?: number;
  61994. tileWidth?: number;
  61995. tileHeight?: number;
  61996. size?: number;
  61997. width?: number;
  61998. height?: number;
  61999. alignHorizontal?: number;
  62000. alignVertical?: number;
  62001. sideOrientation?: number;
  62002. frontUVs?: Vector4;
  62003. backUVs?: Vector4;
  62004. updatable?: boolean;
  62005. }, scene?: Nullable<Scene>): Mesh;
  62006. /**
  62007. * Creates a plane mesh
  62008. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  62009. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  62010. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  62011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62012. * * 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
  62013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62014. * @param name defines the name of the mesh
  62015. * @param options defines the options used to create the mesh
  62016. * @param scene defines the hosting scene
  62017. * @returns the plane mesh
  62018. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  62019. */
  62020. static CreatePlane(name: string, options: {
  62021. size?: number;
  62022. width?: number;
  62023. height?: number;
  62024. sideOrientation?: number;
  62025. frontUVs?: Vector4;
  62026. backUVs?: Vector4;
  62027. updatable?: boolean;
  62028. sourcePlane?: Plane;
  62029. }, scene?: Nullable<Scene>): Mesh;
  62030. /**
  62031. * Creates a ground mesh
  62032. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  62033. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  62034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62035. * @param name defines the name of the mesh
  62036. * @param options defines the options used to create the mesh
  62037. * @param scene defines the hosting scene
  62038. * @returns the ground mesh
  62039. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  62040. */
  62041. static CreateGround(name: string, options: {
  62042. width?: number;
  62043. height?: number;
  62044. subdivisions?: number;
  62045. subdivisionsX?: number;
  62046. subdivisionsY?: number;
  62047. updatable?: boolean;
  62048. }, scene?: Nullable<Scene>): Mesh;
  62049. /**
  62050. * Creates a tiled ground mesh
  62051. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  62052. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  62053. * * 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
  62054. * * 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
  62055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62056. * @param name defines the name of the mesh
  62057. * @param options defines the options used to create the mesh
  62058. * @param scene defines the hosting scene
  62059. * @returns the tiled ground mesh
  62060. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  62061. */
  62062. static CreateTiledGround(name: string, options: {
  62063. xmin: number;
  62064. zmin: number;
  62065. xmax: number;
  62066. zmax: number;
  62067. subdivisions?: {
  62068. w: number;
  62069. h: number;
  62070. };
  62071. precision?: {
  62072. w: number;
  62073. h: number;
  62074. };
  62075. updatable?: boolean;
  62076. }, scene?: Nullable<Scene>): Mesh;
  62077. /**
  62078. * Creates a ground mesh from a height map
  62079. * * The parameter `url` sets the URL of the height map image resource.
  62080. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  62081. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  62082. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  62083. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  62084. * * 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.
  62085. * * 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).
  62086. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  62087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62088. * @param name defines the name of the mesh
  62089. * @param url defines the url to the height map
  62090. * @param options defines the options used to create the mesh
  62091. * @param scene defines the hosting scene
  62092. * @returns the ground mesh
  62093. * @see https://doc.babylonjs.com/babylon101/height_map
  62094. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  62095. */
  62096. static CreateGroundFromHeightMap(name: string, url: string, options: {
  62097. width?: number;
  62098. height?: number;
  62099. subdivisions?: number;
  62100. minHeight?: number;
  62101. maxHeight?: number;
  62102. colorFilter?: Color3;
  62103. alphaFilter?: number;
  62104. updatable?: boolean;
  62105. onReady?: (mesh: GroundMesh) => void;
  62106. }, scene?: Nullable<Scene>): GroundMesh;
  62107. /**
  62108. * Creates a polygon mesh
  62109. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62110. * * 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
  62111. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62113. * * 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)
  62114. * * Remember you can only change the shape positions, not their number when updating a polygon
  62115. * @param name defines the name of the mesh
  62116. * @param options defines the options used to create the mesh
  62117. * @param scene defines the hosting scene
  62118. * @param earcutInjection can be used to inject your own earcut reference
  62119. * @returns the polygon mesh
  62120. */
  62121. static CreatePolygon(name: string, options: {
  62122. shape: Vector3[];
  62123. holes?: Vector3[][];
  62124. depth?: number;
  62125. faceUV?: Vector4[];
  62126. faceColors?: Color4[];
  62127. updatable?: boolean;
  62128. sideOrientation?: number;
  62129. frontUVs?: Vector4;
  62130. backUVs?: Vector4;
  62131. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62132. /**
  62133. * Creates an extruded polygon mesh, with depth in the Y direction.
  62134. * * 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)
  62135. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62136. * @param name defines the name of the mesh
  62137. * @param options defines the options used to create the mesh
  62138. * @param scene defines the hosting scene
  62139. * @param earcutInjection can be used to inject your own earcut reference
  62140. * @returns the polygon mesh
  62141. */
  62142. static ExtrudePolygon(name: string, options: {
  62143. shape: Vector3[];
  62144. holes?: Vector3[][];
  62145. depth?: number;
  62146. faceUV?: Vector4[];
  62147. faceColors?: Color4[];
  62148. updatable?: boolean;
  62149. sideOrientation?: number;
  62150. frontUVs?: Vector4;
  62151. backUVs?: Vector4;
  62152. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62153. /**
  62154. * Creates a tube mesh.
  62155. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62156. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62157. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62158. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62159. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62160. * * 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)
  62161. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62162. * * 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
  62163. * * 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
  62164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62165. * * 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
  62166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62168. * @param name defines the name of the mesh
  62169. * @param options defines the options used to create the mesh
  62170. * @param scene defines the hosting scene
  62171. * @returns the tube mesh
  62172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62173. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62174. */
  62175. static CreateTube(name: string, options: {
  62176. path: Vector3[];
  62177. radius?: number;
  62178. tessellation?: number;
  62179. radiusFunction?: {
  62180. (i: number, distance: number): number;
  62181. };
  62182. cap?: number;
  62183. arc?: number;
  62184. updatable?: boolean;
  62185. sideOrientation?: number;
  62186. frontUVs?: Vector4;
  62187. backUVs?: Vector4;
  62188. instance?: Mesh;
  62189. invertUV?: boolean;
  62190. }, scene?: Nullable<Scene>): Mesh;
  62191. /**
  62192. * Creates a polyhedron mesh
  62193. * * 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
  62194. * * The parameter `size` (positive float, default 1) sets the polygon size
  62195. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  62196. * * 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`
  62197. * * 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
  62198. * * 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)`)
  62199. * * 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
  62200. * * 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
  62201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62202. * * 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
  62203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62204. * @param name defines the name of the mesh
  62205. * @param options defines the options used to create the mesh
  62206. * @param scene defines the hosting scene
  62207. * @returns the polyhedron mesh
  62208. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  62209. */
  62210. static CreatePolyhedron(name: string, options: {
  62211. type?: number;
  62212. size?: number;
  62213. sizeX?: number;
  62214. sizeY?: number;
  62215. sizeZ?: number;
  62216. custom?: any;
  62217. faceUV?: Vector4[];
  62218. faceColors?: Color4[];
  62219. flat?: boolean;
  62220. updatable?: boolean;
  62221. sideOrientation?: number;
  62222. frontUVs?: Vector4;
  62223. backUVs?: Vector4;
  62224. }, scene?: Nullable<Scene>): Mesh;
  62225. /**
  62226. * Creates a decal mesh.
  62227. * 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
  62228. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62229. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62230. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62231. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62232. * @param name defines the name of the mesh
  62233. * @param sourceMesh defines the mesh where the decal must be applied
  62234. * @param options defines the options used to create the mesh
  62235. * @param scene defines the hosting scene
  62236. * @returns the decal mesh
  62237. * @see https://doc.babylonjs.com/how_to/decals
  62238. */
  62239. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62240. position?: Vector3;
  62241. normal?: Vector3;
  62242. size?: Vector3;
  62243. angle?: number;
  62244. }): Mesh;
  62245. }
  62246. }
  62247. declare module BABYLON {
  62248. /**
  62249. * A simplifier interface for future simplification implementations
  62250. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62251. */
  62252. export interface ISimplifier {
  62253. /**
  62254. * Simplification of a given mesh according to the given settings.
  62255. * Since this requires computation, it is assumed that the function runs async.
  62256. * @param settings The settings of the simplification, including quality and distance
  62257. * @param successCallback A callback that will be called after the mesh was simplified.
  62258. * @param errorCallback in case of an error, this callback will be called. optional.
  62259. */
  62260. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  62261. }
  62262. /**
  62263. * Expected simplification settings.
  62264. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  62265. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62266. */
  62267. export interface ISimplificationSettings {
  62268. /**
  62269. * Gets or sets the expected quality
  62270. */
  62271. quality: number;
  62272. /**
  62273. * Gets or sets the distance when this optimized version should be used
  62274. */
  62275. distance: number;
  62276. /**
  62277. * Gets an already optimized mesh
  62278. */
  62279. optimizeMesh?: boolean;
  62280. }
  62281. /**
  62282. * Class used to specify simplification options
  62283. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62284. */
  62285. export class SimplificationSettings implements ISimplificationSettings {
  62286. /** expected quality */
  62287. quality: number;
  62288. /** distance when this optimized version should be used */
  62289. distance: number;
  62290. /** already optimized mesh */
  62291. optimizeMesh?: boolean | undefined;
  62292. /**
  62293. * Creates a SimplificationSettings
  62294. * @param quality expected quality
  62295. * @param distance distance when this optimized version should be used
  62296. * @param optimizeMesh already optimized mesh
  62297. */
  62298. constructor(
  62299. /** expected quality */
  62300. quality: number,
  62301. /** distance when this optimized version should be used */
  62302. distance: number,
  62303. /** already optimized mesh */
  62304. optimizeMesh?: boolean | undefined);
  62305. }
  62306. /**
  62307. * Interface used to define a simplification task
  62308. */
  62309. export interface ISimplificationTask {
  62310. /**
  62311. * Array of settings
  62312. */
  62313. settings: Array<ISimplificationSettings>;
  62314. /**
  62315. * Simplification type
  62316. */
  62317. simplificationType: SimplificationType;
  62318. /**
  62319. * Mesh to simplify
  62320. */
  62321. mesh: Mesh;
  62322. /**
  62323. * Callback called on success
  62324. */
  62325. successCallback?: () => void;
  62326. /**
  62327. * Defines if parallel processing can be used
  62328. */
  62329. parallelProcessing: boolean;
  62330. }
  62331. /**
  62332. * Queue used to order the simplification tasks
  62333. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62334. */
  62335. export class SimplificationQueue {
  62336. private _simplificationArray;
  62337. /**
  62338. * Gets a boolean indicating that the process is still running
  62339. */
  62340. running: boolean;
  62341. /**
  62342. * Creates a new queue
  62343. */
  62344. constructor();
  62345. /**
  62346. * Adds a new simplification task
  62347. * @param task defines a task to add
  62348. */
  62349. addTask(task: ISimplificationTask): void;
  62350. /**
  62351. * Execute next task
  62352. */
  62353. executeNext(): void;
  62354. /**
  62355. * Execute a simplification task
  62356. * @param task defines the task to run
  62357. */
  62358. runSimplification(task: ISimplificationTask): void;
  62359. private getSimplifier;
  62360. }
  62361. /**
  62362. * The implemented types of simplification
  62363. * At the moment only Quadratic Error Decimation is implemented
  62364. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62365. */
  62366. export enum SimplificationType {
  62367. /** Quadratic error decimation */
  62368. QUADRATIC = 0
  62369. }
  62370. /**
  62371. * An implementation of the Quadratic Error simplification algorithm.
  62372. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  62373. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  62374. * @author RaananW
  62375. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62376. */
  62377. export class QuadraticErrorSimplification implements ISimplifier {
  62378. private _mesh;
  62379. private triangles;
  62380. private vertices;
  62381. private references;
  62382. private _reconstructedMesh;
  62383. /** Gets or sets the number pf sync interations */
  62384. syncIterations: number;
  62385. /** Gets or sets the aggressiveness of the simplifier */
  62386. aggressiveness: number;
  62387. /** Gets or sets the number of allowed iterations for decimation */
  62388. decimationIterations: number;
  62389. /** Gets or sets the espilon to use for bounding box computation */
  62390. boundingBoxEpsilon: number;
  62391. /**
  62392. * Creates a new QuadraticErrorSimplification
  62393. * @param _mesh defines the target mesh
  62394. */
  62395. constructor(_mesh: Mesh);
  62396. /**
  62397. * Simplification of a given mesh according to the given settings.
  62398. * Since this requires computation, it is assumed that the function runs async.
  62399. * @param settings The settings of the simplification, including quality and distance
  62400. * @param successCallback A callback that will be called after the mesh was simplified.
  62401. */
  62402. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  62403. private runDecimation;
  62404. private initWithMesh;
  62405. private init;
  62406. private reconstructMesh;
  62407. private initDecimatedMesh;
  62408. private isFlipped;
  62409. private updateTriangles;
  62410. private identifyBorder;
  62411. private updateMesh;
  62412. private vertexError;
  62413. private calculateError;
  62414. }
  62415. }
  62416. declare module BABYLON {
  62417. interface Scene {
  62418. /** @hidden (Backing field) */
  62419. _simplificationQueue: SimplificationQueue;
  62420. /**
  62421. * Gets or sets the simplification queue attached to the scene
  62422. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  62423. */
  62424. simplificationQueue: SimplificationQueue;
  62425. }
  62426. interface Mesh {
  62427. /**
  62428. * Simplify the mesh according to the given array of settings.
  62429. * Function will return immediately and will simplify async
  62430. * @param settings a collection of simplification settings
  62431. * @param parallelProcessing should all levels calculate parallel or one after the other
  62432. * @param simplificationType the type of simplification to run
  62433. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  62434. * @returns the current mesh
  62435. */
  62436. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  62437. }
  62438. /**
  62439. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  62440. * created in a scene
  62441. */
  62442. export class SimplicationQueueSceneComponent implements ISceneComponent {
  62443. /**
  62444. * The component name helpfull to identify the component in the list of scene components.
  62445. */
  62446. readonly name: string;
  62447. /**
  62448. * The scene the component belongs to.
  62449. */
  62450. scene: Scene;
  62451. /**
  62452. * Creates a new instance of the component for the given scene
  62453. * @param scene Defines the scene to register the component in
  62454. */
  62455. constructor(scene: Scene);
  62456. /**
  62457. * Registers the component in a given scene
  62458. */
  62459. register(): void;
  62460. /**
  62461. * Rebuilds the elements related to this component in case of
  62462. * context lost for instance.
  62463. */
  62464. rebuild(): void;
  62465. /**
  62466. * Disposes the component and the associated ressources
  62467. */
  62468. dispose(): void;
  62469. private _beforeCameraUpdate;
  62470. }
  62471. }
  62472. declare module BABYLON {
  62473. /**
  62474. * Navigation plugin interface to add navigation constrained by a navigation mesh
  62475. */
  62476. export interface INavigationEnginePlugin {
  62477. /**
  62478. * plugin name
  62479. */
  62480. name: string;
  62481. /**
  62482. * Creates a navigation mesh
  62483. * @param meshes array of all the geometry used to compute the navigatio mesh
  62484. * @param parameters bunch of parameters used to filter geometry
  62485. */
  62486. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62487. /**
  62488. * Create a navigation mesh debug mesh
  62489. * @param scene is where the mesh will be added
  62490. * @returns debug display mesh
  62491. */
  62492. createDebugNavMesh(scene: Scene): Mesh;
  62493. /**
  62494. * Get a navigation mesh constrained position, closest to the parameter position
  62495. * @param position world position
  62496. * @returns the closest point to position constrained by the navigation mesh
  62497. */
  62498. getClosestPoint(position: Vector3): Vector3;
  62499. /**
  62500. * Get a navigation mesh constrained position, closest to the parameter position
  62501. * @param position world position
  62502. * @param result output the closest point to position constrained by the navigation mesh
  62503. */
  62504. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62505. /**
  62506. * Get a navigation mesh constrained position, within a particular radius
  62507. * @param position world position
  62508. * @param maxRadius the maximum distance to the constrained world position
  62509. * @returns the closest point to position constrained by the navigation mesh
  62510. */
  62511. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62512. /**
  62513. * Get a navigation mesh constrained position, within a particular radius
  62514. * @param position world position
  62515. * @param maxRadius the maximum distance to the constrained world position
  62516. * @param result output the closest point to position constrained by the navigation mesh
  62517. */
  62518. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62519. /**
  62520. * Compute the final position from a segment made of destination-position
  62521. * @param position world position
  62522. * @param destination world position
  62523. * @returns the resulting point along the navmesh
  62524. */
  62525. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62526. /**
  62527. * Compute the final position from a segment made of destination-position
  62528. * @param position world position
  62529. * @param destination world position
  62530. * @param result output the resulting point along the navmesh
  62531. */
  62532. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62533. /**
  62534. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62535. * @param start world position
  62536. * @param end world position
  62537. * @returns array containing world position composing the path
  62538. */
  62539. computePath(start: Vector3, end: Vector3): Vector3[];
  62540. /**
  62541. * If this plugin is supported
  62542. * @returns true if plugin is supported
  62543. */
  62544. isSupported(): boolean;
  62545. /**
  62546. * Create a new Crowd so you can add agents
  62547. * @param maxAgents the maximum agent count in the crowd
  62548. * @param maxAgentRadius the maximum radius an agent can have
  62549. * @param scene to attach the crowd to
  62550. * @returns the crowd you can add agents to
  62551. */
  62552. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62553. /**
  62554. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62555. * The queries will try to find a solution within those bounds
  62556. * default is (1,1,1)
  62557. * @param extent x,y,z value that define the extent around the queries point of reference
  62558. */
  62559. setDefaultQueryExtent(extent: Vector3): void;
  62560. /**
  62561. * Get the Bounding box extent specified by setDefaultQueryExtent
  62562. * @returns the box extent values
  62563. */
  62564. getDefaultQueryExtent(): Vector3;
  62565. /**
  62566. * build the navmesh from a previously saved state using getNavmeshData
  62567. * @param data the Uint8Array returned by getNavmeshData
  62568. */
  62569. buildFromNavmeshData(data: Uint8Array): void;
  62570. /**
  62571. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62572. * @returns data the Uint8Array that can be saved and reused
  62573. */
  62574. getNavmeshData(): Uint8Array;
  62575. /**
  62576. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62577. * @param result output the box extent values
  62578. */
  62579. getDefaultQueryExtentToRef(result: Vector3): void;
  62580. /**
  62581. * Release all resources
  62582. */
  62583. dispose(): void;
  62584. }
  62585. /**
  62586. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  62587. */
  62588. export interface ICrowd {
  62589. /**
  62590. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62591. * You can attach anything to that node. The node position is updated in the scene update tick.
  62592. * @param pos world position that will be constrained by the navigation mesh
  62593. * @param parameters agent parameters
  62594. * @param transform hooked to the agent that will be update by the scene
  62595. * @returns agent index
  62596. */
  62597. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62598. /**
  62599. * Returns the agent position in world space
  62600. * @param index agent index returned by addAgent
  62601. * @returns world space position
  62602. */
  62603. getAgentPosition(index: number): Vector3;
  62604. /**
  62605. * Gets the agent position result in world space
  62606. * @param index agent index returned by addAgent
  62607. * @param result output world space position
  62608. */
  62609. getAgentPositionToRef(index: number, result: Vector3): void;
  62610. /**
  62611. * Gets the agent velocity in world space
  62612. * @param index agent index returned by addAgent
  62613. * @returns world space velocity
  62614. */
  62615. getAgentVelocity(index: number): Vector3;
  62616. /**
  62617. * Gets the agent velocity result in world space
  62618. * @param index agent index returned by addAgent
  62619. * @param result output world space velocity
  62620. */
  62621. getAgentVelocityToRef(index: number, result: Vector3): void;
  62622. /**
  62623. * remove a particular agent previously created
  62624. * @param index agent index returned by addAgent
  62625. */
  62626. removeAgent(index: number): void;
  62627. /**
  62628. * get the list of all agents attached to this crowd
  62629. * @returns list of agent indices
  62630. */
  62631. getAgents(): number[];
  62632. /**
  62633. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62634. * @param deltaTime in seconds
  62635. */
  62636. update(deltaTime: number): void;
  62637. /**
  62638. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62639. * @param index agent index returned by addAgent
  62640. * @param destination targeted world position
  62641. */
  62642. agentGoto(index: number, destination: Vector3): void;
  62643. /**
  62644. * Teleport the agent to a new position
  62645. * @param index agent index returned by addAgent
  62646. * @param destination targeted world position
  62647. */
  62648. agentTeleport(index: number, destination: Vector3): void;
  62649. /**
  62650. * Update agent parameters
  62651. * @param index agent index returned by addAgent
  62652. * @param parameters agent parameters
  62653. */
  62654. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62655. /**
  62656. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62657. * The queries will try to find a solution within those bounds
  62658. * default is (1,1,1)
  62659. * @param extent x,y,z value that define the extent around the queries point of reference
  62660. */
  62661. setDefaultQueryExtent(extent: Vector3): void;
  62662. /**
  62663. * Get the Bounding box extent specified by setDefaultQueryExtent
  62664. * @returns the box extent values
  62665. */
  62666. getDefaultQueryExtent(): Vector3;
  62667. /**
  62668. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62669. * @param result output the box extent values
  62670. */
  62671. getDefaultQueryExtentToRef(result: Vector3): void;
  62672. /**
  62673. * Release all resources
  62674. */
  62675. dispose(): void;
  62676. }
  62677. /**
  62678. * Configures an agent
  62679. */
  62680. export interface IAgentParameters {
  62681. /**
  62682. * Agent radius. [Limit: >= 0]
  62683. */
  62684. radius: number;
  62685. /**
  62686. * Agent height. [Limit: > 0]
  62687. */
  62688. height: number;
  62689. /**
  62690. * Maximum allowed acceleration. [Limit: >= 0]
  62691. */
  62692. maxAcceleration: number;
  62693. /**
  62694. * Maximum allowed speed. [Limit: >= 0]
  62695. */
  62696. maxSpeed: number;
  62697. /**
  62698. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62699. */
  62700. collisionQueryRange: number;
  62701. /**
  62702. * The path visibility optimization range. [Limit: > 0]
  62703. */
  62704. pathOptimizationRange: number;
  62705. /**
  62706. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62707. */
  62708. separationWeight: number;
  62709. }
  62710. /**
  62711. * Configures the navigation mesh creation
  62712. */
  62713. export interface INavMeshParameters {
  62714. /**
  62715. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62716. */
  62717. cs: number;
  62718. /**
  62719. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62720. */
  62721. ch: number;
  62722. /**
  62723. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62724. */
  62725. walkableSlopeAngle: number;
  62726. /**
  62727. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62728. * be considered walkable. [Limit: >= 3] [Units: vx]
  62729. */
  62730. walkableHeight: number;
  62731. /**
  62732. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62733. */
  62734. walkableClimb: number;
  62735. /**
  62736. * The distance to erode/shrink the walkable area of the heightfield away from
  62737. * obstructions. [Limit: >=0] [Units: vx]
  62738. */
  62739. walkableRadius: number;
  62740. /**
  62741. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62742. */
  62743. maxEdgeLen: number;
  62744. /**
  62745. * The maximum distance a simplfied contour's border edges should deviate
  62746. * the original raw contour. [Limit: >=0] [Units: vx]
  62747. */
  62748. maxSimplificationError: number;
  62749. /**
  62750. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62751. */
  62752. minRegionArea: number;
  62753. /**
  62754. * Any regions with a span count smaller than this value will, if possible,
  62755. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62756. */
  62757. mergeRegionArea: number;
  62758. /**
  62759. * The maximum number of vertices allowed for polygons generated during the
  62760. * contour to polygon conversion process. [Limit: >= 3]
  62761. */
  62762. maxVertsPerPoly: number;
  62763. /**
  62764. * Sets the sampling distance to use when generating the detail mesh.
  62765. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62766. */
  62767. detailSampleDist: number;
  62768. /**
  62769. * The maximum distance the detail mesh surface should deviate from heightfield
  62770. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62771. */
  62772. detailSampleMaxError: number;
  62773. }
  62774. }
  62775. declare module BABYLON {
  62776. /**
  62777. * RecastJS navigation plugin
  62778. */
  62779. export class RecastJSPlugin implements INavigationEnginePlugin {
  62780. /**
  62781. * Reference to the Recast library
  62782. */
  62783. bjsRECAST: any;
  62784. /**
  62785. * plugin name
  62786. */
  62787. name: string;
  62788. /**
  62789. * the first navmesh created. We might extend this to support multiple navmeshes
  62790. */
  62791. navMesh: any;
  62792. /**
  62793. * Initializes the recastJS plugin
  62794. * @param recastInjection can be used to inject your own recast reference
  62795. */
  62796. constructor(recastInjection?: any);
  62797. /**
  62798. * Creates a navigation mesh
  62799. * @param meshes array of all the geometry used to compute the navigatio mesh
  62800. * @param parameters bunch of parameters used to filter geometry
  62801. */
  62802. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62803. /**
  62804. * Create a navigation mesh debug mesh
  62805. * @param scene is where the mesh will be added
  62806. * @returns debug display mesh
  62807. */
  62808. createDebugNavMesh(scene: Scene): Mesh;
  62809. /**
  62810. * Get a navigation mesh constrained position, closest to the parameter position
  62811. * @param position world position
  62812. * @returns the closest point to position constrained by the navigation mesh
  62813. */
  62814. getClosestPoint(position: Vector3): Vector3;
  62815. /**
  62816. * Get a navigation mesh constrained position, closest to the parameter position
  62817. * @param position world position
  62818. * @param result output the closest point to position constrained by the navigation mesh
  62819. */
  62820. getClosestPointToRef(position: Vector3, result: Vector3): void;
  62821. /**
  62822. * Get a navigation mesh constrained position, within a particular radius
  62823. * @param position world position
  62824. * @param maxRadius the maximum distance to the constrained world position
  62825. * @returns the closest point to position constrained by the navigation mesh
  62826. */
  62827. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62828. /**
  62829. * Get a navigation mesh constrained position, within a particular radius
  62830. * @param position world position
  62831. * @param maxRadius the maximum distance to the constrained world position
  62832. * @param result output the closest point to position constrained by the navigation mesh
  62833. */
  62834. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  62835. /**
  62836. * Compute the final position from a segment made of destination-position
  62837. * @param position world position
  62838. * @param destination world position
  62839. * @returns the resulting point along the navmesh
  62840. */
  62841. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62842. /**
  62843. * Compute the final position from a segment made of destination-position
  62844. * @param position world position
  62845. * @param destination world position
  62846. * @param result output the resulting point along the navmesh
  62847. */
  62848. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  62849. /**
  62850. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62851. * @param start world position
  62852. * @param end world position
  62853. * @returns array containing world position composing the path
  62854. */
  62855. computePath(start: Vector3, end: Vector3): Vector3[];
  62856. /**
  62857. * Create a new Crowd so you can add agents
  62858. * @param maxAgents the maximum agent count in the crowd
  62859. * @param maxAgentRadius the maximum radius an agent can have
  62860. * @param scene to attach the crowd to
  62861. * @returns the crowd you can add agents to
  62862. */
  62863. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62864. /**
  62865. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62866. * The queries will try to find a solution within those bounds
  62867. * default is (1,1,1)
  62868. * @param extent x,y,z value that define the extent around the queries point of reference
  62869. */
  62870. setDefaultQueryExtent(extent: Vector3): void;
  62871. /**
  62872. * Get the Bounding box extent specified by setDefaultQueryExtent
  62873. * @returns the box extent values
  62874. */
  62875. getDefaultQueryExtent(): Vector3;
  62876. /**
  62877. * build the navmesh from a previously saved state using getNavmeshData
  62878. * @param data the Uint8Array returned by getNavmeshData
  62879. */
  62880. buildFromNavmeshData(data: Uint8Array): void;
  62881. /**
  62882. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  62883. * @returns data the Uint8Array that can be saved and reused
  62884. */
  62885. getNavmeshData(): Uint8Array;
  62886. /**
  62887. * Get the Bounding box extent result specified by setDefaultQueryExtent
  62888. * @param result output the box extent values
  62889. */
  62890. getDefaultQueryExtentToRef(result: Vector3): void;
  62891. /**
  62892. * Disposes
  62893. */
  62894. dispose(): void;
  62895. /**
  62896. * If this plugin is supported
  62897. * @returns true if plugin is supported
  62898. */
  62899. isSupported(): boolean;
  62900. }
  62901. /**
  62902. * Recast detour crowd implementation
  62903. */
  62904. export class RecastJSCrowd implements ICrowd {
  62905. /**
  62906. * Recast/detour plugin
  62907. */
  62908. bjsRECASTPlugin: RecastJSPlugin;
  62909. /**
  62910. * Link to the detour crowd
  62911. */
  62912. recastCrowd: any;
  62913. /**
  62914. * One transform per agent
  62915. */
  62916. transforms: TransformNode[];
  62917. /**
  62918. * All agents created
  62919. */
  62920. agents: number[];
  62921. /**
  62922. * Link to the scene is kept to unregister the crowd from the scene
  62923. */
  62924. private _scene;
  62925. /**
  62926. * Observer for crowd updates
  62927. */
  62928. private _onBeforeAnimationsObserver;
  62929. /**
  62930. * Constructor
  62931. * @param plugin recastJS plugin
  62932. * @param maxAgents the maximum agent count in the crowd
  62933. * @param maxAgentRadius the maximum radius an agent can have
  62934. * @param scene to attach the crowd to
  62935. * @returns the crowd you can add agents to
  62936. */
  62937. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62938. /**
  62939. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62940. * You can attach anything to that node. The node position is updated in the scene update tick.
  62941. * @param pos world position that will be constrained by the navigation mesh
  62942. * @param parameters agent parameters
  62943. * @param transform hooked to the agent that will be update by the scene
  62944. * @returns agent index
  62945. */
  62946. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62947. /**
  62948. * Returns the agent position in world space
  62949. * @param index agent index returned by addAgent
  62950. * @returns world space position
  62951. */
  62952. getAgentPosition(index: number): Vector3;
  62953. /**
  62954. * Returns the agent position result in world space
  62955. * @param index agent index returned by addAgent
  62956. * @param result output world space position
  62957. */
  62958. getAgentPositionToRef(index: number, result: Vector3): void;
  62959. /**
  62960. * Returns the agent velocity in world space
  62961. * @param index agent index returned by addAgent
  62962. * @returns world space velocity
  62963. */
  62964. getAgentVelocity(index: number): Vector3;
  62965. /**
  62966. * Returns the agent velocity result in world space
  62967. * @param index agent index returned by addAgent
  62968. * @param result output world space velocity
  62969. */
  62970. getAgentVelocityToRef(index: number, result: Vector3): void;
  62971. /**
  62972. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62973. * @param index agent index returned by addAgent
  62974. * @param destination targeted world position
  62975. */
  62976. agentGoto(index: number, destination: Vector3): void;
  62977. /**
  62978. * Teleport the agent to a new position
  62979. * @param index agent index returned by addAgent
  62980. * @param destination targeted world position
  62981. */
  62982. agentTeleport(index: number, destination: Vector3): void;
  62983. /**
  62984. * Update agent parameters
  62985. * @param index agent index returned by addAgent
  62986. * @param parameters agent parameters
  62987. */
  62988. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62989. /**
  62990. * remove a particular agent previously created
  62991. * @param index agent index returned by addAgent
  62992. */
  62993. removeAgent(index: number): void;
  62994. /**
  62995. * get the list of all agents attached to this crowd
  62996. * @returns list of agent indices
  62997. */
  62998. getAgents(): number[];
  62999. /**
  63000. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  63001. * @param deltaTime in seconds
  63002. */
  63003. update(deltaTime: number): void;
  63004. /**
  63005. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  63006. * The queries will try to find a solution within those bounds
  63007. * default is (1,1,1)
  63008. * @param extent x,y,z value that define the extent around the queries point of reference
  63009. */
  63010. setDefaultQueryExtent(extent: Vector3): void;
  63011. /**
  63012. * Get the Bounding box extent specified by setDefaultQueryExtent
  63013. * @returns the box extent values
  63014. */
  63015. getDefaultQueryExtent(): Vector3;
  63016. /**
  63017. * Get the Bounding box extent result specified by setDefaultQueryExtent
  63018. * @param result output the box extent values
  63019. */
  63020. getDefaultQueryExtentToRef(result: Vector3): void;
  63021. /**
  63022. * Release all resources
  63023. */
  63024. dispose(): void;
  63025. }
  63026. }
  63027. declare module BABYLON {
  63028. /**
  63029. * Class used to enable access to IndexedDB
  63030. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63031. */
  63032. export class Database implements IOfflineProvider {
  63033. private _callbackManifestChecked;
  63034. private _currentSceneUrl;
  63035. private _db;
  63036. private _enableSceneOffline;
  63037. private _enableTexturesOffline;
  63038. private _manifestVersionFound;
  63039. private _mustUpdateRessources;
  63040. private _hasReachedQuota;
  63041. private _isSupported;
  63042. private _idbFactory;
  63043. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  63044. private static IsUASupportingBlobStorage;
  63045. /**
  63046. * Gets a boolean indicating if Database storate is enabled (off by default)
  63047. */
  63048. static IDBStorageEnabled: boolean;
  63049. /**
  63050. * Gets a boolean indicating if scene must be saved in the database
  63051. */
  63052. get enableSceneOffline(): boolean;
  63053. /**
  63054. * Gets a boolean indicating if textures must be saved in the database
  63055. */
  63056. get enableTexturesOffline(): boolean;
  63057. /**
  63058. * Creates a new Database
  63059. * @param urlToScene defines the url to load the scene
  63060. * @param callbackManifestChecked defines the callback to use when manifest is checked
  63061. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  63062. */
  63063. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  63064. private static _ParseURL;
  63065. private static _ReturnFullUrlLocation;
  63066. private _checkManifestFile;
  63067. /**
  63068. * Open the database and make it available
  63069. * @param successCallback defines the callback to call on success
  63070. * @param errorCallback defines the callback to call on error
  63071. */
  63072. open(successCallback: () => void, errorCallback: () => void): void;
  63073. /**
  63074. * Loads an image from the database
  63075. * @param url defines the url to load from
  63076. * @param image defines the target DOM image
  63077. */
  63078. loadImage(url: string, image: HTMLImageElement): void;
  63079. private _loadImageFromDBAsync;
  63080. private _saveImageIntoDBAsync;
  63081. private _checkVersionFromDB;
  63082. private _loadVersionFromDBAsync;
  63083. private _saveVersionIntoDBAsync;
  63084. /**
  63085. * Loads a file from database
  63086. * @param url defines the URL to load from
  63087. * @param sceneLoaded defines a callback to call on success
  63088. * @param progressCallBack defines a callback to call when progress changed
  63089. * @param errorCallback defines a callback to call on error
  63090. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63091. */
  63092. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63093. private _loadFileAsync;
  63094. private _saveFileAsync;
  63095. /**
  63096. * Validates if xhr data is correct
  63097. * @param xhr defines the request to validate
  63098. * @param dataType defines the expected data type
  63099. * @returns true if data is correct
  63100. */
  63101. private static _ValidateXHRData;
  63102. }
  63103. }
  63104. declare module BABYLON {
  63105. /** @hidden */
  63106. export var gpuUpdateParticlesPixelShader: {
  63107. name: string;
  63108. shader: string;
  63109. };
  63110. }
  63111. declare module BABYLON {
  63112. /** @hidden */
  63113. export var gpuUpdateParticlesVertexShader: {
  63114. name: string;
  63115. shader: string;
  63116. };
  63117. }
  63118. declare module BABYLON {
  63119. /** @hidden */
  63120. export var clipPlaneFragmentDeclaration2: {
  63121. name: string;
  63122. shader: string;
  63123. };
  63124. }
  63125. declare module BABYLON {
  63126. /** @hidden */
  63127. export var gpuRenderParticlesPixelShader: {
  63128. name: string;
  63129. shader: string;
  63130. };
  63131. }
  63132. declare module BABYLON {
  63133. /** @hidden */
  63134. export var clipPlaneVertexDeclaration2: {
  63135. name: string;
  63136. shader: string;
  63137. };
  63138. }
  63139. declare module BABYLON {
  63140. /** @hidden */
  63141. export var gpuRenderParticlesVertexShader: {
  63142. name: string;
  63143. shader: string;
  63144. };
  63145. }
  63146. declare module BABYLON {
  63147. /**
  63148. * This represents a GPU particle system in Babylon
  63149. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  63150. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  63151. */
  63152. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  63153. /**
  63154. * The layer mask we are rendering the particles through.
  63155. */
  63156. layerMask: number;
  63157. private _capacity;
  63158. private _activeCount;
  63159. private _currentActiveCount;
  63160. private _accumulatedCount;
  63161. private _renderEffect;
  63162. private _updateEffect;
  63163. private _buffer0;
  63164. private _buffer1;
  63165. private _spriteBuffer;
  63166. private _updateVAO;
  63167. private _renderVAO;
  63168. private _targetIndex;
  63169. private _sourceBuffer;
  63170. private _targetBuffer;
  63171. private _engine;
  63172. private _currentRenderId;
  63173. private _started;
  63174. private _stopped;
  63175. private _timeDelta;
  63176. private _randomTexture;
  63177. private _randomTexture2;
  63178. private _attributesStrideSize;
  63179. private _updateEffectOptions;
  63180. private _randomTextureSize;
  63181. private _actualFrame;
  63182. private readonly _rawTextureWidth;
  63183. /**
  63184. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  63185. */
  63186. static get IsSupported(): boolean;
  63187. /**
  63188. * An event triggered when the system is disposed.
  63189. */
  63190. onDisposeObservable: Observable<GPUParticleSystem>;
  63191. /**
  63192. * Gets the maximum number of particles active at the same time.
  63193. * @returns The max number of active particles.
  63194. */
  63195. getCapacity(): number;
  63196. /**
  63197. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  63198. * to override the particles.
  63199. */
  63200. forceDepthWrite: boolean;
  63201. /**
  63202. * Gets or set the number of active particles
  63203. */
  63204. get activeParticleCount(): number;
  63205. set activeParticleCount(value: number);
  63206. private _preWarmDone;
  63207. /**
  63208. * Specifies if the particles are updated in emitter local space or world space.
  63209. * This is always false for GPU particles
  63210. */
  63211. get isLocal(): boolean;
  63212. set isLocal(value: boolean);
  63213. /**
  63214. * Is this system ready to be used/rendered
  63215. * @return true if the system is ready
  63216. */
  63217. isReady(): boolean;
  63218. /**
  63219. * Gets if the system has been started. (Note: this will still be true after stop is called)
  63220. * @returns True if it has been started, otherwise false.
  63221. */
  63222. isStarted(): boolean;
  63223. /**
  63224. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  63225. * @returns True if it has been stopped, otherwise false.
  63226. */
  63227. isStopped(): boolean;
  63228. /**
  63229. * Gets a boolean indicating that the system is stopping
  63230. * @returns true if the system is currently stopping
  63231. */
  63232. isStopping(): boolean;
  63233. /**
  63234. * Gets the number of particles active at the same time.
  63235. * @returns The number of active particles.
  63236. */
  63237. getActiveCount(): number;
  63238. /**
  63239. * Starts the particle system and begins to emit
  63240. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  63241. */
  63242. start(delay?: number): void;
  63243. /**
  63244. * Stops the particle system.
  63245. */
  63246. stop(): void;
  63247. /**
  63248. * Remove all active particles
  63249. */
  63250. reset(): void;
  63251. /**
  63252. * Returns the string "GPUParticleSystem"
  63253. * @returns a string containing the class name
  63254. */
  63255. getClassName(): string;
  63256. private _colorGradientsTexture;
  63257. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  63258. /**
  63259. * Adds a new color gradient
  63260. * @param gradient defines the gradient to use (between 0 and 1)
  63261. * @param color1 defines the color to affect to the specified gradient
  63262. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  63263. * @returns the current particle system
  63264. */
  63265. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  63266. private _refreshColorGradient;
  63267. /** Force the system to rebuild all gradients that need to be resync */
  63268. forceRefreshGradients(): void;
  63269. /**
  63270. * Remove a specific color gradient
  63271. * @param gradient defines the gradient to remove
  63272. * @returns the current particle system
  63273. */
  63274. removeColorGradient(gradient: number): GPUParticleSystem;
  63275. private _angularSpeedGradientsTexture;
  63276. private _sizeGradientsTexture;
  63277. private _velocityGradientsTexture;
  63278. private _limitVelocityGradientsTexture;
  63279. private _dragGradientsTexture;
  63280. private _addFactorGradient;
  63281. /**
  63282. * Adds a new size gradient
  63283. * @param gradient defines the gradient to use (between 0 and 1)
  63284. * @param factor defines the size factor to affect to the specified gradient
  63285. * @returns the current particle system
  63286. */
  63287. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  63288. /**
  63289. * Remove a specific size gradient
  63290. * @param gradient defines the gradient to remove
  63291. * @returns the current particle system
  63292. */
  63293. removeSizeGradient(gradient: number): GPUParticleSystem;
  63294. private _refreshFactorGradient;
  63295. /**
  63296. * Adds a new angular speed gradient
  63297. * @param gradient defines the gradient to use (between 0 and 1)
  63298. * @param factor defines the angular speed to affect to the specified gradient
  63299. * @returns the current particle system
  63300. */
  63301. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  63302. /**
  63303. * Remove a specific angular speed gradient
  63304. * @param gradient defines the gradient to remove
  63305. * @returns the current particle system
  63306. */
  63307. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  63308. /**
  63309. * Adds a new velocity gradient
  63310. * @param gradient defines the gradient to use (between 0 and 1)
  63311. * @param factor defines the velocity to affect to the specified gradient
  63312. * @returns the current particle system
  63313. */
  63314. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63315. /**
  63316. * Remove a specific velocity gradient
  63317. * @param gradient defines the gradient to remove
  63318. * @returns the current particle system
  63319. */
  63320. removeVelocityGradient(gradient: number): GPUParticleSystem;
  63321. /**
  63322. * Adds a new limit velocity gradient
  63323. * @param gradient defines the gradient to use (between 0 and 1)
  63324. * @param factor defines the limit velocity value to affect to the specified gradient
  63325. * @returns the current particle system
  63326. */
  63327. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  63328. /**
  63329. * Remove a specific limit velocity gradient
  63330. * @param gradient defines the gradient to remove
  63331. * @returns the current particle system
  63332. */
  63333. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  63334. /**
  63335. * Adds a new drag gradient
  63336. * @param gradient defines the gradient to use (between 0 and 1)
  63337. * @param factor defines the drag value to affect to the specified gradient
  63338. * @returns the current particle system
  63339. */
  63340. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  63341. /**
  63342. * Remove a specific drag gradient
  63343. * @param gradient defines the gradient to remove
  63344. * @returns the current particle system
  63345. */
  63346. removeDragGradient(gradient: number): GPUParticleSystem;
  63347. /**
  63348. * Not supported by GPUParticleSystem
  63349. * @param gradient defines the gradient to use (between 0 and 1)
  63350. * @param factor defines the emit rate value to affect to the specified gradient
  63351. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63352. * @returns the current particle system
  63353. */
  63354. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63355. /**
  63356. * Not supported by GPUParticleSystem
  63357. * @param gradient defines the gradient to remove
  63358. * @returns the current particle system
  63359. */
  63360. removeEmitRateGradient(gradient: number): IParticleSystem;
  63361. /**
  63362. * Not supported by GPUParticleSystem
  63363. * @param gradient defines the gradient to use (between 0 and 1)
  63364. * @param factor defines the start size value to affect to the specified gradient
  63365. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63366. * @returns the current particle system
  63367. */
  63368. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63369. /**
  63370. * Not supported by GPUParticleSystem
  63371. * @param gradient defines the gradient to remove
  63372. * @returns the current particle system
  63373. */
  63374. removeStartSizeGradient(gradient: number): IParticleSystem;
  63375. /**
  63376. * Not supported by GPUParticleSystem
  63377. * @param gradient defines the gradient to use (between 0 and 1)
  63378. * @param min defines the color remap minimal range
  63379. * @param max defines the color remap maximal range
  63380. * @returns the current particle system
  63381. */
  63382. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63383. /**
  63384. * Not supported by GPUParticleSystem
  63385. * @param gradient defines the gradient to remove
  63386. * @returns the current particle system
  63387. */
  63388. removeColorRemapGradient(): IParticleSystem;
  63389. /**
  63390. * Not supported by GPUParticleSystem
  63391. * @param gradient defines the gradient to use (between 0 and 1)
  63392. * @param min defines the alpha remap minimal range
  63393. * @param max defines the alpha remap maximal range
  63394. * @returns the current particle system
  63395. */
  63396. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  63397. /**
  63398. * Not supported by GPUParticleSystem
  63399. * @param gradient defines the gradient to remove
  63400. * @returns the current particle system
  63401. */
  63402. removeAlphaRemapGradient(): IParticleSystem;
  63403. /**
  63404. * Not supported by GPUParticleSystem
  63405. * @param gradient defines the gradient to use (between 0 and 1)
  63406. * @param color defines the color to affect to the specified gradient
  63407. * @returns the current particle system
  63408. */
  63409. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  63410. /**
  63411. * Not supported by GPUParticleSystem
  63412. * @param gradient defines the gradient to remove
  63413. * @returns the current particle system
  63414. */
  63415. removeRampGradient(): IParticleSystem;
  63416. /**
  63417. * Not supported by GPUParticleSystem
  63418. * @returns the list of ramp gradients
  63419. */
  63420. getRampGradients(): Nullable<Array<Color3Gradient>>;
  63421. /**
  63422. * Not supported by GPUParticleSystem
  63423. * Gets or sets a boolean indicating that ramp gradients must be used
  63424. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  63425. */
  63426. get useRampGradients(): boolean;
  63427. set useRampGradients(value: boolean);
  63428. /**
  63429. * Not supported by GPUParticleSystem
  63430. * @param gradient defines the gradient to use (between 0 and 1)
  63431. * @param factor defines the life time factor to affect to the specified gradient
  63432. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  63433. * @returns the current particle system
  63434. */
  63435. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  63436. /**
  63437. * Not supported by GPUParticleSystem
  63438. * @param gradient defines the gradient to remove
  63439. * @returns the current particle system
  63440. */
  63441. removeLifeTimeGradient(gradient: number): IParticleSystem;
  63442. /**
  63443. * Instantiates a GPU particle system.
  63444. * 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.
  63445. * @param name The name of the particle system
  63446. * @param options The options used to create the system
  63447. * @param scene The scene the particle system belongs to
  63448. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  63449. */
  63450. constructor(name: string, options: Partial<{
  63451. capacity: number;
  63452. randomTextureSize: number;
  63453. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  63454. protected _reset(): void;
  63455. private _createUpdateVAO;
  63456. private _createRenderVAO;
  63457. private _initialize;
  63458. /** @hidden */
  63459. _recreateUpdateEffect(): void;
  63460. /** @hidden */
  63461. _recreateRenderEffect(): void;
  63462. /**
  63463. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  63464. * @param preWarm defines if we are in the pre-warmimg phase
  63465. */
  63466. animate(preWarm?: boolean): void;
  63467. private _createFactorGradientTexture;
  63468. private _createSizeGradientTexture;
  63469. private _createAngularSpeedGradientTexture;
  63470. private _createVelocityGradientTexture;
  63471. private _createLimitVelocityGradientTexture;
  63472. private _createDragGradientTexture;
  63473. private _createColorGradientTexture;
  63474. /**
  63475. * Renders the particle system in its current state
  63476. * @param preWarm defines if the system should only update the particles but not render them
  63477. * @returns the current number of particles
  63478. */
  63479. render(preWarm?: boolean): number;
  63480. /**
  63481. * Rebuilds the particle system
  63482. */
  63483. rebuild(): void;
  63484. private _releaseBuffers;
  63485. private _releaseVAOs;
  63486. /**
  63487. * Disposes the particle system and free the associated resources
  63488. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  63489. */
  63490. dispose(disposeTexture?: boolean): void;
  63491. /**
  63492. * Clones the particle system.
  63493. * @param name The name of the cloned object
  63494. * @param newEmitter The new emitter to use
  63495. * @returns the cloned particle system
  63496. */
  63497. clone(name: string, newEmitter: any): GPUParticleSystem;
  63498. /**
  63499. * Serializes the particle system to a JSON object
  63500. * @param serializeTexture defines if the texture must be serialized as well
  63501. * @returns the JSON object
  63502. */
  63503. serialize(serializeTexture?: boolean): any;
  63504. /**
  63505. * Parses a JSON object to create a GPU particle system.
  63506. * @param parsedParticleSystem The JSON object to parse
  63507. * @param scene The scene to create the particle system in
  63508. * @param rootUrl The root url to use to load external dependencies like texture
  63509. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  63510. * @returns the parsed GPU particle system
  63511. */
  63512. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  63513. }
  63514. }
  63515. declare module BABYLON {
  63516. /**
  63517. * Represents a set of particle systems working together to create a specific effect
  63518. */
  63519. export class ParticleSystemSet implements IDisposable {
  63520. /**
  63521. * Gets or sets base Assets URL
  63522. */
  63523. static BaseAssetsUrl: string;
  63524. private _emitterCreationOptions;
  63525. private _emitterNode;
  63526. /**
  63527. * Gets the particle system list
  63528. */
  63529. systems: IParticleSystem[];
  63530. /**
  63531. * Gets the emitter node used with this set
  63532. */
  63533. get emitterNode(): Nullable<TransformNode>;
  63534. /**
  63535. * Creates a new emitter mesh as a sphere
  63536. * @param options defines the options used to create the sphere
  63537. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  63538. * @param scene defines the hosting scene
  63539. */
  63540. setEmitterAsSphere(options: {
  63541. diameter: number;
  63542. segments: number;
  63543. color: Color3;
  63544. }, renderingGroupId: number, scene: Scene): void;
  63545. /**
  63546. * Starts all particle systems of the set
  63547. * @param emitter defines an optional mesh to use as emitter for the particle systems
  63548. */
  63549. start(emitter?: AbstractMesh): void;
  63550. /**
  63551. * Release all associated resources
  63552. */
  63553. dispose(): void;
  63554. /**
  63555. * Serialize the set into a JSON compatible object
  63556. * @param serializeTexture defines if the texture must be serialized as well
  63557. * @returns a JSON compatible representation of the set
  63558. */
  63559. serialize(serializeTexture?: boolean): any;
  63560. /**
  63561. * Parse a new ParticleSystemSet from a serialized source
  63562. * @param data defines a JSON compatible representation of the set
  63563. * @param scene defines the hosting scene
  63564. * @param gpu defines if we want GPU particles or CPU particles
  63565. * @returns a new ParticleSystemSet
  63566. */
  63567. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  63568. }
  63569. }
  63570. declare module BABYLON {
  63571. /**
  63572. * This class is made for on one-liner static method to help creating particle system set.
  63573. */
  63574. export class ParticleHelper {
  63575. /**
  63576. * Gets or sets base Assets URL
  63577. */
  63578. static BaseAssetsUrl: string;
  63579. /** Define the Url to load snippets */
  63580. static SnippetUrl: string;
  63581. /**
  63582. * Create a default particle system that you can tweak
  63583. * @param emitter defines the emitter to use
  63584. * @param capacity defines the system capacity (default is 500 particles)
  63585. * @param scene defines the hosting scene
  63586. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  63587. * @returns the new Particle system
  63588. */
  63589. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  63590. /**
  63591. * This is the main static method (one-liner) of this helper to create different particle systems
  63592. * @param type This string represents the type to the particle system to create
  63593. * @param scene The scene where the particle system should live
  63594. * @param gpu If the system will use gpu
  63595. * @returns the ParticleSystemSet created
  63596. */
  63597. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  63598. /**
  63599. * Static function used to export a particle system to a ParticleSystemSet variable.
  63600. * Please note that the emitter shape is not exported
  63601. * @param systems defines the particle systems to export
  63602. * @returns the created particle system set
  63603. */
  63604. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  63605. /**
  63606. * Creates a particle system from a snippet saved in a remote file
  63607. * @param name defines the name of the particle system to create
  63608. * @param url defines the url to load from
  63609. * @param scene defines the hosting scene
  63610. * @param gpu If the system will use gpu
  63611. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63612. * @returns a promise that will resolve to the new particle system
  63613. */
  63614. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63615. /**
  63616. * Creates a particle system from a snippet saved by the particle system editor
  63617. * @param snippetId defines the snippet to load
  63618. * @param scene defines the hosting scene
  63619. * @param gpu If the system will use gpu
  63620. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63621. * @returns a promise that will resolve to the new particle system
  63622. */
  63623. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  63624. }
  63625. }
  63626. declare module BABYLON {
  63627. interface Engine {
  63628. /**
  63629. * Create an effect to use with particle systems.
  63630. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  63631. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  63632. * @param uniformsNames defines a list of attribute names
  63633. * @param samplers defines an array of string used to represent textures
  63634. * @param defines defines the string containing the defines to use to compile the shaders
  63635. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  63636. * @param onCompiled defines a function to call when the effect creation is successful
  63637. * @param onError defines a function to call when the effect creation has failed
  63638. * @returns the new Effect
  63639. */
  63640. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  63641. }
  63642. interface Mesh {
  63643. /**
  63644. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  63645. * @returns an array of IParticleSystem
  63646. */
  63647. getEmittedParticleSystems(): IParticleSystem[];
  63648. /**
  63649. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  63650. * @returns an array of IParticleSystem
  63651. */
  63652. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  63653. }
  63654. /**
  63655. * @hidden
  63656. */
  63657. export var _IDoNeedToBeInTheBuild: number;
  63658. }
  63659. declare module BABYLON {
  63660. /** Defines the 4 color options */
  63661. export enum PointColor {
  63662. /** color value */
  63663. Color = 2,
  63664. /** uv value */
  63665. UV = 1,
  63666. /** random value */
  63667. Random = 0,
  63668. /** stated value */
  63669. Stated = 3
  63670. }
  63671. /**
  63672. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  63673. * 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.
  63674. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  63675. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  63676. *
  63677. * Full documentation here : TO BE ENTERED
  63678. */
  63679. export class PointsCloudSystem implements IDisposable {
  63680. /**
  63681. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  63682. * Example : var p = SPS.particles[i];
  63683. */
  63684. particles: CloudPoint[];
  63685. /**
  63686. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  63687. */
  63688. nbParticles: number;
  63689. /**
  63690. * This a counter for your own usage. It's not set by any SPS functions.
  63691. */
  63692. counter: number;
  63693. /**
  63694. * The PCS name. This name is also given to the underlying mesh.
  63695. */
  63696. name: string;
  63697. /**
  63698. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  63699. */
  63700. mesh: Mesh;
  63701. /**
  63702. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  63703. * Please read :
  63704. */
  63705. vars: any;
  63706. /**
  63707. * @hidden
  63708. */
  63709. _size: number;
  63710. private _scene;
  63711. private _promises;
  63712. private _positions;
  63713. private _indices;
  63714. private _normals;
  63715. private _colors;
  63716. private _uvs;
  63717. private _indices32;
  63718. private _positions32;
  63719. private _colors32;
  63720. private _uvs32;
  63721. private _updatable;
  63722. private _isVisibilityBoxLocked;
  63723. private _alwaysVisible;
  63724. private _groups;
  63725. private _groupCounter;
  63726. private _computeParticleColor;
  63727. private _computeParticleTexture;
  63728. private _computeParticleRotation;
  63729. private _computeBoundingBox;
  63730. private _isReady;
  63731. /**
  63732. * Creates a PCS (Points Cloud System) object
  63733. * @param name (String) is the PCS name, this will be the underlying mesh name
  63734. * @param pointSize (number) is the size for each point
  63735. * @param scene (Scene) is the scene in which the PCS is added
  63736. * @param options defines the options of the PCS e.g.
  63737. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63738. */
  63739. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63740. updatable?: boolean;
  63741. });
  63742. /**
  63743. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63744. * If no points were added to the PCS, the returned mesh is just a single point.
  63745. * @returns a promise for the created mesh
  63746. */
  63747. buildMeshAsync(): Promise<Mesh>;
  63748. /**
  63749. * @hidden
  63750. */
  63751. private _buildMesh;
  63752. private _addParticle;
  63753. private _randomUnitVector;
  63754. private _getColorIndicesForCoord;
  63755. private _setPointsColorOrUV;
  63756. private _colorFromTexture;
  63757. private _calculateDensity;
  63758. /**
  63759. * Adds points to the PCS in random positions within a unit sphere
  63760. * @param nb (positive integer) the number of particles to be created from this model
  63761. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63762. * @returns the number of groups in the system
  63763. */
  63764. addPoints(nb: number, pointFunction?: any): number;
  63765. /**
  63766. * Adds points to the PCS from the surface of the model shape
  63767. * @param mesh is any Mesh object that will be used as a surface model for the points
  63768. * @param nb (positive integer) the number of particles to be created from this model
  63769. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63770. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63771. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63772. * @returns the number of groups in the system
  63773. */
  63774. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63775. /**
  63776. * Adds points to the PCS inside the model shape
  63777. * @param mesh is any Mesh object that will be used as a surface model for the points
  63778. * @param nb (positive integer) the number of particles to be created from this model
  63779. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63780. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63781. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63782. * @returns the number of groups in the system
  63783. */
  63784. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63785. /**
  63786. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63787. * This method calls `updateParticle()` for each particle of the SPS.
  63788. * For an animated SPS, it is usually called within the render loop.
  63789. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63790. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63791. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63792. * @returns the PCS.
  63793. */
  63794. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63795. /**
  63796. * Disposes the PCS.
  63797. */
  63798. dispose(): void;
  63799. /**
  63800. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63801. * doc :
  63802. * @returns the PCS.
  63803. */
  63804. refreshVisibleSize(): PointsCloudSystem;
  63805. /**
  63806. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63807. * @param size the size (float) of the visibility box
  63808. * note : this doesn't lock the PCS mesh bounding box.
  63809. * doc :
  63810. */
  63811. setVisibilityBox(size: number): void;
  63812. /**
  63813. * Gets whether the PCS is always visible or not
  63814. * doc :
  63815. */
  63816. get isAlwaysVisible(): boolean;
  63817. /**
  63818. * Sets the PCS as always visible or not
  63819. * doc :
  63820. */
  63821. set isAlwaysVisible(val: boolean);
  63822. /**
  63823. * Tells to `setParticles()` to compute the particle rotations or not
  63824. * Default value : false. The PCS is faster when it's set to false
  63825. * Note : particle rotations are only applied to parent particles
  63826. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63827. */
  63828. set computeParticleRotation(val: boolean);
  63829. /**
  63830. * Tells to `setParticles()` to compute the particle colors or not.
  63831. * Default value : true. The PCS is faster when it's set to false.
  63832. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63833. */
  63834. set computeParticleColor(val: boolean);
  63835. set computeParticleTexture(val: boolean);
  63836. /**
  63837. * Gets if `setParticles()` computes the particle colors or not.
  63838. * Default value : false. The PCS is faster when it's set to false.
  63839. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63840. */
  63841. get computeParticleColor(): boolean;
  63842. /**
  63843. * Gets if `setParticles()` computes the particle textures or not.
  63844. * Default value : false. The PCS is faster when it's set to false.
  63845. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63846. */
  63847. get computeParticleTexture(): boolean;
  63848. /**
  63849. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63850. */
  63851. set computeBoundingBox(val: boolean);
  63852. /**
  63853. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63854. */
  63855. get computeBoundingBox(): boolean;
  63856. /**
  63857. * This function does nothing. It may be overwritten to set all the particle first values.
  63858. * The PCS doesn't call this function, you may have to call it by your own.
  63859. * doc :
  63860. */
  63861. initParticles(): void;
  63862. /**
  63863. * This function does nothing. It may be overwritten to recycle a particle
  63864. * The PCS doesn't call this function, you can to call it
  63865. * doc :
  63866. * @param particle The particle to recycle
  63867. * @returns the recycled particle
  63868. */
  63869. recycleParticle(particle: CloudPoint): CloudPoint;
  63870. /**
  63871. * Updates a particle : this function should be overwritten by the user.
  63872. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63873. * doc :
  63874. * @example : just set a particle position or velocity and recycle conditions
  63875. * @param particle The particle to update
  63876. * @returns the updated particle
  63877. */
  63878. updateParticle(particle: CloudPoint): CloudPoint;
  63879. /**
  63880. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63881. * This does nothing and may be overwritten by the user.
  63882. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63883. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63884. * @param update the boolean update value actually passed to setParticles()
  63885. */
  63886. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63887. /**
  63888. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63889. * This will be passed three parameters.
  63890. * This does nothing and may be overwritten by the user.
  63891. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63892. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63893. * @param update the boolean update value actually passed to setParticles()
  63894. */
  63895. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63896. }
  63897. }
  63898. declare module BABYLON {
  63899. /**
  63900. * Represents one particle of a points cloud system.
  63901. */
  63902. export class CloudPoint {
  63903. /**
  63904. * particle global index
  63905. */
  63906. idx: number;
  63907. /**
  63908. * The color of the particle
  63909. */
  63910. color: Nullable<Color4>;
  63911. /**
  63912. * The world space position of the particle.
  63913. */
  63914. position: Vector3;
  63915. /**
  63916. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63917. */
  63918. rotation: Vector3;
  63919. /**
  63920. * The world space rotation quaternion of the particle.
  63921. */
  63922. rotationQuaternion: Nullable<Quaternion>;
  63923. /**
  63924. * The uv of the particle.
  63925. */
  63926. uv: Nullable<Vector2>;
  63927. /**
  63928. * The current speed of the particle.
  63929. */
  63930. velocity: Vector3;
  63931. /**
  63932. * The pivot point in the particle local space.
  63933. */
  63934. pivot: Vector3;
  63935. /**
  63936. * Must the particle be translated from its pivot point in its local space ?
  63937. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63938. * Default : false
  63939. */
  63940. translateFromPivot: boolean;
  63941. /**
  63942. * Index of this particle in the global "positions" array (Internal use)
  63943. * @hidden
  63944. */
  63945. _pos: number;
  63946. /**
  63947. * @hidden Index of this particle in the global "indices" array (Internal use)
  63948. */
  63949. _ind: number;
  63950. /**
  63951. * Group this particle belongs to
  63952. */
  63953. _group: PointsGroup;
  63954. /**
  63955. * Group id of this particle
  63956. */
  63957. groupId: number;
  63958. /**
  63959. * Index of the particle in its group id (Internal use)
  63960. */
  63961. idxInGroup: number;
  63962. /**
  63963. * @hidden Particle BoundingInfo object (Internal use)
  63964. */
  63965. _boundingInfo: BoundingInfo;
  63966. /**
  63967. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63968. */
  63969. _pcs: PointsCloudSystem;
  63970. /**
  63971. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63972. */
  63973. _stillInvisible: boolean;
  63974. /**
  63975. * @hidden Last computed particle rotation matrix
  63976. */
  63977. _rotationMatrix: number[];
  63978. /**
  63979. * Parent particle Id, if any.
  63980. * Default null.
  63981. */
  63982. parentId: Nullable<number>;
  63983. /**
  63984. * @hidden Internal global position in the PCS.
  63985. */
  63986. _globalPosition: Vector3;
  63987. /**
  63988. * Creates a Point Cloud object.
  63989. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63990. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63991. * @param group (PointsGroup) is the group the particle belongs to
  63992. * @param groupId (integer) is the group identifier in the PCS.
  63993. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63994. * @param pcs defines the PCS it is associated to
  63995. */
  63996. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63997. /**
  63998. * get point size
  63999. */
  64000. get size(): Vector3;
  64001. /**
  64002. * Set point size
  64003. */
  64004. set size(scale: Vector3);
  64005. /**
  64006. * Legacy support, changed quaternion to rotationQuaternion
  64007. */
  64008. get quaternion(): Nullable<Quaternion>;
  64009. /**
  64010. * Legacy support, changed quaternion to rotationQuaternion
  64011. */
  64012. set quaternion(q: Nullable<Quaternion>);
  64013. /**
  64014. * Returns a boolean. True if the particle intersects a mesh, else false
  64015. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  64016. * @param target is the object (point or mesh) what the intersection is computed against
  64017. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  64018. * @returns true if it intersects
  64019. */
  64020. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  64021. /**
  64022. * get the rotation matrix of the particle
  64023. * @hidden
  64024. */
  64025. getRotationMatrix(m: Matrix): void;
  64026. }
  64027. /**
  64028. * Represents a group of points in a points cloud system
  64029. * * PCS internal tool, don't use it manually.
  64030. */
  64031. export class PointsGroup {
  64032. /**
  64033. * The group id
  64034. * @hidden
  64035. */
  64036. groupID: number;
  64037. /**
  64038. * image data for group (internal use)
  64039. * @hidden
  64040. */
  64041. _groupImageData: Nullable<ArrayBufferView>;
  64042. /**
  64043. * Image Width (internal use)
  64044. * @hidden
  64045. */
  64046. _groupImgWidth: number;
  64047. /**
  64048. * Image Height (internal use)
  64049. * @hidden
  64050. */
  64051. _groupImgHeight: number;
  64052. /**
  64053. * Custom position function (internal use)
  64054. * @hidden
  64055. */
  64056. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  64057. /**
  64058. * density per facet for surface points
  64059. * @hidden
  64060. */
  64061. _groupDensity: number[];
  64062. /**
  64063. * Only when points are colored by texture carries pointer to texture list array
  64064. * @hidden
  64065. */
  64066. _textureNb: number;
  64067. /**
  64068. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  64069. * PCS internal tool, don't use it manually.
  64070. * @hidden
  64071. */
  64072. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  64073. }
  64074. }
  64075. declare module BABYLON {
  64076. interface Scene {
  64077. /** @hidden (Backing field) */
  64078. _physicsEngine: Nullable<IPhysicsEngine>;
  64079. /** @hidden */
  64080. _physicsTimeAccumulator: number;
  64081. /**
  64082. * Gets the current physics engine
  64083. * @returns a IPhysicsEngine or null if none attached
  64084. */
  64085. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  64086. /**
  64087. * Enables physics to the current scene
  64088. * @param gravity defines the scene's gravity for the physics engine
  64089. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  64090. * @return a boolean indicating if the physics engine was initialized
  64091. */
  64092. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  64093. /**
  64094. * Disables and disposes the physics engine associated with the scene
  64095. */
  64096. disablePhysicsEngine(): void;
  64097. /**
  64098. * Gets a boolean indicating if there is an active physics engine
  64099. * @returns a boolean indicating if there is an active physics engine
  64100. */
  64101. isPhysicsEnabled(): boolean;
  64102. /**
  64103. * Deletes a physics compound impostor
  64104. * @param compound defines the compound to delete
  64105. */
  64106. deleteCompoundImpostor(compound: any): void;
  64107. /**
  64108. * An event triggered when physic simulation is about to be run
  64109. */
  64110. onBeforePhysicsObservable: Observable<Scene>;
  64111. /**
  64112. * An event triggered when physic simulation has been done
  64113. */
  64114. onAfterPhysicsObservable: Observable<Scene>;
  64115. }
  64116. interface AbstractMesh {
  64117. /** @hidden */
  64118. _physicsImpostor: Nullable<PhysicsImpostor>;
  64119. /**
  64120. * Gets or sets impostor used for physic simulation
  64121. * @see http://doc.babylonjs.com/features/physics_engine
  64122. */
  64123. physicsImpostor: Nullable<PhysicsImpostor>;
  64124. /**
  64125. * Gets the current physics impostor
  64126. * @see http://doc.babylonjs.com/features/physics_engine
  64127. * @returns a physics impostor or null
  64128. */
  64129. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  64130. /** Apply a physic impulse to the mesh
  64131. * @param force defines the force to apply
  64132. * @param contactPoint defines where to apply the force
  64133. * @returns the current mesh
  64134. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  64135. */
  64136. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  64137. /**
  64138. * Creates a physic joint between two meshes
  64139. * @param otherMesh defines the other mesh to use
  64140. * @param pivot1 defines the pivot to use on this mesh
  64141. * @param pivot2 defines the pivot to use on the other mesh
  64142. * @param options defines additional options (can be plugin dependent)
  64143. * @returns the current mesh
  64144. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  64145. */
  64146. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  64147. /** @hidden */
  64148. _disposePhysicsObserver: Nullable<Observer<Node>>;
  64149. }
  64150. /**
  64151. * Defines the physics engine scene component responsible to manage a physics engine
  64152. */
  64153. export class PhysicsEngineSceneComponent implements ISceneComponent {
  64154. /**
  64155. * The component name helpful to identify the component in the list of scene components.
  64156. */
  64157. readonly name: string;
  64158. /**
  64159. * The scene the component belongs to.
  64160. */
  64161. scene: Scene;
  64162. /**
  64163. * Creates a new instance of the component for the given scene
  64164. * @param scene Defines the scene to register the component in
  64165. */
  64166. constructor(scene: Scene);
  64167. /**
  64168. * Registers the component in a given scene
  64169. */
  64170. register(): void;
  64171. /**
  64172. * Rebuilds the elements related to this component in case of
  64173. * context lost for instance.
  64174. */
  64175. rebuild(): void;
  64176. /**
  64177. * Disposes the component and the associated ressources
  64178. */
  64179. dispose(): void;
  64180. }
  64181. }
  64182. declare module BABYLON {
  64183. /**
  64184. * A helper for physics simulations
  64185. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64186. */
  64187. export class PhysicsHelper {
  64188. private _scene;
  64189. private _physicsEngine;
  64190. /**
  64191. * Initializes the Physics helper
  64192. * @param scene Babylon.js scene
  64193. */
  64194. constructor(scene: Scene);
  64195. /**
  64196. * Applies a radial explosion impulse
  64197. * @param origin the origin of the explosion
  64198. * @param radiusOrEventOptions the radius or the options of radial explosion
  64199. * @param strength the explosion strength
  64200. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64201. * @returns A physics radial explosion event, or null
  64202. */
  64203. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64204. /**
  64205. * Applies a radial explosion force
  64206. * @param origin the origin of the explosion
  64207. * @param radiusOrEventOptions the radius or the options of radial explosion
  64208. * @param strength the explosion strength
  64209. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64210. * @returns A physics radial explosion event, or null
  64211. */
  64212. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  64213. /**
  64214. * Creates a gravitational field
  64215. * @param origin the origin of the explosion
  64216. * @param radiusOrEventOptions the radius or the options of radial explosion
  64217. * @param strength the explosion strength
  64218. * @param falloff possible options: Constant & Linear. Defaults to Constant
  64219. * @returns A physics gravitational field event, or null
  64220. */
  64221. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  64222. /**
  64223. * Creates a physics updraft event
  64224. * @param origin the origin of the updraft
  64225. * @param radiusOrEventOptions the radius or the options of the updraft
  64226. * @param strength the strength of the updraft
  64227. * @param height the height of the updraft
  64228. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  64229. * @returns A physics updraft event, or null
  64230. */
  64231. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  64232. /**
  64233. * Creates a physics vortex event
  64234. * @param origin the of the vortex
  64235. * @param radiusOrEventOptions the radius or the options of the vortex
  64236. * @param strength the strength of the vortex
  64237. * @param height the height of the vortex
  64238. * @returns a Physics vortex event, or null
  64239. * A physics vortex event or null
  64240. */
  64241. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  64242. }
  64243. /**
  64244. * Represents a physics radial explosion event
  64245. */
  64246. class PhysicsRadialExplosionEvent {
  64247. private _scene;
  64248. private _options;
  64249. private _sphere;
  64250. private _dataFetched;
  64251. /**
  64252. * Initializes a radial explosioin event
  64253. * @param _scene BabylonJS scene
  64254. * @param _options The options for the vortex event
  64255. */
  64256. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  64257. /**
  64258. * Returns the data related to the radial explosion event (sphere).
  64259. * @returns The radial explosion event data
  64260. */
  64261. getData(): PhysicsRadialExplosionEventData;
  64262. /**
  64263. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  64264. * @param impostor A physics imposter
  64265. * @param origin the origin of the explosion
  64266. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  64267. */
  64268. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  64269. /**
  64270. * Triggers affecterd impostors callbacks
  64271. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  64272. */
  64273. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  64274. /**
  64275. * Disposes the sphere.
  64276. * @param force Specifies if the sphere should be disposed by force
  64277. */
  64278. dispose(force?: boolean): void;
  64279. /*** Helpers ***/
  64280. private _prepareSphere;
  64281. private _intersectsWithSphere;
  64282. }
  64283. /**
  64284. * Represents a gravitational field event
  64285. */
  64286. class PhysicsGravitationalFieldEvent {
  64287. private _physicsHelper;
  64288. private _scene;
  64289. private _origin;
  64290. private _options;
  64291. private _tickCallback;
  64292. private _sphere;
  64293. private _dataFetched;
  64294. /**
  64295. * Initializes the physics gravitational field event
  64296. * @param _physicsHelper A physics helper
  64297. * @param _scene BabylonJS scene
  64298. * @param _origin The origin position of the gravitational field event
  64299. * @param _options The options for the vortex event
  64300. */
  64301. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  64302. /**
  64303. * Returns the data related to the gravitational field event (sphere).
  64304. * @returns A gravitational field event
  64305. */
  64306. getData(): PhysicsGravitationalFieldEventData;
  64307. /**
  64308. * Enables the gravitational field.
  64309. */
  64310. enable(): void;
  64311. /**
  64312. * Disables the gravitational field.
  64313. */
  64314. disable(): void;
  64315. /**
  64316. * Disposes the sphere.
  64317. * @param force The force to dispose from the gravitational field event
  64318. */
  64319. dispose(force?: boolean): void;
  64320. private _tick;
  64321. }
  64322. /**
  64323. * Represents a physics updraft event
  64324. */
  64325. class PhysicsUpdraftEvent {
  64326. private _scene;
  64327. private _origin;
  64328. private _options;
  64329. private _physicsEngine;
  64330. private _originTop;
  64331. private _originDirection;
  64332. private _tickCallback;
  64333. private _cylinder;
  64334. private _cylinderPosition;
  64335. private _dataFetched;
  64336. /**
  64337. * Initializes the physics updraft event
  64338. * @param _scene BabylonJS scene
  64339. * @param _origin The origin position of the updraft
  64340. * @param _options The options for the updraft event
  64341. */
  64342. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  64343. /**
  64344. * Returns the data related to the updraft event (cylinder).
  64345. * @returns A physics updraft event
  64346. */
  64347. getData(): PhysicsUpdraftEventData;
  64348. /**
  64349. * Enables the updraft.
  64350. */
  64351. enable(): void;
  64352. /**
  64353. * Disables the updraft.
  64354. */
  64355. disable(): void;
  64356. /**
  64357. * Disposes the cylinder.
  64358. * @param force Specifies if the updraft should be disposed by force
  64359. */
  64360. dispose(force?: boolean): void;
  64361. private getImpostorHitData;
  64362. private _tick;
  64363. /*** Helpers ***/
  64364. private _prepareCylinder;
  64365. private _intersectsWithCylinder;
  64366. }
  64367. /**
  64368. * Represents a physics vortex event
  64369. */
  64370. class PhysicsVortexEvent {
  64371. private _scene;
  64372. private _origin;
  64373. private _options;
  64374. private _physicsEngine;
  64375. private _originTop;
  64376. private _tickCallback;
  64377. private _cylinder;
  64378. private _cylinderPosition;
  64379. private _dataFetched;
  64380. /**
  64381. * Initializes the physics vortex event
  64382. * @param _scene The BabylonJS scene
  64383. * @param _origin The origin position of the vortex
  64384. * @param _options The options for the vortex event
  64385. */
  64386. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  64387. /**
  64388. * Returns the data related to the vortex event (cylinder).
  64389. * @returns The physics vortex event data
  64390. */
  64391. getData(): PhysicsVortexEventData;
  64392. /**
  64393. * Enables the vortex.
  64394. */
  64395. enable(): void;
  64396. /**
  64397. * Disables the cortex.
  64398. */
  64399. disable(): void;
  64400. /**
  64401. * Disposes the sphere.
  64402. * @param force
  64403. */
  64404. dispose(force?: boolean): void;
  64405. private getImpostorHitData;
  64406. private _tick;
  64407. /*** Helpers ***/
  64408. private _prepareCylinder;
  64409. private _intersectsWithCylinder;
  64410. }
  64411. /**
  64412. * Options fot the radial explosion event
  64413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64414. */
  64415. export class PhysicsRadialExplosionEventOptions {
  64416. /**
  64417. * The radius of the sphere for the radial explosion.
  64418. */
  64419. radius: number;
  64420. /**
  64421. * The strenth of the explosion.
  64422. */
  64423. strength: number;
  64424. /**
  64425. * The strenght of the force in correspondence to the distance of the affected object
  64426. */
  64427. falloff: PhysicsRadialImpulseFalloff;
  64428. /**
  64429. * Sphere options for the radial explosion.
  64430. */
  64431. sphere: {
  64432. segments: number;
  64433. diameter: number;
  64434. };
  64435. /**
  64436. * Sphere options for the radial explosion.
  64437. */
  64438. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  64439. }
  64440. /**
  64441. * Options fot the updraft event
  64442. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64443. */
  64444. export class PhysicsUpdraftEventOptions {
  64445. /**
  64446. * The radius of the cylinder for the vortex
  64447. */
  64448. radius: number;
  64449. /**
  64450. * The strenth of the updraft.
  64451. */
  64452. strength: number;
  64453. /**
  64454. * The height of the cylinder for the updraft.
  64455. */
  64456. height: number;
  64457. /**
  64458. * The mode for the the updraft.
  64459. */
  64460. updraftMode: PhysicsUpdraftMode;
  64461. }
  64462. /**
  64463. * Options fot the vortex event
  64464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64465. */
  64466. export class PhysicsVortexEventOptions {
  64467. /**
  64468. * The radius of the cylinder for the vortex
  64469. */
  64470. radius: number;
  64471. /**
  64472. * The strenth of the vortex.
  64473. */
  64474. strength: number;
  64475. /**
  64476. * The height of the cylinder for the vortex.
  64477. */
  64478. height: number;
  64479. /**
  64480. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  64481. */
  64482. centripetalForceThreshold: number;
  64483. /**
  64484. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  64485. */
  64486. centripetalForceMultiplier: number;
  64487. /**
  64488. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  64489. */
  64490. centrifugalForceMultiplier: number;
  64491. /**
  64492. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  64493. */
  64494. updraftForceMultiplier: number;
  64495. }
  64496. /**
  64497. * The strenght of the force in correspondence to the distance of the affected object
  64498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64499. */
  64500. export enum PhysicsRadialImpulseFalloff {
  64501. /** Defines that impulse is constant in strength across it's whole radius */
  64502. Constant = 0,
  64503. /** Defines that impulse gets weaker if it's further from the origin */
  64504. Linear = 1
  64505. }
  64506. /**
  64507. * The strength of the force in correspondence to the distance of the affected object
  64508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64509. */
  64510. export enum PhysicsUpdraftMode {
  64511. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  64512. Center = 0,
  64513. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  64514. Perpendicular = 1
  64515. }
  64516. /**
  64517. * Interface for a physics hit data
  64518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64519. */
  64520. export interface PhysicsHitData {
  64521. /**
  64522. * The force applied at the contact point
  64523. */
  64524. force: Vector3;
  64525. /**
  64526. * The contact point
  64527. */
  64528. contactPoint: Vector3;
  64529. /**
  64530. * The distance from the origin to the contact point
  64531. */
  64532. distanceFromOrigin: number;
  64533. }
  64534. /**
  64535. * Interface for radial explosion event data
  64536. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64537. */
  64538. export interface PhysicsRadialExplosionEventData {
  64539. /**
  64540. * A sphere used for the radial explosion event
  64541. */
  64542. sphere: Mesh;
  64543. }
  64544. /**
  64545. * Interface for gravitational field event data
  64546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64547. */
  64548. export interface PhysicsGravitationalFieldEventData {
  64549. /**
  64550. * A sphere mesh used for the gravitational field event
  64551. */
  64552. sphere: Mesh;
  64553. }
  64554. /**
  64555. * Interface for updraft event data
  64556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64557. */
  64558. export interface PhysicsUpdraftEventData {
  64559. /**
  64560. * A cylinder used for the updraft event
  64561. */
  64562. cylinder: Mesh;
  64563. }
  64564. /**
  64565. * Interface for vortex event data
  64566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64567. */
  64568. export interface PhysicsVortexEventData {
  64569. /**
  64570. * A cylinder used for the vortex event
  64571. */
  64572. cylinder: Mesh;
  64573. }
  64574. /**
  64575. * Interface for an affected physics impostor
  64576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  64577. */
  64578. export interface PhysicsAffectedImpostorWithData {
  64579. /**
  64580. * The impostor affected by the effect
  64581. */
  64582. impostor: PhysicsImpostor;
  64583. /**
  64584. * The data about the hit/horce from the explosion
  64585. */
  64586. hitData: PhysicsHitData;
  64587. }
  64588. }
  64589. declare module BABYLON {
  64590. /** @hidden */
  64591. export var blackAndWhitePixelShader: {
  64592. name: string;
  64593. shader: string;
  64594. };
  64595. }
  64596. declare module BABYLON {
  64597. /**
  64598. * Post process used to render in black and white
  64599. */
  64600. export class BlackAndWhitePostProcess extends PostProcess {
  64601. /**
  64602. * Linear about to convert he result to black and white (default: 1)
  64603. */
  64604. degree: number;
  64605. /**
  64606. * Creates a black and white post process
  64607. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  64608. * @param name The name of the effect.
  64609. * @param options The required width/height ratio to downsize to before computing the render pass.
  64610. * @param camera The camera to apply the render pass to.
  64611. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64612. * @param engine The engine which the post process will be applied. (default: current engine)
  64613. * @param reusable If the post process can be reused on the same frame. (default: false)
  64614. */
  64615. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64616. }
  64617. }
  64618. declare module BABYLON {
  64619. /**
  64620. * This represents a set of one or more post processes in Babylon.
  64621. * A post process can be used to apply a shader to a texture after it is rendered.
  64622. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64623. */
  64624. export class PostProcessRenderEffect {
  64625. private _postProcesses;
  64626. private _getPostProcesses;
  64627. private _singleInstance;
  64628. private _cameras;
  64629. private _indicesForCamera;
  64630. /**
  64631. * Name of the effect
  64632. * @hidden
  64633. */
  64634. _name: string;
  64635. /**
  64636. * Instantiates a post process render effect.
  64637. * A post process can be used to apply a shader to a texture after it is rendered.
  64638. * @param engine The engine the effect is tied to
  64639. * @param name The name of the effect
  64640. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  64641. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  64642. */
  64643. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  64644. /**
  64645. * Checks if all the post processes in the effect are supported.
  64646. */
  64647. get isSupported(): boolean;
  64648. /**
  64649. * Updates the current state of the effect
  64650. * @hidden
  64651. */
  64652. _update(): void;
  64653. /**
  64654. * Attaches the effect on cameras
  64655. * @param cameras The camera to attach to.
  64656. * @hidden
  64657. */
  64658. _attachCameras(cameras: Camera): void;
  64659. /**
  64660. * Attaches the effect on cameras
  64661. * @param cameras The camera to attach to.
  64662. * @hidden
  64663. */
  64664. _attachCameras(cameras: Camera[]): void;
  64665. /**
  64666. * Detaches the effect on cameras
  64667. * @param cameras The camera to detatch from.
  64668. * @hidden
  64669. */
  64670. _detachCameras(cameras: Camera): void;
  64671. /**
  64672. * Detatches the effect on cameras
  64673. * @param cameras The camera to detatch from.
  64674. * @hidden
  64675. */
  64676. _detachCameras(cameras: Camera[]): void;
  64677. /**
  64678. * Enables the effect on given cameras
  64679. * @param cameras The camera to enable.
  64680. * @hidden
  64681. */
  64682. _enable(cameras: Camera): void;
  64683. /**
  64684. * Enables the effect on given cameras
  64685. * @param cameras The camera to enable.
  64686. * @hidden
  64687. */
  64688. _enable(cameras: Nullable<Camera[]>): void;
  64689. /**
  64690. * Disables the effect on the given cameras
  64691. * @param cameras The camera to disable.
  64692. * @hidden
  64693. */
  64694. _disable(cameras: Camera): void;
  64695. /**
  64696. * Disables the effect on the given cameras
  64697. * @param cameras The camera to disable.
  64698. * @hidden
  64699. */
  64700. _disable(cameras: Nullable<Camera[]>): void;
  64701. /**
  64702. * Gets a list of the post processes contained in the effect.
  64703. * @param camera The camera to get the post processes on.
  64704. * @returns The list of the post processes in the effect.
  64705. */
  64706. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  64707. }
  64708. }
  64709. declare module BABYLON {
  64710. /** @hidden */
  64711. export var extractHighlightsPixelShader: {
  64712. name: string;
  64713. shader: string;
  64714. };
  64715. }
  64716. declare module BABYLON {
  64717. /**
  64718. * 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.
  64719. */
  64720. export class ExtractHighlightsPostProcess extends PostProcess {
  64721. /**
  64722. * The luminance threshold, pixels below this value will be set to black.
  64723. */
  64724. threshold: number;
  64725. /** @hidden */
  64726. _exposure: number;
  64727. /**
  64728. * Post process which has the input texture to be used when performing highlight extraction
  64729. * @hidden
  64730. */
  64731. _inputPostProcess: Nullable<PostProcess>;
  64732. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64733. }
  64734. }
  64735. declare module BABYLON {
  64736. /** @hidden */
  64737. export var bloomMergePixelShader: {
  64738. name: string;
  64739. shader: string;
  64740. };
  64741. }
  64742. declare module BABYLON {
  64743. /**
  64744. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64745. */
  64746. export class BloomMergePostProcess extends PostProcess {
  64747. /** Weight of the bloom to be added to the original input. */
  64748. weight: number;
  64749. /**
  64750. * Creates a new instance of @see BloomMergePostProcess
  64751. * @param name The name of the effect.
  64752. * @param originalFromInput Post process which's input will be used for the merge.
  64753. * @param blurred Blurred highlights post process which's output will be used.
  64754. * @param weight Weight of the bloom to be added to the original input.
  64755. * @param options The required width/height ratio to downsize to before computing the render pass.
  64756. * @param camera The camera to apply the render pass to.
  64757. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64758. * @param engine The engine which the post process will be applied. (default: current engine)
  64759. * @param reusable If the post process can be reused on the same frame. (default: false)
  64760. * @param textureType Type of textures used when performing the post process. (default: 0)
  64761. * @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)
  64762. */
  64763. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64764. /** Weight of the bloom to be added to the original input. */
  64765. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64766. }
  64767. }
  64768. declare module BABYLON {
  64769. /**
  64770. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64771. */
  64772. export class BloomEffect extends PostProcessRenderEffect {
  64773. private bloomScale;
  64774. /**
  64775. * @hidden Internal
  64776. */
  64777. _effects: Array<PostProcess>;
  64778. /**
  64779. * @hidden Internal
  64780. */
  64781. _downscale: ExtractHighlightsPostProcess;
  64782. private _blurX;
  64783. private _blurY;
  64784. private _merge;
  64785. /**
  64786. * The luminance threshold to find bright areas of the image to bloom.
  64787. */
  64788. get threshold(): number;
  64789. set threshold(value: number);
  64790. /**
  64791. * The strength of the bloom.
  64792. */
  64793. get weight(): number;
  64794. set weight(value: number);
  64795. /**
  64796. * Specifies the size of the bloom blur kernel, relative to the final output size
  64797. */
  64798. get kernel(): number;
  64799. set kernel(value: number);
  64800. /**
  64801. * Creates a new instance of @see BloomEffect
  64802. * @param scene The scene the effect belongs to.
  64803. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64804. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64805. * @param bloomWeight The the strength of bloom.
  64806. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64807. * @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)
  64808. */
  64809. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64810. /**
  64811. * Disposes each of the internal effects for a given camera.
  64812. * @param camera The camera to dispose the effect on.
  64813. */
  64814. disposeEffects(camera: Camera): void;
  64815. /**
  64816. * @hidden Internal
  64817. */
  64818. _updateEffects(): void;
  64819. /**
  64820. * Internal
  64821. * @returns if all the contained post processes are ready.
  64822. * @hidden
  64823. */
  64824. _isReady(): boolean;
  64825. }
  64826. }
  64827. declare module BABYLON {
  64828. /** @hidden */
  64829. export var chromaticAberrationPixelShader: {
  64830. name: string;
  64831. shader: string;
  64832. };
  64833. }
  64834. declare module BABYLON {
  64835. /**
  64836. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64837. */
  64838. export class ChromaticAberrationPostProcess extends PostProcess {
  64839. /**
  64840. * The amount of seperation of rgb channels (default: 30)
  64841. */
  64842. aberrationAmount: number;
  64843. /**
  64844. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64845. */
  64846. radialIntensity: number;
  64847. /**
  64848. * 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))
  64849. */
  64850. direction: Vector2;
  64851. /**
  64852. * 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))
  64853. */
  64854. centerPosition: Vector2;
  64855. /**
  64856. * Creates a new instance ChromaticAberrationPostProcess
  64857. * @param name The name of the effect.
  64858. * @param screenWidth The width of the screen to apply the effect on.
  64859. * @param screenHeight The height of the screen to apply the effect on.
  64860. * @param options The required width/height ratio to downsize to before computing the render pass.
  64861. * @param camera The camera to apply the render pass to.
  64862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64863. * @param engine The engine which the post process will be applied. (default: current engine)
  64864. * @param reusable If the post process can be reused on the same frame. (default: false)
  64865. * @param textureType Type of textures used when performing the post process. (default: 0)
  64866. * @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)
  64867. */
  64868. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64869. }
  64870. }
  64871. declare module BABYLON {
  64872. /** @hidden */
  64873. export var circleOfConfusionPixelShader: {
  64874. name: string;
  64875. shader: string;
  64876. };
  64877. }
  64878. declare module BABYLON {
  64879. /**
  64880. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64881. */
  64882. export class CircleOfConfusionPostProcess extends PostProcess {
  64883. /**
  64884. * 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.
  64885. */
  64886. lensSize: number;
  64887. /**
  64888. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64889. */
  64890. fStop: number;
  64891. /**
  64892. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64893. */
  64894. focusDistance: number;
  64895. /**
  64896. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64897. */
  64898. focalLength: number;
  64899. private _depthTexture;
  64900. /**
  64901. * Creates a new instance CircleOfConfusionPostProcess
  64902. * @param name The name of the effect.
  64903. * @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.
  64904. * @param options The required width/height ratio to downsize to before computing the render pass.
  64905. * @param camera The camera to apply the render pass to.
  64906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64907. * @param engine The engine which the post process will be applied. (default: current engine)
  64908. * @param reusable If the post process can be reused on the same frame. (default: false)
  64909. * @param textureType Type of textures used when performing the post process. (default: 0)
  64910. * @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)
  64911. */
  64912. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64913. /**
  64914. * 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.
  64915. */
  64916. set depthTexture(value: RenderTargetTexture);
  64917. }
  64918. }
  64919. declare module BABYLON {
  64920. /** @hidden */
  64921. export var colorCorrectionPixelShader: {
  64922. name: string;
  64923. shader: string;
  64924. };
  64925. }
  64926. declare module BABYLON {
  64927. /**
  64928. *
  64929. * This post-process allows the modification of rendered colors by using
  64930. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64931. *
  64932. * The object needs to be provided an url to a texture containing the color
  64933. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64934. * Use an image editing software to tweak the LUT to match your needs.
  64935. *
  64936. * For an example of a color LUT, see here:
  64937. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64938. * For explanations on color grading, see here:
  64939. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64940. *
  64941. */
  64942. export class ColorCorrectionPostProcess extends PostProcess {
  64943. private _colorTableTexture;
  64944. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64945. }
  64946. }
  64947. declare module BABYLON {
  64948. /** @hidden */
  64949. export var convolutionPixelShader: {
  64950. name: string;
  64951. shader: string;
  64952. };
  64953. }
  64954. declare module BABYLON {
  64955. /**
  64956. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64957. * input texture to perform effects such as edge detection or sharpening
  64958. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64959. */
  64960. export class ConvolutionPostProcess extends PostProcess {
  64961. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64962. kernel: number[];
  64963. /**
  64964. * Creates a new instance ConvolutionPostProcess
  64965. * @param name The name of the effect.
  64966. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64967. * @param options The required width/height ratio to downsize to before computing the render pass.
  64968. * @param camera The camera to apply the render pass to.
  64969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64970. * @param engine The engine which the post process will be applied. (default: current engine)
  64971. * @param reusable If the post process can be reused on the same frame. (default: false)
  64972. * @param textureType Type of textures used when performing the post process. (default: 0)
  64973. */
  64974. constructor(name: string,
  64975. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64976. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64977. /**
  64978. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64979. */
  64980. static EdgeDetect0Kernel: number[];
  64981. /**
  64982. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64983. */
  64984. static EdgeDetect1Kernel: number[];
  64985. /**
  64986. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64987. */
  64988. static EdgeDetect2Kernel: number[];
  64989. /**
  64990. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64991. */
  64992. static SharpenKernel: number[];
  64993. /**
  64994. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64995. */
  64996. static EmbossKernel: number[];
  64997. /**
  64998. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64999. */
  65000. static GaussianKernel: number[];
  65001. }
  65002. }
  65003. declare module BABYLON {
  65004. /**
  65005. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  65006. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  65007. * based on samples that have a large difference in distance than the center pixel.
  65008. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  65009. */
  65010. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  65011. direction: Vector2;
  65012. /**
  65013. * Creates a new instance CircleOfConfusionPostProcess
  65014. * @param name The name of the effect.
  65015. * @param scene The scene the effect belongs to.
  65016. * @param direction The direction the blur should be applied.
  65017. * @param kernel The size of the kernel used to blur.
  65018. * @param options The required width/height ratio to downsize to before computing the render pass.
  65019. * @param camera The camera to apply the render pass to.
  65020. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  65021. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  65022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65023. * @param engine The engine which the post process will be applied. (default: current engine)
  65024. * @param reusable If the post process can be reused on the same frame. (default: false)
  65025. * @param textureType Type of textures used when performing the post process. (default: 0)
  65026. * @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)
  65027. */
  65028. 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);
  65029. }
  65030. }
  65031. declare module BABYLON {
  65032. /** @hidden */
  65033. export var depthOfFieldMergePixelShader: {
  65034. name: string;
  65035. shader: string;
  65036. };
  65037. }
  65038. declare module BABYLON {
  65039. /**
  65040. * Options to be set when merging outputs from the default pipeline.
  65041. */
  65042. export class DepthOfFieldMergePostProcessOptions {
  65043. /**
  65044. * The original image to merge on top of
  65045. */
  65046. originalFromInput: PostProcess;
  65047. /**
  65048. * Parameters to perform the merge of the depth of field effect
  65049. */
  65050. depthOfField?: {
  65051. circleOfConfusion: PostProcess;
  65052. blurSteps: Array<PostProcess>;
  65053. };
  65054. /**
  65055. * Parameters to perform the merge of bloom effect
  65056. */
  65057. bloom?: {
  65058. blurred: PostProcess;
  65059. weight: number;
  65060. };
  65061. }
  65062. /**
  65063. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  65064. */
  65065. export class DepthOfFieldMergePostProcess extends PostProcess {
  65066. private blurSteps;
  65067. /**
  65068. * Creates a new instance of DepthOfFieldMergePostProcess
  65069. * @param name The name of the effect.
  65070. * @param originalFromInput Post process which's input will be used for the merge.
  65071. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  65072. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  65073. * @param options The required width/height ratio to downsize to before computing the render pass.
  65074. * @param camera The camera to apply the render pass to.
  65075. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65076. * @param engine The engine which the post process will be applied. (default: current engine)
  65077. * @param reusable If the post process can be reused on the same frame. (default: false)
  65078. * @param textureType Type of textures used when performing the post process. (default: 0)
  65079. * @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)
  65080. */
  65081. 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);
  65082. /**
  65083. * Updates the effect with the current post process compile time values and recompiles the shader.
  65084. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  65085. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  65086. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  65087. * @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
  65088. * @param onCompiled Called when the shader has been compiled.
  65089. * @param onError Called if there is an error when compiling a shader.
  65090. */
  65091. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  65092. }
  65093. }
  65094. declare module BABYLON {
  65095. /**
  65096. * Specifies the level of max blur that should be applied when using the depth of field effect
  65097. */
  65098. export enum DepthOfFieldEffectBlurLevel {
  65099. /**
  65100. * Subtle blur
  65101. */
  65102. Low = 0,
  65103. /**
  65104. * Medium blur
  65105. */
  65106. Medium = 1,
  65107. /**
  65108. * Large blur
  65109. */
  65110. High = 2
  65111. }
  65112. /**
  65113. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  65114. */
  65115. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  65116. private _circleOfConfusion;
  65117. /**
  65118. * @hidden Internal, blurs from high to low
  65119. */
  65120. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  65121. private _depthOfFieldBlurY;
  65122. private _dofMerge;
  65123. /**
  65124. * @hidden Internal post processes in depth of field effect
  65125. */
  65126. _effects: Array<PostProcess>;
  65127. /**
  65128. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  65129. */
  65130. set focalLength(value: number);
  65131. get focalLength(): number;
  65132. /**
  65133. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  65134. */
  65135. set fStop(value: number);
  65136. get fStop(): number;
  65137. /**
  65138. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  65139. */
  65140. set focusDistance(value: number);
  65141. get focusDistance(): number;
  65142. /**
  65143. * 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.
  65144. */
  65145. set lensSize(value: number);
  65146. get lensSize(): number;
  65147. /**
  65148. * Creates a new instance DepthOfFieldEffect
  65149. * @param scene The scene the effect belongs to.
  65150. * @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.
  65151. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  65152. * @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)
  65153. */
  65154. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  65155. /**
  65156. * Get the current class name of the current effet
  65157. * @returns "DepthOfFieldEffect"
  65158. */
  65159. getClassName(): string;
  65160. /**
  65161. * 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.
  65162. */
  65163. set depthTexture(value: RenderTargetTexture);
  65164. /**
  65165. * Disposes each of the internal effects for a given camera.
  65166. * @param camera The camera to dispose the effect on.
  65167. */
  65168. disposeEffects(camera: Camera): void;
  65169. /**
  65170. * @hidden Internal
  65171. */
  65172. _updateEffects(): void;
  65173. /**
  65174. * Internal
  65175. * @returns if all the contained post processes are ready.
  65176. * @hidden
  65177. */
  65178. _isReady(): boolean;
  65179. }
  65180. }
  65181. declare module BABYLON {
  65182. /** @hidden */
  65183. export var displayPassPixelShader: {
  65184. name: string;
  65185. shader: string;
  65186. };
  65187. }
  65188. declare module BABYLON {
  65189. /**
  65190. * DisplayPassPostProcess which produces an output the same as it's input
  65191. */
  65192. export class DisplayPassPostProcess extends PostProcess {
  65193. /**
  65194. * Creates the DisplayPassPostProcess
  65195. * @param name The name of the effect.
  65196. * @param options The required width/height ratio to downsize to before computing the render pass.
  65197. * @param camera The camera to apply the render pass to.
  65198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65199. * @param engine The engine which the post process will be applied. (default: current engine)
  65200. * @param reusable If the post process can be reused on the same frame. (default: false)
  65201. */
  65202. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65203. }
  65204. }
  65205. declare module BABYLON {
  65206. /** @hidden */
  65207. export var filterPixelShader: {
  65208. name: string;
  65209. shader: string;
  65210. };
  65211. }
  65212. declare module BABYLON {
  65213. /**
  65214. * Applies a kernel filter to the image
  65215. */
  65216. export class FilterPostProcess extends PostProcess {
  65217. /** The matrix to be applied to the image */
  65218. kernelMatrix: Matrix;
  65219. /**
  65220. *
  65221. * @param name The name of the effect.
  65222. * @param kernelMatrix The matrix to be applied to the image
  65223. * @param options The required width/height ratio to downsize to before computing the render pass.
  65224. * @param camera The camera to apply the render pass to.
  65225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65226. * @param engine The engine which the post process will be applied. (default: current engine)
  65227. * @param reusable If the post process can be reused on the same frame. (default: false)
  65228. */
  65229. constructor(name: string,
  65230. /** The matrix to be applied to the image */
  65231. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65232. }
  65233. }
  65234. declare module BABYLON {
  65235. /** @hidden */
  65236. export var fxaaPixelShader: {
  65237. name: string;
  65238. shader: string;
  65239. };
  65240. }
  65241. declare module BABYLON {
  65242. /** @hidden */
  65243. export var fxaaVertexShader: {
  65244. name: string;
  65245. shader: string;
  65246. };
  65247. }
  65248. declare module BABYLON {
  65249. /**
  65250. * Fxaa post process
  65251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  65252. */
  65253. export class FxaaPostProcess extends PostProcess {
  65254. /** @hidden */
  65255. texelWidth: number;
  65256. /** @hidden */
  65257. texelHeight: number;
  65258. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65259. private _getDefines;
  65260. }
  65261. }
  65262. declare module BABYLON {
  65263. /** @hidden */
  65264. export var grainPixelShader: {
  65265. name: string;
  65266. shader: string;
  65267. };
  65268. }
  65269. declare module BABYLON {
  65270. /**
  65271. * The GrainPostProcess adds noise to the image at mid luminance levels
  65272. */
  65273. export class GrainPostProcess extends PostProcess {
  65274. /**
  65275. * The intensity of the grain added (default: 30)
  65276. */
  65277. intensity: number;
  65278. /**
  65279. * If the grain should be randomized on every frame
  65280. */
  65281. animated: boolean;
  65282. /**
  65283. * Creates a new instance of @see GrainPostProcess
  65284. * @param name The name of the effect.
  65285. * @param options The required width/height ratio to downsize to before computing the render pass.
  65286. * @param camera The camera to apply the render pass to.
  65287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65288. * @param engine The engine which the post process will be applied. (default: current engine)
  65289. * @param reusable If the post process can be reused on the same frame. (default: false)
  65290. * @param textureType Type of textures used when performing the post process. (default: 0)
  65291. * @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)
  65292. */
  65293. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65294. }
  65295. }
  65296. declare module BABYLON {
  65297. /** @hidden */
  65298. export var highlightsPixelShader: {
  65299. name: string;
  65300. shader: string;
  65301. };
  65302. }
  65303. declare module BABYLON {
  65304. /**
  65305. * Extracts highlights from the image
  65306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65307. */
  65308. export class HighlightsPostProcess extends PostProcess {
  65309. /**
  65310. * Extracts highlights from the image
  65311. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  65312. * @param name The name of the effect.
  65313. * @param options The required width/height ratio to downsize to before computing the render pass.
  65314. * @param camera The camera to apply the render pass to.
  65315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65316. * @param engine The engine which the post process will be applied. (default: current engine)
  65317. * @param reusable If the post process can be reused on the same frame. (default: false)
  65318. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  65319. */
  65320. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  65321. }
  65322. }
  65323. declare module BABYLON {
  65324. /** @hidden */
  65325. export var mrtFragmentDeclaration: {
  65326. name: string;
  65327. shader: string;
  65328. };
  65329. }
  65330. declare module BABYLON {
  65331. /** @hidden */
  65332. export var geometryPixelShader: {
  65333. name: string;
  65334. shader: string;
  65335. };
  65336. }
  65337. declare module BABYLON {
  65338. /** @hidden */
  65339. export var geometryVertexShader: {
  65340. name: string;
  65341. shader: string;
  65342. };
  65343. }
  65344. declare module BABYLON {
  65345. /** @hidden */
  65346. interface ISavedTransformationMatrix {
  65347. world: Matrix;
  65348. viewProjection: Matrix;
  65349. }
  65350. /**
  65351. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  65352. */
  65353. export class GeometryBufferRenderer {
  65354. /**
  65355. * Constant used to retrieve the position texture index in the G-Buffer textures array
  65356. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  65357. */
  65358. static readonly POSITION_TEXTURE_TYPE: number;
  65359. /**
  65360. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  65361. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  65362. */
  65363. static readonly VELOCITY_TEXTURE_TYPE: number;
  65364. /**
  65365. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  65366. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  65367. */
  65368. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  65369. /**
  65370. * Dictionary used to store the previous transformation matrices of each rendered mesh
  65371. * in order to compute objects velocities when enableVelocity is set to "true"
  65372. * @hidden
  65373. */
  65374. _previousTransformationMatrices: {
  65375. [index: number]: ISavedTransformationMatrix;
  65376. };
  65377. /**
  65378. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  65379. * in order to compute objects velocities when enableVelocity is set to "true"
  65380. * @hidden
  65381. */
  65382. _previousBonesTransformationMatrices: {
  65383. [index: number]: Float32Array;
  65384. };
  65385. /**
  65386. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  65387. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  65388. */
  65389. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  65390. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  65391. renderTransparentMeshes: boolean;
  65392. private _scene;
  65393. private _multiRenderTarget;
  65394. private _ratio;
  65395. private _enablePosition;
  65396. private _enableVelocity;
  65397. private _enableReflectivity;
  65398. private _positionIndex;
  65399. private _velocityIndex;
  65400. private _reflectivityIndex;
  65401. protected _effect: Effect;
  65402. protected _cachedDefines: string;
  65403. /**
  65404. * Set the render list (meshes to be rendered) used in the G buffer.
  65405. */
  65406. set renderList(meshes: Mesh[]);
  65407. /**
  65408. * Gets wether or not G buffer are supported by the running hardware.
  65409. * This requires draw buffer supports
  65410. */
  65411. get isSupported(): boolean;
  65412. /**
  65413. * Returns the index of the given texture type in the G-Buffer textures array
  65414. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  65415. * @returns the index of the given texture type in the G-Buffer textures array
  65416. */
  65417. getTextureIndex(textureType: number): number;
  65418. /**
  65419. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  65420. */
  65421. get enablePosition(): boolean;
  65422. /**
  65423. * Sets whether or not objects positions are enabled for the G buffer.
  65424. */
  65425. set enablePosition(enable: boolean);
  65426. /**
  65427. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  65428. */
  65429. get enableVelocity(): boolean;
  65430. /**
  65431. * Sets wether or not objects velocities are enabled for the G buffer.
  65432. */
  65433. set enableVelocity(enable: boolean);
  65434. /**
  65435. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  65436. */
  65437. get enableReflectivity(): boolean;
  65438. /**
  65439. * Sets wether or not objects roughness are enabled for the G buffer.
  65440. */
  65441. set enableReflectivity(enable: boolean);
  65442. /**
  65443. * Gets the scene associated with the buffer.
  65444. */
  65445. get scene(): Scene;
  65446. /**
  65447. * Gets the ratio used by the buffer during its creation.
  65448. * How big is the buffer related to the main canvas.
  65449. */
  65450. get ratio(): number;
  65451. /** @hidden */
  65452. static _SceneComponentInitialization: (scene: Scene) => void;
  65453. /**
  65454. * Creates a new G Buffer for the scene
  65455. * @param scene The scene the buffer belongs to
  65456. * @param ratio How big is the buffer related to the main canvas.
  65457. */
  65458. constructor(scene: Scene, ratio?: number);
  65459. /**
  65460. * Checks wether everything is ready to render a submesh to the G buffer.
  65461. * @param subMesh the submesh to check readiness for
  65462. * @param useInstances is the mesh drawn using instance or not
  65463. * @returns true if ready otherwise false
  65464. */
  65465. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  65466. /**
  65467. * Gets the current underlying G Buffer.
  65468. * @returns the buffer
  65469. */
  65470. getGBuffer(): MultiRenderTarget;
  65471. /**
  65472. * Gets the number of samples used to render the buffer (anti aliasing).
  65473. */
  65474. get samples(): number;
  65475. /**
  65476. * Sets the number of samples used to render the buffer (anti aliasing).
  65477. */
  65478. set samples(value: number);
  65479. /**
  65480. * Disposes the renderer and frees up associated resources.
  65481. */
  65482. dispose(): void;
  65483. protected _createRenderTargets(): void;
  65484. private _copyBonesTransformationMatrices;
  65485. }
  65486. }
  65487. declare module BABYLON {
  65488. interface Scene {
  65489. /** @hidden (Backing field) */
  65490. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65491. /**
  65492. * Gets or Sets the current geometry buffer associated to the scene.
  65493. */
  65494. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  65495. /**
  65496. * Enables a GeometryBufferRender and associates it with the scene
  65497. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  65498. * @returns the GeometryBufferRenderer
  65499. */
  65500. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  65501. /**
  65502. * Disables the GeometryBufferRender associated with the scene
  65503. */
  65504. disableGeometryBufferRenderer(): void;
  65505. }
  65506. /**
  65507. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  65508. * in several rendering techniques.
  65509. */
  65510. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  65511. /**
  65512. * The component name helpful to identify the component in the list of scene components.
  65513. */
  65514. readonly name: string;
  65515. /**
  65516. * The scene the component belongs to.
  65517. */
  65518. scene: Scene;
  65519. /**
  65520. * Creates a new instance of the component for the given scene
  65521. * @param scene Defines the scene to register the component in
  65522. */
  65523. constructor(scene: Scene);
  65524. /**
  65525. * Registers the component in a given scene
  65526. */
  65527. register(): void;
  65528. /**
  65529. * Rebuilds the elements related to this component in case of
  65530. * context lost for instance.
  65531. */
  65532. rebuild(): void;
  65533. /**
  65534. * Disposes the component and the associated ressources
  65535. */
  65536. dispose(): void;
  65537. private _gatherRenderTargets;
  65538. }
  65539. }
  65540. declare module BABYLON {
  65541. /** @hidden */
  65542. export var motionBlurPixelShader: {
  65543. name: string;
  65544. shader: string;
  65545. };
  65546. }
  65547. declare module BABYLON {
  65548. /**
  65549. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  65550. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  65551. * As an example, all you have to do is to create the post-process:
  65552. * var mb = new BABYLON.MotionBlurPostProcess(
  65553. * 'mb', // The name of the effect.
  65554. * scene, // The scene containing the objects to blur according to their velocity.
  65555. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  65556. * camera // The camera to apply the render pass to.
  65557. * );
  65558. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  65559. */
  65560. export class MotionBlurPostProcess extends PostProcess {
  65561. /**
  65562. * Defines how much the image is blurred by the movement. Default value is equal to 1
  65563. */
  65564. motionStrength: number;
  65565. /**
  65566. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  65567. */
  65568. get motionBlurSamples(): number;
  65569. /**
  65570. * Sets the number of iterations to be used for motion blur quality
  65571. */
  65572. set motionBlurSamples(samples: number);
  65573. private _motionBlurSamples;
  65574. private _geometryBufferRenderer;
  65575. /**
  65576. * Creates a new instance MotionBlurPostProcess
  65577. * @param name The name of the effect.
  65578. * @param scene The scene containing the objects to blur according to their velocity.
  65579. * @param options The required width/height ratio to downsize to before computing the render pass.
  65580. * @param camera The camera to apply the render pass to.
  65581. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65582. * @param engine The engine which the post process will be applied. (default: current engine)
  65583. * @param reusable If the post process can be reused on the same frame. (default: false)
  65584. * @param textureType Type of textures used when performing the post process. (default: 0)
  65585. * @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)
  65586. */
  65587. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65588. /**
  65589. * Excludes the given skinned mesh from computing bones velocities.
  65590. * 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.
  65591. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  65592. */
  65593. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65594. /**
  65595. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  65596. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  65597. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  65598. */
  65599. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  65600. /**
  65601. * Disposes the post process.
  65602. * @param camera The camera to dispose the post process on.
  65603. */
  65604. dispose(camera?: Camera): void;
  65605. }
  65606. }
  65607. declare module BABYLON {
  65608. /** @hidden */
  65609. export var refractionPixelShader: {
  65610. name: string;
  65611. shader: string;
  65612. };
  65613. }
  65614. declare module BABYLON {
  65615. /**
  65616. * Post process which applies a refractin texture
  65617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65618. */
  65619. export class RefractionPostProcess extends PostProcess {
  65620. /** the base color of the refraction (used to taint the rendering) */
  65621. color: Color3;
  65622. /** simulated refraction depth */
  65623. depth: number;
  65624. /** the coefficient of the base color (0 to remove base color tainting) */
  65625. colorLevel: number;
  65626. private _refTexture;
  65627. private _ownRefractionTexture;
  65628. /**
  65629. * Gets or sets the refraction texture
  65630. * Please note that you are responsible for disposing the texture if you set it manually
  65631. */
  65632. get refractionTexture(): Texture;
  65633. set refractionTexture(value: Texture);
  65634. /**
  65635. * Initializes the RefractionPostProcess
  65636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  65637. * @param name The name of the effect.
  65638. * @param refractionTextureUrl Url of the refraction texture to use
  65639. * @param color the base color of the refraction (used to taint the rendering)
  65640. * @param depth simulated refraction depth
  65641. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  65642. * @param camera The camera to apply the render pass to.
  65643. * @param options The required width/height ratio to downsize to before computing the render pass.
  65644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65645. * @param engine The engine which the post process will be applied. (default: current engine)
  65646. * @param reusable If the post process can be reused on the same frame. (default: false)
  65647. */
  65648. constructor(name: string, refractionTextureUrl: string,
  65649. /** the base color of the refraction (used to taint the rendering) */
  65650. color: Color3,
  65651. /** simulated refraction depth */
  65652. depth: number,
  65653. /** the coefficient of the base color (0 to remove base color tainting) */
  65654. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  65655. /**
  65656. * Disposes of the post process
  65657. * @param camera Camera to dispose post process on
  65658. */
  65659. dispose(camera: Camera): void;
  65660. }
  65661. }
  65662. declare module BABYLON {
  65663. /** @hidden */
  65664. export var sharpenPixelShader: {
  65665. name: string;
  65666. shader: string;
  65667. };
  65668. }
  65669. declare module BABYLON {
  65670. /**
  65671. * The SharpenPostProcess applies a sharpen kernel to every pixel
  65672. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  65673. */
  65674. export class SharpenPostProcess extends PostProcess {
  65675. /**
  65676. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  65677. */
  65678. colorAmount: number;
  65679. /**
  65680. * How much sharpness should be applied (default: 0.3)
  65681. */
  65682. edgeAmount: number;
  65683. /**
  65684. * Creates a new instance ConvolutionPostProcess
  65685. * @param name The name of the effect.
  65686. * @param options The required width/height ratio to downsize to before computing the render pass.
  65687. * @param camera The camera to apply the render pass to.
  65688. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65689. * @param engine The engine which the post process will be applied. (default: current engine)
  65690. * @param reusable If the post process can be reused on the same frame. (default: false)
  65691. * @param textureType Type of textures used when performing the post process. (default: 0)
  65692. * @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)
  65693. */
  65694. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65695. }
  65696. }
  65697. declare module BABYLON {
  65698. /**
  65699. * PostProcessRenderPipeline
  65700. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65701. */
  65702. export class PostProcessRenderPipeline {
  65703. private engine;
  65704. private _renderEffects;
  65705. private _renderEffectsForIsolatedPass;
  65706. /**
  65707. * List of inspectable custom properties (used by the Inspector)
  65708. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  65709. */
  65710. inspectableCustomProperties: IInspectable[];
  65711. /**
  65712. * @hidden
  65713. */
  65714. protected _cameras: Camera[];
  65715. /** @hidden */
  65716. _name: string;
  65717. /**
  65718. * Gets pipeline name
  65719. */
  65720. get name(): string;
  65721. /** Gets the list of attached cameras */
  65722. get cameras(): Camera[];
  65723. /**
  65724. * Initializes a PostProcessRenderPipeline
  65725. * @param engine engine to add the pipeline to
  65726. * @param name name of the pipeline
  65727. */
  65728. constructor(engine: Engine, name: string);
  65729. /**
  65730. * Gets the class name
  65731. * @returns "PostProcessRenderPipeline"
  65732. */
  65733. getClassName(): string;
  65734. /**
  65735. * If all the render effects in the pipeline are supported
  65736. */
  65737. get isSupported(): boolean;
  65738. /**
  65739. * Adds an effect to the pipeline
  65740. * @param renderEffect the effect to add
  65741. */
  65742. addEffect(renderEffect: PostProcessRenderEffect): void;
  65743. /** @hidden */
  65744. _rebuild(): void;
  65745. /** @hidden */
  65746. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65747. /** @hidden */
  65748. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65749. /** @hidden */
  65750. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65751. /** @hidden */
  65752. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65753. /** @hidden */
  65754. _attachCameras(cameras: Camera, unique: boolean): void;
  65755. /** @hidden */
  65756. _attachCameras(cameras: Camera[], unique: boolean): void;
  65757. /** @hidden */
  65758. _detachCameras(cameras: Camera): void;
  65759. /** @hidden */
  65760. _detachCameras(cameras: Nullable<Camera[]>): void;
  65761. /** @hidden */
  65762. _update(): void;
  65763. /** @hidden */
  65764. _reset(): void;
  65765. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65766. /**
  65767. * Disposes of the pipeline
  65768. */
  65769. dispose(): void;
  65770. }
  65771. }
  65772. declare module BABYLON {
  65773. /**
  65774. * PostProcessRenderPipelineManager class
  65775. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65776. */
  65777. export class PostProcessRenderPipelineManager {
  65778. private _renderPipelines;
  65779. /**
  65780. * Initializes a PostProcessRenderPipelineManager
  65781. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65782. */
  65783. constructor();
  65784. /**
  65785. * Gets the list of supported render pipelines
  65786. */
  65787. get supportedPipelines(): PostProcessRenderPipeline[];
  65788. /**
  65789. * Adds a pipeline to the manager
  65790. * @param renderPipeline The pipeline to add
  65791. */
  65792. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65793. /**
  65794. * Attaches a camera to the pipeline
  65795. * @param renderPipelineName The name of the pipeline to attach to
  65796. * @param cameras the camera to attach
  65797. * @param unique if the camera can be attached multiple times to the pipeline
  65798. */
  65799. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65800. /**
  65801. * Detaches a camera from the pipeline
  65802. * @param renderPipelineName The name of the pipeline to detach from
  65803. * @param cameras the camera to detach
  65804. */
  65805. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65806. /**
  65807. * Enables an effect by name on a pipeline
  65808. * @param renderPipelineName the name of the pipeline to enable the effect in
  65809. * @param renderEffectName the name of the effect to enable
  65810. * @param cameras the cameras that the effect should be enabled on
  65811. */
  65812. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65813. /**
  65814. * Disables an effect by name on a pipeline
  65815. * @param renderPipelineName the name of the pipeline to disable the effect in
  65816. * @param renderEffectName the name of the effect to disable
  65817. * @param cameras the cameras that the effect should be disabled on
  65818. */
  65819. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65820. /**
  65821. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65822. */
  65823. update(): void;
  65824. /** @hidden */
  65825. _rebuild(): void;
  65826. /**
  65827. * Disposes of the manager and pipelines
  65828. */
  65829. dispose(): void;
  65830. }
  65831. }
  65832. declare module BABYLON {
  65833. interface Scene {
  65834. /** @hidden (Backing field) */
  65835. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65836. /**
  65837. * Gets the postprocess render pipeline manager
  65838. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65839. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65840. */
  65841. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65842. }
  65843. /**
  65844. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65845. */
  65846. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65847. /**
  65848. * The component name helpfull to identify the component in the list of scene components.
  65849. */
  65850. readonly name: string;
  65851. /**
  65852. * The scene the component belongs to.
  65853. */
  65854. scene: Scene;
  65855. /**
  65856. * Creates a new instance of the component for the given scene
  65857. * @param scene Defines the scene to register the component in
  65858. */
  65859. constructor(scene: Scene);
  65860. /**
  65861. * Registers the component in a given scene
  65862. */
  65863. register(): void;
  65864. /**
  65865. * Rebuilds the elements related to this component in case of
  65866. * context lost for instance.
  65867. */
  65868. rebuild(): void;
  65869. /**
  65870. * Disposes the component and the associated ressources
  65871. */
  65872. dispose(): void;
  65873. private _gatherRenderTargets;
  65874. }
  65875. }
  65876. declare module BABYLON {
  65877. /**
  65878. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65879. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65880. */
  65881. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65882. private _scene;
  65883. private _camerasToBeAttached;
  65884. /**
  65885. * ID of the sharpen post process,
  65886. */
  65887. private readonly SharpenPostProcessId;
  65888. /**
  65889. * @ignore
  65890. * ID of the image processing post process;
  65891. */
  65892. readonly ImageProcessingPostProcessId: string;
  65893. /**
  65894. * @ignore
  65895. * ID of the Fast Approximate Anti-Aliasing post process;
  65896. */
  65897. readonly FxaaPostProcessId: string;
  65898. /**
  65899. * ID of the chromatic aberration post process,
  65900. */
  65901. private readonly ChromaticAberrationPostProcessId;
  65902. /**
  65903. * ID of the grain post process
  65904. */
  65905. private readonly GrainPostProcessId;
  65906. /**
  65907. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65908. */
  65909. sharpen: SharpenPostProcess;
  65910. private _sharpenEffect;
  65911. private bloom;
  65912. /**
  65913. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65914. */
  65915. depthOfField: DepthOfFieldEffect;
  65916. /**
  65917. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65918. */
  65919. fxaa: FxaaPostProcess;
  65920. /**
  65921. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65922. */
  65923. imageProcessing: ImageProcessingPostProcess;
  65924. /**
  65925. * Chromatic aberration post process which will shift rgb colors in the image
  65926. */
  65927. chromaticAberration: ChromaticAberrationPostProcess;
  65928. private _chromaticAberrationEffect;
  65929. /**
  65930. * Grain post process which add noise to the image
  65931. */
  65932. grain: GrainPostProcess;
  65933. private _grainEffect;
  65934. /**
  65935. * Glow post process which adds a glow to emissive areas of the image
  65936. */
  65937. private _glowLayer;
  65938. /**
  65939. * Animations which can be used to tweak settings over a period of time
  65940. */
  65941. animations: Animation[];
  65942. private _imageProcessingConfigurationObserver;
  65943. private _sharpenEnabled;
  65944. private _bloomEnabled;
  65945. private _depthOfFieldEnabled;
  65946. private _depthOfFieldBlurLevel;
  65947. private _fxaaEnabled;
  65948. private _imageProcessingEnabled;
  65949. private _defaultPipelineTextureType;
  65950. private _bloomScale;
  65951. private _chromaticAberrationEnabled;
  65952. private _grainEnabled;
  65953. private _buildAllowed;
  65954. /**
  65955. * Gets active scene
  65956. */
  65957. get scene(): Scene;
  65958. /**
  65959. * Enable or disable the sharpen process from the pipeline
  65960. */
  65961. set sharpenEnabled(enabled: boolean);
  65962. get sharpenEnabled(): boolean;
  65963. private _resizeObserver;
  65964. private _hardwareScaleLevel;
  65965. private _bloomKernel;
  65966. /**
  65967. * Specifies the size of the bloom blur kernel, relative to the final output size
  65968. */
  65969. get bloomKernel(): number;
  65970. set bloomKernel(value: number);
  65971. /**
  65972. * Specifies the weight of the bloom in the final rendering
  65973. */
  65974. private _bloomWeight;
  65975. /**
  65976. * Specifies the luma threshold for the area that will be blurred by the bloom
  65977. */
  65978. private _bloomThreshold;
  65979. private _hdr;
  65980. /**
  65981. * The strength of the bloom.
  65982. */
  65983. set bloomWeight(value: number);
  65984. get bloomWeight(): number;
  65985. /**
  65986. * The strength of the bloom.
  65987. */
  65988. set bloomThreshold(value: number);
  65989. get bloomThreshold(): number;
  65990. /**
  65991. * The scale of the bloom, lower value will provide better performance.
  65992. */
  65993. set bloomScale(value: number);
  65994. get bloomScale(): number;
  65995. /**
  65996. * Enable or disable the bloom from the pipeline
  65997. */
  65998. set bloomEnabled(enabled: boolean);
  65999. get bloomEnabled(): boolean;
  66000. private _rebuildBloom;
  66001. /**
  66002. * If the depth of field is enabled.
  66003. */
  66004. get depthOfFieldEnabled(): boolean;
  66005. set depthOfFieldEnabled(enabled: boolean);
  66006. /**
  66007. * Blur level of the depth of field effect. (Higher blur will effect performance)
  66008. */
  66009. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  66010. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  66011. /**
  66012. * If the anti aliasing is enabled.
  66013. */
  66014. set fxaaEnabled(enabled: boolean);
  66015. get fxaaEnabled(): boolean;
  66016. private _samples;
  66017. /**
  66018. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66019. */
  66020. set samples(sampleCount: number);
  66021. get samples(): number;
  66022. /**
  66023. * If image processing is enabled.
  66024. */
  66025. set imageProcessingEnabled(enabled: boolean);
  66026. get imageProcessingEnabled(): boolean;
  66027. /**
  66028. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  66029. */
  66030. set glowLayerEnabled(enabled: boolean);
  66031. get glowLayerEnabled(): boolean;
  66032. /**
  66033. * Gets the glow layer (or null if not defined)
  66034. */
  66035. get glowLayer(): Nullable<GlowLayer>;
  66036. /**
  66037. * Enable or disable the chromaticAberration process from the pipeline
  66038. */
  66039. set chromaticAberrationEnabled(enabled: boolean);
  66040. get chromaticAberrationEnabled(): boolean;
  66041. /**
  66042. * Enable or disable the grain process from the pipeline
  66043. */
  66044. set grainEnabled(enabled: boolean);
  66045. get grainEnabled(): boolean;
  66046. /**
  66047. * @constructor
  66048. * @param name - The rendering pipeline name (default: "")
  66049. * @param hdr - If high dynamic range textures should be used (default: true)
  66050. * @param scene - The scene linked to this pipeline (default: the last created scene)
  66051. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  66052. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  66053. */
  66054. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  66055. /**
  66056. * Get the class name
  66057. * @returns "DefaultRenderingPipeline"
  66058. */
  66059. getClassName(): string;
  66060. /**
  66061. * Force the compilation of the entire pipeline.
  66062. */
  66063. prepare(): void;
  66064. private _hasCleared;
  66065. private _prevPostProcess;
  66066. private _prevPrevPostProcess;
  66067. private _setAutoClearAndTextureSharing;
  66068. private _depthOfFieldSceneObserver;
  66069. private _buildPipeline;
  66070. private _disposePostProcesses;
  66071. /**
  66072. * Adds a camera to the pipeline
  66073. * @param camera the camera to be added
  66074. */
  66075. addCamera(camera: Camera): void;
  66076. /**
  66077. * Removes a camera from the pipeline
  66078. * @param camera the camera to remove
  66079. */
  66080. removeCamera(camera: Camera): void;
  66081. /**
  66082. * Dispose of the pipeline and stop all post processes
  66083. */
  66084. dispose(): void;
  66085. /**
  66086. * Serialize the rendering pipeline (Used when exporting)
  66087. * @returns the serialized object
  66088. */
  66089. serialize(): any;
  66090. /**
  66091. * Parse the serialized pipeline
  66092. * @param source Source pipeline.
  66093. * @param scene The scene to load the pipeline to.
  66094. * @param rootUrl The URL of the serialized pipeline.
  66095. * @returns An instantiated pipeline from the serialized object.
  66096. */
  66097. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  66098. }
  66099. }
  66100. declare module BABYLON {
  66101. /** @hidden */
  66102. export var lensHighlightsPixelShader: {
  66103. name: string;
  66104. shader: string;
  66105. };
  66106. }
  66107. declare module BABYLON {
  66108. /** @hidden */
  66109. export var depthOfFieldPixelShader: {
  66110. name: string;
  66111. shader: string;
  66112. };
  66113. }
  66114. declare module BABYLON {
  66115. /**
  66116. * BABYLON.JS Chromatic Aberration GLSL Shader
  66117. * Author: Olivier Guyot
  66118. * Separates very slightly R, G and B colors on the edges of the screen
  66119. * Inspired by Francois Tarlier & Martins Upitis
  66120. */
  66121. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  66122. /**
  66123. * @ignore
  66124. * The chromatic aberration PostProcess id in the pipeline
  66125. */
  66126. LensChromaticAberrationEffect: string;
  66127. /**
  66128. * @ignore
  66129. * The highlights enhancing PostProcess id in the pipeline
  66130. */
  66131. HighlightsEnhancingEffect: string;
  66132. /**
  66133. * @ignore
  66134. * The depth-of-field PostProcess id in the pipeline
  66135. */
  66136. LensDepthOfFieldEffect: string;
  66137. private _scene;
  66138. private _depthTexture;
  66139. private _grainTexture;
  66140. private _chromaticAberrationPostProcess;
  66141. private _highlightsPostProcess;
  66142. private _depthOfFieldPostProcess;
  66143. private _edgeBlur;
  66144. private _grainAmount;
  66145. private _chromaticAberration;
  66146. private _distortion;
  66147. private _highlightsGain;
  66148. private _highlightsThreshold;
  66149. private _dofDistance;
  66150. private _dofAperture;
  66151. private _dofDarken;
  66152. private _dofPentagon;
  66153. private _blurNoise;
  66154. /**
  66155. * @constructor
  66156. *
  66157. * Effect parameters are as follow:
  66158. * {
  66159. * chromatic_aberration: number; // from 0 to x (1 for realism)
  66160. * edge_blur: number; // from 0 to x (1 for realism)
  66161. * distortion: number; // from 0 to x (1 for realism)
  66162. * grain_amount: number; // from 0 to 1
  66163. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  66164. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  66165. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  66166. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  66167. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  66168. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  66169. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  66170. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  66171. * }
  66172. * Note: if an effect parameter is unset, effect is disabled
  66173. *
  66174. * @param name The rendering pipeline name
  66175. * @param parameters - An object containing all parameters (see above)
  66176. * @param scene The scene linked to this pipeline
  66177. * @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)
  66178. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66179. */
  66180. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  66181. /**
  66182. * Get the class name
  66183. * @returns "LensRenderingPipeline"
  66184. */
  66185. getClassName(): string;
  66186. /**
  66187. * Gets associated scene
  66188. */
  66189. get scene(): Scene;
  66190. /**
  66191. * Gets or sets the edge blur
  66192. */
  66193. get edgeBlur(): number;
  66194. set edgeBlur(value: number);
  66195. /**
  66196. * Gets or sets the grain amount
  66197. */
  66198. get grainAmount(): number;
  66199. set grainAmount(value: number);
  66200. /**
  66201. * Gets or sets the chromatic aberration amount
  66202. */
  66203. get chromaticAberration(): number;
  66204. set chromaticAberration(value: number);
  66205. /**
  66206. * Gets or sets the depth of field aperture
  66207. */
  66208. get dofAperture(): number;
  66209. set dofAperture(value: number);
  66210. /**
  66211. * Gets or sets the edge distortion
  66212. */
  66213. get edgeDistortion(): number;
  66214. set edgeDistortion(value: number);
  66215. /**
  66216. * Gets or sets the depth of field distortion
  66217. */
  66218. get dofDistortion(): number;
  66219. set dofDistortion(value: number);
  66220. /**
  66221. * Gets or sets the darken out of focus amount
  66222. */
  66223. get darkenOutOfFocus(): number;
  66224. set darkenOutOfFocus(value: number);
  66225. /**
  66226. * Gets or sets a boolean indicating if blur noise is enabled
  66227. */
  66228. get blurNoise(): boolean;
  66229. set blurNoise(value: boolean);
  66230. /**
  66231. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  66232. */
  66233. get pentagonBokeh(): boolean;
  66234. set pentagonBokeh(value: boolean);
  66235. /**
  66236. * Gets or sets the highlight grain amount
  66237. */
  66238. get highlightsGain(): number;
  66239. set highlightsGain(value: number);
  66240. /**
  66241. * Gets or sets the highlight threshold
  66242. */
  66243. get highlightsThreshold(): number;
  66244. set highlightsThreshold(value: number);
  66245. /**
  66246. * Sets the amount of blur at the edges
  66247. * @param amount blur amount
  66248. */
  66249. setEdgeBlur(amount: number): void;
  66250. /**
  66251. * Sets edge blur to 0
  66252. */
  66253. disableEdgeBlur(): void;
  66254. /**
  66255. * Sets the amout of grain
  66256. * @param amount Amount of grain
  66257. */
  66258. setGrainAmount(amount: number): void;
  66259. /**
  66260. * Set grain amount to 0
  66261. */
  66262. disableGrain(): void;
  66263. /**
  66264. * Sets the chromatic aberration amount
  66265. * @param amount amount of chromatic aberration
  66266. */
  66267. setChromaticAberration(amount: number): void;
  66268. /**
  66269. * Sets chromatic aberration amount to 0
  66270. */
  66271. disableChromaticAberration(): void;
  66272. /**
  66273. * Sets the EdgeDistortion amount
  66274. * @param amount amount of EdgeDistortion
  66275. */
  66276. setEdgeDistortion(amount: number): void;
  66277. /**
  66278. * Sets edge distortion to 0
  66279. */
  66280. disableEdgeDistortion(): void;
  66281. /**
  66282. * Sets the FocusDistance amount
  66283. * @param amount amount of FocusDistance
  66284. */
  66285. setFocusDistance(amount: number): void;
  66286. /**
  66287. * Disables depth of field
  66288. */
  66289. disableDepthOfField(): void;
  66290. /**
  66291. * Sets the Aperture amount
  66292. * @param amount amount of Aperture
  66293. */
  66294. setAperture(amount: number): void;
  66295. /**
  66296. * Sets the DarkenOutOfFocus amount
  66297. * @param amount amount of DarkenOutOfFocus
  66298. */
  66299. setDarkenOutOfFocus(amount: number): void;
  66300. private _pentagonBokehIsEnabled;
  66301. /**
  66302. * Creates a pentagon bokeh effect
  66303. */
  66304. enablePentagonBokeh(): void;
  66305. /**
  66306. * Disables the pentagon bokeh effect
  66307. */
  66308. disablePentagonBokeh(): void;
  66309. /**
  66310. * Enables noise blur
  66311. */
  66312. enableNoiseBlur(): void;
  66313. /**
  66314. * Disables noise blur
  66315. */
  66316. disableNoiseBlur(): void;
  66317. /**
  66318. * Sets the HighlightsGain amount
  66319. * @param amount amount of HighlightsGain
  66320. */
  66321. setHighlightsGain(amount: number): void;
  66322. /**
  66323. * Sets the HighlightsThreshold amount
  66324. * @param amount amount of HighlightsThreshold
  66325. */
  66326. setHighlightsThreshold(amount: number): void;
  66327. /**
  66328. * Disables highlights
  66329. */
  66330. disableHighlights(): void;
  66331. /**
  66332. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  66333. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  66334. */
  66335. dispose(disableDepthRender?: boolean): void;
  66336. private _createChromaticAberrationPostProcess;
  66337. private _createHighlightsPostProcess;
  66338. private _createDepthOfFieldPostProcess;
  66339. private _createGrainTexture;
  66340. }
  66341. }
  66342. declare module BABYLON {
  66343. /** @hidden */
  66344. export var ssao2PixelShader: {
  66345. name: string;
  66346. shader: string;
  66347. };
  66348. }
  66349. declare module BABYLON {
  66350. /** @hidden */
  66351. export var ssaoCombinePixelShader: {
  66352. name: string;
  66353. shader: string;
  66354. };
  66355. }
  66356. declare module BABYLON {
  66357. /**
  66358. * Render pipeline to produce ssao effect
  66359. */
  66360. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  66361. /**
  66362. * @ignore
  66363. * The PassPostProcess id in the pipeline that contains the original scene color
  66364. */
  66365. SSAOOriginalSceneColorEffect: string;
  66366. /**
  66367. * @ignore
  66368. * The SSAO PostProcess id in the pipeline
  66369. */
  66370. SSAORenderEffect: string;
  66371. /**
  66372. * @ignore
  66373. * The horizontal blur PostProcess id in the pipeline
  66374. */
  66375. SSAOBlurHRenderEffect: string;
  66376. /**
  66377. * @ignore
  66378. * The vertical blur PostProcess id in the pipeline
  66379. */
  66380. SSAOBlurVRenderEffect: string;
  66381. /**
  66382. * @ignore
  66383. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66384. */
  66385. SSAOCombineRenderEffect: string;
  66386. /**
  66387. * The output strength of the SSAO post-process. Default value is 1.0.
  66388. */
  66389. totalStrength: number;
  66390. /**
  66391. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  66392. */
  66393. maxZ: number;
  66394. /**
  66395. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  66396. */
  66397. minZAspect: number;
  66398. private _samples;
  66399. /**
  66400. * Number of samples used for the SSAO calculations. Default value is 8
  66401. */
  66402. set samples(n: number);
  66403. get samples(): number;
  66404. private _textureSamples;
  66405. /**
  66406. * Number of samples to use for antialiasing
  66407. */
  66408. set textureSamples(n: number);
  66409. get textureSamples(): number;
  66410. /**
  66411. * Ratio object used for SSAO ratio and blur ratio
  66412. */
  66413. private _ratio;
  66414. /**
  66415. * Dynamically generated sphere sampler.
  66416. */
  66417. private _sampleSphere;
  66418. /**
  66419. * Blur filter offsets
  66420. */
  66421. private _samplerOffsets;
  66422. private _expensiveBlur;
  66423. /**
  66424. * If bilateral blur should be used
  66425. */
  66426. set expensiveBlur(b: boolean);
  66427. get expensiveBlur(): boolean;
  66428. /**
  66429. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  66430. */
  66431. radius: number;
  66432. /**
  66433. * The base color of the SSAO post-process
  66434. * The final result is "base + ssao" between [0, 1]
  66435. */
  66436. base: number;
  66437. /**
  66438. * Support test.
  66439. */
  66440. static get IsSupported(): boolean;
  66441. private _scene;
  66442. private _depthTexture;
  66443. private _normalTexture;
  66444. private _randomTexture;
  66445. private _originalColorPostProcess;
  66446. private _ssaoPostProcess;
  66447. private _blurHPostProcess;
  66448. private _blurVPostProcess;
  66449. private _ssaoCombinePostProcess;
  66450. /**
  66451. * Gets active scene
  66452. */
  66453. get scene(): Scene;
  66454. /**
  66455. * @constructor
  66456. * @param name The rendering pipeline name
  66457. * @param scene The scene linked to this pipeline
  66458. * @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 }
  66459. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66460. */
  66461. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66462. /**
  66463. * Get the class name
  66464. * @returns "SSAO2RenderingPipeline"
  66465. */
  66466. getClassName(): string;
  66467. /**
  66468. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66469. */
  66470. dispose(disableGeometryBufferRenderer?: boolean): void;
  66471. private _createBlurPostProcess;
  66472. /** @hidden */
  66473. _rebuild(): void;
  66474. private _bits;
  66475. private _radicalInverse_VdC;
  66476. private _hammersley;
  66477. private _hemisphereSample_uniform;
  66478. private _generateHemisphere;
  66479. private _createSSAOPostProcess;
  66480. private _createSSAOCombinePostProcess;
  66481. private _createRandomTexture;
  66482. /**
  66483. * Serialize the rendering pipeline (Used when exporting)
  66484. * @returns the serialized object
  66485. */
  66486. serialize(): any;
  66487. /**
  66488. * Parse the serialized pipeline
  66489. * @param source Source pipeline.
  66490. * @param scene The scene to load the pipeline to.
  66491. * @param rootUrl The URL of the serialized pipeline.
  66492. * @returns An instantiated pipeline from the serialized object.
  66493. */
  66494. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  66495. }
  66496. }
  66497. declare module BABYLON {
  66498. /** @hidden */
  66499. export var ssaoPixelShader: {
  66500. name: string;
  66501. shader: string;
  66502. };
  66503. }
  66504. declare module BABYLON {
  66505. /**
  66506. * Render pipeline to produce ssao effect
  66507. */
  66508. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  66509. /**
  66510. * @ignore
  66511. * The PassPostProcess id in the pipeline that contains the original scene color
  66512. */
  66513. SSAOOriginalSceneColorEffect: string;
  66514. /**
  66515. * @ignore
  66516. * The SSAO PostProcess id in the pipeline
  66517. */
  66518. SSAORenderEffect: string;
  66519. /**
  66520. * @ignore
  66521. * The horizontal blur PostProcess id in the pipeline
  66522. */
  66523. SSAOBlurHRenderEffect: string;
  66524. /**
  66525. * @ignore
  66526. * The vertical blur PostProcess id in the pipeline
  66527. */
  66528. SSAOBlurVRenderEffect: string;
  66529. /**
  66530. * @ignore
  66531. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  66532. */
  66533. SSAOCombineRenderEffect: string;
  66534. /**
  66535. * The output strength of the SSAO post-process. Default value is 1.0.
  66536. */
  66537. totalStrength: number;
  66538. /**
  66539. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  66540. */
  66541. radius: number;
  66542. /**
  66543. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  66544. * Must not be equal to fallOff and superior to fallOff.
  66545. * Default value is 0.0075
  66546. */
  66547. area: number;
  66548. /**
  66549. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  66550. * Must not be equal to area and inferior to area.
  66551. * Default value is 0.000001
  66552. */
  66553. fallOff: number;
  66554. /**
  66555. * The base color of the SSAO post-process
  66556. * The final result is "base + ssao" between [0, 1]
  66557. */
  66558. base: number;
  66559. private _scene;
  66560. private _depthTexture;
  66561. private _randomTexture;
  66562. private _originalColorPostProcess;
  66563. private _ssaoPostProcess;
  66564. private _blurHPostProcess;
  66565. private _blurVPostProcess;
  66566. private _ssaoCombinePostProcess;
  66567. private _firstUpdate;
  66568. /**
  66569. * Gets active scene
  66570. */
  66571. get scene(): Scene;
  66572. /**
  66573. * @constructor
  66574. * @param name - The rendering pipeline name
  66575. * @param scene - The scene linked to this pipeline
  66576. * @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 }
  66577. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  66578. */
  66579. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  66580. /**
  66581. * Get the class name
  66582. * @returns "SSAORenderingPipeline"
  66583. */
  66584. getClassName(): string;
  66585. /**
  66586. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  66587. */
  66588. dispose(disableDepthRender?: boolean): void;
  66589. private _createBlurPostProcess;
  66590. /** @hidden */
  66591. _rebuild(): void;
  66592. private _createSSAOPostProcess;
  66593. private _createSSAOCombinePostProcess;
  66594. private _createRandomTexture;
  66595. }
  66596. }
  66597. declare module BABYLON {
  66598. /** @hidden */
  66599. export var screenSpaceReflectionPixelShader: {
  66600. name: string;
  66601. shader: string;
  66602. };
  66603. }
  66604. declare module BABYLON {
  66605. /**
  66606. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  66607. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  66608. */
  66609. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  66610. /**
  66611. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  66612. */
  66613. threshold: number;
  66614. /**
  66615. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  66616. */
  66617. strength: number;
  66618. /**
  66619. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  66620. */
  66621. reflectionSpecularFalloffExponent: number;
  66622. /**
  66623. * 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]
  66624. */
  66625. step: number;
  66626. /**
  66627. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  66628. */
  66629. roughnessFactor: number;
  66630. private _geometryBufferRenderer;
  66631. private _enableSmoothReflections;
  66632. private _reflectionSamples;
  66633. private _smoothSteps;
  66634. /**
  66635. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  66636. * @param name The name of the effect.
  66637. * @param scene The scene containing the objects to calculate reflections.
  66638. * @param options The required width/height ratio to downsize to before computing the render pass.
  66639. * @param camera The camera to apply the render pass to.
  66640. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66641. * @param engine The engine which the post process will be applied. (default: current engine)
  66642. * @param reusable If the post process can be reused on the same frame. (default: false)
  66643. * @param textureType Type of textures used when performing the post process. (default: 0)
  66644. * @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)
  66645. */
  66646. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66647. /**
  66648. * Gets wether or not smoothing reflections is enabled.
  66649. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66650. */
  66651. get enableSmoothReflections(): boolean;
  66652. /**
  66653. * Sets wether or not smoothing reflections is enabled.
  66654. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  66655. */
  66656. set enableSmoothReflections(enabled: boolean);
  66657. /**
  66658. * Gets the number of samples taken while computing reflections. More samples count is high,
  66659. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66660. */
  66661. get reflectionSamples(): number;
  66662. /**
  66663. * Sets the number of samples taken while computing reflections. More samples count is high,
  66664. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  66665. */
  66666. set reflectionSamples(samples: number);
  66667. /**
  66668. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  66669. * more the post-process will require GPU power and can generate a drop in FPS.
  66670. * Default value (5.0) work pretty well in all cases but can be adjusted.
  66671. */
  66672. get smoothSteps(): number;
  66673. set smoothSteps(steps: number);
  66674. private _updateEffectDefines;
  66675. }
  66676. }
  66677. declare module BABYLON {
  66678. /** @hidden */
  66679. export var standardPixelShader: {
  66680. name: string;
  66681. shader: string;
  66682. };
  66683. }
  66684. declare module BABYLON {
  66685. /**
  66686. * Standard rendering pipeline
  66687. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66688. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  66689. */
  66690. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  66691. /**
  66692. * Public members
  66693. */
  66694. /**
  66695. * Post-process which contains the original scene color before the pipeline applies all the effects
  66696. */
  66697. originalPostProcess: Nullable<PostProcess>;
  66698. /**
  66699. * Post-process used to down scale an image x4
  66700. */
  66701. downSampleX4PostProcess: Nullable<PostProcess>;
  66702. /**
  66703. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  66704. */
  66705. brightPassPostProcess: Nullable<PostProcess>;
  66706. /**
  66707. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  66708. */
  66709. blurHPostProcesses: PostProcess[];
  66710. /**
  66711. * Post-process array storing all the vertical blur post-processes used by the pipeline
  66712. */
  66713. blurVPostProcesses: PostProcess[];
  66714. /**
  66715. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  66716. */
  66717. textureAdderPostProcess: Nullable<PostProcess>;
  66718. /**
  66719. * Post-process used to create volumetric lighting effect
  66720. */
  66721. volumetricLightPostProcess: Nullable<PostProcess>;
  66722. /**
  66723. * Post-process used to smooth the previous volumetric light post-process on the X axis
  66724. */
  66725. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  66726. /**
  66727. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  66728. */
  66729. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  66730. /**
  66731. * Post-process used to merge the volumetric light effect and the real scene color
  66732. */
  66733. volumetricLightMergePostProces: Nullable<PostProcess>;
  66734. /**
  66735. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66736. */
  66737. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66738. /**
  66739. * Base post-process used to calculate the average luminance of the final image for HDR
  66740. */
  66741. luminancePostProcess: Nullable<PostProcess>;
  66742. /**
  66743. * Post-processes used to create down sample post-processes in order to get
  66744. * the average luminance of the final image for HDR
  66745. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66746. */
  66747. luminanceDownSamplePostProcesses: PostProcess[];
  66748. /**
  66749. * Post-process used to create a HDR effect (light adaptation)
  66750. */
  66751. hdrPostProcess: Nullable<PostProcess>;
  66752. /**
  66753. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66754. */
  66755. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66756. /**
  66757. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66758. */
  66759. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66760. /**
  66761. * Post-process used to merge the final HDR post-process and the real scene color
  66762. */
  66763. hdrFinalPostProcess: Nullable<PostProcess>;
  66764. /**
  66765. * Post-process used to create a lens flare effect
  66766. */
  66767. lensFlarePostProcess: Nullable<PostProcess>;
  66768. /**
  66769. * Post-process that merges the result of the lens flare post-process and the real scene color
  66770. */
  66771. lensFlareComposePostProcess: Nullable<PostProcess>;
  66772. /**
  66773. * Post-process used to create a motion blur effect
  66774. */
  66775. motionBlurPostProcess: Nullable<PostProcess>;
  66776. /**
  66777. * Post-process used to create a depth of field effect
  66778. */
  66779. depthOfFieldPostProcess: Nullable<PostProcess>;
  66780. /**
  66781. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66782. */
  66783. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66784. /**
  66785. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66786. */
  66787. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66788. /**
  66789. * Represents the brightness threshold in order to configure the illuminated surfaces
  66790. */
  66791. brightThreshold: number;
  66792. /**
  66793. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66794. */
  66795. blurWidth: number;
  66796. /**
  66797. * Sets if the blur for highlighted surfaces must be only horizontal
  66798. */
  66799. horizontalBlur: boolean;
  66800. /**
  66801. * Gets the overall exposure used by the pipeline
  66802. */
  66803. get exposure(): number;
  66804. /**
  66805. * Sets the overall exposure used by the pipeline
  66806. */
  66807. set exposure(value: number);
  66808. /**
  66809. * Texture used typically to simulate "dirty" on camera lens
  66810. */
  66811. lensTexture: Nullable<Texture>;
  66812. /**
  66813. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66814. */
  66815. volumetricLightCoefficient: number;
  66816. /**
  66817. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66818. */
  66819. volumetricLightPower: number;
  66820. /**
  66821. * Used the set the blur intensity to smooth the volumetric lights
  66822. */
  66823. volumetricLightBlurScale: number;
  66824. /**
  66825. * Light (spot or directional) used to generate the volumetric lights rays
  66826. * The source light must have a shadow generate so the pipeline can get its
  66827. * depth map
  66828. */
  66829. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66830. /**
  66831. * For eye adaptation, represents the minimum luminance the eye can see
  66832. */
  66833. hdrMinimumLuminance: number;
  66834. /**
  66835. * For eye adaptation, represents the decrease luminance speed
  66836. */
  66837. hdrDecreaseRate: number;
  66838. /**
  66839. * For eye adaptation, represents the increase luminance speed
  66840. */
  66841. hdrIncreaseRate: number;
  66842. /**
  66843. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66844. */
  66845. get hdrAutoExposure(): boolean;
  66846. /**
  66847. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66848. */
  66849. set hdrAutoExposure(value: boolean);
  66850. /**
  66851. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66852. */
  66853. lensColorTexture: Nullable<Texture>;
  66854. /**
  66855. * The overall strengh for the lens flare effect
  66856. */
  66857. lensFlareStrength: number;
  66858. /**
  66859. * Dispersion coefficient for lens flare ghosts
  66860. */
  66861. lensFlareGhostDispersal: number;
  66862. /**
  66863. * Main lens flare halo width
  66864. */
  66865. lensFlareHaloWidth: number;
  66866. /**
  66867. * Based on the lens distortion effect, defines how much the lens flare result
  66868. * is distorted
  66869. */
  66870. lensFlareDistortionStrength: number;
  66871. /**
  66872. * Configures the blur intensity used for for lens flare (halo)
  66873. */
  66874. lensFlareBlurWidth: number;
  66875. /**
  66876. * Lens star texture must be used to simulate rays on the flares and is available
  66877. * in the documentation
  66878. */
  66879. lensStarTexture: Nullable<Texture>;
  66880. /**
  66881. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66882. * flare effect by taking account of the dirt texture
  66883. */
  66884. lensFlareDirtTexture: Nullable<Texture>;
  66885. /**
  66886. * Represents the focal length for the depth of field effect
  66887. */
  66888. depthOfFieldDistance: number;
  66889. /**
  66890. * Represents the blur intensity for the blurred part of the depth of field effect
  66891. */
  66892. depthOfFieldBlurWidth: number;
  66893. /**
  66894. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66895. */
  66896. get motionStrength(): number;
  66897. /**
  66898. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66899. */
  66900. set motionStrength(strength: number);
  66901. /**
  66902. * Gets wether or not the motion blur post-process is object based or screen based.
  66903. */
  66904. get objectBasedMotionBlur(): boolean;
  66905. /**
  66906. * Sets wether or not the motion blur post-process should be object based or screen based
  66907. */
  66908. set objectBasedMotionBlur(value: boolean);
  66909. /**
  66910. * List of animations for the pipeline (IAnimatable implementation)
  66911. */
  66912. animations: Animation[];
  66913. /**
  66914. * Private members
  66915. */
  66916. private _scene;
  66917. private _currentDepthOfFieldSource;
  66918. private _basePostProcess;
  66919. private _fixedExposure;
  66920. private _currentExposure;
  66921. private _hdrAutoExposure;
  66922. private _hdrCurrentLuminance;
  66923. private _motionStrength;
  66924. private _isObjectBasedMotionBlur;
  66925. private _floatTextureType;
  66926. private _camerasToBeAttached;
  66927. private _ratio;
  66928. private _bloomEnabled;
  66929. private _depthOfFieldEnabled;
  66930. private _vlsEnabled;
  66931. private _lensFlareEnabled;
  66932. private _hdrEnabled;
  66933. private _motionBlurEnabled;
  66934. private _fxaaEnabled;
  66935. private _screenSpaceReflectionsEnabled;
  66936. private _motionBlurSamples;
  66937. private _volumetricLightStepsCount;
  66938. private _samples;
  66939. /**
  66940. * @ignore
  66941. * Specifies if the bloom pipeline is enabled
  66942. */
  66943. get BloomEnabled(): boolean;
  66944. set BloomEnabled(enabled: boolean);
  66945. /**
  66946. * @ignore
  66947. * Specifies if the depth of field pipeline is enabed
  66948. */
  66949. get DepthOfFieldEnabled(): boolean;
  66950. set DepthOfFieldEnabled(enabled: boolean);
  66951. /**
  66952. * @ignore
  66953. * Specifies if the lens flare pipeline is enabed
  66954. */
  66955. get LensFlareEnabled(): boolean;
  66956. set LensFlareEnabled(enabled: boolean);
  66957. /**
  66958. * @ignore
  66959. * Specifies if the HDR pipeline is enabled
  66960. */
  66961. get HDREnabled(): boolean;
  66962. set HDREnabled(enabled: boolean);
  66963. /**
  66964. * @ignore
  66965. * Specifies if the volumetric lights scattering effect is enabled
  66966. */
  66967. get VLSEnabled(): boolean;
  66968. set VLSEnabled(enabled: boolean);
  66969. /**
  66970. * @ignore
  66971. * Specifies if the motion blur effect is enabled
  66972. */
  66973. get MotionBlurEnabled(): boolean;
  66974. set MotionBlurEnabled(enabled: boolean);
  66975. /**
  66976. * Specifies if anti-aliasing is enabled
  66977. */
  66978. get fxaaEnabled(): boolean;
  66979. set fxaaEnabled(enabled: boolean);
  66980. /**
  66981. * Specifies if screen space reflections are enabled.
  66982. */
  66983. get screenSpaceReflectionsEnabled(): boolean;
  66984. set screenSpaceReflectionsEnabled(enabled: boolean);
  66985. /**
  66986. * Specifies the number of steps used to calculate the volumetric lights
  66987. * Typically in interval [50, 200]
  66988. */
  66989. get volumetricLightStepsCount(): number;
  66990. set volumetricLightStepsCount(count: number);
  66991. /**
  66992. * Specifies the number of samples used for the motion blur effect
  66993. * Typically in interval [16, 64]
  66994. */
  66995. get motionBlurSamples(): number;
  66996. set motionBlurSamples(samples: number);
  66997. /**
  66998. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66999. */
  67000. get samples(): number;
  67001. set samples(sampleCount: number);
  67002. /**
  67003. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  67004. * @constructor
  67005. * @param name The rendering pipeline name
  67006. * @param scene The scene linked to this pipeline
  67007. * @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)
  67008. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  67009. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67010. */
  67011. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  67012. private _buildPipeline;
  67013. private _createDownSampleX4PostProcess;
  67014. private _createBrightPassPostProcess;
  67015. private _createBlurPostProcesses;
  67016. private _createTextureAdderPostProcess;
  67017. private _createVolumetricLightPostProcess;
  67018. private _createLuminancePostProcesses;
  67019. private _createHdrPostProcess;
  67020. private _createLensFlarePostProcess;
  67021. private _createDepthOfFieldPostProcess;
  67022. private _createMotionBlurPostProcess;
  67023. private _getDepthTexture;
  67024. private _disposePostProcesses;
  67025. /**
  67026. * Dispose of the pipeline and stop all post processes
  67027. */
  67028. dispose(): void;
  67029. /**
  67030. * Serialize the rendering pipeline (Used when exporting)
  67031. * @returns the serialized object
  67032. */
  67033. serialize(): any;
  67034. /**
  67035. * Parse the serialized pipeline
  67036. * @param source Source pipeline.
  67037. * @param scene The scene to load the pipeline to.
  67038. * @param rootUrl The URL of the serialized pipeline.
  67039. * @returns An instantiated pipeline from the serialized object.
  67040. */
  67041. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  67042. /**
  67043. * Luminance steps
  67044. */
  67045. static LuminanceSteps: number;
  67046. }
  67047. }
  67048. declare module BABYLON {
  67049. /** @hidden */
  67050. export var tonemapPixelShader: {
  67051. name: string;
  67052. shader: string;
  67053. };
  67054. }
  67055. declare module BABYLON {
  67056. /** Defines operator used for tonemapping */
  67057. export enum TonemappingOperator {
  67058. /** Hable */
  67059. Hable = 0,
  67060. /** Reinhard */
  67061. Reinhard = 1,
  67062. /** HejiDawson */
  67063. HejiDawson = 2,
  67064. /** Photographic */
  67065. Photographic = 3
  67066. }
  67067. /**
  67068. * Defines a post process to apply tone mapping
  67069. */
  67070. export class TonemapPostProcess extends PostProcess {
  67071. private _operator;
  67072. /** Defines the required exposure adjustement */
  67073. exposureAdjustment: number;
  67074. /**
  67075. * Creates a new TonemapPostProcess
  67076. * @param name defines the name of the postprocess
  67077. * @param _operator defines the operator to use
  67078. * @param exposureAdjustment defines the required exposure adjustement
  67079. * @param camera defines the camera to use (can be null)
  67080. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  67081. * @param engine defines the hosting engine (can be ignore if camera is set)
  67082. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  67083. */
  67084. constructor(name: string, _operator: TonemappingOperator,
  67085. /** Defines the required exposure adjustement */
  67086. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  67087. }
  67088. }
  67089. declare module BABYLON {
  67090. /** @hidden */
  67091. export var volumetricLightScatteringPixelShader: {
  67092. name: string;
  67093. shader: string;
  67094. };
  67095. }
  67096. declare module BABYLON {
  67097. /** @hidden */
  67098. export var volumetricLightScatteringPassVertexShader: {
  67099. name: string;
  67100. shader: string;
  67101. };
  67102. }
  67103. declare module BABYLON {
  67104. /** @hidden */
  67105. export var volumetricLightScatteringPassPixelShader: {
  67106. name: string;
  67107. shader: string;
  67108. };
  67109. }
  67110. declare module BABYLON {
  67111. /**
  67112. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  67113. */
  67114. export class VolumetricLightScatteringPostProcess extends PostProcess {
  67115. private _volumetricLightScatteringPass;
  67116. private _volumetricLightScatteringRTT;
  67117. private _viewPort;
  67118. private _screenCoordinates;
  67119. private _cachedDefines;
  67120. /**
  67121. * If not undefined, the mesh position is computed from the attached node position
  67122. */
  67123. attachedNode: {
  67124. position: Vector3;
  67125. };
  67126. /**
  67127. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  67128. */
  67129. customMeshPosition: Vector3;
  67130. /**
  67131. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  67132. */
  67133. useCustomMeshPosition: boolean;
  67134. /**
  67135. * If the post-process should inverse the light scattering direction
  67136. */
  67137. invert: boolean;
  67138. /**
  67139. * The internal mesh used by the post-process
  67140. */
  67141. mesh: Mesh;
  67142. /**
  67143. * @hidden
  67144. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  67145. */
  67146. get useDiffuseColor(): boolean;
  67147. set useDiffuseColor(useDiffuseColor: boolean);
  67148. /**
  67149. * Array containing the excluded meshes not rendered in the internal pass
  67150. */
  67151. excludedMeshes: AbstractMesh[];
  67152. /**
  67153. * Controls the overall intensity of the post-process
  67154. */
  67155. exposure: number;
  67156. /**
  67157. * Dissipates each sample's contribution in range [0, 1]
  67158. */
  67159. decay: number;
  67160. /**
  67161. * Controls the overall intensity of each sample
  67162. */
  67163. weight: number;
  67164. /**
  67165. * Controls the density of each sample
  67166. */
  67167. density: number;
  67168. /**
  67169. * @constructor
  67170. * @param name The post-process name
  67171. * @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)
  67172. * @param camera The camera that the post-process will be attached to
  67173. * @param mesh The mesh used to create the light scattering
  67174. * @param samples The post-process quality, default 100
  67175. * @param samplingModeThe post-process filtering mode
  67176. * @param engine The babylon engine
  67177. * @param reusable If the post-process is reusable
  67178. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  67179. */
  67180. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  67181. /**
  67182. * Returns the string "VolumetricLightScatteringPostProcess"
  67183. * @returns "VolumetricLightScatteringPostProcess"
  67184. */
  67185. getClassName(): string;
  67186. private _isReady;
  67187. /**
  67188. * Sets the new light position for light scattering effect
  67189. * @param position The new custom light position
  67190. */
  67191. setCustomMeshPosition(position: Vector3): void;
  67192. /**
  67193. * Returns the light position for light scattering effect
  67194. * @return Vector3 The custom light position
  67195. */
  67196. getCustomMeshPosition(): Vector3;
  67197. /**
  67198. * Disposes the internal assets and detaches the post-process from the camera
  67199. */
  67200. dispose(camera: Camera): void;
  67201. /**
  67202. * Returns the render target texture used by the post-process
  67203. * @return the render target texture used by the post-process
  67204. */
  67205. getPass(): RenderTargetTexture;
  67206. private _meshExcluded;
  67207. private _createPass;
  67208. private _updateMeshScreenCoordinates;
  67209. /**
  67210. * Creates a default mesh for the Volumeric Light Scattering post-process
  67211. * @param name The mesh name
  67212. * @param scene The scene where to create the mesh
  67213. * @return the default mesh
  67214. */
  67215. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  67216. }
  67217. }
  67218. declare module BABYLON {
  67219. interface Scene {
  67220. /** @hidden (Backing field) */
  67221. _boundingBoxRenderer: BoundingBoxRenderer;
  67222. /** @hidden (Backing field) */
  67223. _forceShowBoundingBoxes: boolean;
  67224. /**
  67225. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  67226. */
  67227. forceShowBoundingBoxes: boolean;
  67228. /**
  67229. * Gets the bounding box renderer associated with the scene
  67230. * @returns a BoundingBoxRenderer
  67231. */
  67232. getBoundingBoxRenderer(): BoundingBoxRenderer;
  67233. }
  67234. interface AbstractMesh {
  67235. /** @hidden (Backing field) */
  67236. _showBoundingBox: boolean;
  67237. /**
  67238. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  67239. */
  67240. showBoundingBox: boolean;
  67241. }
  67242. /**
  67243. * Component responsible of rendering the bounding box of the meshes in a scene.
  67244. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  67245. */
  67246. export class BoundingBoxRenderer implements ISceneComponent {
  67247. /**
  67248. * The component name helpfull to identify the component in the list of scene components.
  67249. */
  67250. readonly name: string;
  67251. /**
  67252. * The scene the component belongs to.
  67253. */
  67254. scene: Scene;
  67255. /**
  67256. * Color of the bounding box lines placed in front of an object
  67257. */
  67258. frontColor: Color3;
  67259. /**
  67260. * Color of the bounding box lines placed behind an object
  67261. */
  67262. backColor: Color3;
  67263. /**
  67264. * Defines if the renderer should show the back lines or not
  67265. */
  67266. showBackLines: boolean;
  67267. /**
  67268. * @hidden
  67269. */
  67270. renderList: SmartArray<BoundingBox>;
  67271. private _colorShader;
  67272. private _vertexBuffers;
  67273. private _indexBuffer;
  67274. private _fillIndexBuffer;
  67275. private _fillIndexData;
  67276. /**
  67277. * Instantiates a new bounding box renderer in a scene.
  67278. * @param scene the scene the renderer renders in
  67279. */
  67280. constructor(scene: Scene);
  67281. /**
  67282. * Registers the component in a given scene
  67283. */
  67284. register(): void;
  67285. private _evaluateSubMesh;
  67286. private _activeMesh;
  67287. private _prepareRessources;
  67288. private _createIndexBuffer;
  67289. /**
  67290. * Rebuilds the elements related to this component in case of
  67291. * context lost for instance.
  67292. */
  67293. rebuild(): void;
  67294. /**
  67295. * @hidden
  67296. */
  67297. reset(): void;
  67298. /**
  67299. * Render the bounding boxes of a specific rendering group
  67300. * @param renderingGroupId defines the rendering group to render
  67301. */
  67302. render(renderingGroupId: number): void;
  67303. /**
  67304. * In case of occlusion queries, we can render the occlusion bounding box through this method
  67305. * @param mesh Define the mesh to render the occlusion bounding box for
  67306. */
  67307. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  67308. /**
  67309. * Dispose and release the resources attached to this renderer.
  67310. */
  67311. dispose(): void;
  67312. }
  67313. }
  67314. declare module BABYLON {
  67315. interface Scene {
  67316. /** @hidden (Backing field) */
  67317. _depthRenderer: {
  67318. [id: string]: DepthRenderer;
  67319. };
  67320. /**
  67321. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  67322. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  67323. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  67324. * @returns the created depth renderer
  67325. */
  67326. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  67327. /**
  67328. * Disables a depth renderer for a given camera
  67329. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  67330. */
  67331. disableDepthRenderer(camera?: Nullable<Camera>): void;
  67332. }
  67333. /**
  67334. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  67335. * in several rendering techniques.
  67336. */
  67337. export class DepthRendererSceneComponent implements ISceneComponent {
  67338. /**
  67339. * The component name helpfull to identify the component in the list of scene components.
  67340. */
  67341. readonly name: string;
  67342. /**
  67343. * The scene the component belongs to.
  67344. */
  67345. scene: Scene;
  67346. /**
  67347. * Creates a new instance of the component for the given scene
  67348. * @param scene Defines the scene to register the component in
  67349. */
  67350. constructor(scene: Scene);
  67351. /**
  67352. * Registers the component in a given scene
  67353. */
  67354. register(): void;
  67355. /**
  67356. * Rebuilds the elements related to this component in case of
  67357. * context lost for instance.
  67358. */
  67359. rebuild(): void;
  67360. /**
  67361. * Disposes the component and the associated ressources
  67362. */
  67363. dispose(): void;
  67364. private _gatherRenderTargets;
  67365. private _gatherActiveCameraRenderTargets;
  67366. }
  67367. }
  67368. declare module BABYLON {
  67369. /** @hidden */
  67370. export var outlinePixelShader: {
  67371. name: string;
  67372. shader: string;
  67373. };
  67374. }
  67375. declare module BABYLON {
  67376. /** @hidden */
  67377. export var outlineVertexShader: {
  67378. name: string;
  67379. shader: string;
  67380. };
  67381. }
  67382. declare module BABYLON {
  67383. interface Scene {
  67384. /** @hidden */
  67385. _outlineRenderer: OutlineRenderer;
  67386. /**
  67387. * Gets the outline renderer associated with the scene
  67388. * @returns a OutlineRenderer
  67389. */
  67390. getOutlineRenderer(): OutlineRenderer;
  67391. }
  67392. interface AbstractMesh {
  67393. /** @hidden (Backing field) */
  67394. _renderOutline: boolean;
  67395. /**
  67396. * Gets or sets a boolean indicating if the outline must be rendered as well
  67397. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  67398. */
  67399. renderOutline: boolean;
  67400. /** @hidden (Backing field) */
  67401. _renderOverlay: boolean;
  67402. /**
  67403. * Gets or sets a boolean indicating if the overlay must be rendered as well
  67404. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  67405. */
  67406. renderOverlay: boolean;
  67407. }
  67408. /**
  67409. * This class is responsible to draw bothe outline/overlay of meshes.
  67410. * It should not be used directly but through the available method on mesh.
  67411. */
  67412. export class OutlineRenderer implements ISceneComponent {
  67413. /**
  67414. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  67415. */
  67416. private static _StencilReference;
  67417. /**
  67418. * The name of the component. Each component must have a unique name.
  67419. */
  67420. name: string;
  67421. /**
  67422. * The scene the component belongs to.
  67423. */
  67424. scene: Scene;
  67425. /**
  67426. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  67427. */
  67428. zOffset: number;
  67429. private _engine;
  67430. private _effect;
  67431. private _cachedDefines;
  67432. private _savedDepthWrite;
  67433. /**
  67434. * Instantiates a new outline renderer. (There could be only one per scene).
  67435. * @param scene Defines the scene it belongs to
  67436. */
  67437. constructor(scene: Scene);
  67438. /**
  67439. * Register the component to one instance of a scene.
  67440. */
  67441. register(): void;
  67442. /**
  67443. * Rebuilds the elements related to this component in case of
  67444. * context lost for instance.
  67445. */
  67446. rebuild(): void;
  67447. /**
  67448. * Disposes the component and the associated ressources.
  67449. */
  67450. dispose(): void;
  67451. /**
  67452. * Renders the outline in the canvas.
  67453. * @param subMesh Defines the sumesh to render
  67454. * @param batch Defines the batch of meshes in case of instances
  67455. * @param useOverlay Defines if the rendering is for the overlay or the outline
  67456. */
  67457. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  67458. /**
  67459. * Returns whether or not the outline renderer is ready for a given submesh.
  67460. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  67461. * @param subMesh Defines the submesh to check readyness for
  67462. * @param useInstances Defines wheter wee are trying to render instances or not
  67463. * @returns true if ready otherwise false
  67464. */
  67465. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  67466. private _beforeRenderingMesh;
  67467. private _afterRenderingMesh;
  67468. }
  67469. }
  67470. declare module BABYLON {
  67471. /**
  67472. * Defines the basic options interface of a Sprite Frame Source Size.
  67473. */
  67474. export interface ISpriteJSONSpriteSourceSize {
  67475. /**
  67476. * number of the original width of the Frame
  67477. */
  67478. w: number;
  67479. /**
  67480. * number of the original height of the Frame
  67481. */
  67482. h: number;
  67483. }
  67484. /**
  67485. * Defines the basic options interface of a Sprite Frame Data.
  67486. */
  67487. export interface ISpriteJSONSpriteFrameData {
  67488. /**
  67489. * number of the x offset of the Frame
  67490. */
  67491. x: number;
  67492. /**
  67493. * number of the y offset of the Frame
  67494. */
  67495. y: number;
  67496. /**
  67497. * number of the width of the Frame
  67498. */
  67499. w: number;
  67500. /**
  67501. * number of the height of the Frame
  67502. */
  67503. h: number;
  67504. }
  67505. /**
  67506. * Defines the basic options interface of a JSON Sprite.
  67507. */
  67508. export interface ISpriteJSONSprite {
  67509. /**
  67510. * string name of the Frame
  67511. */
  67512. filename: string;
  67513. /**
  67514. * ISpriteJSONSpriteFrame basic object of the frame data
  67515. */
  67516. frame: ISpriteJSONSpriteFrameData;
  67517. /**
  67518. * boolean to flag is the frame was rotated.
  67519. */
  67520. rotated: boolean;
  67521. /**
  67522. * boolean to flag is the frame was trimmed.
  67523. */
  67524. trimmed: boolean;
  67525. /**
  67526. * ISpriteJSONSpriteFrame basic object of the source data
  67527. */
  67528. spriteSourceSize: ISpriteJSONSpriteFrameData;
  67529. /**
  67530. * ISpriteJSONSpriteFrame basic object of the source data
  67531. */
  67532. sourceSize: ISpriteJSONSpriteSourceSize;
  67533. }
  67534. /**
  67535. * Defines the basic options interface of a JSON atlas.
  67536. */
  67537. export interface ISpriteJSONAtlas {
  67538. /**
  67539. * Array of objects that contain the frame data.
  67540. */
  67541. frames: Array<ISpriteJSONSprite>;
  67542. /**
  67543. * object basic object containing the sprite meta data.
  67544. */
  67545. meta?: object;
  67546. }
  67547. }
  67548. declare module BABYLON {
  67549. /** @hidden */
  67550. export var spriteMapPixelShader: {
  67551. name: string;
  67552. shader: string;
  67553. };
  67554. }
  67555. declare module BABYLON {
  67556. /** @hidden */
  67557. export var spriteMapVertexShader: {
  67558. name: string;
  67559. shader: string;
  67560. };
  67561. }
  67562. declare module BABYLON {
  67563. /**
  67564. * Defines the basic options interface of a SpriteMap
  67565. */
  67566. export interface ISpriteMapOptions {
  67567. /**
  67568. * Vector2 of the number of cells in the grid.
  67569. */
  67570. stageSize?: Vector2;
  67571. /**
  67572. * Vector2 of the size of the output plane in World Units.
  67573. */
  67574. outputSize?: Vector2;
  67575. /**
  67576. * Vector3 of the position of the output plane in World Units.
  67577. */
  67578. outputPosition?: Vector3;
  67579. /**
  67580. * Vector3 of the rotation of the output plane.
  67581. */
  67582. outputRotation?: Vector3;
  67583. /**
  67584. * number of layers that the system will reserve in resources.
  67585. */
  67586. layerCount?: number;
  67587. /**
  67588. * number of max animation frames a single cell will reserve in resources.
  67589. */
  67590. maxAnimationFrames?: number;
  67591. /**
  67592. * number cell index of the base tile when the system compiles.
  67593. */
  67594. baseTile?: number;
  67595. /**
  67596. * boolean flip the sprite after its been repositioned by the framing data.
  67597. */
  67598. flipU?: boolean;
  67599. /**
  67600. * Vector3 scalar of the global RGB values of the SpriteMap.
  67601. */
  67602. colorMultiply?: Vector3;
  67603. }
  67604. /**
  67605. * Defines the IDisposable interface in order to be cleanable from resources.
  67606. */
  67607. export interface ISpriteMap extends IDisposable {
  67608. /**
  67609. * String name of the SpriteMap.
  67610. */
  67611. name: string;
  67612. /**
  67613. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  67614. */
  67615. atlasJSON: ISpriteJSONAtlas;
  67616. /**
  67617. * Texture of the SpriteMap.
  67618. */
  67619. spriteSheet: Texture;
  67620. /**
  67621. * The parameters to initialize the SpriteMap with.
  67622. */
  67623. options: ISpriteMapOptions;
  67624. }
  67625. /**
  67626. * Class used to manage a grid restricted sprite deployment on an Output plane.
  67627. */
  67628. export class SpriteMap implements ISpriteMap {
  67629. /** The Name of the spriteMap */
  67630. name: string;
  67631. /** The JSON file with the frame and meta data */
  67632. atlasJSON: ISpriteJSONAtlas;
  67633. /** The systems Sprite Sheet Texture */
  67634. spriteSheet: Texture;
  67635. /** Arguments passed with the Constructor */
  67636. options: ISpriteMapOptions;
  67637. /** Public Sprite Storage array, parsed from atlasJSON */
  67638. sprites: Array<ISpriteJSONSprite>;
  67639. /** Returns the Number of Sprites in the System */
  67640. get spriteCount(): number;
  67641. /** Returns the Position of Output Plane*/
  67642. get position(): Vector3;
  67643. /** Returns the Position of Output Plane*/
  67644. set position(v: Vector3);
  67645. /** Returns the Rotation of Output Plane*/
  67646. get rotation(): Vector3;
  67647. /** Returns the Rotation of Output Plane*/
  67648. set rotation(v: Vector3);
  67649. /** Sets the AnimationMap*/
  67650. get animationMap(): RawTexture;
  67651. /** Sets the AnimationMap*/
  67652. set animationMap(v: RawTexture);
  67653. /** Scene that the SpriteMap was created in */
  67654. private _scene;
  67655. /** Texture Buffer of Float32 that holds tile frame data*/
  67656. private _frameMap;
  67657. /** Texture Buffers of Float32 that holds tileMap data*/
  67658. private _tileMaps;
  67659. /** Texture Buffer of Float32 that holds Animation Data*/
  67660. private _animationMap;
  67661. /** Custom ShaderMaterial Central to the System*/
  67662. private _material;
  67663. /** Custom ShaderMaterial Central to the System*/
  67664. private _output;
  67665. /** Systems Time Ticker*/
  67666. private _time;
  67667. /**
  67668. * Creates a new SpriteMap
  67669. * @param name defines the SpriteMaps Name
  67670. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  67671. * @param spriteSheet is the Texture that the Sprites are on.
  67672. * @param options a basic deployment configuration
  67673. * @param scene The Scene that the map is deployed on
  67674. */
  67675. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  67676. /**
  67677. * Returns tileID location
  67678. * @returns Vector2 the cell position ID
  67679. */
  67680. getTileID(): Vector2;
  67681. /**
  67682. * Gets the UV location of the mouse over the SpriteMap.
  67683. * @returns Vector2 the UV position of the mouse interaction
  67684. */
  67685. getMousePosition(): Vector2;
  67686. /**
  67687. * Creates the "frame" texture Buffer
  67688. * -------------------------------------
  67689. * Structure of frames
  67690. * "filename": "Falling-Water-2.png",
  67691. * "frame": {"x":69,"y":103,"w":24,"h":32},
  67692. * "rotated": true,
  67693. * "trimmed": true,
  67694. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  67695. * "sourceSize": {"w":32,"h":32}
  67696. * @returns RawTexture of the frameMap
  67697. */
  67698. private _createFrameBuffer;
  67699. /**
  67700. * Creates the tileMap texture Buffer
  67701. * @param buffer normally and array of numbers, or a false to generate from scratch
  67702. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  67703. * @returns RawTexture of the tileMap
  67704. */
  67705. private _createTileBuffer;
  67706. /**
  67707. * Modifies the data of the tileMaps
  67708. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  67709. * @param pos is the iVector2 Coordinates of the Tile
  67710. * @param tile The SpriteIndex of the new Tile
  67711. */
  67712. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  67713. /**
  67714. * Creates the animationMap texture Buffer
  67715. * @param buffer normally and array of numbers, or a false to generate from scratch
  67716. * @returns RawTexture of the animationMap
  67717. */
  67718. private _createTileAnimationBuffer;
  67719. /**
  67720. * Modifies the data of the animationMap
  67721. * @param cellID is the Index of the Sprite
  67722. * @param _frame is the target Animation frame
  67723. * @param toCell is the Target Index of the next frame of the animation
  67724. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  67725. * @param speed is a global scalar of the time variable on the map.
  67726. */
  67727. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  67728. /**
  67729. * Exports the .tilemaps file
  67730. */
  67731. saveTileMaps(): void;
  67732. /**
  67733. * Imports the .tilemaps file
  67734. * @param url of the .tilemaps file
  67735. */
  67736. loadTileMaps(url: string): void;
  67737. /**
  67738. * Release associated resources
  67739. */
  67740. dispose(): void;
  67741. }
  67742. }
  67743. declare module BABYLON {
  67744. /**
  67745. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67746. * @see http://doc.babylonjs.com/babylon101/sprites
  67747. */
  67748. export class SpritePackedManager extends SpriteManager {
  67749. /** defines the packed manager's name */
  67750. name: string;
  67751. /**
  67752. * Creates a new sprite manager from a packed sprite sheet
  67753. * @param name defines the manager's name
  67754. * @param imgUrl defines the sprite sheet url
  67755. * @param capacity defines the maximum allowed number of sprites
  67756. * @param scene defines the hosting scene
  67757. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67758. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67759. * @param samplingMode defines the smapling mode to use with spritesheet
  67760. * @param fromPacked set to true; do not alter
  67761. */
  67762. constructor(
  67763. /** defines the packed manager's name */
  67764. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67765. }
  67766. }
  67767. declare module BABYLON {
  67768. /**
  67769. * Defines the list of states available for a task inside a AssetsManager
  67770. */
  67771. export enum AssetTaskState {
  67772. /**
  67773. * Initialization
  67774. */
  67775. INIT = 0,
  67776. /**
  67777. * Running
  67778. */
  67779. RUNNING = 1,
  67780. /**
  67781. * Done
  67782. */
  67783. DONE = 2,
  67784. /**
  67785. * Error
  67786. */
  67787. ERROR = 3
  67788. }
  67789. /**
  67790. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67791. */
  67792. export abstract class AbstractAssetTask {
  67793. /**
  67794. * Task name
  67795. */ name: string;
  67796. /**
  67797. * Callback called when the task is successful
  67798. */
  67799. onSuccess: (task: any) => void;
  67800. /**
  67801. * Callback called when the task is not successful
  67802. */
  67803. onError: (task: any, message?: string, exception?: any) => void;
  67804. /**
  67805. * Creates a new AssetsManager
  67806. * @param name defines the name of the task
  67807. */
  67808. constructor(
  67809. /**
  67810. * Task name
  67811. */ name: string);
  67812. private _isCompleted;
  67813. private _taskState;
  67814. private _errorObject;
  67815. /**
  67816. * Get if the task is completed
  67817. */
  67818. get isCompleted(): boolean;
  67819. /**
  67820. * Gets the current state of the task
  67821. */
  67822. get taskState(): AssetTaskState;
  67823. /**
  67824. * Gets the current error object (if task is in error)
  67825. */
  67826. get errorObject(): {
  67827. message?: string;
  67828. exception?: any;
  67829. };
  67830. /**
  67831. * Internal only
  67832. * @hidden
  67833. */
  67834. _setErrorObject(message?: string, exception?: any): void;
  67835. /**
  67836. * Execute the current task
  67837. * @param scene defines the scene where you want your assets to be loaded
  67838. * @param onSuccess is a callback called when the task is successfully executed
  67839. * @param onError is a callback called if an error occurs
  67840. */
  67841. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67842. /**
  67843. * Execute the current task
  67844. * @param scene defines the scene where you want your assets to be loaded
  67845. * @param onSuccess is a callback called when the task is successfully executed
  67846. * @param onError is a callback called if an error occurs
  67847. */
  67848. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67849. /**
  67850. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67851. * This can be used with failed tasks that have the reason for failure fixed.
  67852. */
  67853. reset(): void;
  67854. private onErrorCallback;
  67855. private onDoneCallback;
  67856. }
  67857. /**
  67858. * Define the interface used by progress events raised during assets loading
  67859. */
  67860. export interface IAssetsProgressEvent {
  67861. /**
  67862. * Defines the number of remaining tasks to process
  67863. */
  67864. remainingCount: number;
  67865. /**
  67866. * Defines the total number of tasks
  67867. */
  67868. totalCount: number;
  67869. /**
  67870. * Defines the task that was just processed
  67871. */
  67872. task: AbstractAssetTask;
  67873. }
  67874. /**
  67875. * Class used to share progress information about assets loading
  67876. */
  67877. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67878. /**
  67879. * Defines the number of remaining tasks to process
  67880. */
  67881. remainingCount: number;
  67882. /**
  67883. * Defines the total number of tasks
  67884. */
  67885. totalCount: number;
  67886. /**
  67887. * Defines the task that was just processed
  67888. */
  67889. task: AbstractAssetTask;
  67890. /**
  67891. * Creates a AssetsProgressEvent
  67892. * @param remainingCount defines the number of remaining tasks to process
  67893. * @param totalCount defines the total number of tasks
  67894. * @param task defines the task that was just processed
  67895. */
  67896. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67897. }
  67898. /**
  67899. * Define a task used by AssetsManager to load meshes
  67900. */
  67901. export class MeshAssetTask extends AbstractAssetTask {
  67902. /**
  67903. * Defines the name of the task
  67904. */
  67905. name: string;
  67906. /**
  67907. * Defines the list of mesh's names you want to load
  67908. */
  67909. meshesNames: any;
  67910. /**
  67911. * Defines the root url to use as a base to load your meshes and associated resources
  67912. */
  67913. rootUrl: string;
  67914. /**
  67915. * Defines the filename of the scene to load from
  67916. */
  67917. sceneFilename: string;
  67918. /**
  67919. * Gets the list of loaded meshes
  67920. */
  67921. loadedMeshes: Array<AbstractMesh>;
  67922. /**
  67923. * Gets the list of loaded particle systems
  67924. */
  67925. loadedParticleSystems: Array<IParticleSystem>;
  67926. /**
  67927. * Gets the list of loaded skeletons
  67928. */
  67929. loadedSkeletons: Array<Skeleton>;
  67930. /**
  67931. * Gets the list of loaded animation groups
  67932. */
  67933. loadedAnimationGroups: Array<AnimationGroup>;
  67934. /**
  67935. * Callback called when the task is successful
  67936. */
  67937. onSuccess: (task: MeshAssetTask) => void;
  67938. /**
  67939. * Callback called when the task is successful
  67940. */
  67941. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67942. /**
  67943. * Creates a new MeshAssetTask
  67944. * @param name defines the name of the task
  67945. * @param meshesNames defines the list of mesh's names you want to load
  67946. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67947. * @param sceneFilename defines the filename of the scene to load from
  67948. */
  67949. constructor(
  67950. /**
  67951. * Defines the name of the task
  67952. */
  67953. name: string,
  67954. /**
  67955. * Defines the list of mesh's names you want to load
  67956. */
  67957. meshesNames: any,
  67958. /**
  67959. * Defines the root url to use as a base to load your meshes and associated resources
  67960. */
  67961. rootUrl: string,
  67962. /**
  67963. * Defines the filename of the scene to load from
  67964. */
  67965. sceneFilename: string);
  67966. /**
  67967. * Execute the current task
  67968. * @param scene defines the scene where you want your assets to be loaded
  67969. * @param onSuccess is a callback called when the task is successfully executed
  67970. * @param onError is a callback called if an error occurs
  67971. */
  67972. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67973. }
  67974. /**
  67975. * Define a task used by AssetsManager to load text content
  67976. */
  67977. export class TextFileAssetTask extends AbstractAssetTask {
  67978. /**
  67979. * Defines the name of the task
  67980. */
  67981. name: string;
  67982. /**
  67983. * Defines the location of the file to load
  67984. */
  67985. url: string;
  67986. /**
  67987. * Gets the loaded text string
  67988. */
  67989. text: string;
  67990. /**
  67991. * Callback called when the task is successful
  67992. */
  67993. onSuccess: (task: TextFileAssetTask) => void;
  67994. /**
  67995. * Callback called when the task is successful
  67996. */
  67997. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67998. /**
  67999. * Creates a new TextFileAssetTask object
  68000. * @param name defines the name of the task
  68001. * @param url defines the location of the file to load
  68002. */
  68003. constructor(
  68004. /**
  68005. * Defines the name of the task
  68006. */
  68007. name: string,
  68008. /**
  68009. * Defines the location of the file to load
  68010. */
  68011. url: string);
  68012. /**
  68013. * Execute the current task
  68014. * @param scene defines the scene where you want your assets to be loaded
  68015. * @param onSuccess is a callback called when the task is successfully executed
  68016. * @param onError is a callback called if an error occurs
  68017. */
  68018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68019. }
  68020. /**
  68021. * Define a task used by AssetsManager to load binary data
  68022. */
  68023. export class BinaryFileAssetTask extends AbstractAssetTask {
  68024. /**
  68025. * Defines the name of the task
  68026. */
  68027. name: string;
  68028. /**
  68029. * Defines the location of the file to load
  68030. */
  68031. url: string;
  68032. /**
  68033. * Gets the lodaded data (as an array buffer)
  68034. */
  68035. data: ArrayBuffer;
  68036. /**
  68037. * Callback called when the task is successful
  68038. */
  68039. onSuccess: (task: BinaryFileAssetTask) => void;
  68040. /**
  68041. * Callback called when the task is successful
  68042. */
  68043. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  68044. /**
  68045. * Creates a new BinaryFileAssetTask object
  68046. * @param name defines the name of the new task
  68047. * @param url defines the location of the file to load
  68048. */
  68049. constructor(
  68050. /**
  68051. * Defines the name of the task
  68052. */
  68053. name: string,
  68054. /**
  68055. * Defines the location of the file to load
  68056. */
  68057. url: string);
  68058. /**
  68059. * Execute the current task
  68060. * @param scene defines the scene where you want your assets to be loaded
  68061. * @param onSuccess is a callback called when the task is successfully executed
  68062. * @param onError is a callback called if an error occurs
  68063. */
  68064. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68065. }
  68066. /**
  68067. * Define a task used by AssetsManager to load images
  68068. */
  68069. export class ImageAssetTask extends AbstractAssetTask {
  68070. /**
  68071. * Defines the name of the task
  68072. */
  68073. name: string;
  68074. /**
  68075. * Defines the location of the image to load
  68076. */
  68077. url: string;
  68078. /**
  68079. * Gets the loaded images
  68080. */
  68081. image: HTMLImageElement;
  68082. /**
  68083. * Callback called when the task is successful
  68084. */
  68085. onSuccess: (task: ImageAssetTask) => void;
  68086. /**
  68087. * Callback called when the task is successful
  68088. */
  68089. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  68090. /**
  68091. * Creates a new ImageAssetTask
  68092. * @param name defines the name of the task
  68093. * @param url defines the location of the image to load
  68094. */
  68095. constructor(
  68096. /**
  68097. * Defines the name of the task
  68098. */
  68099. name: string,
  68100. /**
  68101. * Defines the location of the image to load
  68102. */
  68103. url: string);
  68104. /**
  68105. * Execute the current task
  68106. * @param scene defines the scene where you want your assets to be loaded
  68107. * @param onSuccess is a callback called when the task is successfully executed
  68108. * @param onError is a callback called if an error occurs
  68109. */
  68110. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68111. }
  68112. /**
  68113. * Defines the interface used by texture loading tasks
  68114. */
  68115. export interface ITextureAssetTask<TEX extends BaseTexture> {
  68116. /**
  68117. * Gets the loaded texture
  68118. */
  68119. texture: TEX;
  68120. }
  68121. /**
  68122. * Define a task used by AssetsManager to load 2D textures
  68123. */
  68124. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  68125. /**
  68126. * Defines the name of the task
  68127. */
  68128. name: string;
  68129. /**
  68130. * Defines the location of the file to load
  68131. */
  68132. url: string;
  68133. /**
  68134. * Defines if mipmap should not be generated (default is false)
  68135. */
  68136. noMipmap?: boolean | undefined;
  68137. /**
  68138. * Defines if texture must be inverted on Y axis (default is true)
  68139. */
  68140. invertY: boolean;
  68141. /**
  68142. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68143. */
  68144. samplingMode: number;
  68145. /**
  68146. * Gets the loaded texture
  68147. */
  68148. texture: Texture;
  68149. /**
  68150. * Callback called when the task is successful
  68151. */
  68152. onSuccess: (task: TextureAssetTask) => void;
  68153. /**
  68154. * Callback called when the task is successful
  68155. */
  68156. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  68157. /**
  68158. * Creates a new TextureAssetTask object
  68159. * @param name defines the name of the task
  68160. * @param url defines the location of the file to load
  68161. * @param noMipmap defines if mipmap should not be generated (default is false)
  68162. * @param invertY defines if texture must be inverted on Y axis (default is true)
  68163. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68164. */
  68165. constructor(
  68166. /**
  68167. * Defines the name of the task
  68168. */
  68169. name: string,
  68170. /**
  68171. * Defines the location of the file to load
  68172. */
  68173. url: string,
  68174. /**
  68175. * Defines if mipmap should not be generated (default is false)
  68176. */
  68177. noMipmap?: boolean | undefined,
  68178. /**
  68179. * Defines if texture must be inverted on Y axis (default is true)
  68180. */
  68181. invertY?: boolean,
  68182. /**
  68183. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  68184. */
  68185. samplingMode?: number);
  68186. /**
  68187. * Execute the current task
  68188. * @param scene defines the scene where you want your assets to be loaded
  68189. * @param onSuccess is a callback called when the task is successfully executed
  68190. * @param onError is a callback called if an error occurs
  68191. */
  68192. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68193. }
  68194. /**
  68195. * Define a task used by AssetsManager to load cube textures
  68196. */
  68197. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  68198. /**
  68199. * Defines the name of the task
  68200. */
  68201. name: string;
  68202. /**
  68203. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68204. */
  68205. url: string;
  68206. /**
  68207. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68208. */
  68209. extensions?: string[] | undefined;
  68210. /**
  68211. * Defines if mipmaps should not be generated (default is false)
  68212. */
  68213. noMipmap?: boolean | undefined;
  68214. /**
  68215. * Defines the explicit list of files (undefined by default)
  68216. */
  68217. files?: string[] | undefined;
  68218. /**
  68219. * Gets the loaded texture
  68220. */
  68221. texture: CubeTexture;
  68222. /**
  68223. * Callback called when the task is successful
  68224. */
  68225. onSuccess: (task: CubeTextureAssetTask) => void;
  68226. /**
  68227. * Callback called when the task is successful
  68228. */
  68229. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  68230. /**
  68231. * Creates a new CubeTextureAssetTask
  68232. * @param name defines the name of the task
  68233. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68234. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68235. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68236. * @param files defines the explicit list of files (undefined by default)
  68237. */
  68238. constructor(
  68239. /**
  68240. * Defines the name of the task
  68241. */
  68242. name: string,
  68243. /**
  68244. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  68245. */
  68246. url: string,
  68247. /**
  68248. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  68249. */
  68250. extensions?: string[] | undefined,
  68251. /**
  68252. * Defines if mipmaps should not be generated (default is false)
  68253. */
  68254. noMipmap?: boolean | undefined,
  68255. /**
  68256. * Defines the explicit list of files (undefined by default)
  68257. */
  68258. files?: string[] | undefined);
  68259. /**
  68260. * Execute the current task
  68261. * @param scene defines the scene where you want your assets to be loaded
  68262. * @param onSuccess is a callback called when the task is successfully executed
  68263. * @param onError is a callback called if an error occurs
  68264. */
  68265. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68266. }
  68267. /**
  68268. * Define a task used by AssetsManager to load HDR cube textures
  68269. */
  68270. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  68271. /**
  68272. * Defines the name of the task
  68273. */
  68274. name: string;
  68275. /**
  68276. * Defines the location of the file to load
  68277. */
  68278. url: string;
  68279. /**
  68280. * Defines the desired size (the more it increases the longer the generation will be)
  68281. */
  68282. size: number;
  68283. /**
  68284. * Defines if mipmaps should not be generated (default is false)
  68285. */
  68286. noMipmap: boolean;
  68287. /**
  68288. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68289. */
  68290. generateHarmonics: boolean;
  68291. /**
  68292. * 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)
  68293. */
  68294. gammaSpace: boolean;
  68295. /**
  68296. * Internal Use Only
  68297. */
  68298. reserved: boolean;
  68299. /**
  68300. * Gets the loaded texture
  68301. */
  68302. texture: HDRCubeTexture;
  68303. /**
  68304. * Callback called when the task is successful
  68305. */
  68306. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  68307. /**
  68308. * Callback called when the task is successful
  68309. */
  68310. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  68311. /**
  68312. * Creates a new HDRCubeTextureAssetTask object
  68313. * @param name defines the name of the task
  68314. * @param url defines the location of the file to load
  68315. * @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.
  68316. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68317. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68318. * @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)
  68319. * @param reserved Internal use only
  68320. */
  68321. constructor(
  68322. /**
  68323. * Defines the name of the task
  68324. */
  68325. name: string,
  68326. /**
  68327. * Defines the location of the file to load
  68328. */
  68329. url: string,
  68330. /**
  68331. * Defines the desired size (the more it increases the longer the generation will be)
  68332. */
  68333. size: number,
  68334. /**
  68335. * Defines if mipmaps should not be generated (default is false)
  68336. */
  68337. noMipmap?: boolean,
  68338. /**
  68339. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  68340. */
  68341. generateHarmonics?: boolean,
  68342. /**
  68343. * 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)
  68344. */
  68345. gammaSpace?: boolean,
  68346. /**
  68347. * Internal Use Only
  68348. */
  68349. reserved?: boolean);
  68350. /**
  68351. * Execute the current task
  68352. * @param scene defines the scene where you want your assets to be loaded
  68353. * @param onSuccess is a callback called when the task is successfully executed
  68354. * @param onError is a callback called if an error occurs
  68355. */
  68356. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68357. }
  68358. /**
  68359. * Define a task used by AssetsManager to load Equirectangular cube textures
  68360. */
  68361. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  68362. /**
  68363. * Defines the name of the task
  68364. */
  68365. name: string;
  68366. /**
  68367. * Defines the location of the file to load
  68368. */
  68369. url: string;
  68370. /**
  68371. * Defines the desired size (the more it increases the longer the generation will be)
  68372. */
  68373. size: number;
  68374. /**
  68375. * Defines if mipmaps should not be generated (default is false)
  68376. */
  68377. noMipmap: boolean;
  68378. /**
  68379. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68380. * but the standard material would require them in Gamma space) (default is true)
  68381. */
  68382. gammaSpace: boolean;
  68383. /**
  68384. * Gets the loaded texture
  68385. */
  68386. texture: EquiRectangularCubeTexture;
  68387. /**
  68388. * Callback called when the task is successful
  68389. */
  68390. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  68391. /**
  68392. * Callback called when the task is successful
  68393. */
  68394. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  68395. /**
  68396. * Creates a new EquiRectangularCubeTextureAssetTask object
  68397. * @param name defines the name of the task
  68398. * @param url defines the location of the file to load
  68399. * @param size defines the desired size (the more it increases the longer the generation will be)
  68400. * If the size is omitted this implies you are using a preprocessed cubemap.
  68401. * @param noMipmap defines if mipmaps should not be generated (default is false)
  68402. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  68403. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  68404. * (default is true)
  68405. */
  68406. constructor(
  68407. /**
  68408. * Defines the name of the task
  68409. */
  68410. name: string,
  68411. /**
  68412. * Defines the location of the file to load
  68413. */
  68414. url: string,
  68415. /**
  68416. * Defines the desired size (the more it increases the longer the generation will be)
  68417. */
  68418. size: number,
  68419. /**
  68420. * Defines if mipmaps should not be generated (default is false)
  68421. */
  68422. noMipmap?: boolean,
  68423. /**
  68424. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  68425. * but the standard material would require them in Gamma space) (default is true)
  68426. */
  68427. gammaSpace?: boolean);
  68428. /**
  68429. * Execute the current task
  68430. * @param scene defines the scene where you want your assets to be loaded
  68431. * @param onSuccess is a callback called when the task is successfully executed
  68432. * @param onError is a callback called if an error occurs
  68433. */
  68434. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  68435. }
  68436. /**
  68437. * This class can be used to easily import assets into a scene
  68438. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  68439. */
  68440. export class AssetsManager {
  68441. private _scene;
  68442. private _isLoading;
  68443. protected _tasks: AbstractAssetTask[];
  68444. protected _waitingTasksCount: number;
  68445. protected _totalTasksCount: number;
  68446. /**
  68447. * Callback called when all tasks are processed
  68448. */
  68449. onFinish: (tasks: AbstractAssetTask[]) => void;
  68450. /**
  68451. * Callback called when a task is successful
  68452. */
  68453. onTaskSuccess: (task: AbstractAssetTask) => void;
  68454. /**
  68455. * Callback called when a task had an error
  68456. */
  68457. onTaskError: (task: AbstractAssetTask) => void;
  68458. /**
  68459. * Callback called when a task is done (whatever the result is)
  68460. */
  68461. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  68462. /**
  68463. * Observable called when all tasks are processed
  68464. */
  68465. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  68466. /**
  68467. * Observable called when a task had an error
  68468. */
  68469. onTaskErrorObservable: Observable<AbstractAssetTask>;
  68470. /**
  68471. * Observable called when all tasks were executed
  68472. */
  68473. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  68474. /**
  68475. * Observable called when a task is done (whatever the result is)
  68476. */
  68477. onProgressObservable: Observable<IAssetsProgressEvent>;
  68478. /**
  68479. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  68480. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  68481. */
  68482. useDefaultLoadingScreen: boolean;
  68483. /**
  68484. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  68485. * when all assets have been downloaded.
  68486. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  68487. */
  68488. autoHideLoadingUI: boolean;
  68489. /**
  68490. * Creates a new AssetsManager
  68491. * @param scene defines the scene to work on
  68492. */
  68493. constructor(scene: Scene);
  68494. /**
  68495. * Add a MeshAssetTask to the list of active tasks
  68496. * @param taskName defines the name of the new task
  68497. * @param meshesNames defines the name of meshes to load
  68498. * @param rootUrl defines the root url to use to locate files
  68499. * @param sceneFilename defines the filename of the scene file
  68500. * @returns a new MeshAssetTask object
  68501. */
  68502. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  68503. /**
  68504. * Add a TextFileAssetTask to the list of active tasks
  68505. * @param taskName defines the name of the new task
  68506. * @param url defines the url of the file to load
  68507. * @returns a new TextFileAssetTask object
  68508. */
  68509. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  68510. /**
  68511. * Add a BinaryFileAssetTask to the list of active tasks
  68512. * @param taskName defines the name of the new task
  68513. * @param url defines the url of the file to load
  68514. * @returns a new BinaryFileAssetTask object
  68515. */
  68516. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  68517. /**
  68518. * Add a ImageAssetTask to the list of active tasks
  68519. * @param taskName defines the name of the new task
  68520. * @param url defines the url of the file to load
  68521. * @returns a new ImageAssetTask object
  68522. */
  68523. addImageTask(taskName: string, url: string): ImageAssetTask;
  68524. /**
  68525. * Add a TextureAssetTask to the list of active tasks
  68526. * @param taskName defines the name of the new task
  68527. * @param url defines the url of the file to load
  68528. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68529. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  68530. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  68531. * @returns a new TextureAssetTask object
  68532. */
  68533. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  68534. /**
  68535. * Add a CubeTextureAssetTask to the list of active tasks
  68536. * @param taskName defines the name of the new task
  68537. * @param url defines the url of the file to load
  68538. * @param extensions defines the extension to use to load the cube map (can be null)
  68539. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68540. * @param files defines the list of files to load (can be null)
  68541. * @returns a new CubeTextureAssetTask object
  68542. */
  68543. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  68544. /**
  68545. *
  68546. * Add a HDRCubeTextureAssetTask to the list of active tasks
  68547. * @param taskName defines the name of the new task
  68548. * @param url defines the url of the file to load
  68549. * @param size defines the size you want for the cubemap (can be null)
  68550. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68551. * @param generateHarmonics defines if you want to automatically generate (true by default)
  68552. * @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)
  68553. * @param reserved Internal use only
  68554. * @returns a new HDRCubeTextureAssetTask object
  68555. */
  68556. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  68557. /**
  68558. *
  68559. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  68560. * @param taskName defines the name of the new task
  68561. * @param url defines the url of the file to load
  68562. * @param size defines the size you want for the cubemap (can be null)
  68563. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  68564. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  68565. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  68566. * @returns a new EquiRectangularCubeTextureAssetTask object
  68567. */
  68568. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  68569. /**
  68570. * Remove a task from the assets manager.
  68571. * @param task the task to remove
  68572. */
  68573. removeTask(task: AbstractAssetTask): void;
  68574. private _decreaseWaitingTasksCount;
  68575. private _runTask;
  68576. /**
  68577. * Reset the AssetsManager and remove all tasks
  68578. * @return the current instance of the AssetsManager
  68579. */
  68580. reset(): AssetsManager;
  68581. /**
  68582. * Start the loading process
  68583. * @return the current instance of the AssetsManager
  68584. */
  68585. load(): AssetsManager;
  68586. /**
  68587. * Start the loading process as an async operation
  68588. * @return a promise returning the list of failed tasks
  68589. */
  68590. loadAsync(): Promise<void>;
  68591. }
  68592. }
  68593. declare module BABYLON {
  68594. /**
  68595. * Wrapper class for promise with external resolve and reject.
  68596. */
  68597. export class Deferred<T> {
  68598. /**
  68599. * The promise associated with this deferred object.
  68600. */
  68601. readonly promise: Promise<T>;
  68602. private _resolve;
  68603. private _reject;
  68604. /**
  68605. * The resolve method of the promise associated with this deferred object.
  68606. */
  68607. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  68608. /**
  68609. * The reject method of the promise associated with this deferred object.
  68610. */
  68611. get reject(): (reason?: any) => void;
  68612. /**
  68613. * Constructor for this deferred object.
  68614. */
  68615. constructor();
  68616. }
  68617. }
  68618. declare module BABYLON {
  68619. /**
  68620. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  68621. */
  68622. export class MeshExploder {
  68623. private _centerMesh;
  68624. private _meshes;
  68625. private _meshesOrigins;
  68626. private _toCenterVectors;
  68627. private _scaledDirection;
  68628. private _newPosition;
  68629. private _centerPosition;
  68630. /**
  68631. * Explodes meshes from a center mesh.
  68632. * @param meshes The meshes to explode.
  68633. * @param centerMesh The mesh to be center of explosion.
  68634. */
  68635. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  68636. private _setCenterMesh;
  68637. /**
  68638. * Get class name
  68639. * @returns "MeshExploder"
  68640. */
  68641. getClassName(): string;
  68642. /**
  68643. * "Exploded meshes"
  68644. * @returns Array of meshes with the centerMesh at index 0.
  68645. */
  68646. getMeshes(): Array<Mesh>;
  68647. /**
  68648. * Explodes meshes giving a specific direction
  68649. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  68650. */
  68651. explode(direction?: number): void;
  68652. }
  68653. }
  68654. declare module BABYLON {
  68655. /**
  68656. * Class used to help managing file picking and drag'n'drop
  68657. */
  68658. export class FilesInput {
  68659. /**
  68660. * List of files ready to be loaded
  68661. */
  68662. static get FilesToLoad(): {
  68663. [key: string]: File;
  68664. };
  68665. /**
  68666. * Callback called when a file is processed
  68667. */
  68668. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  68669. private _engine;
  68670. private _currentScene;
  68671. private _sceneLoadedCallback;
  68672. private _progressCallback;
  68673. private _additionalRenderLoopLogicCallback;
  68674. private _textureLoadingCallback;
  68675. private _startingProcessingFilesCallback;
  68676. private _onReloadCallback;
  68677. private _errorCallback;
  68678. private _elementToMonitor;
  68679. private _sceneFileToLoad;
  68680. private _filesToLoad;
  68681. /**
  68682. * Creates a new FilesInput
  68683. * @param engine defines the rendering engine
  68684. * @param scene defines the hosting scene
  68685. * @param sceneLoadedCallback callback called when scene is loaded
  68686. * @param progressCallback callback called to track progress
  68687. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  68688. * @param textureLoadingCallback callback called when a texture is loading
  68689. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  68690. * @param onReloadCallback callback called when a reload is requested
  68691. * @param errorCallback callback call if an error occurs
  68692. */
  68693. 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);
  68694. private _dragEnterHandler;
  68695. private _dragOverHandler;
  68696. private _dropHandler;
  68697. /**
  68698. * Calls this function to listen to drag'n'drop events on a specific DOM element
  68699. * @param elementToMonitor defines the DOM element to track
  68700. */
  68701. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  68702. /**
  68703. * Release all associated resources
  68704. */
  68705. dispose(): void;
  68706. private renderFunction;
  68707. private drag;
  68708. private drop;
  68709. private _traverseFolder;
  68710. private _processFiles;
  68711. /**
  68712. * Load files from a drop event
  68713. * @param event defines the drop event to use as source
  68714. */
  68715. loadFiles(event: any): void;
  68716. private _processReload;
  68717. /**
  68718. * Reload the current scene from the loaded files
  68719. */
  68720. reload(): void;
  68721. }
  68722. }
  68723. declare module BABYLON {
  68724. /**
  68725. * Defines the root class used to create scene optimization to use with SceneOptimizer
  68726. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68727. */
  68728. export class SceneOptimization {
  68729. /**
  68730. * Defines the priority of this optimization (0 by default which means first in the list)
  68731. */
  68732. priority: number;
  68733. /**
  68734. * Gets a string describing the action executed by the current optimization
  68735. * @returns description string
  68736. */
  68737. getDescription(): string;
  68738. /**
  68739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68740. * @param scene defines the current scene where to apply this optimization
  68741. * @param optimizer defines the current optimizer
  68742. * @returns true if everything that can be done was applied
  68743. */
  68744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68745. /**
  68746. * Creates the SceneOptimization object
  68747. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68748. * @param desc defines the description associated with the optimization
  68749. */
  68750. constructor(
  68751. /**
  68752. * Defines the priority of this optimization (0 by default which means first in the list)
  68753. */
  68754. priority?: number);
  68755. }
  68756. /**
  68757. * Defines an optimization used to reduce the size of render target textures
  68758. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68759. */
  68760. export class TextureOptimization extends SceneOptimization {
  68761. /**
  68762. * Defines the priority of this optimization (0 by default which means first in the list)
  68763. */
  68764. priority: number;
  68765. /**
  68766. * 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
  68767. */
  68768. maximumSize: number;
  68769. /**
  68770. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68771. */
  68772. step: number;
  68773. /**
  68774. * Gets a string describing the action executed by the current optimization
  68775. * @returns description string
  68776. */
  68777. getDescription(): string;
  68778. /**
  68779. * Creates the TextureOptimization object
  68780. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68781. * @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
  68782. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68783. */
  68784. constructor(
  68785. /**
  68786. * Defines the priority of this optimization (0 by default which means first in the list)
  68787. */
  68788. priority?: number,
  68789. /**
  68790. * 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
  68791. */
  68792. maximumSize?: number,
  68793. /**
  68794. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68795. */
  68796. step?: number);
  68797. /**
  68798. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68799. * @param scene defines the current scene where to apply this optimization
  68800. * @param optimizer defines the current optimizer
  68801. * @returns true if everything that can be done was applied
  68802. */
  68803. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68804. }
  68805. /**
  68806. * Defines an optimization used to increase or decrease the rendering resolution
  68807. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68808. */
  68809. export class HardwareScalingOptimization extends SceneOptimization {
  68810. /**
  68811. * Defines the priority of this optimization (0 by default which means first in the list)
  68812. */
  68813. priority: number;
  68814. /**
  68815. * Defines the maximum scale to use (2 by default)
  68816. */
  68817. maximumScale: number;
  68818. /**
  68819. * Defines the step to use between two passes (0.5 by default)
  68820. */
  68821. step: number;
  68822. private _currentScale;
  68823. private _directionOffset;
  68824. /**
  68825. * Gets a string describing the action executed by the current optimization
  68826. * @return description string
  68827. */
  68828. getDescription(): string;
  68829. /**
  68830. * Creates the HardwareScalingOptimization object
  68831. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68832. * @param maximumScale defines the maximum scale to use (2 by default)
  68833. * @param step defines the step to use between two passes (0.5 by default)
  68834. */
  68835. constructor(
  68836. /**
  68837. * Defines the priority of this optimization (0 by default which means first in the list)
  68838. */
  68839. priority?: number,
  68840. /**
  68841. * Defines the maximum scale to use (2 by default)
  68842. */
  68843. maximumScale?: number,
  68844. /**
  68845. * Defines the step to use between two passes (0.5 by default)
  68846. */
  68847. step?: number);
  68848. /**
  68849. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68850. * @param scene defines the current scene where to apply this optimization
  68851. * @param optimizer defines the current optimizer
  68852. * @returns true if everything that can be done was applied
  68853. */
  68854. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68855. }
  68856. /**
  68857. * Defines an optimization used to remove shadows
  68858. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68859. */
  68860. export class ShadowsOptimization extends SceneOptimization {
  68861. /**
  68862. * Gets a string describing the action executed by the current optimization
  68863. * @return description string
  68864. */
  68865. getDescription(): string;
  68866. /**
  68867. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68868. * @param scene defines the current scene where to apply this optimization
  68869. * @param optimizer defines the current optimizer
  68870. * @returns true if everything that can be done was applied
  68871. */
  68872. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68873. }
  68874. /**
  68875. * Defines an optimization used to turn post-processes off
  68876. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68877. */
  68878. export class PostProcessesOptimization extends SceneOptimization {
  68879. /**
  68880. * Gets a string describing the action executed by the current optimization
  68881. * @return description string
  68882. */
  68883. getDescription(): string;
  68884. /**
  68885. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68886. * @param scene defines the current scene where to apply this optimization
  68887. * @param optimizer defines the current optimizer
  68888. * @returns true if everything that can be done was applied
  68889. */
  68890. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68891. }
  68892. /**
  68893. * Defines an optimization used to turn lens flares off
  68894. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68895. */
  68896. export class LensFlaresOptimization extends SceneOptimization {
  68897. /**
  68898. * Gets a string describing the action executed by the current optimization
  68899. * @return description string
  68900. */
  68901. getDescription(): string;
  68902. /**
  68903. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68904. * @param scene defines the current scene where to apply this optimization
  68905. * @param optimizer defines the current optimizer
  68906. * @returns true if everything that can be done was applied
  68907. */
  68908. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68909. }
  68910. /**
  68911. * Defines an optimization based on user defined callback.
  68912. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68913. */
  68914. export class CustomOptimization extends SceneOptimization {
  68915. /**
  68916. * Callback called to apply the custom optimization.
  68917. */
  68918. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68919. /**
  68920. * Callback called to get custom description
  68921. */
  68922. onGetDescription: () => string;
  68923. /**
  68924. * Gets a string describing the action executed by the current optimization
  68925. * @returns description string
  68926. */
  68927. getDescription(): string;
  68928. /**
  68929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68930. * @param scene defines the current scene where to apply this optimization
  68931. * @param optimizer defines the current optimizer
  68932. * @returns true if everything that can be done was applied
  68933. */
  68934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68935. }
  68936. /**
  68937. * Defines an optimization used to turn particles off
  68938. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68939. */
  68940. export class ParticlesOptimization extends SceneOptimization {
  68941. /**
  68942. * Gets a string describing the action executed by the current optimization
  68943. * @return description string
  68944. */
  68945. getDescription(): string;
  68946. /**
  68947. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68948. * @param scene defines the current scene where to apply this optimization
  68949. * @param optimizer defines the current optimizer
  68950. * @returns true if everything that can be done was applied
  68951. */
  68952. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68953. }
  68954. /**
  68955. * Defines an optimization used to turn render targets off
  68956. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68957. */
  68958. export class RenderTargetsOptimization extends SceneOptimization {
  68959. /**
  68960. * Gets a string describing the action executed by the current optimization
  68961. * @return description string
  68962. */
  68963. getDescription(): string;
  68964. /**
  68965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68966. * @param scene defines the current scene where to apply this optimization
  68967. * @param optimizer defines the current optimizer
  68968. * @returns true if everything that can be done was applied
  68969. */
  68970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68971. }
  68972. /**
  68973. * Defines an optimization used to merge meshes with compatible materials
  68974. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68975. */
  68976. export class MergeMeshesOptimization extends SceneOptimization {
  68977. private static _UpdateSelectionTree;
  68978. /**
  68979. * Gets or sets a boolean which defines if optimization octree has to be updated
  68980. */
  68981. static get UpdateSelectionTree(): boolean;
  68982. /**
  68983. * Gets or sets a boolean which defines if optimization octree has to be updated
  68984. */
  68985. static set UpdateSelectionTree(value: boolean);
  68986. /**
  68987. * Gets a string describing the action executed by the current optimization
  68988. * @return description string
  68989. */
  68990. getDescription(): string;
  68991. private _canBeMerged;
  68992. /**
  68993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68994. * @param scene defines the current scene where to apply this optimization
  68995. * @param optimizer defines the current optimizer
  68996. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68997. * @returns true if everything that can be done was applied
  68998. */
  68999. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  69000. }
  69001. /**
  69002. * Defines a list of options used by SceneOptimizer
  69003. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69004. */
  69005. export class SceneOptimizerOptions {
  69006. /**
  69007. * Defines the target frame rate to reach (60 by default)
  69008. */
  69009. targetFrameRate: number;
  69010. /**
  69011. * Defines the interval between two checkes (2000ms by default)
  69012. */
  69013. trackerDuration: number;
  69014. /**
  69015. * Gets the list of optimizations to apply
  69016. */
  69017. optimizations: SceneOptimization[];
  69018. /**
  69019. * Creates a new list of options used by SceneOptimizer
  69020. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  69021. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  69022. */
  69023. constructor(
  69024. /**
  69025. * Defines the target frame rate to reach (60 by default)
  69026. */
  69027. targetFrameRate?: number,
  69028. /**
  69029. * Defines the interval between two checkes (2000ms by default)
  69030. */
  69031. trackerDuration?: number);
  69032. /**
  69033. * Add a new optimization
  69034. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  69035. * @returns the current SceneOptimizerOptions
  69036. */
  69037. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  69038. /**
  69039. * Add a new custom optimization
  69040. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  69041. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  69042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  69043. * @returns the current SceneOptimizerOptions
  69044. */
  69045. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  69046. /**
  69047. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  69048. * @param targetFrameRate defines the target frame rate (60 by default)
  69049. * @returns a SceneOptimizerOptions object
  69050. */
  69051. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69052. /**
  69053. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  69054. * @param targetFrameRate defines the target frame rate (60 by default)
  69055. * @returns a SceneOptimizerOptions object
  69056. */
  69057. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69058. /**
  69059. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  69060. * @param targetFrameRate defines the target frame rate (60 by default)
  69061. * @returns a SceneOptimizerOptions object
  69062. */
  69063. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  69064. }
  69065. /**
  69066. * Class used to run optimizations in order to reach a target frame rate
  69067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  69068. */
  69069. export class SceneOptimizer implements IDisposable {
  69070. private _isRunning;
  69071. private _options;
  69072. private _scene;
  69073. private _currentPriorityLevel;
  69074. private _targetFrameRate;
  69075. private _trackerDuration;
  69076. private _currentFrameRate;
  69077. private _sceneDisposeObserver;
  69078. private _improvementMode;
  69079. /**
  69080. * Defines an observable called when the optimizer reaches the target frame rate
  69081. */
  69082. onSuccessObservable: Observable<SceneOptimizer>;
  69083. /**
  69084. * Defines an observable called when the optimizer enables an optimization
  69085. */
  69086. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  69087. /**
  69088. * Defines an observable called when the optimizer is not able to reach the target frame rate
  69089. */
  69090. onFailureObservable: Observable<SceneOptimizer>;
  69091. /**
  69092. * Gets a boolean indicating if the optimizer is in improvement mode
  69093. */
  69094. get isInImprovementMode(): boolean;
  69095. /**
  69096. * Gets the current priority level (0 at start)
  69097. */
  69098. get currentPriorityLevel(): number;
  69099. /**
  69100. * Gets the current frame rate checked by the SceneOptimizer
  69101. */
  69102. get currentFrameRate(): number;
  69103. /**
  69104. * Gets or sets the current target frame rate (60 by default)
  69105. */
  69106. get targetFrameRate(): number;
  69107. /**
  69108. * Gets or sets the current target frame rate (60 by default)
  69109. */
  69110. set targetFrameRate(value: number);
  69111. /**
  69112. * Gets or sets the current interval between two checks (every 2000ms by default)
  69113. */
  69114. get trackerDuration(): number;
  69115. /**
  69116. * Gets or sets the current interval between two checks (every 2000ms by default)
  69117. */
  69118. set trackerDuration(value: number);
  69119. /**
  69120. * Gets the list of active optimizations
  69121. */
  69122. get optimizations(): SceneOptimization[];
  69123. /**
  69124. * Creates a new SceneOptimizer
  69125. * @param scene defines the scene to work on
  69126. * @param options defines the options to use with the SceneOptimizer
  69127. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  69128. * @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)
  69129. */
  69130. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  69131. /**
  69132. * Stops the current optimizer
  69133. */
  69134. stop(): void;
  69135. /**
  69136. * Reset the optimizer to initial step (current priority level = 0)
  69137. */
  69138. reset(): void;
  69139. /**
  69140. * Start the optimizer. By default it will try to reach a specific framerate
  69141. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  69142. */
  69143. start(): void;
  69144. private _checkCurrentState;
  69145. /**
  69146. * Release all resources
  69147. */
  69148. dispose(): void;
  69149. /**
  69150. * Helper function to create a SceneOptimizer with one single line of code
  69151. * @param scene defines the scene to work on
  69152. * @param options defines the options to use with the SceneOptimizer
  69153. * @param onSuccess defines a callback to call on success
  69154. * @param onFailure defines a callback to call on failure
  69155. * @returns the new SceneOptimizer object
  69156. */
  69157. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  69158. }
  69159. }
  69160. declare module BABYLON {
  69161. /**
  69162. * Class used to serialize a scene into a string
  69163. */
  69164. export class SceneSerializer {
  69165. /**
  69166. * Clear cache used by a previous serialization
  69167. */
  69168. static ClearCache(): void;
  69169. /**
  69170. * Serialize a scene into a JSON compatible object
  69171. * @param scene defines the scene to serialize
  69172. * @returns a JSON compatible object
  69173. */
  69174. static Serialize(scene: Scene): any;
  69175. /**
  69176. * Serialize a mesh into a JSON compatible object
  69177. * @param toSerialize defines the mesh to serialize
  69178. * @param withParents defines if parents must be serialized as well
  69179. * @param withChildren defines if children must be serialized as well
  69180. * @returns a JSON compatible object
  69181. */
  69182. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  69183. }
  69184. }
  69185. declare module BABYLON {
  69186. /**
  69187. * Class used to host texture specific utilities
  69188. */
  69189. export class TextureTools {
  69190. /**
  69191. * Uses the GPU to create a copy texture rescaled at a given size
  69192. * @param texture Texture to copy from
  69193. * @param width defines the desired width
  69194. * @param height defines the desired height
  69195. * @param useBilinearMode defines if bilinear mode has to be used
  69196. * @return the generated texture
  69197. */
  69198. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  69199. }
  69200. }
  69201. declare module BABYLON {
  69202. /**
  69203. * This represents the different options available for the video capture.
  69204. */
  69205. export interface VideoRecorderOptions {
  69206. /** Defines the mime type of the video. */
  69207. mimeType: string;
  69208. /** Defines the FPS the video should be recorded at. */
  69209. fps: number;
  69210. /** Defines the chunk size for the recording data. */
  69211. recordChunckSize: number;
  69212. /** The audio tracks to attach to the recording. */
  69213. audioTracks?: MediaStreamTrack[];
  69214. }
  69215. /**
  69216. * This can help with recording videos from BabylonJS.
  69217. * This is based on the available WebRTC functionalities of the browser.
  69218. *
  69219. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  69220. */
  69221. export class VideoRecorder {
  69222. private static readonly _defaultOptions;
  69223. /**
  69224. * Returns whether or not the VideoRecorder is available in your browser.
  69225. * @param engine Defines the Babylon Engine.
  69226. * @returns true if supported otherwise false.
  69227. */
  69228. static IsSupported(engine: Engine): boolean;
  69229. private readonly _options;
  69230. private _canvas;
  69231. private _mediaRecorder;
  69232. private _recordedChunks;
  69233. private _fileName;
  69234. private _resolve;
  69235. private _reject;
  69236. /**
  69237. * True when a recording is already in progress.
  69238. */
  69239. get isRecording(): boolean;
  69240. /**
  69241. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  69242. * @param engine Defines the BabylonJS Engine you wish to record.
  69243. * @param options Defines options that can be used to customize the capture.
  69244. */
  69245. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  69246. /**
  69247. * Stops the current recording before the default capture timeout passed in the startRecording function.
  69248. */
  69249. stopRecording(): void;
  69250. /**
  69251. * Starts recording the canvas for a max duration specified in parameters.
  69252. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  69253. * If null no automatic download will start and you can rely on the promise to get the data back.
  69254. * @param maxDuration Defines the maximum recording time in seconds.
  69255. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  69256. * @return A promise callback at the end of the recording with the video data in Blob.
  69257. */
  69258. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  69259. /**
  69260. * Releases internal resources used during the recording.
  69261. */
  69262. dispose(): void;
  69263. private _handleDataAvailable;
  69264. private _handleError;
  69265. private _handleStop;
  69266. }
  69267. }
  69268. declare module BABYLON {
  69269. /**
  69270. * Class containing a set of static utilities functions for screenshots
  69271. */
  69272. export class ScreenshotTools {
  69273. /**
  69274. * Captures a screenshot of the current rendering
  69275. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69276. * @param engine defines the rendering engine
  69277. * @param camera defines the source camera
  69278. * @param size This parameter can be set to a single number or to an object with the
  69279. * following (optional) properties: precision, width, height. If a single number is passed,
  69280. * it will be used for both width and height. If an object is passed, the screenshot size
  69281. * will be derived from the parameters. The precision property is a multiplier allowing
  69282. * rendering at a higher or lower resolution
  69283. * @param successCallback defines the callback receives a single parameter which contains the
  69284. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69285. * src parameter of an <img> to display it
  69286. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69287. * Check your browser for supported MIME types
  69288. */
  69289. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  69290. /**
  69291. * Captures a screenshot of the current rendering
  69292. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69293. * @param engine defines the rendering engine
  69294. * @param camera defines the source camera
  69295. * @param size This parameter can be set to a single number or to an object with the
  69296. * following (optional) properties: precision, width, height. If a single number is passed,
  69297. * it will be used for both width and height. If an object is passed, the screenshot size
  69298. * will be derived from the parameters. The precision property is a multiplier allowing
  69299. * rendering at a higher or lower resolution
  69300. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  69301. * Check your browser for supported MIME types
  69302. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69303. * to the src parameter of an <img> to display it
  69304. */
  69305. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  69306. /**
  69307. * Generates an image screenshot from the specified camera.
  69308. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69309. * @param engine The engine to use for rendering
  69310. * @param camera The camera to use for rendering
  69311. * @param size This parameter can be set to a single number or to an object with the
  69312. * following (optional) properties: precision, width, height. If a single number is passed,
  69313. * it will be used for both width and height. If an object is passed, the screenshot size
  69314. * will be derived from the parameters. The precision property is a multiplier allowing
  69315. * rendering at a higher or lower resolution
  69316. * @param successCallback The callback receives a single parameter which contains the
  69317. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  69318. * src parameter of an <img> to display it
  69319. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69320. * Check your browser for supported MIME types
  69321. * @param samples Texture samples (default: 1)
  69322. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69323. * @param fileName A name for for the downloaded file.
  69324. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69325. */
  69326. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  69327. /**
  69328. * Generates an image screenshot from the specified camera.
  69329. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  69330. * @param engine The engine to use for rendering
  69331. * @param camera The camera to use for rendering
  69332. * @param size This parameter can be set to a single number or to an object with the
  69333. * following (optional) properties: precision, width, height. If a single number is passed,
  69334. * it will be used for both width and height. If an object is passed, the screenshot size
  69335. * will be derived from the parameters. The precision property is a multiplier allowing
  69336. * rendering at a higher or lower resolution
  69337. * @param mimeType The MIME type of the screenshot image (default: image/png).
  69338. * Check your browser for supported MIME types
  69339. * @param samples Texture samples (default: 1)
  69340. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  69341. * @param fileName A name for for the downloaded file.
  69342. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  69343. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  69344. * to the src parameter of an <img> to display it
  69345. */
  69346. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  69347. /**
  69348. * Gets height and width for screenshot size
  69349. * @private
  69350. */
  69351. private static _getScreenshotSize;
  69352. }
  69353. }
  69354. declare module BABYLON {
  69355. /**
  69356. * Interface for a data buffer
  69357. */
  69358. export interface IDataBuffer {
  69359. /**
  69360. * Reads bytes from the data buffer.
  69361. * @param byteOffset The byte offset to read
  69362. * @param byteLength The byte length to read
  69363. * @returns A promise that resolves when the bytes are read
  69364. */
  69365. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  69366. /**
  69367. * The byte length of the buffer.
  69368. */
  69369. readonly byteLength: number;
  69370. }
  69371. /**
  69372. * Utility class for reading from a data buffer
  69373. */
  69374. export class DataReader {
  69375. /**
  69376. * The data buffer associated with this data reader.
  69377. */
  69378. readonly buffer: IDataBuffer;
  69379. /**
  69380. * The current byte offset from the beginning of the data buffer.
  69381. */
  69382. byteOffset: number;
  69383. private _dataView;
  69384. private _dataByteOffset;
  69385. /**
  69386. * Constructor
  69387. * @param buffer The buffer to read
  69388. */
  69389. constructor(buffer: IDataBuffer);
  69390. /**
  69391. * Loads the given byte length.
  69392. * @param byteLength The byte length to load
  69393. * @returns A promise that resolves when the load is complete
  69394. */
  69395. loadAsync(byteLength: number): Promise<void>;
  69396. /**
  69397. * Read a unsigned 32-bit integer from the currently loaded data range.
  69398. * @returns The 32-bit integer read
  69399. */
  69400. readUint32(): number;
  69401. /**
  69402. * Read a byte array from the currently loaded data range.
  69403. * @param byteLength The byte length to read
  69404. * @returns The byte array read
  69405. */
  69406. readUint8Array(byteLength: number): Uint8Array;
  69407. /**
  69408. * Read a string from the currently loaded data range.
  69409. * @param byteLength The byte length to read
  69410. * @returns The string read
  69411. */
  69412. readString(byteLength: number): string;
  69413. /**
  69414. * Skips the given byte length the currently loaded data range.
  69415. * @param byteLength The byte length to skip
  69416. */
  69417. skipBytes(byteLength: number): void;
  69418. }
  69419. }
  69420. declare module BABYLON {
  69421. /**
  69422. * Class for storing data to local storage if available or in-memory storage otherwise
  69423. */
  69424. export class DataStorage {
  69425. private static _Storage;
  69426. private static _GetStorage;
  69427. /**
  69428. * Reads a string from the data storage
  69429. * @param key The key to read
  69430. * @param defaultValue The value if the key doesn't exist
  69431. * @returns The string value
  69432. */
  69433. static ReadString(key: string, defaultValue: string): string;
  69434. /**
  69435. * Writes a string to the data storage
  69436. * @param key The key to write
  69437. * @param value The value to write
  69438. */
  69439. static WriteString(key: string, value: string): void;
  69440. /**
  69441. * Reads a boolean from the data storage
  69442. * @param key The key to read
  69443. * @param defaultValue The value if the key doesn't exist
  69444. * @returns The boolean value
  69445. */
  69446. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  69447. /**
  69448. * Writes a boolean to the data storage
  69449. * @param key The key to write
  69450. * @param value The value to write
  69451. */
  69452. static WriteBoolean(key: string, value: boolean): void;
  69453. /**
  69454. * Reads a number from the data storage
  69455. * @param key The key to read
  69456. * @param defaultValue The value if the key doesn't exist
  69457. * @returns The number value
  69458. */
  69459. static ReadNumber(key: string, defaultValue: number): number;
  69460. /**
  69461. * Writes a number to the data storage
  69462. * @param key The key to write
  69463. * @param value The value to write
  69464. */
  69465. static WriteNumber(key: string, value: number): void;
  69466. }
  69467. }
  69468. declare module BABYLON {
  69469. /**
  69470. * Options used for hit testing
  69471. */
  69472. export interface IWebXRLegacyHitTestOptions {
  69473. /**
  69474. * Only test when user interacted with the scene. Default - hit test every frame
  69475. */
  69476. testOnPointerDownOnly?: boolean;
  69477. /**
  69478. * The node to use to transform the local results to world coordinates
  69479. */
  69480. worldParentNode?: TransformNode;
  69481. }
  69482. /**
  69483. * Interface defining the babylon result of raycasting/hit-test
  69484. */
  69485. export interface IWebXRLegacyHitResult {
  69486. /**
  69487. * Transformation matrix that can be applied to a node that will put it in the hit point location
  69488. */
  69489. transformationMatrix: Matrix;
  69490. /**
  69491. * The native hit test result
  69492. */
  69493. xrHitResult: XRHitResult | XRHitTestResult;
  69494. }
  69495. /**
  69496. * The currently-working hit-test module.
  69497. * Hit test (or Ray-casting) is used to interact with the real world.
  69498. * For further information read here - https://github.com/immersive-web/hit-test
  69499. */
  69500. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  69501. /**
  69502. * options to use when constructing this feature
  69503. */
  69504. readonly options: IWebXRLegacyHitTestOptions;
  69505. private _direction;
  69506. private _mat;
  69507. private _onSelectEnabled;
  69508. private _origin;
  69509. /**
  69510. * The module's name
  69511. */
  69512. static readonly Name: string;
  69513. /**
  69514. * The (Babylon) version of this module.
  69515. * This is an integer representing the implementation version.
  69516. * This number does not correspond to the WebXR specs version
  69517. */
  69518. static readonly Version: number;
  69519. /**
  69520. * Populated with the last native XR Hit Results
  69521. */
  69522. lastNativeXRHitResults: XRHitResult[];
  69523. /**
  69524. * Triggered when new babylon (transformed) hit test results are available
  69525. */
  69526. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  69527. /**
  69528. * Creates a new instance of the (legacy version) hit test feature
  69529. * @param _xrSessionManager an instance of WebXRSessionManager
  69530. * @param options options to use when constructing this feature
  69531. */
  69532. constructor(_xrSessionManager: WebXRSessionManager,
  69533. /**
  69534. * options to use when constructing this feature
  69535. */
  69536. options?: IWebXRLegacyHitTestOptions);
  69537. /**
  69538. * execute a hit test with an XR Ray
  69539. *
  69540. * @param xrSession a native xrSession that will execute this hit test
  69541. * @param xrRay the ray (position and direction) to use for ray-casting
  69542. * @param referenceSpace native XR reference space to use for the hit-test
  69543. * @param filter filter function that will filter the results
  69544. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69545. */
  69546. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  69547. /**
  69548. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  69549. * @param event the (select) event to use to select with
  69550. * @param referenceSpace the reference space to use for this hit test
  69551. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  69552. */
  69553. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69554. /**
  69555. * attach this feature
  69556. * Will usually be called by the features manager
  69557. *
  69558. * @returns true if successful.
  69559. */
  69560. attach(): boolean;
  69561. /**
  69562. * detach this feature.
  69563. * Will usually be called by the features manager
  69564. *
  69565. * @returns true if successful.
  69566. */
  69567. detach(): boolean;
  69568. /**
  69569. * Dispose this feature and all of the resources attached
  69570. */
  69571. dispose(): void;
  69572. protected _onXRFrame(frame: XRFrame): void;
  69573. private _onHitTestResults;
  69574. private _onSelect;
  69575. }
  69576. }
  69577. declare module BABYLON {
  69578. /**
  69579. * Options used in the plane detector module
  69580. */
  69581. export interface IWebXRPlaneDetectorOptions {
  69582. /**
  69583. * The node to use to transform the local results to world coordinates
  69584. */
  69585. worldParentNode?: TransformNode;
  69586. }
  69587. /**
  69588. * A babylon interface for a WebXR plane.
  69589. * A Plane is actually a polygon, built from N points in space
  69590. *
  69591. * Supported in chrome 79, not supported in canary 81 ATM
  69592. */
  69593. export interface IWebXRPlane {
  69594. /**
  69595. * a babylon-assigned ID for this polygon
  69596. */
  69597. id: number;
  69598. /**
  69599. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  69600. */
  69601. polygonDefinition: Array<Vector3>;
  69602. /**
  69603. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  69604. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  69605. */
  69606. transformationMatrix: Matrix;
  69607. /**
  69608. * the native xr-plane object
  69609. */
  69610. xrPlane: XRPlane;
  69611. }
  69612. /**
  69613. * The plane detector is used to detect planes in the real world when in AR
  69614. * For more information see https://github.com/immersive-web/real-world-geometry/
  69615. */
  69616. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  69617. private _options;
  69618. private _detectedPlanes;
  69619. private _enabled;
  69620. private _lastFrameDetected;
  69621. /**
  69622. * The module's name
  69623. */
  69624. static readonly Name: string;
  69625. /**
  69626. * The (Babylon) version of this module.
  69627. * This is an integer representing the implementation version.
  69628. * This number does not correspond to the WebXR specs version
  69629. */
  69630. static readonly Version: number;
  69631. /**
  69632. * Observers registered here will be executed when a new plane was added to the session
  69633. */
  69634. onPlaneAddedObservable: Observable<IWebXRPlane>;
  69635. /**
  69636. * Observers registered here will be executed when a plane is no longer detected in the session
  69637. */
  69638. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  69639. /**
  69640. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  69641. * This can execute N times every frame
  69642. */
  69643. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  69644. /**
  69645. * construct a new Plane Detector
  69646. * @param _xrSessionManager an instance of xr Session manager
  69647. * @param _options configuration to use when constructing this feature
  69648. */
  69649. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  69650. /**
  69651. * Dispose this feature and all of the resources attached
  69652. */
  69653. dispose(): void;
  69654. protected _onXRFrame(frame: XRFrame): void;
  69655. private _init;
  69656. private _updatePlaneWithXRPlane;
  69657. /**
  69658. * avoiding using Array.find for global support.
  69659. * @param xrPlane the plane to find in the array
  69660. */
  69661. private findIndexInPlaneArray;
  69662. }
  69663. }
  69664. declare module BABYLON {
  69665. /**
  69666. * Configuration options of the anchor system
  69667. */
  69668. export interface IWebXRAnchorSystemOptions {
  69669. /**
  69670. * Should a new anchor be added every time a select event is triggered
  69671. */
  69672. addAnchorOnSelect?: boolean;
  69673. /**
  69674. * should the anchor system use plane detection.
  69675. * If set to true, the plane-detection feature should be set using setPlaneDetector
  69676. */
  69677. usePlaneDetection?: boolean;
  69678. /**
  69679. * a node that will be used to convert local to world coordinates
  69680. */
  69681. worldParentNode?: TransformNode;
  69682. }
  69683. /**
  69684. * A babylon container for an XR Anchor
  69685. */
  69686. export interface IWebXRAnchor {
  69687. /**
  69688. * A babylon-assigned ID for this anchor
  69689. */
  69690. id: number;
  69691. /**
  69692. * Transformation matrix to apply to an object attached to this anchor
  69693. */
  69694. transformationMatrix: Matrix;
  69695. /**
  69696. * The native anchor object
  69697. */
  69698. xrAnchor: XRAnchor;
  69699. }
  69700. /**
  69701. * An implementation of the anchor system of WebXR.
  69702. * Note that the current documented implementation is not available in any browser. Future implementations
  69703. * will use the frame to create an anchor and not the session or a detected plane
  69704. * For further information see https://github.com/immersive-web/anchors/
  69705. */
  69706. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  69707. private _options;
  69708. private _enabled;
  69709. private _hitTestModule;
  69710. private _lastFrameDetected;
  69711. private _onSelect;
  69712. private _planeDetector;
  69713. private _trackedAnchors;
  69714. /**
  69715. * The module's name
  69716. */
  69717. static readonly Name: string;
  69718. /**
  69719. * The (Babylon) version of this module.
  69720. * This is an integer representing the implementation version.
  69721. * This number does not correspond to the WebXR specs version
  69722. */
  69723. static readonly Version: number;
  69724. /**
  69725. * Observers registered here will be executed when a new anchor was added to the session
  69726. */
  69727. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  69728. /**
  69729. * Observers registered here will be executed when an anchor was removed from the session
  69730. */
  69731. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  69732. /**
  69733. * Observers registered here will be executed when an existing anchor updates
  69734. * This can execute N times every frame
  69735. */
  69736. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  69737. /**
  69738. * constructs a new anchor system
  69739. * @param _xrSessionManager an instance of WebXRSessionManager
  69740. * @param _options configuration object for this feature
  69741. */
  69742. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  69743. /**
  69744. * Add anchor at a specific XR point.
  69745. *
  69746. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  69747. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  69748. * @returns a promise the fulfills when the anchor was created
  69749. */
  69750. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  69751. /**
  69752. * attach this feature
  69753. * Will usually be called by the features manager
  69754. *
  69755. * @returns true if successful.
  69756. */
  69757. attach(): boolean;
  69758. /**
  69759. * detach this feature.
  69760. * Will usually be called by the features manager
  69761. *
  69762. * @returns true if successful.
  69763. */
  69764. detach(): boolean;
  69765. /**
  69766. * Dispose this feature and all of the resources attached
  69767. */
  69768. dispose(): void;
  69769. /**
  69770. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  69771. * @param hitTestModule the hit-test module to use.
  69772. */
  69773. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  69774. /**
  69775. * set the plane detector to use in order to create anchors from frames
  69776. * @param planeDetector the plane-detector module to use
  69777. * @param enable enable plane-anchors. default is true
  69778. */
  69779. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  69780. protected _onXRFrame(frame: XRFrame): void;
  69781. /**
  69782. * avoiding using Array.find for global support.
  69783. * @param xrAnchor the plane to find in the array
  69784. */
  69785. private _findIndexInAnchorArray;
  69786. private _updateAnchorWithXRFrame;
  69787. }
  69788. }
  69789. declare module BABYLON {
  69790. /**
  69791. * Options interface for the background remover plugin
  69792. */
  69793. export interface IWebXRBackgroundRemoverOptions {
  69794. /**
  69795. * Further background meshes to disable when entering AR
  69796. */
  69797. backgroundMeshes?: AbstractMesh[];
  69798. /**
  69799. * flags to configure the removal of the environment helper.
  69800. * If not set, the entire background will be removed. If set, flags should be set as well.
  69801. */
  69802. environmentHelperRemovalFlags?: {
  69803. /**
  69804. * Should the skybox be removed (default false)
  69805. */
  69806. skyBox?: boolean;
  69807. /**
  69808. * Should the ground be removed (default false)
  69809. */
  69810. ground?: boolean;
  69811. };
  69812. /**
  69813. * don't disable the environment helper
  69814. */
  69815. ignoreEnvironmentHelper?: boolean;
  69816. }
  69817. /**
  69818. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69819. */
  69820. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69821. /**
  69822. * read-only options to be used in this module
  69823. */
  69824. readonly options: IWebXRBackgroundRemoverOptions;
  69825. /**
  69826. * The module's name
  69827. */
  69828. static readonly Name: string;
  69829. /**
  69830. * The (Babylon) version of this module.
  69831. * This is an integer representing the implementation version.
  69832. * This number does not correspond to the WebXR specs version
  69833. */
  69834. static readonly Version: number;
  69835. /**
  69836. * registered observers will be triggered when the background state changes
  69837. */
  69838. onBackgroundStateChangedObservable: Observable<boolean>;
  69839. /**
  69840. * constructs a new background remover module
  69841. * @param _xrSessionManager the session manager for this module
  69842. * @param options read-only options to be used in this module
  69843. */
  69844. constructor(_xrSessionManager: WebXRSessionManager,
  69845. /**
  69846. * read-only options to be used in this module
  69847. */
  69848. options?: IWebXRBackgroundRemoverOptions);
  69849. /**
  69850. * attach this feature
  69851. * Will usually be called by the features manager
  69852. *
  69853. * @returns true if successful.
  69854. */
  69855. attach(): boolean;
  69856. /**
  69857. * detach this feature.
  69858. * Will usually be called by the features manager
  69859. *
  69860. * @returns true if successful.
  69861. */
  69862. detach(): boolean;
  69863. /**
  69864. * Dispose this feature and all of the resources attached
  69865. */
  69866. dispose(): void;
  69867. protected _onXRFrame(_xrFrame: XRFrame): void;
  69868. private _setBackgroundState;
  69869. }
  69870. }
  69871. declare module BABYLON {
  69872. /**
  69873. * Options for the controller physics feature
  69874. */
  69875. export class IWebXRControllerPhysicsOptions {
  69876. /**
  69877. * Should the headset get its own impostor
  69878. */
  69879. enableHeadsetImpostor?: boolean;
  69880. /**
  69881. * Optional parameters for the headset impostor
  69882. */
  69883. headsetImpostorParams?: {
  69884. /**
  69885. * The type of impostor to create. Default is sphere
  69886. */
  69887. impostorType: number;
  69888. /**
  69889. * the size of the impostor. Defaults to 10cm
  69890. */
  69891. impostorSize?: number | {
  69892. width: number;
  69893. height: number;
  69894. depth: number;
  69895. };
  69896. /**
  69897. * Friction definitions
  69898. */
  69899. friction?: number;
  69900. /**
  69901. * Restitution
  69902. */
  69903. restitution?: number;
  69904. };
  69905. /**
  69906. * The physics properties of the future impostors
  69907. */
  69908. physicsProperties?: {
  69909. /**
  69910. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69911. * Note that this requires a physics engine that supports mesh impostors!
  69912. */
  69913. useControllerMesh?: boolean;
  69914. /**
  69915. * The type of impostor to create. Default is sphere
  69916. */
  69917. impostorType?: number;
  69918. /**
  69919. * the size of the impostor. Defaults to 10cm
  69920. */
  69921. impostorSize?: number | {
  69922. width: number;
  69923. height: number;
  69924. depth: number;
  69925. };
  69926. /**
  69927. * Friction definitions
  69928. */
  69929. friction?: number;
  69930. /**
  69931. * Restitution
  69932. */
  69933. restitution?: number;
  69934. };
  69935. /**
  69936. * the xr input to use with this pointer selection
  69937. */
  69938. xrInput: WebXRInput;
  69939. }
  69940. /**
  69941. * Add physics impostor to your webxr controllers,
  69942. * including naive calculation of their linear and angular velocity
  69943. */
  69944. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69945. private readonly _options;
  69946. private _attachController;
  69947. private _controllers;
  69948. private _debugMode;
  69949. private _delta;
  69950. private _headsetImpostor?;
  69951. private _headsetMesh?;
  69952. private _lastTimestamp;
  69953. private _tmpQuaternion;
  69954. private _tmpVector;
  69955. /**
  69956. * The module's name
  69957. */
  69958. static readonly Name: string;
  69959. /**
  69960. * The (Babylon) version of this module.
  69961. * This is an integer representing the implementation version.
  69962. * This number does not correspond to the webxr specs version
  69963. */
  69964. static readonly Version: number;
  69965. /**
  69966. * Construct a new Controller Physics Feature
  69967. * @param _xrSessionManager the corresponding xr session manager
  69968. * @param _options options to create this feature with
  69969. */
  69970. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69971. /**
  69972. * @hidden
  69973. * enable debugging - will show console outputs and the impostor mesh
  69974. */
  69975. _enablePhysicsDebug(): void;
  69976. /**
  69977. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69978. * @param xrController the controller to add
  69979. */
  69980. addController(xrController: WebXRInputSource): void;
  69981. /**
  69982. * attach this feature
  69983. * Will usually be called by the features manager
  69984. *
  69985. * @returns true if successful.
  69986. */
  69987. attach(): boolean;
  69988. /**
  69989. * detach this feature.
  69990. * Will usually be called by the features manager
  69991. *
  69992. * @returns true if successful.
  69993. */
  69994. detach(): boolean;
  69995. /**
  69996. * Get the headset impostor, if enabled
  69997. * @returns the impostor
  69998. */
  69999. getHeadsetImpostor(): PhysicsImpostor | undefined;
  70000. /**
  70001. * Get the physics impostor of a specific controller.
  70002. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  70003. * @param controller the controller or the controller id of which to get the impostor
  70004. * @returns the impostor or null
  70005. */
  70006. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  70007. /**
  70008. * Update the physics properties provided in the constructor
  70009. * @param newProperties the new properties object
  70010. */
  70011. setPhysicsProperties(newProperties: {
  70012. impostorType?: number;
  70013. impostorSize?: number | {
  70014. width: number;
  70015. height: number;
  70016. depth: number;
  70017. };
  70018. friction?: number;
  70019. restitution?: number;
  70020. }): void;
  70021. protected _onXRFrame(_xrFrame: any): void;
  70022. private _detachController;
  70023. }
  70024. }
  70025. declare module BABYLON {
  70026. /**
  70027. * Options used for hit testing (version 2)
  70028. */
  70029. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  70030. /**
  70031. * Do not create a permanent hit test. Will usually be used when only
  70032. * transient inputs are needed.
  70033. */
  70034. disablePermanentHitTest?: boolean;
  70035. /**
  70036. * Enable transient (for example touch-based) hit test inspections
  70037. */
  70038. enableTransientHitTest?: boolean;
  70039. /**
  70040. * Offset ray for the permanent hit test
  70041. */
  70042. offsetRay?: Vector3;
  70043. /**
  70044. * Offset ray for the transient hit test
  70045. */
  70046. transientOffsetRay?: Vector3;
  70047. /**
  70048. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  70049. */
  70050. useReferenceSpace?: boolean;
  70051. }
  70052. /**
  70053. * Interface defining the babylon result of hit-test
  70054. */
  70055. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  70056. /**
  70057. * The input source that generated this hit test (if transient)
  70058. */
  70059. inputSource?: XRInputSource;
  70060. /**
  70061. * Is this a transient hit test
  70062. */
  70063. isTransient?: boolean;
  70064. /**
  70065. * Position of the hit test result
  70066. */
  70067. position: Vector3;
  70068. /**
  70069. * Rotation of the hit test result
  70070. */
  70071. rotationQuaternion: Quaternion;
  70072. }
  70073. /**
  70074. * The currently-working hit-test module.
  70075. * Hit test (or Ray-casting) is used to interact with the real world.
  70076. * For further information read here - https://github.com/immersive-web/hit-test
  70077. *
  70078. * Tested on chrome (mobile) 80.
  70079. */
  70080. export class WebXRHitTest extends WebXRAbstractFeature {
  70081. /**
  70082. * options to use when constructing this feature
  70083. */
  70084. readonly options: IWebXRHitTestOptions;
  70085. private _tmpMat;
  70086. private _tmpPos;
  70087. private _tmpQuat;
  70088. private _transientXrHitTestSource;
  70089. private _xrHitTestSource;
  70090. private initHitTestSource;
  70091. /**
  70092. * The module's name
  70093. */
  70094. static readonly Name: string;
  70095. /**
  70096. * The (Babylon) version of this module.
  70097. * This is an integer representing the implementation version.
  70098. * This number does not correspond to the WebXR specs version
  70099. */
  70100. static readonly Version: number;
  70101. /**
  70102. * When set to true, each hit test will have its own position/rotation objects
  70103. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  70104. * the developers will clone them or copy them as they see fit.
  70105. */
  70106. autoCloneTransformation: boolean;
  70107. /**
  70108. * Populated with the last native XR Hit Results
  70109. */
  70110. lastNativeXRHitResults: XRHitResult[];
  70111. /**
  70112. * Triggered when new babylon (transformed) hit test results are available
  70113. */
  70114. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  70115. /**
  70116. * Use this to temporarily pause hit test checks.
  70117. */
  70118. paused: boolean;
  70119. /**
  70120. * Creates a new instance of the hit test feature
  70121. * @param _xrSessionManager an instance of WebXRSessionManager
  70122. * @param options options to use when constructing this feature
  70123. */
  70124. constructor(_xrSessionManager: WebXRSessionManager,
  70125. /**
  70126. * options to use when constructing this feature
  70127. */
  70128. options?: IWebXRHitTestOptions);
  70129. /**
  70130. * attach this feature
  70131. * Will usually be called by the features manager
  70132. *
  70133. * @returns true if successful.
  70134. */
  70135. attach(): boolean;
  70136. /**
  70137. * detach this feature.
  70138. * Will usually be called by the features manager
  70139. *
  70140. * @returns true if successful.
  70141. */
  70142. detach(): boolean;
  70143. /**
  70144. * Dispose this feature and all of the resources attached
  70145. */
  70146. dispose(): void;
  70147. protected _onXRFrame(frame: XRFrame): void;
  70148. private _processWebXRHitTestResult;
  70149. }
  70150. }
  70151. declare module BABYLON {
  70152. /**
  70153. * The motion controller class for all microsoft mixed reality controllers
  70154. */
  70155. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  70156. protected readonly _mapping: {
  70157. defaultButton: {
  70158. valueNodeName: string;
  70159. unpressedNodeName: string;
  70160. pressedNodeName: string;
  70161. };
  70162. defaultAxis: {
  70163. valueNodeName: string;
  70164. minNodeName: string;
  70165. maxNodeName: string;
  70166. };
  70167. buttons: {
  70168. "xr-standard-trigger": {
  70169. rootNodeName: string;
  70170. componentProperty: string;
  70171. states: string[];
  70172. };
  70173. "xr-standard-squeeze": {
  70174. rootNodeName: string;
  70175. componentProperty: string;
  70176. states: string[];
  70177. };
  70178. "xr-standard-touchpad": {
  70179. rootNodeName: string;
  70180. labelAnchorNodeName: string;
  70181. touchPointNodeName: string;
  70182. };
  70183. "xr-standard-thumbstick": {
  70184. rootNodeName: string;
  70185. componentProperty: string;
  70186. states: string[];
  70187. };
  70188. };
  70189. axes: {
  70190. "xr-standard-touchpad": {
  70191. "x-axis": {
  70192. rootNodeName: string;
  70193. };
  70194. "y-axis": {
  70195. rootNodeName: string;
  70196. };
  70197. };
  70198. "xr-standard-thumbstick": {
  70199. "x-axis": {
  70200. rootNodeName: string;
  70201. };
  70202. "y-axis": {
  70203. rootNodeName: string;
  70204. };
  70205. };
  70206. };
  70207. };
  70208. /**
  70209. * The base url used to load the left and right controller models
  70210. */
  70211. static MODEL_BASE_URL: string;
  70212. /**
  70213. * The name of the left controller model file
  70214. */
  70215. static MODEL_LEFT_FILENAME: string;
  70216. /**
  70217. * The name of the right controller model file
  70218. */
  70219. static MODEL_RIGHT_FILENAME: string;
  70220. profileId: string;
  70221. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70222. protected _getFilenameAndPath(): {
  70223. filename: string;
  70224. path: string;
  70225. };
  70226. protected _getModelLoadingConstraints(): boolean;
  70227. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70228. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70229. protected _updateModel(): void;
  70230. }
  70231. }
  70232. declare module BABYLON {
  70233. /**
  70234. * The motion controller class for oculus touch (quest, rift).
  70235. * This class supports legacy mapping as well the standard xr mapping
  70236. */
  70237. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  70238. private _forceLegacyControllers;
  70239. private _modelRootNode;
  70240. /**
  70241. * The base url used to load the left and right controller models
  70242. */
  70243. static MODEL_BASE_URL: string;
  70244. /**
  70245. * The name of the left controller model file
  70246. */
  70247. static MODEL_LEFT_FILENAME: string;
  70248. /**
  70249. * The name of the right controller model file
  70250. */
  70251. static MODEL_RIGHT_FILENAME: string;
  70252. /**
  70253. * Base Url for the Quest controller model.
  70254. */
  70255. static QUEST_MODEL_BASE_URL: string;
  70256. profileId: string;
  70257. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  70258. protected _getFilenameAndPath(): {
  70259. filename: string;
  70260. path: string;
  70261. };
  70262. protected _getModelLoadingConstraints(): boolean;
  70263. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70264. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70265. protected _updateModel(): void;
  70266. /**
  70267. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  70268. * between the touch and touch 2.
  70269. */
  70270. private _isQuest;
  70271. }
  70272. }
  70273. declare module BABYLON {
  70274. /**
  70275. * The motion controller class for the standard HTC-Vive controllers
  70276. */
  70277. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  70278. private _modelRootNode;
  70279. /**
  70280. * The base url used to load the left and right controller models
  70281. */
  70282. static MODEL_BASE_URL: string;
  70283. /**
  70284. * File name for the controller model.
  70285. */
  70286. static MODEL_FILENAME: string;
  70287. profileId: string;
  70288. /**
  70289. * Create a new Vive motion controller object
  70290. * @param scene the scene to use to create this controller
  70291. * @param gamepadObject the corresponding gamepad object
  70292. * @param handness the handness of the controller
  70293. */
  70294. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  70295. protected _getFilenameAndPath(): {
  70296. filename: string;
  70297. path: string;
  70298. };
  70299. protected _getModelLoadingConstraints(): boolean;
  70300. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  70301. protected _setRootMesh(meshes: AbstractMesh[]): void;
  70302. protected _updateModel(): void;
  70303. }
  70304. }
  70305. declare module BABYLON {
  70306. /**
  70307. * A cursor which tracks a point on a path
  70308. */
  70309. export class PathCursor {
  70310. private path;
  70311. /**
  70312. * Stores path cursor callbacks for when an onchange event is triggered
  70313. */
  70314. private _onchange;
  70315. /**
  70316. * The value of the path cursor
  70317. */
  70318. value: number;
  70319. /**
  70320. * The animation array of the path cursor
  70321. */
  70322. animations: Animation[];
  70323. /**
  70324. * Initializes the path cursor
  70325. * @param path The path to track
  70326. */
  70327. constructor(path: Path2);
  70328. /**
  70329. * Gets the cursor point on the path
  70330. * @returns A point on the path cursor at the cursor location
  70331. */
  70332. getPoint(): Vector3;
  70333. /**
  70334. * Moves the cursor ahead by the step amount
  70335. * @param step The amount to move the cursor forward
  70336. * @returns This path cursor
  70337. */
  70338. moveAhead(step?: number): PathCursor;
  70339. /**
  70340. * Moves the cursor behind by the step amount
  70341. * @param step The amount to move the cursor back
  70342. * @returns This path cursor
  70343. */
  70344. moveBack(step?: number): PathCursor;
  70345. /**
  70346. * Moves the cursor by the step amount
  70347. * If the step amount is greater than one, an exception is thrown
  70348. * @param step The amount to move the cursor
  70349. * @returns This path cursor
  70350. */
  70351. move(step: number): PathCursor;
  70352. /**
  70353. * Ensures that the value is limited between zero and one
  70354. * @returns This path cursor
  70355. */
  70356. private ensureLimits;
  70357. /**
  70358. * Runs onchange callbacks on change (used by the animation engine)
  70359. * @returns This path cursor
  70360. */
  70361. private raiseOnChange;
  70362. /**
  70363. * Executes a function on change
  70364. * @param f A path cursor onchange callback
  70365. * @returns This path cursor
  70366. */
  70367. onchange(f: (cursor: PathCursor) => void): PathCursor;
  70368. }
  70369. }
  70370. declare module BABYLON {
  70371. /** @hidden */
  70372. export var blurPixelShader: {
  70373. name: string;
  70374. shader: string;
  70375. };
  70376. }
  70377. declare module BABYLON {
  70378. /** @hidden */
  70379. export var pointCloudVertexDeclaration: {
  70380. name: string;
  70381. shader: string;
  70382. };
  70383. }
  70384. // Mixins
  70385. interface Window {
  70386. mozIndexedDB: IDBFactory;
  70387. webkitIndexedDB: IDBFactory;
  70388. msIndexedDB: IDBFactory;
  70389. webkitURL: typeof URL;
  70390. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  70391. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  70392. WebGLRenderingContext: WebGLRenderingContext;
  70393. MSGesture: MSGesture;
  70394. CANNON: any;
  70395. AudioContext: AudioContext;
  70396. webkitAudioContext: AudioContext;
  70397. PointerEvent: any;
  70398. Math: Math;
  70399. Uint8Array: Uint8ArrayConstructor;
  70400. Float32Array: Float32ArrayConstructor;
  70401. mozURL: typeof URL;
  70402. msURL: typeof URL;
  70403. VRFrameData: any; // WebVR, from specs 1.1
  70404. DracoDecoderModule: any;
  70405. setImmediate(handler: (...args: any[]) => void): number;
  70406. }
  70407. interface HTMLCanvasElement {
  70408. requestPointerLock(): void;
  70409. msRequestPointerLock?(): void;
  70410. mozRequestPointerLock?(): void;
  70411. webkitRequestPointerLock?(): void;
  70412. /** Track wether a record is in progress */
  70413. isRecording: boolean;
  70414. /** Capture Stream method defined by some browsers */
  70415. captureStream(fps?: number): MediaStream;
  70416. }
  70417. interface CanvasRenderingContext2D {
  70418. msImageSmoothingEnabled: boolean;
  70419. }
  70420. interface MouseEvent {
  70421. mozMovementX: number;
  70422. mozMovementY: number;
  70423. webkitMovementX: number;
  70424. webkitMovementY: number;
  70425. msMovementX: number;
  70426. msMovementY: number;
  70427. }
  70428. interface Navigator {
  70429. mozGetVRDevices: (any: any) => any;
  70430. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70431. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70432. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  70433. webkitGetGamepads(): Gamepad[];
  70434. msGetGamepads(): Gamepad[];
  70435. webkitGamepads(): Gamepad[];
  70436. }
  70437. interface HTMLVideoElement {
  70438. mozSrcObject: any;
  70439. }
  70440. interface Math {
  70441. fround(x: number): number;
  70442. imul(a: number, b: number): number;
  70443. }
  70444. interface WebGLRenderingContext {
  70445. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  70446. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  70447. vertexAttribDivisor(index: number, divisor: number): void;
  70448. createVertexArray(): any;
  70449. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  70450. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  70451. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  70452. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  70453. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  70454. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  70455. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  70456. // Queries
  70457. createQuery(): WebGLQuery;
  70458. deleteQuery(query: WebGLQuery): void;
  70459. beginQuery(target: number, query: WebGLQuery): void;
  70460. endQuery(target: number): void;
  70461. getQueryParameter(query: WebGLQuery, pname: number): any;
  70462. getQuery(target: number, pname: number): any;
  70463. MAX_SAMPLES: number;
  70464. RGBA8: number;
  70465. READ_FRAMEBUFFER: number;
  70466. DRAW_FRAMEBUFFER: number;
  70467. UNIFORM_BUFFER: number;
  70468. HALF_FLOAT_OES: number;
  70469. RGBA16F: number;
  70470. RGBA32F: number;
  70471. R32F: number;
  70472. RG32F: number;
  70473. RGB32F: number;
  70474. R16F: number;
  70475. RG16F: number;
  70476. RGB16F: number;
  70477. RED: number;
  70478. RG: number;
  70479. R8: number;
  70480. RG8: number;
  70481. UNSIGNED_INT_24_8: number;
  70482. DEPTH24_STENCIL8: number;
  70483. MIN: number;
  70484. MAX: number;
  70485. /* Multiple Render Targets */
  70486. drawBuffers(buffers: number[]): void;
  70487. readBuffer(src: number): void;
  70488. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  70489. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  70490. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  70491. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  70492. // Occlusion Query
  70493. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  70494. ANY_SAMPLES_PASSED: number;
  70495. QUERY_RESULT_AVAILABLE: number;
  70496. QUERY_RESULT: number;
  70497. }
  70498. interface WebGLProgram {
  70499. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  70500. }
  70501. interface EXT_disjoint_timer_query {
  70502. QUERY_COUNTER_BITS_EXT: number;
  70503. TIME_ELAPSED_EXT: number;
  70504. TIMESTAMP_EXT: number;
  70505. GPU_DISJOINT_EXT: number;
  70506. QUERY_RESULT_EXT: number;
  70507. QUERY_RESULT_AVAILABLE_EXT: number;
  70508. queryCounterEXT(query: WebGLQuery, target: number): void;
  70509. createQueryEXT(): WebGLQuery;
  70510. beginQueryEXT(target: number, query: WebGLQuery): void;
  70511. endQueryEXT(target: number): void;
  70512. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  70513. deleteQueryEXT(query: WebGLQuery): void;
  70514. }
  70515. interface WebGLUniformLocation {
  70516. _currentState: any;
  70517. }
  70518. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  70519. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  70520. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  70521. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70522. interface WebGLRenderingContext {
  70523. readonly RASTERIZER_DISCARD: number;
  70524. readonly DEPTH_COMPONENT24: number;
  70525. readonly TEXTURE_3D: number;
  70526. readonly TEXTURE_2D_ARRAY: number;
  70527. readonly TEXTURE_COMPARE_FUNC: number;
  70528. readonly TEXTURE_COMPARE_MODE: number;
  70529. readonly COMPARE_REF_TO_TEXTURE: number;
  70530. readonly TEXTURE_WRAP_R: number;
  70531. readonly HALF_FLOAT: number;
  70532. readonly RGB8: number;
  70533. readonly RED_INTEGER: number;
  70534. readonly RG_INTEGER: number;
  70535. readonly RGB_INTEGER: number;
  70536. readonly RGBA_INTEGER: number;
  70537. readonly R8_SNORM: number;
  70538. readonly RG8_SNORM: number;
  70539. readonly RGB8_SNORM: number;
  70540. readonly RGBA8_SNORM: number;
  70541. readonly R8I: number;
  70542. readonly RG8I: number;
  70543. readonly RGB8I: number;
  70544. readonly RGBA8I: number;
  70545. readonly R8UI: number;
  70546. readonly RG8UI: number;
  70547. readonly RGB8UI: number;
  70548. readonly RGBA8UI: number;
  70549. readonly R16I: number;
  70550. readonly RG16I: number;
  70551. readonly RGB16I: number;
  70552. readonly RGBA16I: number;
  70553. readonly R16UI: number;
  70554. readonly RG16UI: number;
  70555. readonly RGB16UI: number;
  70556. readonly RGBA16UI: number;
  70557. readonly R32I: number;
  70558. readonly RG32I: number;
  70559. readonly RGB32I: number;
  70560. readonly RGBA32I: number;
  70561. readonly R32UI: number;
  70562. readonly RG32UI: number;
  70563. readonly RGB32UI: number;
  70564. readonly RGBA32UI: number;
  70565. readonly RGB10_A2UI: number;
  70566. readonly R11F_G11F_B10F: number;
  70567. readonly RGB9_E5: number;
  70568. readonly RGB10_A2: number;
  70569. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  70570. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  70571. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  70572. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  70573. readonly DEPTH_COMPONENT32F: number;
  70574. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  70575. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  70576. 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;
  70577. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  70578. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  70579. readonly TRANSFORM_FEEDBACK: number;
  70580. readonly INTERLEAVED_ATTRIBS: number;
  70581. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  70582. createTransformFeedback(): WebGLTransformFeedback;
  70583. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  70584. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  70585. beginTransformFeedback(primitiveMode: number): void;
  70586. endTransformFeedback(): void;
  70587. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  70588. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70589. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70590. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  70591. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  70592. }
  70593. interface ImageBitmap {
  70594. readonly width: number;
  70595. readonly height: number;
  70596. close(): void;
  70597. }
  70598. interface WebGLQuery extends WebGLObject {
  70599. }
  70600. declare var WebGLQuery: {
  70601. prototype: WebGLQuery;
  70602. new(): WebGLQuery;
  70603. };
  70604. interface WebGLSampler extends WebGLObject {
  70605. }
  70606. declare var WebGLSampler: {
  70607. prototype: WebGLSampler;
  70608. new(): WebGLSampler;
  70609. };
  70610. interface WebGLSync extends WebGLObject {
  70611. }
  70612. declare var WebGLSync: {
  70613. prototype: WebGLSync;
  70614. new(): WebGLSync;
  70615. };
  70616. interface WebGLTransformFeedback extends WebGLObject {
  70617. }
  70618. declare var WebGLTransformFeedback: {
  70619. prototype: WebGLTransformFeedback;
  70620. new(): WebGLTransformFeedback;
  70621. };
  70622. interface WebGLVertexArrayObject extends WebGLObject {
  70623. }
  70624. declare var WebGLVertexArrayObject: {
  70625. prototype: WebGLVertexArrayObject;
  70626. new(): WebGLVertexArrayObject;
  70627. };
  70628. // Type definitions for WebVR API
  70629. // Project: https://w3c.github.io/webvr/
  70630. // Definitions by: six a <https://github.com/lostfictions>
  70631. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  70632. interface VRDisplay extends EventTarget {
  70633. /**
  70634. * Dictionary of capabilities describing the VRDisplay.
  70635. */
  70636. readonly capabilities: VRDisplayCapabilities;
  70637. /**
  70638. * z-depth defining the far plane of the eye view frustum
  70639. * enables mapping of values in the render target depth
  70640. * attachment to scene coordinates. Initially set to 10000.0.
  70641. */
  70642. depthFar: number;
  70643. /**
  70644. * z-depth defining the near plane of the eye view frustum
  70645. * enables mapping of values in the render target depth
  70646. * attachment to scene coordinates. Initially set to 0.01.
  70647. */
  70648. depthNear: number;
  70649. /**
  70650. * An identifier for this distinct VRDisplay. Used as an
  70651. * association point in the Gamepad API.
  70652. */
  70653. readonly displayId: number;
  70654. /**
  70655. * A display name, a user-readable name identifying it.
  70656. */
  70657. readonly displayName: string;
  70658. readonly isConnected: boolean;
  70659. readonly isPresenting: boolean;
  70660. /**
  70661. * If this VRDisplay supports room-scale experiences, the optional
  70662. * stage attribute contains details on the room-scale parameters.
  70663. */
  70664. readonly stageParameters: VRStageParameters | null;
  70665. /**
  70666. * Passing the value returned by `requestAnimationFrame` to
  70667. * `cancelAnimationFrame` will unregister the callback.
  70668. * @param handle Define the hanle of the request to cancel
  70669. */
  70670. cancelAnimationFrame(handle: number): void;
  70671. /**
  70672. * Stops presenting to the VRDisplay.
  70673. * @returns a promise to know when it stopped
  70674. */
  70675. exitPresent(): Promise<void>;
  70676. /**
  70677. * Return the current VREyeParameters for the given eye.
  70678. * @param whichEye Define the eye we want the parameter for
  70679. * @returns the eye parameters
  70680. */
  70681. getEyeParameters(whichEye: string): VREyeParameters;
  70682. /**
  70683. * Populates the passed VRFrameData with the information required to render
  70684. * the current frame.
  70685. * @param frameData Define the data structure to populate
  70686. * @returns true if ok otherwise false
  70687. */
  70688. getFrameData(frameData: VRFrameData): boolean;
  70689. /**
  70690. * Get the layers currently being presented.
  70691. * @returns the list of VR layers
  70692. */
  70693. getLayers(): VRLayer[];
  70694. /**
  70695. * Return a VRPose containing the future predicted pose of the VRDisplay
  70696. * when the current frame will be presented. The value returned will not
  70697. * change until JavaScript has returned control to the browser.
  70698. *
  70699. * The VRPose will contain the position, orientation, velocity,
  70700. * and acceleration of each of these properties.
  70701. * @returns the pose object
  70702. */
  70703. getPose(): VRPose;
  70704. /**
  70705. * Return the current instantaneous pose of the VRDisplay, with no
  70706. * prediction applied.
  70707. * @returns the current instantaneous pose
  70708. */
  70709. getImmediatePose(): VRPose;
  70710. /**
  70711. * The callback passed to `requestAnimationFrame` will be called
  70712. * any time a new frame should be rendered. When the VRDisplay is
  70713. * presenting the callback will be called at the native refresh
  70714. * rate of the HMD. When not presenting this function acts
  70715. * identically to how window.requestAnimationFrame acts. Content should
  70716. * make no assumptions of frame rate or vsync behavior as the HMD runs
  70717. * asynchronously from other displays and at differing refresh rates.
  70718. * @param callback Define the eaction to run next frame
  70719. * @returns the request handle it
  70720. */
  70721. requestAnimationFrame(callback: FrameRequestCallback): number;
  70722. /**
  70723. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  70724. * Repeat calls while already presenting will update the VRLayers being displayed.
  70725. * @param layers Define the list of layer to present
  70726. * @returns a promise to know when the request has been fulfilled
  70727. */
  70728. requestPresent(layers: VRLayer[]): Promise<void>;
  70729. /**
  70730. * Reset the pose for this display, treating its current position and
  70731. * orientation as the "origin/zero" values. VRPose.position,
  70732. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  70733. * updated when calling resetPose(). This should be called in only
  70734. * sitting-space experiences.
  70735. */
  70736. resetPose(): void;
  70737. /**
  70738. * The VRLayer provided to the VRDisplay will be captured and presented
  70739. * in the HMD. Calling this function has the same effect on the source
  70740. * canvas as any other operation that uses its source image, and canvases
  70741. * created without preserveDrawingBuffer set to true will be cleared.
  70742. * @param pose Define the pose to submit
  70743. */
  70744. submitFrame(pose?: VRPose): void;
  70745. }
  70746. declare var VRDisplay: {
  70747. prototype: VRDisplay;
  70748. new(): VRDisplay;
  70749. };
  70750. interface VRLayer {
  70751. leftBounds?: number[] | Float32Array | null;
  70752. rightBounds?: number[] | Float32Array | null;
  70753. source?: HTMLCanvasElement | null;
  70754. }
  70755. interface VRDisplayCapabilities {
  70756. readonly canPresent: boolean;
  70757. readonly hasExternalDisplay: boolean;
  70758. readonly hasOrientation: boolean;
  70759. readonly hasPosition: boolean;
  70760. readonly maxLayers: number;
  70761. }
  70762. interface VREyeParameters {
  70763. /** @deprecated */
  70764. readonly fieldOfView: VRFieldOfView;
  70765. readonly offset: Float32Array;
  70766. readonly renderHeight: number;
  70767. readonly renderWidth: number;
  70768. }
  70769. interface VRFieldOfView {
  70770. readonly downDegrees: number;
  70771. readonly leftDegrees: number;
  70772. readonly rightDegrees: number;
  70773. readonly upDegrees: number;
  70774. }
  70775. interface VRFrameData {
  70776. readonly leftProjectionMatrix: Float32Array;
  70777. readonly leftViewMatrix: Float32Array;
  70778. readonly pose: VRPose;
  70779. readonly rightProjectionMatrix: Float32Array;
  70780. readonly rightViewMatrix: Float32Array;
  70781. readonly timestamp: number;
  70782. }
  70783. interface VRPose {
  70784. readonly angularAcceleration: Float32Array | null;
  70785. readonly angularVelocity: Float32Array | null;
  70786. readonly linearAcceleration: Float32Array | null;
  70787. readonly linearVelocity: Float32Array | null;
  70788. readonly orientation: Float32Array | null;
  70789. readonly position: Float32Array | null;
  70790. readonly timestamp: number;
  70791. }
  70792. interface VRStageParameters {
  70793. sittingToStandingTransform?: Float32Array;
  70794. sizeX?: number;
  70795. sizeY?: number;
  70796. }
  70797. interface Navigator {
  70798. getVRDisplays(): Promise<VRDisplay[]>;
  70799. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  70800. }
  70801. interface Window {
  70802. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  70803. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  70804. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  70805. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70806. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  70807. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  70808. }
  70809. interface Gamepad {
  70810. readonly displayId: number;
  70811. }
  70812. type XRSessionMode =
  70813. | "inline"
  70814. | "immersive-vr"
  70815. | "immersive-ar";
  70816. type XRReferenceSpaceType =
  70817. | "viewer"
  70818. | "local"
  70819. | "local-floor"
  70820. | "bounded-floor"
  70821. | "unbounded";
  70822. type XREnvironmentBlendMode =
  70823. | "opaque"
  70824. | "additive"
  70825. | "alpha-blend";
  70826. type XRVisibilityState =
  70827. | "visible"
  70828. | "visible-blurred"
  70829. | "hidden";
  70830. type XRHandedness =
  70831. | "none"
  70832. | "left"
  70833. | "right";
  70834. type XRTargetRayMode =
  70835. | "gaze"
  70836. | "tracked-pointer"
  70837. | "screen";
  70838. type XREye =
  70839. | "none"
  70840. | "left"
  70841. | "right";
  70842. interface XRSpace extends EventTarget {
  70843. }
  70844. interface XRRenderState {
  70845. depthNear?: number;
  70846. depthFar?: number;
  70847. inlineVerticalFieldOfView?: number;
  70848. baseLayer?: XRWebGLLayer;
  70849. }
  70850. interface XRInputSource {
  70851. handedness: XRHandedness;
  70852. targetRayMode: XRTargetRayMode;
  70853. targetRaySpace: XRSpace;
  70854. gripSpace: XRSpace | undefined;
  70855. gamepad: Gamepad | undefined;
  70856. profiles: Array<string>;
  70857. }
  70858. interface XRSessionInit {
  70859. optionalFeatures?: XRReferenceSpaceType[];
  70860. requiredFeatures?: XRReferenceSpaceType[];
  70861. }
  70862. interface XRSession extends XRAnchorCreator {
  70863. addEventListener: Function;
  70864. removeEventListener: Function;
  70865. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  70866. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  70867. requestAnimationFrame: Function;
  70868. end(): Promise<void>;
  70869. renderState: XRRenderState;
  70870. inputSources: Array<XRInputSource>;
  70871. // hit test
  70872. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  70873. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  70874. // legacy AR hit test
  70875. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  70876. // legacy plane detection
  70877. updateWorldTrackingState(options: {
  70878. planeDetectionState?: { enabled: boolean; }
  70879. }): void;
  70880. }
  70881. interface XRReferenceSpace extends XRSpace {
  70882. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  70883. onreset: any;
  70884. }
  70885. type XRPlaneSet = Set<XRPlane>;
  70886. type XRAnchorSet = Set<XRAnchor>;
  70887. interface XRFrame {
  70888. session: XRSession;
  70889. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  70890. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  70891. // AR
  70892. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  70893. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  70894. // Anchors
  70895. trackedAnchors?: XRAnchorSet;
  70896. // Planes
  70897. worldInformation: {
  70898. detectedPlanes?: XRPlaneSet;
  70899. };
  70900. }
  70901. interface XRViewerPose extends XRPose {
  70902. views: Array<XRView>;
  70903. }
  70904. interface XRPose {
  70905. transform: XRRigidTransform;
  70906. emulatedPosition: boolean;
  70907. }
  70908. interface XRWebGLLayerOptions {
  70909. antialias?: boolean;
  70910. depth?: boolean;
  70911. stencil?: boolean;
  70912. alpha?: boolean;
  70913. multiview?: boolean;
  70914. framebufferScaleFactor?: number;
  70915. }
  70916. declare var XRWebGLLayer: {
  70917. prototype: XRWebGLLayer;
  70918. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70919. };
  70920. interface XRWebGLLayer {
  70921. framebuffer: WebGLFramebuffer;
  70922. framebufferWidth: number;
  70923. framebufferHeight: number;
  70924. getViewport: Function;
  70925. }
  70926. declare class XRRigidTransform {
  70927. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70928. position: DOMPointReadOnly;
  70929. orientation: DOMPointReadOnly;
  70930. matrix: Float32Array;
  70931. inverse: XRRigidTransform;
  70932. }
  70933. interface XRView {
  70934. eye: XREye;
  70935. projectionMatrix: Float32Array;
  70936. transform: XRRigidTransform;
  70937. }
  70938. interface XRInputSourceChangeEvent {
  70939. session: XRSession;
  70940. removed: Array<XRInputSource>;
  70941. added: Array<XRInputSource>;
  70942. }
  70943. interface XRInputSourceEvent extends Event {
  70944. readonly frame: XRFrame;
  70945. readonly inputSource: XRInputSource;
  70946. }
  70947. // Experimental(er) features
  70948. declare class XRRay {
  70949. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70950. origin: DOMPointReadOnly;
  70951. direction: DOMPointReadOnly;
  70952. matrix: Float32Array;
  70953. }
  70954. declare enum XRHitTestTrackableType {
  70955. "point",
  70956. "plane"
  70957. }
  70958. interface XRHitResult {
  70959. hitMatrix: Float32Array;
  70960. }
  70961. interface XRTransientInputHitTestResult {
  70962. readonly inputSource: XRInputSource;
  70963. readonly results: Array<XRHitTestResult>;
  70964. }
  70965. interface XRHitTestResult {
  70966. getPose(baseSpace: XRSpace): XRPose | undefined;
  70967. }
  70968. interface XRHitTestSource {
  70969. cancel(): void;
  70970. }
  70971. interface XRTransientInputHitTestSource {
  70972. cancel(): void;
  70973. }
  70974. interface XRHitTestOptionsInit {
  70975. space: XRSpace;
  70976. entityTypes?: Array<XRHitTestTrackableType>;
  70977. offsetRay?: XRRay;
  70978. }
  70979. interface XRTransientInputHitTestOptionsInit {
  70980. profile: string;
  70981. entityTypes?: Array<XRHitTestTrackableType>;
  70982. offsetRay?: XRRay;
  70983. }
  70984. interface XRAnchor {
  70985. // remove?
  70986. id?: string;
  70987. anchorSpace: XRSpace;
  70988. lastChangedTime: number;
  70989. detach(): void;
  70990. }
  70991. interface XRPlane extends XRAnchorCreator {
  70992. orientation: "Horizontal" | "Vertical";
  70993. planeSpace: XRSpace;
  70994. polygon: Array<DOMPointReadOnly>;
  70995. lastChangedTime: number;
  70996. }
  70997. interface XRAnchorCreator {
  70998. // AR Anchors
  70999. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  71000. }
  71001. /**
  71002. * @ignore
  71003. */
  71004. declare module BABYLON.GLTF2.Exporter {
  71005. }
  71006. /**
  71007. * @ignore
  71008. */
  71009. declare module BABYLON.GLTF1 {
  71010. }
  71011. declare module BABYLON.GUI {
  71012. /**
  71013. * Class used to specific a value and its associated unit
  71014. */
  71015. export class ValueAndUnit {
  71016. /** defines the unit to store */
  71017. unit: number;
  71018. /** defines a boolean indicating if the value can be negative */
  71019. negativeValueAllowed: boolean;
  71020. private _value;
  71021. private _originalUnit;
  71022. /**
  71023. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  71024. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71025. */
  71026. ignoreAdaptiveScaling: boolean;
  71027. /**
  71028. * Creates a new ValueAndUnit
  71029. * @param value defines the value to store
  71030. * @param unit defines the unit to store
  71031. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  71032. */
  71033. constructor(value: number,
  71034. /** defines the unit to store */
  71035. unit?: number,
  71036. /** defines a boolean indicating if the value can be negative */
  71037. negativeValueAllowed?: boolean);
  71038. /** Gets a boolean indicating if the value is a percentage */
  71039. get isPercentage(): boolean;
  71040. /** Gets a boolean indicating if the value is store as pixel */
  71041. get isPixel(): boolean;
  71042. /** Gets direct internal value */
  71043. get internalValue(): number;
  71044. /**
  71045. * Gets value as pixel
  71046. * @param host defines the root host
  71047. * @param refValue defines the reference value for percentages
  71048. * @returns the value as pixel
  71049. */
  71050. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  71051. /**
  71052. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  71053. * @param value defines the value to store
  71054. * @param unit defines the unit to store
  71055. * @returns the current ValueAndUnit
  71056. */
  71057. updateInPlace(value: number, unit?: number): ValueAndUnit;
  71058. /**
  71059. * Gets the value accordingly to its unit
  71060. * @param host defines the root host
  71061. * @returns the value
  71062. */
  71063. getValue(host: AdvancedDynamicTexture): number;
  71064. /**
  71065. * Gets a string representation of the value
  71066. * @param host defines the root host
  71067. * @param decimals defines an optional number of decimals to display
  71068. * @returns a string
  71069. */
  71070. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  71071. /**
  71072. * Store a value parsed from a string
  71073. * @param source defines the source string
  71074. * @returns true if the value was successfully parsed
  71075. */
  71076. fromString(source: string | number): boolean;
  71077. private static _Regex;
  71078. private static _UNITMODE_PERCENTAGE;
  71079. private static _UNITMODE_PIXEL;
  71080. /** UNITMODE_PERCENTAGE */
  71081. static get UNITMODE_PERCENTAGE(): number;
  71082. /** UNITMODE_PIXEL */
  71083. static get UNITMODE_PIXEL(): number;
  71084. }
  71085. }
  71086. declare module BABYLON.GUI {
  71087. /**
  71088. * Define a style used by control to automatically setup properties based on a template.
  71089. * Only support font related properties so far
  71090. */
  71091. export class Style implements BABYLON.IDisposable {
  71092. private _fontFamily;
  71093. private _fontStyle;
  71094. private _fontWeight;
  71095. /** @hidden */
  71096. _host: AdvancedDynamicTexture;
  71097. /** @hidden */
  71098. _fontSize: ValueAndUnit;
  71099. /**
  71100. * BABYLON.Observable raised when the style values are changed
  71101. */
  71102. onChangedObservable: BABYLON.Observable<Style>;
  71103. /**
  71104. * Creates a new style object
  71105. * @param host defines the AdvancedDynamicTexture which hosts this style
  71106. */
  71107. constructor(host: AdvancedDynamicTexture);
  71108. /**
  71109. * Gets or sets the font size
  71110. */
  71111. get fontSize(): string | number;
  71112. set fontSize(value: string | number);
  71113. /**
  71114. * Gets or sets the font family
  71115. */
  71116. get fontFamily(): string;
  71117. set fontFamily(value: string);
  71118. /**
  71119. * Gets or sets the font style
  71120. */
  71121. get fontStyle(): string;
  71122. set fontStyle(value: string);
  71123. /** Gets or sets font weight */
  71124. get fontWeight(): string;
  71125. set fontWeight(value: string);
  71126. /** Dispose all associated resources */
  71127. dispose(): void;
  71128. }
  71129. }
  71130. declare module BABYLON.GUI {
  71131. /**
  71132. * Class used to transport BABYLON.Vector2 information for pointer events
  71133. */
  71134. export class Vector2WithInfo extends BABYLON.Vector2 {
  71135. /** defines the current mouse button index */
  71136. buttonIndex: number;
  71137. /**
  71138. * Creates a new Vector2WithInfo
  71139. * @param source defines the vector2 data to transport
  71140. * @param buttonIndex defines the current mouse button index
  71141. */
  71142. constructor(source: BABYLON.Vector2,
  71143. /** defines the current mouse button index */
  71144. buttonIndex?: number);
  71145. }
  71146. /** Class used to provide 2D matrix features */
  71147. export class Matrix2D {
  71148. /** Gets the internal array of 6 floats used to store matrix data */
  71149. m: Float32Array;
  71150. /**
  71151. * Creates a new matrix
  71152. * @param m00 defines value for (0, 0)
  71153. * @param m01 defines value for (0, 1)
  71154. * @param m10 defines value for (1, 0)
  71155. * @param m11 defines value for (1, 1)
  71156. * @param m20 defines value for (2, 0)
  71157. * @param m21 defines value for (2, 1)
  71158. */
  71159. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  71160. /**
  71161. * Fills the matrix from direct values
  71162. * @param m00 defines value for (0, 0)
  71163. * @param m01 defines value for (0, 1)
  71164. * @param m10 defines value for (1, 0)
  71165. * @param m11 defines value for (1, 1)
  71166. * @param m20 defines value for (2, 0)
  71167. * @param m21 defines value for (2, 1)
  71168. * @returns the current modified matrix
  71169. */
  71170. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  71171. /**
  71172. * Gets matrix determinant
  71173. * @returns the determinant
  71174. */
  71175. determinant(): number;
  71176. /**
  71177. * Inverses the matrix and stores it in a target matrix
  71178. * @param result defines the target matrix
  71179. * @returns the current matrix
  71180. */
  71181. invertToRef(result: Matrix2D): Matrix2D;
  71182. /**
  71183. * Multiplies the current matrix with another one
  71184. * @param other defines the second operand
  71185. * @param result defines the target matrix
  71186. * @returns the current matrix
  71187. */
  71188. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  71189. /**
  71190. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  71191. * @param x defines the x coordinate to transform
  71192. * @param y defines the x coordinate to transform
  71193. * @param result defines the target vector2
  71194. * @returns the current matrix
  71195. */
  71196. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  71197. /**
  71198. * Creates an identity matrix
  71199. * @returns a new matrix
  71200. */
  71201. static Identity(): Matrix2D;
  71202. /**
  71203. * Creates a translation matrix and stores it in a target matrix
  71204. * @param x defines the x coordinate of the translation
  71205. * @param y defines the y coordinate of the translation
  71206. * @param result defines the target matrix
  71207. */
  71208. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  71209. /**
  71210. * Creates a scaling matrix and stores it in a target matrix
  71211. * @param x defines the x coordinate of the scaling
  71212. * @param y defines the y coordinate of the scaling
  71213. * @param result defines the target matrix
  71214. */
  71215. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  71216. /**
  71217. * Creates a rotation matrix and stores it in a target matrix
  71218. * @param angle defines the rotation angle
  71219. * @param result defines the target matrix
  71220. */
  71221. static RotationToRef(angle: number, result: Matrix2D): void;
  71222. private static _TempPreTranslationMatrix;
  71223. private static _TempPostTranslationMatrix;
  71224. private static _TempRotationMatrix;
  71225. private static _TempScalingMatrix;
  71226. private static _TempCompose0;
  71227. private static _TempCompose1;
  71228. private static _TempCompose2;
  71229. /**
  71230. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  71231. * @param tx defines the x coordinate of the translation
  71232. * @param ty defines the y coordinate of the translation
  71233. * @param angle defines the rotation angle
  71234. * @param scaleX defines the x coordinate of the scaling
  71235. * @param scaleY defines the y coordinate of the scaling
  71236. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  71237. * @param result defines the target matrix
  71238. */
  71239. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  71240. }
  71241. }
  71242. declare module BABYLON.GUI {
  71243. /**
  71244. * Class used to store 2D control sizes
  71245. */
  71246. export class Measure {
  71247. /** defines left coordinate */
  71248. left: number;
  71249. /** defines top coordinate */
  71250. top: number;
  71251. /** defines width dimension */
  71252. width: number;
  71253. /** defines height dimension */
  71254. height: number;
  71255. /**
  71256. * Creates a new measure
  71257. * @param left defines left coordinate
  71258. * @param top defines top coordinate
  71259. * @param width defines width dimension
  71260. * @param height defines height dimension
  71261. */
  71262. constructor(
  71263. /** defines left coordinate */
  71264. left: number,
  71265. /** defines top coordinate */
  71266. top: number,
  71267. /** defines width dimension */
  71268. width: number,
  71269. /** defines height dimension */
  71270. height: number);
  71271. /**
  71272. * Copy from another measure
  71273. * @param other defines the other measure to copy from
  71274. */
  71275. copyFrom(other: Measure): void;
  71276. /**
  71277. * Copy from a group of 4 floats
  71278. * @param left defines left coordinate
  71279. * @param top defines top coordinate
  71280. * @param width defines width dimension
  71281. * @param height defines height dimension
  71282. */
  71283. copyFromFloats(left: number, top: number, width: number, height: number): void;
  71284. /**
  71285. * Computes the axis aligned bounding box measure for two given measures
  71286. * @param a Input measure
  71287. * @param b Input measure
  71288. * @param result the resulting bounding measure
  71289. */
  71290. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  71291. /**
  71292. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  71293. * @param transform the matrix to transform the measure before computing the AABB
  71294. * @param result the resulting AABB
  71295. */
  71296. transformToRef(transform: Matrix2D, result: Measure): void;
  71297. /**
  71298. * Check equality between this measure and another one
  71299. * @param other defines the other measures
  71300. * @returns true if both measures are equals
  71301. */
  71302. isEqualsTo(other: Measure): boolean;
  71303. /**
  71304. * Creates an empty measure
  71305. * @returns a new measure
  71306. */
  71307. static Empty(): Measure;
  71308. }
  71309. }
  71310. declare module BABYLON.GUI {
  71311. /**
  71312. * Interface used to define a control that can receive focus
  71313. */
  71314. export interface IFocusableControl {
  71315. /**
  71316. * Function called when the control receives the focus
  71317. */
  71318. onFocus(): void;
  71319. /**
  71320. * Function called when the control loses the focus
  71321. */
  71322. onBlur(): void;
  71323. /**
  71324. * Function called to let the control handle keyboard events
  71325. * @param evt defines the current keyboard event
  71326. */
  71327. processKeyboard(evt: KeyboardEvent): void;
  71328. /**
  71329. * Function called to get the list of controls that should not steal the focus from this control
  71330. * @returns an array of controls
  71331. */
  71332. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71333. }
  71334. /**
  71335. * Class used to create texture to support 2D GUI elements
  71336. * @see http://doc.babylonjs.com/how_to/gui
  71337. */
  71338. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  71339. private _isDirty;
  71340. private _renderObserver;
  71341. private _resizeObserver;
  71342. private _preKeyboardObserver;
  71343. private _pointerMoveObserver;
  71344. private _pointerObserver;
  71345. private _canvasPointerOutObserver;
  71346. private _background;
  71347. /** @hidden */
  71348. _rootContainer: Container;
  71349. /** @hidden */
  71350. _lastPickedControl: Control;
  71351. /** @hidden */
  71352. _lastControlOver: {
  71353. [pointerId: number]: Control;
  71354. };
  71355. /** @hidden */
  71356. _lastControlDown: {
  71357. [pointerId: number]: Control;
  71358. };
  71359. /** @hidden */
  71360. _capturingControl: {
  71361. [pointerId: number]: Control;
  71362. };
  71363. /** @hidden */
  71364. _shouldBlockPointer: boolean;
  71365. /** @hidden */
  71366. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  71367. /** @hidden */
  71368. _linkedControls: Control[];
  71369. private _isFullscreen;
  71370. private _fullscreenViewport;
  71371. private _idealWidth;
  71372. private _idealHeight;
  71373. private _useSmallestIdeal;
  71374. private _renderAtIdealSize;
  71375. private _focusedControl;
  71376. private _blockNextFocusCheck;
  71377. private _renderScale;
  71378. private _rootElement;
  71379. private _cursorChanged;
  71380. private _defaultMousePointerId;
  71381. /** @hidden */
  71382. _numLayoutCalls: number;
  71383. /** Gets the number of layout calls made the last time the ADT has been rendered */
  71384. get numLayoutCalls(): number;
  71385. /** @hidden */
  71386. _numRenderCalls: number;
  71387. /** Gets the number of render calls made the last time the ADT has been rendered */
  71388. get numRenderCalls(): number;
  71389. /**
  71390. * Define type to string to ensure compatibility across browsers
  71391. * Safari doesn't support DataTransfer constructor
  71392. */
  71393. private _clipboardData;
  71394. /**
  71395. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  71396. */
  71397. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  71398. /**
  71399. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  71400. */
  71401. onControlPickedObservable: BABYLON.Observable<Control>;
  71402. /**
  71403. * BABYLON.Observable event triggered before layout is evaluated
  71404. */
  71405. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71406. /**
  71407. * BABYLON.Observable event triggered after the layout was evaluated
  71408. */
  71409. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71410. /**
  71411. * BABYLON.Observable event triggered before the texture is rendered
  71412. */
  71413. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71414. /**
  71415. * BABYLON.Observable event triggered after the texture was rendered
  71416. */
  71417. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  71418. /**
  71419. * Gets or sets a boolean defining if alpha is stored as premultiplied
  71420. */
  71421. premulAlpha: boolean;
  71422. /**
  71423. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  71424. * Useful when you want more antialiasing
  71425. */
  71426. get renderScale(): number;
  71427. set renderScale(value: number);
  71428. /** Gets or sets the background color */
  71429. get background(): string;
  71430. set background(value: string);
  71431. /**
  71432. * Gets or sets the ideal width used to design controls.
  71433. * The GUI will then rescale everything accordingly
  71434. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71435. */
  71436. get idealWidth(): number;
  71437. set idealWidth(value: number);
  71438. /**
  71439. * Gets or sets the ideal height used to design controls.
  71440. * The GUI will then rescale everything accordingly
  71441. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71442. */
  71443. get idealHeight(): number;
  71444. set idealHeight(value: number);
  71445. /**
  71446. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  71447. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71448. */
  71449. get useSmallestIdeal(): boolean;
  71450. set useSmallestIdeal(value: boolean);
  71451. /**
  71452. * Gets or sets a boolean indicating if adaptive scaling must be used
  71453. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71454. */
  71455. get renderAtIdealSize(): boolean;
  71456. set renderAtIdealSize(value: boolean);
  71457. /**
  71458. * Gets the ratio used when in "ideal mode"
  71459. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  71460. * */
  71461. get idealRatio(): number;
  71462. /**
  71463. * Gets the underlying layer used to render the texture when in fullscreen mode
  71464. */
  71465. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  71466. /**
  71467. * Gets the root container control
  71468. */
  71469. get rootContainer(): Container;
  71470. /**
  71471. * Returns an array containing the root container.
  71472. * This is mostly used to let the Inspector introspects the ADT
  71473. * @returns an array containing the rootContainer
  71474. */
  71475. getChildren(): Array<Container>;
  71476. /**
  71477. * Will return all controls that are inside this texture
  71478. * @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
  71479. * @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
  71480. * @return all child controls
  71481. */
  71482. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71483. /**
  71484. * Gets or sets the current focused control
  71485. */
  71486. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  71487. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  71488. /**
  71489. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  71490. */
  71491. get isForeground(): boolean;
  71492. set isForeground(value: boolean);
  71493. /**
  71494. * Gets or set information about clipboardData
  71495. */
  71496. get clipboardData(): string;
  71497. set clipboardData(value: string);
  71498. /**
  71499. * Creates a new AdvancedDynamicTexture
  71500. * @param name defines the name of the texture
  71501. * @param width defines the width of the texture
  71502. * @param height defines the height of the texture
  71503. * @param scene defines the hosting scene
  71504. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  71505. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71506. */
  71507. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  71508. /**
  71509. * Get the current class name of the texture useful for serialization or dynamic coding.
  71510. * @returns "AdvancedDynamicTexture"
  71511. */
  71512. getClassName(): string;
  71513. /**
  71514. * Function used to execute a function on all controls
  71515. * @param func defines the function to execute
  71516. * @param container defines the container where controls belong. If null the root container will be used
  71517. */
  71518. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  71519. private _useInvalidateRectOptimization;
  71520. /**
  71521. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  71522. */
  71523. get useInvalidateRectOptimization(): boolean;
  71524. set useInvalidateRectOptimization(value: boolean);
  71525. private _invalidatedRectangle;
  71526. /**
  71527. * Invalidates a rectangle area on the gui texture
  71528. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  71529. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  71530. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  71531. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  71532. */
  71533. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  71534. /**
  71535. * Marks the texture as dirty forcing a complete update
  71536. */
  71537. markAsDirty(): void;
  71538. /**
  71539. * Helper function used to create a new style
  71540. * @returns a new style
  71541. * @see http://doc.babylonjs.com/how_to/gui#styles
  71542. */
  71543. createStyle(): Style;
  71544. /**
  71545. * Adds a new control to the root container
  71546. * @param control defines the control to add
  71547. * @returns the current texture
  71548. */
  71549. addControl(control: Control): AdvancedDynamicTexture;
  71550. /**
  71551. * Removes a control from the root container
  71552. * @param control defines the control to remove
  71553. * @returns the current texture
  71554. */
  71555. removeControl(control: Control): AdvancedDynamicTexture;
  71556. /**
  71557. * Release all resources
  71558. */
  71559. dispose(): void;
  71560. private _onResize;
  71561. /** @hidden */
  71562. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  71563. /**
  71564. * Get screen coordinates for a vector3
  71565. * @param position defines the position to project
  71566. * @param worldMatrix defines the world matrix to use
  71567. * @returns the projected position
  71568. */
  71569. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  71570. private _checkUpdate;
  71571. private _clearMeasure;
  71572. private _render;
  71573. /** @hidden */
  71574. _changeCursor(cursor: string): void;
  71575. /** @hidden */
  71576. _registerLastControlDown(control: Control, pointerId: number): void;
  71577. private _doPicking;
  71578. /** @hidden */
  71579. _cleanControlAfterRemovalFromList(list: {
  71580. [pointerId: number]: Control;
  71581. }, control: Control): void;
  71582. /** @hidden */
  71583. _cleanControlAfterRemoval(control: Control): void;
  71584. /** Attach to all scene events required to support pointer events */
  71585. attach(): void;
  71586. /** @hidden */
  71587. private onClipboardCopy;
  71588. /** @hidden */
  71589. private onClipboardCut;
  71590. /** @hidden */
  71591. private onClipboardPaste;
  71592. /**
  71593. * Register the clipboard Events onto the canvas
  71594. */
  71595. registerClipboardEvents(): void;
  71596. /**
  71597. * Unregister the clipboard Events from the canvas
  71598. */
  71599. unRegisterClipboardEvents(): void;
  71600. /**
  71601. * Connect the texture to a hosting mesh to enable interactions
  71602. * @param mesh defines the mesh to attach to
  71603. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  71604. */
  71605. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  71606. /**
  71607. * Move the focus to a specific control
  71608. * @param control defines the control which will receive the focus
  71609. */
  71610. moveFocusToControl(control: IFocusableControl): void;
  71611. private _manageFocus;
  71612. private _attachToOnPointerOut;
  71613. /**
  71614. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  71615. * @param mesh defines the mesh which will receive the texture
  71616. * @param width defines the texture width (1024 by default)
  71617. * @param height defines the texture height (1024 by default)
  71618. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  71619. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  71620. * @returns a new AdvancedDynamicTexture
  71621. */
  71622. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  71623. /**
  71624. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  71625. * In this mode the texture will rely on a layer for its rendering.
  71626. * This allows it to be treated like any other layer.
  71627. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  71628. * LayerMask is set through advancedTexture.layer.layerMask
  71629. * @param name defines name for the texture
  71630. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  71631. * @param scene defines the hsoting scene
  71632. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  71633. * @returns a new AdvancedDynamicTexture
  71634. */
  71635. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  71636. }
  71637. }
  71638. declare module BABYLON.GUI {
  71639. /**
  71640. * Root class used for all 2D controls
  71641. * @see http://doc.babylonjs.com/how_to/gui#controls
  71642. */
  71643. export class Control {
  71644. /** defines the name of the control */
  71645. name?: string | undefined;
  71646. /**
  71647. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  71648. */
  71649. static AllowAlphaInheritance: boolean;
  71650. private _alpha;
  71651. private _alphaSet;
  71652. private _zIndex;
  71653. /** @hidden */
  71654. _host: AdvancedDynamicTexture;
  71655. /** Gets or sets the control parent */
  71656. parent: BABYLON.Nullable<Container>;
  71657. /** @hidden */
  71658. _currentMeasure: Measure;
  71659. private _fontFamily;
  71660. private _fontStyle;
  71661. private _fontWeight;
  71662. private _fontSize;
  71663. private _font;
  71664. /** @hidden */
  71665. _width: ValueAndUnit;
  71666. /** @hidden */
  71667. _height: ValueAndUnit;
  71668. /** @hidden */
  71669. protected _fontOffset: {
  71670. ascent: number;
  71671. height: number;
  71672. descent: number;
  71673. };
  71674. private _color;
  71675. private _style;
  71676. private _styleObserver;
  71677. /** @hidden */
  71678. protected _horizontalAlignment: number;
  71679. /** @hidden */
  71680. protected _verticalAlignment: number;
  71681. /** @hidden */
  71682. protected _isDirty: boolean;
  71683. /** @hidden */
  71684. protected _wasDirty: boolean;
  71685. /** @hidden */
  71686. _tempParentMeasure: Measure;
  71687. /** @hidden */
  71688. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  71689. /** @hidden */
  71690. protected _cachedParentMeasure: Measure;
  71691. private _paddingLeft;
  71692. private _paddingRight;
  71693. private _paddingTop;
  71694. private _paddingBottom;
  71695. /** @hidden */
  71696. _left: ValueAndUnit;
  71697. /** @hidden */
  71698. _top: ValueAndUnit;
  71699. private _scaleX;
  71700. private _scaleY;
  71701. private _rotation;
  71702. private _transformCenterX;
  71703. private _transformCenterY;
  71704. /** @hidden */
  71705. _transformMatrix: Matrix2D;
  71706. /** @hidden */
  71707. protected _invertTransformMatrix: Matrix2D;
  71708. /** @hidden */
  71709. protected _transformedPosition: BABYLON.Vector2;
  71710. private _isMatrixDirty;
  71711. private _cachedOffsetX;
  71712. private _cachedOffsetY;
  71713. private _isVisible;
  71714. private _isHighlighted;
  71715. /** @hidden */
  71716. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  71717. private _fontSet;
  71718. private _dummyVector2;
  71719. private _downCount;
  71720. private _enterCount;
  71721. private _doNotRender;
  71722. private _downPointerIds;
  71723. protected _isEnabled: boolean;
  71724. protected _disabledColor: string;
  71725. protected _disabledColorItem: string;
  71726. /** @hidden */
  71727. protected _rebuildLayout: boolean;
  71728. /** @hidden */
  71729. _customData: any;
  71730. /** @hidden */
  71731. _isClipped: boolean;
  71732. /** @hidden */
  71733. _automaticSize: boolean;
  71734. /** @hidden */
  71735. _tag: any;
  71736. /**
  71737. * 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
  71738. */
  71739. uniqueId: number;
  71740. /**
  71741. * Gets or sets an object used to store user defined information for the node
  71742. */
  71743. metadata: any;
  71744. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  71745. isHitTestVisible: boolean;
  71746. /** Gets or sets a boolean indicating if the control can block pointer events */
  71747. isPointerBlocker: boolean;
  71748. /** Gets or sets a boolean indicating if the control can be focusable */
  71749. isFocusInvisible: boolean;
  71750. /**
  71751. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  71752. * 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
  71753. */
  71754. clipChildren: boolean;
  71755. /**
  71756. * Gets or sets a boolean indicating that control content must be clipped
  71757. * 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
  71758. */
  71759. clipContent: boolean;
  71760. /**
  71761. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  71762. */
  71763. useBitmapCache: boolean;
  71764. private _cacheData;
  71765. private _shadowOffsetX;
  71766. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  71767. get shadowOffsetX(): number;
  71768. set shadowOffsetX(value: number);
  71769. private _shadowOffsetY;
  71770. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  71771. get shadowOffsetY(): number;
  71772. set shadowOffsetY(value: number);
  71773. private _shadowBlur;
  71774. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  71775. get shadowBlur(): number;
  71776. set shadowBlur(value: number);
  71777. private _shadowColor;
  71778. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  71779. get shadowColor(): string;
  71780. set shadowColor(value: string);
  71781. /** Gets or sets the cursor to use when the control is hovered */
  71782. hoverCursor: string;
  71783. /** @hidden */
  71784. protected _linkOffsetX: ValueAndUnit;
  71785. /** @hidden */
  71786. protected _linkOffsetY: ValueAndUnit;
  71787. /** Gets the control type name */
  71788. get typeName(): string;
  71789. /**
  71790. * Get the current class name of the control.
  71791. * @returns current class name
  71792. */
  71793. getClassName(): string;
  71794. /**
  71795. * An event triggered when pointer wheel is scrolled
  71796. */
  71797. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  71798. /**
  71799. * An event triggered when the pointer move over the control.
  71800. */
  71801. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  71802. /**
  71803. * An event triggered when the pointer move out of the control.
  71804. */
  71805. onPointerOutObservable: BABYLON.Observable<Control>;
  71806. /**
  71807. * An event triggered when the pointer taps the control
  71808. */
  71809. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  71810. /**
  71811. * An event triggered when pointer up
  71812. */
  71813. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  71814. /**
  71815. * An event triggered when a control is clicked on
  71816. */
  71817. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  71818. /**
  71819. * An event triggered when pointer enters the control
  71820. */
  71821. onPointerEnterObservable: BABYLON.Observable<Control>;
  71822. /**
  71823. * An event triggered when the control is marked as dirty
  71824. */
  71825. onDirtyObservable: BABYLON.Observable<Control>;
  71826. /**
  71827. * An event triggered before drawing the control
  71828. */
  71829. onBeforeDrawObservable: BABYLON.Observable<Control>;
  71830. /**
  71831. * An event triggered after the control was drawn
  71832. */
  71833. onAfterDrawObservable: BABYLON.Observable<Control>;
  71834. /**
  71835. * Get the hosting AdvancedDynamicTexture
  71836. */
  71837. get host(): AdvancedDynamicTexture;
  71838. /** Gets or set information about font offsets (used to render and align text) */
  71839. get fontOffset(): {
  71840. ascent: number;
  71841. height: number;
  71842. descent: number;
  71843. };
  71844. set fontOffset(offset: {
  71845. ascent: number;
  71846. height: number;
  71847. descent: number;
  71848. });
  71849. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  71850. get alpha(): number;
  71851. set alpha(value: number);
  71852. /**
  71853. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  71854. */
  71855. get isHighlighted(): boolean;
  71856. set isHighlighted(value: boolean);
  71857. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  71858. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71859. */
  71860. get scaleX(): number;
  71861. set scaleX(value: number);
  71862. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  71863. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71864. */
  71865. get scaleY(): number;
  71866. set scaleY(value: number);
  71867. /** Gets or sets the rotation angle (0 by default)
  71868. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71869. */
  71870. get rotation(): number;
  71871. set rotation(value: number);
  71872. /** Gets or sets the transformation center on Y axis (0 by default)
  71873. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71874. */
  71875. get transformCenterY(): number;
  71876. set transformCenterY(value: number);
  71877. /** Gets or sets the transformation center on X axis (0 by default)
  71878. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  71879. */
  71880. get transformCenterX(): number;
  71881. set transformCenterX(value: number);
  71882. /**
  71883. * Gets or sets the horizontal alignment
  71884. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71885. */
  71886. get horizontalAlignment(): number;
  71887. set horizontalAlignment(value: number);
  71888. /**
  71889. * Gets or sets the vertical alignment
  71890. * @see http://doc.babylonjs.com/how_to/gui#alignments
  71891. */
  71892. get verticalAlignment(): number;
  71893. set verticalAlignment(value: number);
  71894. /**
  71895. * Gets or sets control width
  71896. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71897. */
  71898. get width(): string | number;
  71899. set width(value: string | number);
  71900. /**
  71901. * Gets or sets the control width in pixel
  71902. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71903. */
  71904. get widthInPixels(): number;
  71905. set widthInPixels(value: number);
  71906. /**
  71907. * Gets or sets control height
  71908. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71909. */
  71910. get height(): string | number;
  71911. set height(value: string | number);
  71912. /**
  71913. * Gets or sets control height in pixel
  71914. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71915. */
  71916. get heightInPixels(): number;
  71917. set heightInPixels(value: number);
  71918. /** Gets or set font family */
  71919. get fontFamily(): string;
  71920. set fontFamily(value: string);
  71921. /** Gets or sets font style */
  71922. get fontStyle(): string;
  71923. set fontStyle(value: string);
  71924. /** Gets or sets font weight */
  71925. get fontWeight(): string;
  71926. set fontWeight(value: string);
  71927. /**
  71928. * Gets or sets style
  71929. * @see http://doc.babylonjs.com/how_to/gui#styles
  71930. */
  71931. get style(): BABYLON.Nullable<Style>;
  71932. set style(value: BABYLON.Nullable<Style>);
  71933. /** @hidden */
  71934. get _isFontSizeInPercentage(): boolean;
  71935. /** Gets or sets font size in pixels */
  71936. get fontSizeInPixels(): number;
  71937. set fontSizeInPixels(value: number);
  71938. /** Gets or sets font size */
  71939. get fontSize(): string | number;
  71940. set fontSize(value: string | number);
  71941. /** Gets or sets foreground color */
  71942. get color(): string;
  71943. set color(value: string);
  71944. /** Gets or sets z index which is used to reorder controls on the z axis */
  71945. get zIndex(): number;
  71946. set zIndex(value: number);
  71947. /** Gets or sets a boolean indicating if the control can be rendered */
  71948. get notRenderable(): boolean;
  71949. set notRenderable(value: boolean);
  71950. /** Gets or sets a boolean indicating if the control is visible */
  71951. get isVisible(): boolean;
  71952. set isVisible(value: boolean);
  71953. /** Gets a boolean indicating that the control needs to update its rendering */
  71954. get isDirty(): boolean;
  71955. /**
  71956. * Gets the current linked mesh (or null if none)
  71957. */
  71958. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71959. /**
  71960. * Gets or sets a value indicating the padding to use on the left of the control
  71961. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71962. */
  71963. get paddingLeft(): string | number;
  71964. set paddingLeft(value: string | number);
  71965. /**
  71966. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71967. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71968. */
  71969. get paddingLeftInPixels(): number;
  71970. set paddingLeftInPixels(value: number);
  71971. /**
  71972. * Gets or sets a value indicating the padding to use on the right of the control
  71973. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71974. */
  71975. get paddingRight(): string | number;
  71976. set paddingRight(value: string | number);
  71977. /**
  71978. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71979. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71980. */
  71981. get paddingRightInPixels(): number;
  71982. set paddingRightInPixels(value: number);
  71983. /**
  71984. * Gets or sets a value indicating the padding to use on the top of the control
  71985. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71986. */
  71987. get paddingTop(): string | number;
  71988. set paddingTop(value: string | number);
  71989. /**
  71990. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71991. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71992. */
  71993. get paddingTopInPixels(): number;
  71994. set paddingTopInPixels(value: number);
  71995. /**
  71996. * Gets or sets a value indicating the padding to use on the bottom of the control
  71997. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71998. */
  71999. get paddingBottom(): string | number;
  72000. set paddingBottom(value: string | number);
  72001. /**
  72002. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  72003. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72004. */
  72005. get paddingBottomInPixels(): number;
  72006. set paddingBottomInPixels(value: number);
  72007. /**
  72008. * Gets or sets a value indicating the left coordinate of the control
  72009. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72010. */
  72011. get left(): string | number;
  72012. set left(value: string | number);
  72013. /**
  72014. * Gets or sets a value indicating the left coordinate in pixels of the control
  72015. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72016. */
  72017. get leftInPixels(): number;
  72018. set leftInPixels(value: number);
  72019. /**
  72020. * Gets or sets a value indicating the top coordinate of the control
  72021. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72022. */
  72023. get top(): string | number;
  72024. set top(value: string | number);
  72025. /**
  72026. * Gets or sets a value indicating the top coordinate in pixels of the control
  72027. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72028. */
  72029. get topInPixels(): number;
  72030. set topInPixels(value: number);
  72031. /**
  72032. * Gets or sets a value indicating the offset on X axis to the linked mesh
  72033. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72034. */
  72035. get linkOffsetX(): string | number;
  72036. set linkOffsetX(value: string | number);
  72037. /**
  72038. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  72039. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72040. */
  72041. get linkOffsetXInPixels(): number;
  72042. set linkOffsetXInPixels(value: number);
  72043. /**
  72044. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  72045. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72046. */
  72047. get linkOffsetY(): string | number;
  72048. set linkOffsetY(value: string | number);
  72049. /**
  72050. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  72051. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72052. */
  72053. get linkOffsetYInPixels(): number;
  72054. set linkOffsetYInPixels(value: number);
  72055. /** Gets the center coordinate on X axis */
  72056. get centerX(): number;
  72057. /** Gets the center coordinate on Y axis */
  72058. get centerY(): number;
  72059. /** Gets or sets if control is Enabled*/
  72060. get isEnabled(): boolean;
  72061. set isEnabled(value: boolean);
  72062. /** Gets or sets background color of control if it's disabled*/
  72063. get disabledColor(): string;
  72064. set disabledColor(value: string);
  72065. /** Gets or sets front color of control if it's disabled*/
  72066. get disabledColorItem(): string;
  72067. set disabledColorItem(value: string);
  72068. /**
  72069. * Creates a new control
  72070. * @param name defines the name of the control
  72071. */
  72072. constructor(
  72073. /** defines the name of the control */
  72074. name?: string | undefined);
  72075. /** @hidden */
  72076. protected _getTypeName(): string;
  72077. /**
  72078. * Gets the first ascendant in the hierarchy of the given type
  72079. * @param className defines the required type
  72080. * @returns the ascendant or null if not found
  72081. */
  72082. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  72083. /** @hidden */
  72084. _resetFontCache(): void;
  72085. /**
  72086. * Determines if a container is an ascendant of the current control
  72087. * @param container defines the container to look for
  72088. * @returns true if the container is one of the ascendant of the control
  72089. */
  72090. isAscendant(container: Control): boolean;
  72091. /**
  72092. * Gets coordinates in local control space
  72093. * @param globalCoordinates defines the coordinates to transform
  72094. * @returns the new coordinates in local space
  72095. */
  72096. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72097. /**
  72098. * Gets coordinates in local control space
  72099. * @param globalCoordinates defines the coordinates to transform
  72100. * @param result defines the target vector2 where to store the result
  72101. * @returns the current control
  72102. */
  72103. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  72104. /**
  72105. * Gets coordinates in parent local control space
  72106. * @param globalCoordinates defines the coordinates to transform
  72107. * @returns the new coordinates in parent local space
  72108. */
  72109. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  72110. /**
  72111. * Move the current control to a vector3 position projected onto the screen.
  72112. * @param position defines the target position
  72113. * @param scene defines the hosting scene
  72114. */
  72115. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  72116. /**
  72117. * Will store all controls that have this control as ascendant in a given array
  72118. * @param results defines the array where to store the descendants
  72119. * @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
  72120. * @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
  72121. */
  72122. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72123. /**
  72124. * Will return all controls that have this control as ascendant
  72125. * @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
  72126. * @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
  72127. * @return all child controls
  72128. */
  72129. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  72130. /**
  72131. * Link current control with a target mesh
  72132. * @param mesh defines the mesh to link with
  72133. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  72134. */
  72135. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  72136. /** @hidden */
  72137. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  72138. /** @hidden */
  72139. _offsetLeft(offset: number): void;
  72140. /** @hidden */
  72141. _offsetTop(offset: number): void;
  72142. /** @hidden */
  72143. _markMatrixAsDirty(): void;
  72144. /** @hidden */
  72145. _flagDescendantsAsMatrixDirty(): void;
  72146. /** @hidden */
  72147. _intersectsRect(rect: Measure): boolean;
  72148. /** @hidden */
  72149. protected invalidateRect(): void;
  72150. /** @hidden */
  72151. _markAsDirty(force?: boolean): void;
  72152. /** @hidden */
  72153. _markAllAsDirty(): void;
  72154. /** @hidden */
  72155. _link(host: AdvancedDynamicTexture): void;
  72156. /** @hidden */
  72157. protected _transform(context?: CanvasRenderingContext2D): void;
  72158. /** @hidden */
  72159. _renderHighlight(context: CanvasRenderingContext2D): void;
  72160. /** @hidden */
  72161. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72162. /** @hidden */
  72163. protected _applyStates(context: CanvasRenderingContext2D): void;
  72164. /** @hidden */
  72165. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72166. /** @hidden */
  72167. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72168. protected _evaluateClippingState(parentMeasure: Measure): void;
  72169. /** @hidden */
  72170. _measure(): void;
  72171. /** @hidden */
  72172. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72173. /** @hidden */
  72174. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72175. /** @hidden */
  72176. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72177. /** @hidden */
  72178. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72179. private static _ClipMeasure;
  72180. private _tmpMeasureA;
  72181. private _clip;
  72182. /** @hidden */
  72183. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  72184. /** @hidden */
  72185. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72186. /**
  72187. * Tests if a given coordinates belong to the current control
  72188. * @param x defines x coordinate to test
  72189. * @param y defines y coordinate to test
  72190. * @returns true if the coordinates are inside the control
  72191. */
  72192. contains(x: number, y: number): boolean;
  72193. /** @hidden */
  72194. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72195. /** @hidden */
  72196. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72197. /** @hidden */
  72198. _onPointerEnter(target: Control): boolean;
  72199. /** @hidden */
  72200. _onPointerOut(target: Control, force?: boolean): void;
  72201. /** @hidden */
  72202. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72203. /** @hidden */
  72204. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72205. /** @hidden */
  72206. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72207. /** @hidden */
  72208. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  72209. /** @hidden */
  72210. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72211. private _prepareFont;
  72212. /** Releases associated resources */
  72213. dispose(): void;
  72214. private static _HORIZONTAL_ALIGNMENT_LEFT;
  72215. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  72216. private static _HORIZONTAL_ALIGNMENT_CENTER;
  72217. private static _VERTICAL_ALIGNMENT_TOP;
  72218. private static _VERTICAL_ALIGNMENT_BOTTOM;
  72219. private static _VERTICAL_ALIGNMENT_CENTER;
  72220. /** HORIZONTAL_ALIGNMENT_LEFT */
  72221. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  72222. /** HORIZONTAL_ALIGNMENT_RIGHT */
  72223. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  72224. /** HORIZONTAL_ALIGNMENT_CENTER */
  72225. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  72226. /** VERTICAL_ALIGNMENT_TOP */
  72227. static get VERTICAL_ALIGNMENT_TOP(): number;
  72228. /** VERTICAL_ALIGNMENT_BOTTOM */
  72229. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  72230. /** VERTICAL_ALIGNMENT_CENTER */
  72231. static get VERTICAL_ALIGNMENT_CENTER(): number;
  72232. private static _FontHeightSizes;
  72233. /** @hidden */
  72234. static _GetFontOffset(font: string): {
  72235. ascent: number;
  72236. height: number;
  72237. descent: number;
  72238. };
  72239. /**
  72240. * Creates a stack panel that can be used to render headers
  72241. * @param control defines the control to associate with the header
  72242. * @param text defines the text of the header
  72243. * @param size defines the size of the header
  72244. * @param options defines options used to configure the header
  72245. * @returns a new StackPanel
  72246. * @ignore
  72247. * @hidden
  72248. */
  72249. static AddHeader: (control: Control, text: string, size: string | number, options: {
  72250. isHorizontal: boolean;
  72251. controlFirst: boolean;
  72252. }) => any;
  72253. /** @hidden */
  72254. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  72255. }
  72256. }
  72257. declare module BABYLON.GUI {
  72258. /**
  72259. * Root class for 2D containers
  72260. * @see http://doc.babylonjs.com/how_to/gui#containers
  72261. */
  72262. export class Container extends Control {
  72263. name?: string | undefined;
  72264. /** @hidden */
  72265. _children: Control[];
  72266. /** @hidden */
  72267. protected _measureForChildren: Measure;
  72268. /** @hidden */
  72269. protected _background: string;
  72270. /** @hidden */
  72271. protected _adaptWidthToChildren: boolean;
  72272. /** @hidden */
  72273. protected _adaptHeightToChildren: boolean;
  72274. /**
  72275. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  72276. */
  72277. logLayoutCycleErrors: boolean;
  72278. /**
  72279. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  72280. */
  72281. maxLayoutCycle: number;
  72282. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  72283. get adaptHeightToChildren(): boolean;
  72284. set adaptHeightToChildren(value: boolean);
  72285. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  72286. get adaptWidthToChildren(): boolean;
  72287. set adaptWidthToChildren(value: boolean);
  72288. /** Gets or sets background color */
  72289. get background(): string;
  72290. set background(value: string);
  72291. /** Gets the list of children */
  72292. get children(): Control[];
  72293. /**
  72294. * Creates a new Container
  72295. * @param name defines the name of the container
  72296. */
  72297. constructor(name?: string | undefined);
  72298. protected _getTypeName(): string;
  72299. _flagDescendantsAsMatrixDirty(): void;
  72300. /**
  72301. * Gets a child using its name
  72302. * @param name defines the child name to look for
  72303. * @returns the child control if found
  72304. */
  72305. getChildByName(name: string): BABYLON.Nullable<Control>;
  72306. /**
  72307. * Gets a child using its type and its name
  72308. * @param name defines the child name to look for
  72309. * @param type defines the child type to look for
  72310. * @returns the child control if found
  72311. */
  72312. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  72313. /**
  72314. * Search for a specific control in children
  72315. * @param control defines the control to look for
  72316. * @returns true if the control is in child list
  72317. */
  72318. containsControl(control: Control): boolean;
  72319. /**
  72320. * Adds a new control to the current container
  72321. * @param control defines the control to add
  72322. * @returns the current container
  72323. */
  72324. addControl(control: BABYLON.Nullable<Control>): Container;
  72325. /**
  72326. * Removes all controls from the current container
  72327. * @returns the current container
  72328. */
  72329. clearControls(): Container;
  72330. /**
  72331. * Removes a control from the current container
  72332. * @param control defines the control to remove
  72333. * @returns the current container
  72334. */
  72335. removeControl(control: Control): Container;
  72336. /** @hidden */
  72337. _reOrderControl(control: Control): void;
  72338. /** @hidden */
  72339. _offsetLeft(offset: number): void;
  72340. /** @hidden */
  72341. _offsetTop(offset: number): void;
  72342. /** @hidden */
  72343. _markAllAsDirty(): void;
  72344. /** @hidden */
  72345. protected _localDraw(context: CanvasRenderingContext2D): void;
  72346. /** @hidden */
  72347. _link(host: AdvancedDynamicTexture): void;
  72348. /** @hidden */
  72349. protected _beforeLayout(): void;
  72350. /** @hidden */
  72351. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72352. /** @hidden */
  72353. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72354. protected _postMeasure(): void;
  72355. /** @hidden */
  72356. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72357. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  72358. /** @hidden */
  72359. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72360. /** @hidden */
  72361. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72362. /** Releases associated resources */
  72363. dispose(): void;
  72364. }
  72365. }
  72366. declare module BABYLON.GUI {
  72367. /** Class used to create rectangle container */
  72368. export class Rectangle extends Container {
  72369. name?: string | undefined;
  72370. private _thickness;
  72371. private _cornerRadius;
  72372. /** Gets or sets border thickness */
  72373. get thickness(): number;
  72374. set thickness(value: number);
  72375. /** Gets or sets the corner radius angle */
  72376. get cornerRadius(): number;
  72377. set cornerRadius(value: number);
  72378. /**
  72379. * Creates a new Rectangle
  72380. * @param name defines the control name
  72381. */
  72382. constructor(name?: string | undefined);
  72383. protected _getTypeName(): string;
  72384. protected _localDraw(context: CanvasRenderingContext2D): void;
  72385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72386. private _drawRoundedRect;
  72387. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72388. }
  72389. }
  72390. declare module BABYLON.GUI {
  72391. /**
  72392. * Enum that determines the text-wrapping mode to use.
  72393. */
  72394. export enum TextWrapping {
  72395. /**
  72396. * Clip the text when it's larger than Control.width; this is the default mode.
  72397. */
  72398. Clip = 0,
  72399. /**
  72400. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  72401. */
  72402. WordWrap = 1,
  72403. /**
  72404. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  72405. */
  72406. Ellipsis = 2
  72407. }
  72408. /**
  72409. * Class used to create text block control
  72410. */
  72411. export class TextBlock extends Control {
  72412. /**
  72413. * Defines the name of the control
  72414. */
  72415. name?: string | undefined;
  72416. private _text;
  72417. private _textWrapping;
  72418. private _textHorizontalAlignment;
  72419. private _textVerticalAlignment;
  72420. private _lines;
  72421. private _resizeToFit;
  72422. private _lineSpacing;
  72423. private _outlineWidth;
  72424. private _outlineColor;
  72425. /**
  72426. * An event triggered after the text is changed
  72427. */
  72428. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  72429. /**
  72430. * An event triggered after the text was broken up into lines
  72431. */
  72432. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  72433. /**
  72434. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  72435. */
  72436. get lines(): any[];
  72437. /**
  72438. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72439. */
  72440. get resizeToFit(): boolean;
  72441. /**
  72442. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  72443. */
  72444. set resizeToFit(value: boolean);
  72445. /**
  72446. * Gets or sets a boolean indicating if text must be wrapped
  72447. */
  72448. get textWrapping(): TextWrapping | boolean;
  72449. /**
  72450. * Gets or sets a boolean indicating if text must be wrapped
  72451. */
  72452. set textWrapping(value: TextWrapping | boolean);
  72453. /**
  72454. * Gets or sets text to display
  72455. */
  72456. get text(): string;
  72457. /**
  72458. * Gets or sets text to display
  72459. */
  72460. set text(value: string);
  72461. /**
  72462. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72463. */
  72464. get textHorizontalAlignment(): number;
  72465. /**
  72466. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  72467. */
  72468. set textHorizontalAlignment(value: number);
  72469. /**
  72470. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72471. */
  72472. get textVerticalAlignment(): number;
  72473. /**
  72474. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  72475. */
  72476. set textVerticalAlignment(value: number);
  72477. /**
  72478. * Gets or sets line spacing value
  72479. */
  72480. set lineSpacing(value: string | number);
  72481. /**
  72482. * Gets or sets line spacing value
  72483. */
  72484. get lineSpacing(): string | number;
  72485. /**
  72486. * Gets or sets outlineWidth of the text to display
  72487. */
  72488. get outlineWidth(): number;
  72489. /**
  72490. * Gets or sets outlineWidth of the text to display
  72491. */
  72492. set outlineWidth(value: number);
  72493. /**
  72494. * Gets or sets outlineColor of the text to display
  72495. */
  72496. get outlineColor(): string;
  72497. /**
  72498. * Gets or sets outlineColor of the text to display
  72499. */
  72500. set outlineColor(value: string);
  72501. /**
  72502. * Creates a new TextBlock object
  72503. * @param name defines the name of the control
  72504. * @param text defines the text to display (emptry string by default)
  72505. */
  72506. constructor(
  72507. /**
  72508. * Defines the name of the control
  72509. */
  72510. name?: string | undefined, text?: string);
  72511. protected _getTypeName(): string;
  72512. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72513. private _drawText;
  72514. /** @hidden */
  72515. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72516. protected _applyStates(context: CanvasRenderingContext2D): void;
  72517. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  72518. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  72519. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  72520. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  72521. protected _renderLines(context: CanvasRenderingContext2D): void;
  72522. /**
  72523. * Given a width constraint applied on the text block, find the expected height
  72524. * @returns expected height
  72525. */
  72526. computeExpectedHeight(): number;
  72527. dispose(): void;
  72528. }
  72529. }
  72530. declare module BABYLON.GUI {
  72531. /**
  72532. * Class used to create 2D images
  72533. */
  72534. export class Image extends Control {
  72535. name?: string | undefined;
  72536. private _workingCanvas;
  72537. private _domImage;
  72538. private _imageWidth;
  72539. private _imageHeight;
  72540. private _loaded;
  72541. private _stretch;
  72542. private _source;
  72543. private _autoScale;
  72544. private _sourceLeft;
  72545. private _sourceTop;
  72546. private _sourceWidth;
  72547. private _sourceHeight;
  72548. private _svgAttributesComputationCompleted;
  72549. private _isSVG;
  72550. private _cellWidth;
  72551. private _cellHeight;
  72552. private _cellId;
  72553. private _populateNinePatchSlicesFromImage;
  72554. private _sliceLeft;
  72555. private _sliceRight;
  72556. private _sliceTop;
  72557. private _sliceBottom;
  72558. private _detectPointerOnOpaqueOnly;
  72559. /**
  72560. * BABYLON.Observable notified when the content is loaded
  72561. */
  72562. onImageLoadedObservable: BABYLON.Observable<Image>;
  72563. /**
  72564. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  72565. */
  72566. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  72567. /**
  72568. * Gets a boolean indicating that the content is loaded
  72569. */
  72570. get isLoaded(): boolean;
  72571. /**
  72572. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  72573. */
  72574. get populateNinePatchSlicesFromImage(): boolean;
  72575. set populateNinePatchSlicesFromImage(value: boolean);
  72576. /**
  72577. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  72578. * Beware using this as this will comsume more memory as the image has to be stored twice
  72579. */
  72580. get detectPointerOnOpaqueOnly(): boolean;
  72581. set detectPointerOnOpaqueOnly(value: boolean);
  72582. /**
  72583. * Gets or sets the left value for slicing (9-patch)
  72584. */
  72585. get sliceLeft(): number;
  72586. set sliceLeft(value: number);
  72587. /**
  72588. * Gets or sets the right value for slicing (9-patch)
  72589. */
  72590. get sliceRight(): number;
  72591. set sliceRight(value: number);
  72592. /**
  72593. * Gets or sets the top value for slicing (9-patch)
  72594. */
  72595. get sliceTop(): number;
  72596. set sliceTop(value: number);
  72597. /**
  72598. * Gets or sets the bottom value for slicing (9-patch)
  72599. */
  72600. get sliceBottom(): number;
  72601. set sliceBottom(value: number);
  72602. /**
  72603. * Gets or sets the left coordinate in the source image
  72604. */
  72605. get sourceLeft(): number;
  72606. set sourceLeft(value: number);
  72607. /**
  72608. * Gets or sets the top coordinate in the source image
  72609. */
  72610. get sourceTop(): number;
  72611. set sourceTop(value: number);
  72612. /**
  72613. * Gets or sets the width to capture in the source image
  72614. */
  72615. get sourceWidth(): number;
  72616. set sourceWidth(value: number);
  72617. /**
  72618. * Gets or sets the height to capture in the source image
  72619. */
  72620. get sourceHeight(): number;
  72621. set sourceHeight(value: number);
  72622. /** Indicates if the format of the image is SVG */
  72623. get isSVG(): boolean;
  72624. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  72625. get svgAttributesComputationCompleted(): boolean;
  72626. /**
  72627. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  72628. * @see http://doc.babylonjs.com/how_to/gui#image
  72629. */
  72630. get autoScale(): boolean;
  72631. set autoScale(value: boolean);
  72632. /** Gets or sets the streching mode used by the image */
  72633. get stretch(): number;
  72634. set stretch(value: number);
  72635. /** @hidden */
  72636. _rotate90(n: number, preserveProperties?: boolean): Image;
  72637. private _handleRotationForSVGImage;
  72638. private _rotate90SourceProperties;
  72639. /**
  72640. * Gets or sets the internal DOM image used to render the control
  72641. */
  72642. set domImage(value: HTMLImageElement);
  72643. get domImage(): HTMLImageElement;
  72644. private _onImageLoaded;
  72645. private _extractNinePatchSliceDataFromImage;
  72646. /**
  72647. * Gets or sets image source url
  72648. */
  72649. set source(value: BABYLON.Nullable<string>);
  72650. /**
  72651. * Checks for svg document with icon id present
  72652. */
  72653. private _svgCheck;
  72654. /**
  72655. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  72656. * given external svg file and icon id
  72657. */
  72658. private _getSVGAttribs;
  72659. /**
  72660. * Gets or sets the cell width to use when animation sheet is enabled
  72661. * @see http://doc.babylonjs.com/how_to/gui#image
  72662. */
  72663. get cellWidth(): number;
  72664. set cellWidth(value: number);
  72665. /**
  72666. * Gets or sets the cell height to use when animation sheet is enabled
  72667. * @see http://doc.babylonjs.com/how_to/gui#image
  72668. */
  72669. get cellHeight(): number;
  72670. set cellHeight(value: number);
  72671. /**
  72672. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  72673. * @see http://doc.babylonjs.com/how_to/gui#image
  72674. */
  72675. get cellId(): number;
  72676. set cellId(value: number);
  72677. /**
  72678. * Creates a new Image
  72679. * @param name defines the control name
  72680. * @param url defines the image url
  72681. */
  72682. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  72683. /**
  72684. * Tests if a given coordinates belong to the current control
  72685. * @param x defines x coordinate to test
  72686. * @param y defines y coordinate to test
  72687. * @returns true if the coordinates are inside the control
  72688. */
  72689. contains(x: number, y: number): boolean;
  72690. protected _getTypeName(): string;
  72691. /** Force the control to synchronize with its content */
  72692. synchronizeSizeWithContent(): void;
  72693. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72694. private _prepareWorkingCanvasForOpaqueDetection;
  72695. private _drawImage;
  72696. _draw(context: CanvasRenderingContext2D): void;
  72697. private _renderCornerPatch;
  72698. private _renderNinePatch;
  72699. dispose(): void;
  72700. /** STRETCH_NONE */
  72701. static readonly STRETCH_NONE: number;
  72702. /** STRETCH_FILL */
  72703. static readonly STRETCH_FILL: number;
  72704. /** STRETCH_UNIFORM */
  72705. static readonly STRETCH_UNIFORM: number;
  72706. /** STRETCH_EXTEND */
  72707. static readonly STRETCH_EXTEND: number;
  72708. /** NINE_PATCH */
  72709. static readonly STRETCH_NINE_PATCH: number;
  72710. }
  72711. }
  72712. declare module BABYLON.GUI {
  72713. /**
  72714. * Class used to create 2D buttons
  72715. */
  72716. export class Button extends Rectangle {
  72717. name?: string | undefined;
  72718. /**
  72719. * Function called to generate a pointer enter animation
  72720. */
  72721. pointerEnterAnimation: () => void;
  72722. /**
  72723. * Function called to generate a pointer out animation
  72724. */
  72725. pointerOutAnimation: () => void;
  72726. /**
  72727. * Function called to generate a pointer down animation
  72728. */
  72729. pointerDownAnimation: () => void;
  72730. /**
  72731. * Function called to generate a pointer up animation
  72732. */
  72733. pointerUpAnimation: () => void;
  72734. /**
  72735. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  72736. */
  72737. delegatePickingToChildren: boolean;
  72738. private _image;
  72739. /**
  72740. * Returns the image part of the button (if any)
  72741. */
  72742. get image(): BABYLON.Nullable<Image>;
  72743. private _textBlock;
  72744. /**
  72745. * Returns the image part of the button (if any)
  72746. */
  72747. get textBlock(): BABYLON.Nullable<TextBlock>;
  72748. /**
  72749. * Creates a new Button
  72750. * @param name defines the name of the button
  72751. */
  72752. constructor(name?: string | undefined);
  72753. protected _getTypeName(): string;
  72754. /** @hidden */
  72755. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  72756. /** @hidden */
  72757. _onPointerEnter(target: Control): boolean;
  72758. /** @hidden */
  72759. _onPointerOut(target: Control, force?: boolean): void;
  72760. /** @hidden */
  72761. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72762. /** @hidden */
  72763. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72764. /**
  72765. * Creates a new button made with an image and a text
  72766. * @param name defines the name of the button
  72767. * @param text defines the text of the button
  72768. * @param imageUrl defines the url of the image
  72769. * @returns a new Button
  72770. */
  72771. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  72772. /**
  72773. * Creates a new button made with an image
  72774. * @param name defines the name of the button
  72775. * @param imageUrl defines the url of the image
  72776. * @returns a new Button
  72777. */
  72778. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  72779. /**
  72780. * Creates a new button made with a text
  72781. * @param name defines the name of the button
  72782. * @param text defines the text of the button
  72783. * @returns a new Button
  72784. */
  72785. static CreateSimpleButton(name: string, text: string): Button;
  72786. /**
  72787. * Creates a new button made with an image and a centered text
  72788. * @param name defines the name of the button
  72789. * @param text defines the text of the button
  72790. * @param imageUrl defines the url of the image
  72791. * @returns a new Button
  72792. */
  72793. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  72794. }
  72795. }
  72796. declare module BABYLON.GUI {
  72797. /**
  72798. * Class used to create a 2D stack panel container
  72799. */
  72800. export class StackPanel extends Container {
  72801. name?: string | undefined;
  72802. private _isVertical;
  72803. private _manualWidth;
  72804. private _manualHeight;
  72805. private _doNotTrackManualChanges;
  72806. /**
  72807. * Gets or sets a boolean indicating that layou warnings should be ignored
  72808. */
  72809. ignoreLayoutWarnings: boolean;
  72810. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  72811. get isVertical(): boolean;
  72812. set isVertical(value: boolean);
  72813. /**
  72814. * Gets or sets panel width.
  72815. * This value should not be set when in horizontal mode as it will be computed automatically
  72816. */
  72817. set width(value: string | number);
  72818. get width(): string | number;
  72819. /**
  72820. * Gets or sets panel height.
  72821. * This value should not be set when in vertical mode as it will be computed automatically
  72822. */
  72823. set height(value: string | number);
  72824. get height(): string | number;
  72825. /**
  72826. * Creates a new StackPanel
  72827. * @param name defines control name
  72828. */
  72829. constructor(name?: string | undefined);
  72830. protected _getTypeName(): string;
  72831. /** @hidden */
  72832. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72833. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72834. protected _postMeasure(): void;
  72835. }
  72836. }
  72837. declare module BABYLON.GUI {
  72838. /**
  72839. * Class used to represent a 2D checkbox
  72840. */
  72841. export class Checkbox extends Control {
  72842. name?: string | undefined;
  72843. private _isChecked;
  72844. private _background;
  72845. private _checkSizeRatio;
  72846. private _thickness;
  72847. /** Gets or sets border thickness */
  72848. get thickness(): number;
  72849. set thickness(value: number);
  72850. /**
  72851. * BABYLON.Observable raised when isChecked property changes
  72852. */
  72853. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72854. /** Gets or sets a value indicating the ratio between overall size and check size */
  72855. get checkSizeRatio(): number;
  72856. set checkSizeRatio(value: number);
  72857. /** Gets or sets background color */
  72858. get background(): string;
  72859. set background(value: string);
  72860. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72861. get isChecked(): boolean;
  72862. set isChecked(value: boolean);
  72863. /**
  72864. * Creates a new CheckBox
  72865. * @param name defines the control name
  72866. */
  72867. constructor(name?: string | undefined);
  72868. protected _getTypeName(): string;
  72869. /** @hidden */
  72870. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72871. /** @hidden */
  72872. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72873. /**
  72874. * Utility function to easily create a checkbox with a header
  72875. * @param title defines the label to use for the header
  72876. * @param onValueChanged defines the callback to call when value changes
  72877. * @returns a StackPanel containing the checkbox and a textBlock
  72878. */
  72879. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  72880. }
  72881. }
  72882. declare module BABYLON.GUI {
  72883. /**
  72884. * Class used to store key control properties
  72885. */
  72886. export class KeyPropertySet {
  72887. /** Width */
  72888. width?: string;
  72889. /** Height */
  72890. height?: string;
  72891. /** Left padding */
  72892. paddingLeft?: string;
  72893. /** Right padding */
  72894. paddingRight?: string;
  72895. /** Top padding */
  72896. paddingTop?: string;
  72897. /** Bottom padding */
  72898. paddingBottom?: string;
  72899. /** Foreground color */
  72900. color?: string;
  72901. /** Background color */
  72902. background?: string;
  72903. }
  72904. /**
  72905. * Class used to create virtual keyboard
  72906. */
  72907. export class VirtualKeyboard extends StackPanel {
  72908. /** BABYLON.Observable raised when a key is pressed */
  72909. onKeyPressObservable: BABYLON.Observable<string>;
  72910. /** Gets or sets default key button width */
  72911. defaultButtonWidth: string;
  72912. /** Gets or sets default key button height */
  72913. defaultButtonHeight: string;
  72914. /** Gets or sets default key button left padding */
  72915. defaultButtonPaddingLeft: string;
  72916. /** Gets or sets default key button right padding */
  72917. defaultButtonPaddingRight: string;
  72918. /** Gets or sets default key button top padding */
  72919. defaultButtonPaddingTop: string;
  72920. /** Gets or sets default key button bottom padding */
  72921. defaultButtonPaddingBottom: string;
  72922. /** Gets or sets default key button foreground color */
  72923. defaultButtonColor: string;
  72924. /** Gets or sets default key button background color */
  72925. defaultButtonBackground: string;
  72926. /** Gets or sets shift button foreground color */
  72927. shiftButtonColor: string;
  72928. /** Gets or sets shift button thickness*/
  72929. selectedShiftThickness: number;
  72930. /** Gets shift key state */
  72931. shiftState: number;
  72932. protected _getTypeName(): string;
  72933. private _createKey;
  72934. /**
  72935. * Adds a new row of keys
  72936. * @param keys defines the list of keys to add
  72937. * @param propertySets defines the associated property sets
  72938. */
  72939. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  72940. /**
  72941. * Set the shift key to a specific state
  72942. * @param shiftState defines the new shift state
  72943. */
  72944. applyShiftState(shiftState: number): void;
  72945. private _currentlyConnectedInputText;
  72946. private _connectedInputTexts;
  72947. private _onKeyPressObserver;
  72948. /** Gets the input text control currently attached to the keyboard */
  72949. get connectedInputText(): BABYLON.Nullable<InputText>;
  72950. /**
  72951. * Connects the keyboard with an input text control
  72952. *
  72953. * @param input defines the target control
  72954. */
  72955. connect(input: InputText): void;
  72956. /**
  72957. * Disconnects the keyboard from connected InputText controls
  72958. *
  72959. * @param input optionally defines a target control, otherwise all are disconnected
  72960. */
  72961. disconnect(input?: InputText): void;
  72962. private _removeConnectedInputObservables;
  72963. /**
  72964. * Release all resources
  72965. */
  72966. dispose(): void;
  72967. /**
  72968. * Creates a new keyboard using a default layout
  72969. *
  72970. * @param name defines control name
  72971. * @returns a new VirtualKeyboard
  72972. */
  72973. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72974. }
  72975. }
  72976. declare module BABYLON.GUI {
  72977. /**
  72978. * Class used to create input text control
  72979. */
  72980. export class InputText extends Control implements IFocusableControl {
  72981. name?: string | undefined;
  72982. private _text;
  72983. private _placeholderText;
  72984. private _background;
  72985. private _focusedBackground;
  72986. private _focusedColor;
  72987. private _placeholderColor;
  72988. private _thickness;
  72989. private _margin;
  72990. private _autoStretchWidth;
  72991. private _maxWidth;
  72992. private _isFocused;
  72993. private _blinkTimeout;
  72994. private _blinkIsEven;
  72995. private _cursorOffset;
  72996. private _scrollLeft;
  72997. private _textWidth;
  72998. private _clickedCoordinate;
  72999. private _deadKey;
  73000. private _addKey;
  73001. private _currentKey;
  73002. private _isTextHighlightOn;
  73003. private _textHighlightColor;
  73004. private _highligherOpacity;
  73005. private _highlightedText;
  73006. private _startHighlightIndex;
  73007. private _endHighlightIndex;
  73008. private _cursorIndex;
  73009. private _onFocusSelectAll;
  73010. private _isPointerDown;
  73011. private _onClipboardObserver;
  73012. private _onPointerDblTapObserver;
  73013. /** @hidden */
  73014. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  73015. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  73016. promptMessage: string;
  73017. /** Force disable prompt on mobile device */
  73018. disableMobilePrompt: boolean;
  73019. /** BABYLON.Observable raised when the text changes */
  73020. onTextChangedObservable: BABYLON.Observable<InputText>;
  73021. /** BABYLON.Observable raised just before an entered character is to be added */
  73022. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  73023. /** BABYLON.Observable raised when the control gets the focus */
  73024. onFocusObservable: BABYLON.Observable<InputText>;
  73025. /** BABYLON.Observable raised when the control loses the focus */
  73026. onBlurObservable: BABYLON.Observable<InputText>;
  73027. /**Observable raised when the text is highlighted */
  73028. onTextHighlightObservable: BABYLON.Observable<InputText>;
  73029. /**Observable raised when copy event is triggered */
  73030. onTextCopyObservable: BABYLON.Observable<InputText>;
  73031. /** BABYLON.Observable raised when cut event is triggered */
  73032. onTextCutObservable: BABYLON.Observable<InputText>;
  73033. /** BABYLON.Observable raised when paste event is triggered */
  73034. onTextPasteObservable: BABYLON.Observable<InputText>;
  73035. /** BABYLON.Observable raised when a key event was processed */
  73036. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  73037. /** Gets or sets the maximum width allowed by the control */
  73038. get maxWidth(): string | number;
  73039. /** Gets the maximum width allowed by the control in pixels */
  73040. get maxWidthInPixels(): number;
  73041. set maxWidth(value: string | number);
  73042. /** Gets or sets the text highlighter transparency; default: 0.4 */
  73043. get highligherOpacity(): number;
  73044. set highligherOpacity(value: number);
  73045. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  73046. get onFocusSelectAll(): boolean;
  73047. set onFocusSelectAll(value: boolean);
  73048. /** Gets or sets the text hightlight color */
  73049. get textHighlightColor(): string;
  73050. set textHighlightColor(value: string);
  73051. /** Gets or sets control margin */
  73052. get margin(): string;
  73053. /** Gets control margin in pixels */
  73054. get marginInPixels(): number;
  73055. set margin(value: string);
  73056. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  73057. get autoStretchWidth(): boolean;
  73058. set autoStretchWidth(value: boolean);
  73059. /** Gets or sets border thickness */
  73060. get thickness(): number;
  73061. set thickness(value: number);
  73062. /** Gets or sets the background color when focused */
  73063. get focusedBackground(): string;
  73064. set focusedBackground(value: string);
  73065. /** Gets or sets the background color when focused */
  73066. get focusedColor(): string;
  73067. set focusedColor(value: string);
  73068. /** Gets or sets the background color */
  73069. get background(): string;
  73070. set background(value: string);
  73071. /** Gets or sets the placeholder color */
  73072. get placeholderColor(): string;
  73073. set placeholderColor(value: string);
  73074. /** Gets or sets the text displayed when the control is empty */
  73075. get placeholderText(): string;
  73076. set placeholderText(value: string);
  73077. /** Gets or sets the dead key flag */
  73078. get deadKey(): boolean;
  73079. set deadKey(flag: boolean);
  73080. /** Gets or sets the highlight text */
  73081. get highlightedText(): string;
  73082. set highlightedText(text: string);
  73083. /** Gets or sets if the current key should be added */
  73084. get addKey(): boolean;
  73085. set addKey(flag: boolean);
  73086. /** Gets or sets the value of the current key being entered */
  73087. get currentKey(): string;
  73088. set currentKey(key: string);
  73089. /** Gets or sets the text displayed in the control */
  73090. get text(): string;
  73091. set text(value: string);
  73092. /** Gets or sets control width */
  73093. get width(): string | number;
  73094. set width(value: string | number);
  73095. /**
  73096. * Creates a new InputText
  73097. * @param name defines the control name
  73098. * @param text defines the text of the control
  73099. */
  73100. constructor(name?: string | undefined, text?: string);
  73101. /** @hidden */
  73102. onBlur(): void;
  73103. /** @hidden */
  73104. onFocus(): void;
  73105. protected _getTypeName(): string;
  73106. /**
  73107. * Function called to get the list of controls that should not steal the focus from this control
  73108. * @returns an array of controls
  73109. */
  73110. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  73111. /** @hidden */
  73112. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  73113. /** @hidden */
  73114. private _updateValueFromCursorIndex;
  73115. /** @hidden */
  73116. private _processDblClick;
  73117. /** @hidden */
  73118. private _selectAllText;
  73119. /**
  73120. * Handles the keyboard event
  73121. * @param evt Defines the KeyboardEvent
  73122. */
  73123. processKeyboard(evt: KeyboardEvent): void;
  73124. /** @hidden */
  73125. private _onCopyText;
  73126. /** @hidden */
  73127. private _onCutText;
  73128. /** @hidden */
  73129. private _onPasteText;
  73130. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73131. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73132. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73133. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73134. protected _beforeRenderText(text: string): string;
  73135. dispose(): void;
  73136. }
  73137. }
  73138. declare module BABYLON.GUI {
  73139. /**
  73140. * Class used to create a 2D grid container
  73141. */
  73142. export class Grid extends Container {
  73143. name?: string | undefined;
  73144. private _rowDefinitions;
  73145. private _columnDefinitions;
  73146. private _cells;
  73147. private _childControls;
  73148. /**
  73149. * Gets the number of columns
  73150. */
  73151. get columnCount(): number;
  73152. /**
  73153. * Gets the number of rows
  73154. */
  73155. get rowCount(): number;
  73156. /** Gets the list of children */
  73157. get children(): Control[];
  73158. /** Gets the list of cells (e.g. the containers) */
  73159. get cells(): {
  73160. [key: string]: Container;
  73161. };
  73162. /**
  73163. * Gets the definition of a specific row
  73164. * @param index defines the index of the row
  73165. * @returns the row definition
  73166. */
  73167. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73168. /**
  73169. * Gets the definition of a specific column
  73170. * @param index defines the index of the column
  73171. * @returns the column definition
  73172. */
  73173. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  73174. /**
  73175. * Adds a new row to the grid
  73176. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73177. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  73178. * @returns the current grid
  73179. */
  73180. addRowDefinition(height: number, isPixel?: boolean): Grid;
  73181. /**
  73182. * Adds a new column to the grid
  73183. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73184. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73185. * @returns the current grid
  73186. */
  73187. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  73188. /**
  73189. * Update a row definition
  73190. * @param index defines the index of the row to update
  73191. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  73192. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  73193. * @returns the current grid
  73194. */
  73195. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  73196. /**
  73197. * Update a column definition
  73198. * @param index defines the index of the column to update
  73199. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  73200. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  73201. * @returns the current grid
  73202. */
  73203. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  73204. /**
  73205. * Gets the list of children stored in a specific cell
  73206. * @param row defines the row to check
  73207. * @param column defines the column to check
  73208. * @returns the list of controls
  73209. */
  73210. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  73211. /**
  73212. * Gets a string representing the child cell info (row x column)
  73213. * @param child defines the control to get info from
  73214. * @returns a string containing the child cell info (row x column)
  73215. */
  73216. getChildCellInfo(child: Control): string;
  73217. private _removeCell;
  73218. private _offsetCell;
  73219. /**
  73220. * Remove a column definition at specified index
  73221. * @param index defines the index of the column to remove
  73222. * @returns the current grid
  73223. */
  73224. removeColumnDefinition(index: number): Grid;
  73225. /**
  73226. * Remove a row definition at specified index
  73227. * @param index defines the index of the row to remove
  73228. * @returns the current grid
  73229. */
  73230. removeRowDefinition(index: number): Grid;
  73231. /**
  73232. * Adds a new control to the current grid
  73233. * @param control defines the control to add
  73234. * @param row defines the row where to add the control (0 by default)
  73235. * @param column defines the column where to add the control (0 by default)
  73236. * @returns the current grid
  73237. */
  73238. addControl(control: Control, row?: number, column?: number): Grid;
  73239. /**
  73240. * Removes a control from the current container
  73241. * @param control defines the control to remove
  73242. * @returns the current container
  73243. */
  73244. removeControl(control: Control): Container;
  73245. /**
  73246. * Creates a new Grid
  73247. * @param name defines control name
  73248. */
  73249. constructor(name?: string | undefined);
  73250. protected _getTypeName(): string;
  73251. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  73252. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73253. _flagDescendantsAsMatrixDirty(): void;
  73254. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73255. /** Releases associated resources */
  73256. dispose(): void;
  73257. }
  73258. }
  73259. declare module BABYLON.GUI {
  73260. /** Class used to create color pickers */
  73261. export class ColorPicker extends Control {
  73262. name?: string | undefined;
  73263. private static _Epsilon;
  73264. private _colorWheelCanvas;
  73265. private _value;
  73266. private _tmpColor;
  73267. private _pointerStartedOnSquare;
  73268. private _pointerStartedOnWheel;
  73269. private _squareLeft;
  73270. private _squareTop;
  73271. private _squareSize;
  73272. private _h;
  73273. private _s;
  73274. private _v;
  73275. private _lastPointerDownID;
  73276. /**
  73277. * BABYLON.Observable raised when the value changes
  73278. */
  73279. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  73280. /** Gets or sets the color of the color picker */
  73281. get value(): BABYLON.Color3;
  73282. set value(value: BABYLON.Color3);
  73283. /**
  73284. * Gets or sets control width
  73285. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73286. */
  73287. get width(): string | number;
  73288. set width(value: string | number);
  73289. /**
  73290. * Gets or sets control height
  73291. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  73292. */
  73293. get height(): string | number;
  73294. /** Gets or sets control height */
  73295. set height(value: string | number);
  73296. /** Gets or sets control size */
  73297. get size(): string | number;
  73298. set size(value: string | number);
  73299. /**
  73300. * Creates a new ColorPicker
  73301. * @param name defines the control name
  73302. */
  73303. constructor(name?: string | undefined);
  73304. protected _getTypeName(): string;
  73305. /** @hidden */
  73306. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73307. private _updateSquareProps;
  73308. private _drawGradientSquare;
  73309. private _drawCircle;
  73310. private _createColorWheelCanvas;
  73311. /** @hidden */
  73312. _draw(context: CanvasRenderingContext2D): void;
  73313. private _pointerIsDown;
  73314. private _updateValueFromPointer;
  73315. private _isPointOnSquare;
  73316. private _isPointOnWheel;
  73317. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73318. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73319. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73320. /**
  73321. * This function expands the color picker by creating a color picker dialog with manual
  73322. * color value input and the ability to save colors into an array to be used later in
  73323. * subsequent launches of the dialogue.
  73324. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  73325. * @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.
  73326. * @returns picked color as a hex string and the saved colors array as hex strings.
  73327. */
  73328. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  73329. pickerWidth?: string;
  73330. pickerHeight?: string;
  73331. headerHeight?: string;
  73332. lastColor?: string;
  73333. swatchLimit?: number;
  73334. numSwatchesPerLine?: number;
  73335. savedColors?: Array<string>;
  73336. }): Promise<{
  73337. savedColors?: string[];
  73338. pickedColor: string;
  73339. }>;
  73340. }
  73341. }
  73342. declare module BABYLON.GUI {
  73343. /** Class used to create 2D ellipse containers */
  73344. export class Ellipse extends Container {
  73345. name?: string | undefined;
  73346. private _thickness;
  73347. /** Gets or sets border thickness */
  73348. get thickness(): number;
  73349. set thickness(value: number);
  73350. /**
  73351. * Creates a new Ellipse
  73352. * @param name defines the control name
  73353. */
  73354. constructor(name?: string | undefined);
  73355. protected _getTypeName(): string;
  73356. protected _localDraw(context: CanvasRenderingContext2D): void;
  73357. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73358. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  73359. }
  73360. }
  73361. declare module BABYLON.GUI {
  73362. /**
  73363. * Class used to create a password control
  73364. */
  73365. export class InputPassword extends InputText {
  73366. protected _beforeRenderText(text: string): string;
  73367. }
  73368. }
  73369. declare module BABYLON.GUI {
  73370. /** Class used to render 2D lines */
  73371. export class Line extends Control {
  73372. name?: string | undefined;
  73373. private _lineWidth;
  73374. private _x1;
  73375. private _y1;
  73376. private _x2;
  73377. private _y2;
  73378. private _dash;
  73379. private _connectedControl;
  73380. private _connectedControlDirtyObserver;
  73381. /** Gets or sets the dash pattern */
  73382. get dash(): Array<number>;
  73383. set dash(value: Array<number>);
  73384. /** Gets or sets the control connected with the line end */
  73385. get connectedControl(): Control;
  73386. set connectedControl(value: Control);
  73387. /** Gets or sets start coordinates on X axis */
  73388. get x1(): string | number;
  73389. set x1(value: string | number);
  73390. /** Gets or sets start coordinates on Y axis */
  73391. get y1(): string | number;
  73392. set y1(value: string | number);
  73393. /** Gets or sets end coordinates on X axis */
  73394. get x2(): string | number;
  73395. set x2(value: string | number);
  73396. /** Gets or sets end coordinates on Y axis */
  73397. get y2(): string | number;
  73398. set y2(value: string | number);
  73399. /** Gets or sets line width */
  73400. get lineWidth(): number;
  73401. set lineWidth(value: number);
  73402. /** Gets or sets horizontal alignment */
  73403. set horizontalAlignment(value: number);
  73404. /** Gets or sets vertical alignment */
  73405. set verticalAlignment(value: number);
  73406. private get _effectiveX2();
  73407. private get _effectiveY2();
  73408. /**
  73409. * Creates a new Line
  73410. * @param name defines the control name
  73411. */
  73412. constructor(name?: string | undefined);
  73413. protected _getTypeName(): string;
  73414. _draw(context: CanvasRenderingContext2D): void;
  73415. _measure(): void;
  73416. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73417. /**
  73418. * Move one end of the line given 3D cartesian coordinates.
  73419. * @param position Targeted world position
  73420. * @param scene BABYLON.Scene
  73421. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73422. */
  73423. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  73424. /**
  73425. * Move one end of the line to a position in screen absolute space.
  73426. * @param projectedPosition Position in screen absolute space (X, Y)
  73427. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  73428. */
  73429. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  73430. }
  73431. }
  73432. declare module BABYLON.GUI {
  73433. /**
  73434. * Class used to store a point for a MultiLine object.
  73435. * The point can be pure 2D coordinates, a mesh or a control
  73436. */
  73437. export class MultiLinePoint {
  73438. private _multiLine;
  73439. private _x;
  73440. private _y;
  73441. private _control;
  73442. private _mesh;
  73443. private _controlObserver;
  73444. private _meshObserver;
  73445. /** @hidden */
  73446. _point: BABYLON.Vector2;
  73447. /**
  73448. * Creates a new MultiLinePoint
  73449. * @param multiLine defines the source MultiLine object
  73450. */
  73451. constructor(multiLine: MultiLine);
  73452. /** Gets or sets x coordinate */
  73453. get x(): string | number;
  73454. set x(value: string | number);
  73455. /** Gets or sets y coordinate */
  73456. get y(): string | number;
  73457. set y(value: string | number);
  73458. /** Gets or sets the control associated with this point */
  73459. get control(): BABYLON.Nullable<Control>;
  73460. set control(value: BABYLON.Nullable<Control>);
  73461. /** Gets or sets the mesh associated with this point */
  73462. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73463. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  73464. /** Resets links */
  73465. resetLinks(): void;
  73466. /**
  73467. * Gets a translation vector
  73468. * @returns the translation vector
  73469. */
  73470. translate(): BABYLON.Vector2;
  73471. private _translatePoint;
  73472. /** Release associated resources */
  73473. dispose(): void;
  73474. }
  73475. }
  73476. declare module BABYLON.GUI {
  73477. /**
  73478. * Class used to create multi line control
  73479. */
  73480. export class MultiLine extends Control {
  73481. name?: string | undefined;
  73482. private _lineWidth;
  73483. private _dash;
  73484. private _points;
  73485. private _minX;
  73486. private _minY;
  73487. private _maxX;
  73488. private _maxY;
  73489. /**
  73490. * Creates a new MultiLine
  73491. * @param name defines the control name
  73492. */
  73493. constructor(name?: string | undefined);
  73494. /** Gets or sets dash pattern */
  73495. get dash(): Array<number>;
  73496. set dash(value: Array<number>);
  73497. /**
  73498. * Gets point stored at specified index
  73499. * @param index defines the index to look for
  73500. * @returns the requested point if found
  73501. */
  73502. getAt(index: number): MultiLinePoint;
  73503. /** Function called when a point is updated */
  73504. onPointUpdate: () => void;
  73505. /**
  73506. * Adds new points to the point collection
  73507. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  73508. * @returns the list of created MultiLinePoint
  73509. */
  73510. add(...items: (AbstractMesh | Control | {
  73511. x: string | number;
  73512. y: string | number;
  73513. })[]): MultiLinePoint[];
  73514. /**
  73515. * Adds a new point to the point collection
  73516. * @param item defines the item (mesh, control or 2d coordiantes) to add
  73517. * @returns the created MultiLinePoint
  73518. */
  73519. push(item?: (AbstractMesh | Control | {
  73520. x: string | number;
  73521. y: string | number;
  73522. })): MultiLinePoint;
  73523. /**
  73524. * Remove a specific value or point from the active point collection
  73525. * @param value defines the value or point to remove
  73526. */
  73527. remove(value: number | MultiLinePoint): void;
  73528. /**
  73529. * Resets this object to initial state (no point)
  73530. */
  73531. reset(): void;
  73532. /**
  73533. * Resets all links
  73534. */
  73535. resetLinks(): void;
  73536. /** Gets or sets line width */
  73537. get lineWidth(): number;
  73538. set lineWidth(value: number);
  73539. set horizontalAlignment(value: number);
  73540. set verticalAlignment(value: number);
  73541. protected _getTypeName(): string;
  73542. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73543. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73544. _measure(): void;
  73545. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73546. dispose(): void;
  73547. }
  73548. }
  73549. declare module BABYLON.GUI {
  73550. /**
  73551. * Class used to create radio button controls
  73552. */
  73553. export class RadioButton extends Control {
  73554. name?: string | undefined;
  73555. private _isChecked;
  73556. private _background;
  73557. private _checkSizeRatio;
  73558. private _thickness;
  73559. /** Gets or sets border thickness */
  73560. get thickness(): number;
  73561. set thickness(value: number);
  73562. /** Gets or sets group name */
  73563. group: string;
  73564. /** BABYLON.Observable raised when isChecked is changed */
  73565. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  73566. /** Gets or sets a value indicating the ratio between overall size and check size */
  73567. get checkSizeRatio(): number;
  73568. set checkSizeRatio(value: number);
  73569. /** Gets or sets background color */
  73570. get background(): string;
  73571. set background(value: string);
  73572. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  73573. get isChecked(): boolean;
  73574. set isChecked(value: boolean);
  73575. /**
  73576. * Creates a new RadioButton
  73577. * @param name defines the control name
  73578. */
  73579. constructor(name?: string | undefined);
  73580. protected _getTypeName(): string;
  73581. _draw(context: CanvasRenderingContext2D): void;
  73582. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73583. /**
  73584. * Utility function to easily create a radio button with a header
  73585. * @param title defines the label to use for the header
  73586. * @param group defines the group to use for the radio button
  73587. * @param isChecked defines the initial state of the radio button
  73588. * @param onValueChanged defines the callback to call when value changes
  73589. * @returns a StackPanel containing the radio button and a textBlock
  73590. */
  73591. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  73592. }
  73593. }
  73594. declare module BABYLON.GUI {
  73595. /**
  73596. * Class used to create slider controls
  73597. */
  73598. export class BaseSlider extends Control {
  73599. name?: string | undefined;
  73600. protected _thumbWidth: ValueAndUnit;
  73601. private _minimum;
  73602. private _maximum;
  73603. private _value;
  73604. private _isVertical;
  73605. protected _barOffset: ValueAndUnit;
  73606. private _isThumbClamped;
  73607. protected _displayThumb: boolean;
  73608. private _step;
  73609. private _lastPointerDownID;
  73610. protected _effectiveBarOffset: number;
  73611. protected _renderLeft: number;
  73612. protected _renderTop: number;
  73613. protected _renderWidth: number;
  73614. protected _renderHeight: number;
  73615. protected _backgroundBoxLength: number;
  73616. protected _backgroundBoxThickness: number;
  73617. protected _effectiveThumbThickness: number;
  73618. /** BABYLON.Observable raised when the sldier value changes */
  73619. onValueChangedObservable: BABYLON.Observable<number>;
  73620. /** Gets or sets a boolean indicating if the thumb must be rendered */
  73621. get displayThumb(): boolean;
  73622. set displayThumb(value: boolean);
  73623. /** Gets or sets a step to apply to values (0 by default) */
  73624. get step(): number;
  73625. set step(value: number);
  73626. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  73627. get barOffset(): string | number;
  73628. /** Gets main bar offset in pixels*/
  73629. get barOffsetInPixels(): number;
  73630. set barOffset(value: string | number);
  73631. /** Gets or sets thumb width */
  73632. get thumbWidth(): string | number;
  73633. /** Gets thumb width in pixels */
  73634. get thumbWidthInPixels(): number;
  73635. set thumbWidth(value: string | number);
  73636. /** Gets or sets minimum value */
  73637. get minimum(): number;
  73638. set minimum(value: number);
  73639. /** Gets or sets maximum value */
  73640. get maximum(): number;
  73641. set maximum(value: number);
  73642. /** Gets or sets current value */
  73643. get value(): number;
  73644. set value(value: number);
  73645. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  73646. get isVertical(): boolean;
  73647. set isVertical(value: boolean);
  73648. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  73649. get isThumbClamped(): boolean;
  73650. set isThumbClamped(value: boolean);
  73651. /**
  73652. * Creates a new BaseSlider
  73653. * @param name defines the control name
  73654. */
  73655. constructor(name?: string | undefined);
  73656. protected _getTypeName(): string;
  73657. protected _getThumbPosition(): number;
  73658. protected _getThumbThickness(type: string): number;
  73659. protected _prepareRenderingData(type: string): void;
  73660. private _pointerIsDown;
  73661. /** @hidden */
  73662. protected _updateValueFromPointer(x: number, y: number): void;
  73663. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73664. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  73665. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73666. }
  73667. }
  73668. declare module BABYLON.GUI {
  73669. /**
  73670. * Class used to create slider controls
  73671. */
  73672. export class Slider extends BaseSlider {
  73673. name?: string | undefined;
  73674. private _background;
  73675. private _borderColor;
  73676. private _isThumbCircle;
  73677. protected _displayValueBar: boolean;
  73678. /** Gets or sets a boolean indicating if the value bar must be rendered */
  73679. get displayValueBar(): boolean;
  73680. set displayValueBar(value: boolean);
  73681. /** Gets or sets border color */
  73682. get borderColor(): string;
  73683. set borderColor(value: string);
  73684. /** Gets or sets background color */
  73685. get background(): string;
  73686. set background(value: string);
  73687. /** Gets or sets a boolean indicating if the thumb should be round or square */
  73688. get isThumbCircle(): boolean;
  73689. set isThumbCircle(value: boolean);
  73690. /**
  73691. * Creates a new Slider
  73692. * @param name defines the control name
  73693. */
  73694. constructor(name?: string | undefined);
  73695. protected _getTypeName(): string;
  73696. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73697. }
  73698. }
  73699. declare module BABYLON.GUI {
  73700. /** Class used to create a RadioGroup
  73701. * which contains groups of radio buttons
  73702. */
  73703. export class SelectorGroup {
  73704. /** name of SelectorGroup */
  73705. name: string;
  73706. private _groupPanel;
  73707. private _selectors;
  73708. private _groupHeader;
  73709. /**
  73710. * Creates a new SelectorGroup
  73711. * @param name of group, used as a group heading
  73712. */
  73713. constructor(
  73714. /** name of SelectorGroup */
  73715. name: string);
  73716. /** Gets the groupPanel of the SelectorGroup */
  73717. get groupPanel(): StackPanel;
  73718. /** Gets the selectors array */
  73719. get selectors(): StackPanel[];
  73720. /** Gets and sets the group header */
  73721. get header(): string;
  73722. set header(label: string);
  73723. /** @hidden */
  73724. private _addGroupHeader;
  73725. /** @hidden*/
  73726. _getSelector(selectorNb: number): StackPanel | undefined;
  73727. /** Removes the selector at the given position
  73728. * @param selectorNb the position of the selector within the group
  73729. */
  73730. removeSelector(selectorNb: number): void;
  73731. }
  73732. /** Class used to create a CheckboxGroup
  73733. * which contains groups of checkbox buttons
  73734. */
  73735. export class CheckboxGroup extends SelectorGroup {
  73736. /** Adds a checkbox as a control
  73737. * @param text is the label for the selector
  73738. * @param func is the function called when the Selector is checked
  73739. * @param checked is true when Selector is checked
  73740. */
  73741. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  73742. /** @hidden */
  73743. _setSelectorLabel(selectorNb: number, label: string): void;
  73744. /** @hidden */
  73745. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73746. /** @hidden */
  73747. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73748. /** @hidden */
  73749. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73750. }
  73751. /** Class used to create a RadioGroup
  73752. * which contains groups of radio buttons
  73753. */
  73754. export class RadioGroup extends SelectorGroup {
  73755. private _selectNb;
  73756. /** Adds a radio button as a control
  73757. * @param label is the label for the selector
  73758. * @param func is the function called when the Selector is checked
  73759. * @param checked is true when Selector is checked
  73760. */
  73761. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  73762. /** @hidden */
  73763. _setSelectorLabel(selectorNb: number, label: string): void;
  73764. /** @hidden */
  73765. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73766. /** @hidden */
  73767. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73768. /** @hidden */
  73769. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73770. }
  73771. /** Class used to create a SliderGroup
  73772. * which contains groups of slider buttons
  73773. */
  73774. export class SliderGroup extends SelectorGroup {
  73775. /**
  73776. * Adds a slider to the SelectorGroup
  73777. * @param label is the label for the SliderBar
  73778. * @param func is the function called when the Slider moves
  73779. * @param unit is a string describing the units used, eg degrees or metres
  73780. * @param min is the minimum value for the Slider
  73781. * @param max is the maximum value for the Slider
  73782. * @param value is the start value for the Slider between min and max
  73783. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  73784. */
  73785. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  73786. /** @hidden */
  73787. _setSelectorLabel(selectorNb: number, label: string): void;
  73788. /** @hidden */
  73789. _setSelectorLabelColor(selectorNb: number, color: string): void;
  73790. /** @hidden */
  73791. _setSelectorButtonColor(selectorNb: number, color: string): void;
  73792. /** @hidden */
  73793. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  73794. }
  73795. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  73796. * @see http://doc.babylonjs.com/how_to/selector
  73797. */
  73798. export class SelectionPanel extends Rectangle {
  73799. /** name of SelectionPanel */
  73800. name: string;
  73801. /** an array of SelectionGroups */
  73802. groups: SelectorGroup[];
  73803. private _panel;
  73804. private _buttonColor;
  73805. private _buttonBackground;
  73806. private _headerColor;
  73807. private _barColor;
  73808. private _barHeight;
  73809. private _spacerHeight;
  73810. private _labelColor;
  73811. private _groups;
  73812. private _bars;
  73813. /**
  73814. * Creates a new SelectionPanel
  73815. * @param name of SelectionPanel
  73816. * @param groups is an array of SelectionGroups
  73817. */
  73818. constructor(
  73819. /** name of SelectionPanel */
  73820. name: string,
  73821. /** an array of SelectionGroups */
  73822. groups?: SelectorGroup[]);
  73823. protected _getTypeName(): string;
  73824. /** Gets or sets the headerColor */
  73825. get headerColor(): string;
  73826. set headerColor(color: string);
  73827. private _setHeaderColor;
  73828. /** Gets or sets the button color */
  73829. get buttonColor(): string;
  73830. set buttonColor(color: string);
  73831. private _setbuttonColor;
  73832. /** Gets or sets the label color */
  73833. get labelColor(): string;
  73834. set labelColor(color: string);
  73835. private _setLabelColor;
  73836. /** Gets or sets the button background */
  73837. get buttonBackground(): string;
  73838. set buttonBackground(color: string);
  73839. private _setButtonBackground;
  73840. /** Gets or sets the color of separator bar */
  73841. get barColor(): string;
  73842. set barColor(color: string);
  73843. private _setBarColor;
  73844. /** Gets or sets the height of separator bar */
  73845. get barHeight(): string;
  73846. set barHeight(value: string);
  73847. private _setBarHeight;
  73848. /** Gets or sets the height of spacers*/
  73849. get spacerHeight(): string;
  73850. set spacerHeight(value: string);
  73851. private _setSpacerHeight;
  73852. /** Adds a bar between groups */
  73853. private _addSpacer;
  73854. /** Add a group to the selection panel
  73855. * @param group is the selector group to add
  73856. */
  73857. addGroup(group: SelectorGroup): void;
  73858. /** Remove the group from the given position
  73859. * @param groupNb is the position of the group in the list
  73860. */
  73861. removeGroup(groupNb: number): void;
  73862. /** Change a group header label
  73863. * @param label is the new group header label
  73864. * @param groupNb is the number of the group to relabel
  73865. * */
  73866. setHeaderName(label: string, groupNb: number): void;
  73867. /** Change selector label to the one given
  73868. * @param label is the new selector label
  73869. * @param groupNb is the number of the groupcontaining the selector
  73870. * @param selectorNb is the number of the selector within a group to relabel
  73871. * */
  73872. relabel(label: string, groupNb: number, selectorNb: number): void;
  73873. /** For a given group position remove the selector at the given position
  73874. * @param groupNb is the number of the group to remove the selector from
  73875. * @param selectorNb is the number of the selector within the group
  73876. */
  73877. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  73878. /** For a given group position of correct type add a checkbox button
  73879. * @param groupNb is the number of the group to remove the selector from
  73880. * @param label is the label for the selector
  73881. * @param func is the function called when the Selector is checked
  73882. * @param checked is true when Selector is checked
  73883. */
  73884. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73885. /** For a given group position of correct type add a radio button
  73886. * @param groupNb is the number of the group to remove the selector from
  73887. * @param label is the label for the selector
  73888. * @param func is the function called when the Selector is checked
  73889. * @param checked is true when Selector is checked
  73890. */
  73891. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  73892. /**
  73893. * For a given slider group add a slider
  73894. * @param groupNb is the number of the group to add the slider to
  73895. * @param label is the label for the Slider
  73896. * @param func is the function called when the Slider moves
  73897. * @param unit is a string describing the units used, eg degrees or metres
  73898. * @param min is the minimum value for the Slider
  73899. * @param max is the maximum value for the Slider
  73900. * @param value is the start value for the Slider between min and max
  73901. * @param onVal is the function used to format the value displayed, eg radians to degrees
  73902. */
  73903. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  73904. }
  73905. }
  73906. declare module BABYLON.GUI {
  73907. /**
  73908. * Class used to hold a the container for ScrollViewer
  73909. * @hidden
  73910. */
  73911. export class _ScrollViewerWindow extends Container {
  73912. parentClientWidth: number;
  73913. parentClientHeight: number;
  73914. private _freezeControls;
  73915. private _parentMeasure;
  73916. private _oldLeft;
  73917. private _oldTop;
  73918. get freezeControls(): boolean;
  73919. set freezeControls(value: boolean);
  73920. private _bucketWidth;
  73921. private _bucketHeight;
  73922. private _buckets;
  73923. private _bucketLen;
  73924. get bucketWidth(): number;
  73925. get bucketHeight(): number;
  73926. setBucketSizes(width: number, height: number): void;
  73927. private _useBuckets;
  73928. private _makeBuckets;
  73929. private _dispatchInBuckets;
  73930. private _updateMeasures;
  73931. private _updateChildrenMeasures;
  73932. private _restoreMeasures;
  73933. /**
  73934. * Creates a new ScrollViewerWindow
  73935. * @param name of ScrollViewerWindow
  73936. */
  73937. constructor(name?: string);
  73938. protected _getTypeName(): string;
  73939. /** @hidden */
  73940. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73941. /** @hidden */
  73942. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  73943. private _scrollChildren;
  73944. private _scrollChildrenWithBuckets;
  73945. /** @hidden */
  73946. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  73947. protected _postMeasure(): void;
  73948. }
  73949. }
  73950. declare module BABYLON.GUI {
  73951. /**
  73952. * Class used to create slider controls
  73953. */
  73954. export class ScrollBar extends BaseSlider {
  73955. name?: string | undefined;
  73956. private _background;
  73957. private _borderColor;
  73958. private _tempMeasure;
  73959. /** Gets or sets border color */
  73960. get borderColor(): string;
  73961. set borderColor(value: string);
  73962. /** Gets or sets background color */
  73963. get background(): string;
  73964. set background(value: string);
  73965. /**
  73966. * Creates a new Slider
  73967. * @param name defines the control name
  73968. */
  73969. constructor(name?: string | undefined);
  73970. protected _getTypeName(): string;
  73971. protected _getThumbThickness(): number;
  73972. _draw(context: CanvasRenderingContext2D): void;
  73973. private _first;
  73974. private _originX;
  73975. private _originY;
  73976. /** @hidden */
  73977. protected _updateValueFromPointer(x: number, y: number): void;
  73978. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73979. }
  73980. }
  73981. declare module BABYLON.GUI {
  73982. /**
  73983. * Class used to create slider controls
  73984. */
  73985. export class ImageScrollBar extends BaseSlider {
  73986. name?: string | undefined;
  73987. private _backgroundBaseImage;
  73988. private _backgroundImage;
  73989. private _thumbImage;
  73990. private _thumbBaseImage;
  73991. private _thumbLength;
  73992. private _thumbHeight;
  73993. private _barImageHeight;
  73994. private _tempMeasure;
  73995. /** Number of 90° rotation to apply on the images when in vertical mode */
  73996. num90RotationInVerticalMode: number;
  73997. /**
  73998. * Gets or sets the image used to render the background for horizontal bar
  73999. */
  74000. get backgroundImage(): Image;
  74001. set backgroundImage(value: Image);
  74002. /**
  74003. * Gets or sets the image used to render the thumb
  74004. */
  74005. get thumbImage(): Image;
  74006. set thumbImage(value: Image);
  74007. /**
  74008. * Gets or sets the length of the thumb
  74009. */
  74010. get thumbLength(): number;
  74011. set thumbLength(value: number);
  74012. /**
  74013. * Gets or sets the height of the thumb
  74014. */
  74015. get thumbHeight(): number;
  74016. set thumbHeight(value: number);
  74017. /**
  74018. * Gets or sets the height of the bar image
  74019. */
  74020. get barImageHeight(): number;
  74021. set barImageHeight(value: number);
  74022. /**
  74023. * Creates a new ImageScrollBar
  74024. * @param name defines the control name
  74025. */
  74026. constructor(name?: string | undefined);
  74027. protected _getTypeName(): string;
  74028. protected _getThumbThickness(): number;
  74029. _draw(context: CanvasRenderingContext2D): void;
  74030. private _first;
  74031. private _originX;
  74032. private _originY;
  74033. /** @hidden */
  74034. protected _updateValueFromPointer(x: number, y: number): void;
  74035. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  74036. }
  74037. }
  74038. declare module BABYLON.GUI {
  74039. /**
  74040. * Class used to hold a viewer window and sliders in a grid
  74041. */
  74042. export class ScrollViewer extends Rectangle {
  74043. private _grid;
  74044. private _horizontalBarSpace;
  74045. private _verticalBarSpace;
  74046. private _dragSpace;
  74047. private _horizontalBar;
  74048. private _verticalBar;
  74049. private _barColor;
  74050. private _barBackground;
  74051. private _barImage;
  74052. private _horizontalBarImage;
  74053. private _verticalBarImage;
  74054. private _barBackgroundImage;
  74055. private _horizontalBarBackgroundImage;
  74056. private _verticalBarBackgroundImage;
  74057. private _barSize;
  74058. private _window;
  74059. private _pointerIsOver;
  74060. private _wheelPrecision;
  74061. private _onWheelObserver;
  74062. private _clientWidth;
  74063. private _clientHeight;
  74064. private _useImageBar;
  74065. private _thumbLength;
  74066. private _thumbHeight;
  74067. private _barImageHeight;
  74068. private _horizontalBarImageHeight;
  74069. private _verticalBarImageHeight;
  74070. /**
  74071. * Gets the horizontal scrollbar
  74072. */
  74073. get horizontalBar(): ScrollBar | ImageScrollBar;
  74074. /**
  74075. * Gets the vertical scrollbar
  74076. */
  74077. get verticalBar(): ScrollBar | ImageScrollBar;
  74078. /**
  74079. * Adds a new control to the current container
  74080. * @param control defines the control to add
  74081. * @returns the current container
  74082. */
  74083. addControl(control: BABYLON.Nullable<Control>): Container;
  74084. /**
  74085. * Removes a control from the current container
  74086. * @param control defines the control to remove
  74087. * @returns the current container
  74088. */
  74089. removeControl(control: Control): Container;
  74090. /** Gets the list of children */
  74091. get children(): Control[];
  74092. _flagDescendantsAsMatrixDirty(): void;
  74093. /**
  74094. * Freezes or unfreezes the controls in the window.
  74095. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  74096. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  74097. */
  74098. get freezeControls(): boolean;
  74099. set freezeControls(value: boolean);
  74100. /** Gets the bucket width */
  74101. get bucketWidth(): number;
  74102. /** Gets the bucket height */
  74103. get bucketHeight(): number;
  74104. /**
  74105. * Sets the bucket sizes.
  74106. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  74107. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  74108. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  74109. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  74110. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  74111. * used), that's why it is not enabled by default.
  74112. * @param width width of the bucket
  74113. * @param height height of the bucket
  74114. */
  74115. setBucketSizes(width: number, height: number): void;
  74116. private _forceHorizontalBar;
  74117. private _forceVerticalBar;
  74118. /**
  74119. * Forces the horizontal scroll bar to be displayed
  74120. */
  74121. get forceHorizontalBar(): boolean;
  74122. set forceHorizontalBar(value: boolean);
  74123. /**
  74124. * Forces the vertical scroll bar to be displayed
  74125. */
  74126. get forceVerticalBar(): boolean;
  74127. set forceVerticalBar(value: boolean);
  74128. /**
  74129. * Creates a new ScrollViewer
  74130. * @param name of ScrollViewer
  74131. */
  74132. constructor(name?: string, isImageBased?: boolean);
  74133. /** Reset the scroll viewer window to initial size */
  74134. resetWindow(): void;
  74135. protected _getTypeName(): string;
  74136. private _buildClientSizes;
  74137. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  74138. protected _postMeasure(): void;
  74139. /**
  74140. * Gets or sets the mouse wheel precision
  74141. * from 0 to 1 with a default value of 0.05
  74142. * */
  74143. get wheelPrecision(): number;
  74144. set wheelPrecision(value: number);
  74145. /** Gets or sets the scroll bar container background color */
  74146. get scrollBackground(): string;
  74147. set scrollBackground(color: string);
  74148. /** Gets or sets the bar color */
  74149. get barColor(): string;
  74150. set barColor(color: string);
  74151. /** Gets or sets the bar image */
  74152. get thumbImage(): Image;
  74153. set thumbImage(value: Image);
  74154. /** Gets or sets the horizontal bar image */
  74155. get horizontalThumbImage(): Image;
  74156. set horizontalThumbImage(value: Image);
  74157. /** Gets or sets the vertical bar image */
  74158. get verticalThumbImage(): Image;
  74159. set verticalThumbImage(value: Image);
  74160. /** Gets or sets the size of the bar */
  74161. get barSize(): number;
  74162. set barSize(value: number);
  74163. /** Gets or sets the length of the thumb */
  74164. get thumbLength(): number;
  74165. set thumbLength(value: number);
  74166. /** Gets or sets the height of the thumb */
  74167. get thumbHeight(): number;
  74168. set thumbHeight(value: number);
  74169. /** Gets or sets the height of the bar image */
  74170. get barImageHeight(): number;
  74171. set barImageHeight(value: number);
  74172. /** Gets or sets the height of the horizontal bar image */
  74173. get horizontalBarImageHeight(): number;
  74174. set horizontalBarImageHeight(value: number);
  74175. /** Gets or sets the height of the vertical bar image */
  74176. get verticalBarImageHeight(): number;
  74177. set verticalBarImageHeight(value: number);
  74178. /** Gets or sets the bar background */
  74179. get barBackground(): string;
  74180. set barBackground(color: string);
  74181. /** Gets or sets the bar background image */
  74182. get barImage(): Image;
  74183. set barImage(value: Image);
  74184. /** Gets or sets the horizontal bar background image */
  74185. get horizontalBarImage(): Image;
  74186. set horizontalBarImage(value: Image);
  74187. /** Gets or sets the vertical bar background image */
  74188. get verticalBarImage(): Image;
  74189. set verticalBarImage(value: Image);
  74190. private _setWindowPosition;
  74191. /** @hidden */
  74192. private _updateScroller;
  74193. _link(host: AdvancedDynamicTexture): void;
  74194. /** @hidden */
  74195. private _addBar;
  74196. /** @hidden */
  74197. private _attachWheel;
  74198. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  74199. /** Releases associated resources */
  74200. dispose(): void;
  74201. }
  74202. }
  74203. declare module BABYLON.GUI {
  74204. /** Class used to render a grid */
  74205. export class DisplayGrid extends Control {
  74206. name?: string | undefined;
  74207. private _cellWidth;
  74208. private _cellHeight;
  74209. private _minorLineTickness;
  74210. private _minorLineColor;
  74211. private _majorLineTickness;
  74212. private _majorLineColor;
  74213. private _majorLineFrequency;
  74214. private _background;
  74215. private _displayMajorLines;
  74216. private _displayMinorLines;
  74217. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  74218. get displayMinorLines(): boolean;
  74219. set displayMinorLines(value: boolean);
  74220. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  74221. get displayMajorLines(): boolean;
  74222. set displayMajorLines(value: boolean);
  74223. /** Gets or sets background color (Black by default) */
  74224. get background(): string;
  74225. set background(value: string);
  74226. /** Gets or sets the width of each cell (20 by default) */
  74227. get cellWidth(): number;
  74228. set cellWidth(value: number);
  74229. /** Gets or sets the height of each cell (20 by default) */
  74230. get cellHeight(): number;
  74231. set cellHeight(value: number);
  74232. /** Gets or sets the tickness of minor lines (1 by default) */
  74233. get minorLineTickness(): number;
  74234. set minorLineTickness(value: number);
  74235. /** Gets or sets the color of minor lines (DarkGray by default) */
  74236. get minorLineColor(): string;
  74237. set minorLineColor(value: string);
  74238. /** Gets or sets the tickness of major lines (2 by default) */
  74239. get majorLineTickness(): number;
  74240. set majorLineTickness(value: number);
  74241. /** Gets or sets the color of major lines (White by default) */
  74242. get majorLineColor(): string;
  74243. set majorLineColor(value: string);
  74244. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  74245. get majorLineFrequency(): number;
  74246. set majorLineFrequency(value: number);
  74247. /**
  74248. * Creates a new GridDisplayRectangle
  74249. * @param name defines the control name
  74250. */
  74251. constructor(name?: string | undefined);
  74252. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74253. protected _getTypeName(): string;
  74254. }
  74255. }
  74256. declare module BABYLON.GUI {
  74257. /**
  74258. * Class used to create slider controls based on images
  74259. */
  74260. export class ImageBasedSlider extends BaseSlider {
  74261. name?: string | undefined;
  74262. private _backgroundImage;
  74263. private _thumbImage;
  74264. private _valueBarImage;
  74265. private _tempMeasure;
  74266. get displayThumb(): boolean;
  74267. set displayThumb(value: boolean);
  74268. /**
  74269. * Gets or sets the image used to render the background
  74270. */
  74271. get backgroundImage(): Image;
  74272. set backgroundImage(value: Image);
  74273. /**
  74274. * Gets or sets the image used to render the value bar
  74275. */
  74276. get valueBarImage(): Image;
  74277. set valueBarImage(value: Image);
  74278. /**
  74279. * Gets or sets the image used to render the thumb
  74280. */
  74281. get thumbImage(): Image;
  74282. set thumbImage(value: Image);
  74283. /**
  74284. * Creates a new ImageBasedSlider
  74285. * @param name defines the control name
  74286. */
  74287. constructor(name?: string | undefined);
  74288. protected _getTypeName(): string;
  74289. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  74290. }
  74291. }
  74292. declare module BABYLON.GUI {
  74293. /**
  74294. * Forcing an export so that this code will execute
  74295. * @hidden
  74296. */
  74297. const name = "Statics";
  74298. }
  74299. declare module BABYLON.GUI {
  74300. /**
  74301. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  74302. */
  74303. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  74304. /**
  74305. * Define the instrumented AdvancedDynamicTexture.
  74306. */
  74307. texture: AdvancedDynamicTexture;
  74308. private _captureRenderTime;
  74309. private _renderTime;
  74310. private _captureLayoutTime;
  74311. private _layoutTime;
  74312. private _onBeginRenderObserver;
  74313. private _onEndRenderObserver;
  74314. private _onBeginLayoutObserver;
  74315. private _onEndLayoutObserver;
  74316. /**
  74317. * Gets the perf counter used to capture render time
  74318. */
  74319. get renderTimeCounter(): BABYLON.PerfCounter;
  74320. /**
  74321. * Gets the perf counter used to capture layout time
  74322. */
  74323. get layoutTimeCounter(): BABYLON.PerfCounter;
  74324. /**
  74325. * Enable or disable the render time capture
  74326. */
  74327. get captureRenderTime(): boolean;
  74328. set captureRenderTime(value: boolean);
  74329. /**
  74330. * Enable or disable the layout time capture
  74331. */
  74332. get captureLayoutTime(): boolean;
  74333. set captureLayoutTime(value: boolean);
  74334. /**
  74335. * Instantiates a new advanced dynamic texture instrumentation.
  74336. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  74337. * @param texture Defines the AdvancedDynamicTexture to instrument
  74338. */
  74339. constructor(
  74340. /**
  74341. * Define the instrumented AdvancedDynamicTexture.
  74342. */
  74343. texture: AdvancedDynamicTexture);
  74344. /**
  74345. * Dispose and release associated resources.
  74346. */
  74347. dispose(): void;
  74348. }
  74349. }
  74350. declare module BABYLON.GUI {
  74351. /**
  74352. * Class used to load GUI via XML.
  74353. */
  74354. export class XmlLoader {
  74355. private _nodes;
  74356. private _nodeTypes;
  74357. private _isLoaded;
  74358. private _objectAttributes;
  74359. private _parentClass;
  74360. /**
  74361. * Create a new xml loader
  74362. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  74363. */
  74364. constructor(parentClass?: null);
  74365. private _getChainElement;
  74366. private _getClassAttribute;
  74367. private _createGuiElement;
  74368. private _parseGrid;
  74369. private _parseElement;
  74370. private _prepareSourceElement;
  74371. private _parseElementsFromSource;
  74372. private _parseXml;
  74373. /**
  74374. * Gets if the loading has finished.
  74375. * @returns whether the loading has finished or not
  74376. */
  74377. isLoaded(): boolean;
  74378. /**
  74379. * Gets a loaded node / control by id.
  74380. * @param id the Controls id set in the xml
  74381. * @returns element of type Control
  74382. */
  74383. getNodeById(id: string): any;
  74384. /**
  74385. * Gets all loaded nodes / controls
  74386. * @returns Array of controls
  74387. */
  74388. getNodes(): any;
  74389. /**
  74390. * Initiates the xml layout loading
  74391. * @param xmlFile defines the xml layout to load
  74392. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  74393. * @param callback defines the callback called on layout load.
  74394. */
  74395. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  74396. }
  74397. }
  74398. declare module BABYLON.GUI {
  74399. /**
  74400. * Class used to create containers for controls
  74401. */
  74402. export class Container3D extends Control3D {
  74403. private _blockLayout;
  74404. /**
  74405. * Gets the list of child controls
  74406. */
  74407. protected _children: Control3D[];
  74408. /**
  74409. * Gets the list of child controls
  74410. */
  74411. get children(): Array<Control3D>;
  74412. /**
  74413. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  74414. * This is helpful to optimize layout operation when adding multiple children in a row
  74415. */
  74416. get blockLayout(): boolean;
  74417. set blockLayout(value: boolean);
  74418. /**
  74419. * Creates a new container
  74420. * @param name defines the container name
  74421. */
  74422. constructor(name?: string);
  74423. /**
  74424. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  74425. * @returns the current container
  74426. */
  74427. updateLayout(): Container3D;
  74428. /**
  74429. * Gets a boolean indicating if the given control is in the children of this control
  74430. * @param control defines the control to check
  74431. * @returns true if the control is in the child list
  74432. */
  74433. containsControl(control: Control3D): boolean;
  74434. /**
  74435. * Adds a control to the children of this control
  74436. * @param control defines the control to add
  74437. * @returns the current container
  74438. */
  74439. addControl(control: Control3D): Container3D;
  74440. /**
  74441. * This function will be called everytime a new control is added
  74442. */
  74443. protected _arrangeChildren(): void;
  74444. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74445. /**
  74446. * Removes a control from the children of this control
  74447. * @param control defines the control to remove
  74448. * @returns the current container
  74449. */
  74450. removeControl(control: Control3D): Container3D;
  74451. protected _getTypeName(): string;
  74452. /**
  74453. * Releases all associated resources
  74454. */
  74455. dispose(): void;
  74456. /** Control rotation will remain unchanged */
  74457. static readonly UNSET_ORIENTATION: number;
  74458. /** Control will rotate to make it look at sphere central axis */
  74459. static readonly FACEORIGIN_ORIENTATION: number;
  74460. /** Control will rotate to make it look back at sphere central axis */
  74461. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  74462. /** Control will rotate to look at z axis (0, 0, 1) */
  74463. static readonly FACEFORWARD_ORIENTATION: number;
  74464. /** Control will rotate to look at negative z axis (0, 0, -1) */
  74465. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  74466. }
  74467. }
  74468. declare module BABYLON.GUI {
  74469. /**
  74470. * Class used to manage 3D user interface
  74471. * @see http://doc.babylonjs.com/how_to/gui3d
  74472. */
  74473. export class GUI3DManager implements BABYLON.IDisposable {
  74474. private _scene;
  74475. private _sceneDisposeObserver;
  74476. private _utilityLayer;
  74477. private _rootContainer;
  74478. private _pointerObserver;
  74479. private _pointerOutObserver;
  74480. /** @hidden */
  74481. _lastPickedControl: Control3D;
  74482. /** @hidden */
  74483. _lastControlOver: {
  74484. [pointerId: number]: Control3D;
  74485. };
  74486. /** @hidden */
  74487. _lastControlDown: {
  74488. [pointerId: number]: Control3D;
  74489. };
  74490. /**
  74491. * BABYLON.Observable raised when the point picked by the pointer events changed
  74492. */
  74493. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  74494. /** @hidden */
  74495. _sharedMaterials: {
  74496. [key: string]: BABYLON.Material;
  74497. };
  74498. /** Gets the hosting scene */
  74499. get scene(): BABYLON.Scene;
  74500. /** Gets associated utility layer */
  74501. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  74502. /**
  74503. * Creates a new GUI3DManager
  74504. * @param scene
  74505. */
  74506. constructor(scene?: BABYLON.Scene);
  74507. private _handlePointerOut;
  74508. private _doPicking;
  74509. /**
  74510. * Gets the root container
  74511. */
  74512. get rootContainer(): Container3D;
  74513. /**
  74514. * Gets a boolean indicating if the given control is in the root child list
  74515. * @param control defines the control to check
  74516. * @returns true if the control is in the root child list
  74517. */
  74518. containsControl(control: Control3D): boolean;
  74519. /**
  74520. * Adds a control to the root child list
  74521. * @param control defines the control to add
  74522. * @returns the current manager
  74523. */
  74524. addControl(control: Control3D): GUI3DManager;
  74525. /**
  74526. * Removes a control from the root child list
  74527. * @param control defines the control to remove
  74528. * @returns the current container
  74529. */
  74530. removeControl(control: Control3D): GUI3DManager;
  74531. /**
  74532. * Releases all associated resources
  74533. */
  74534. dispose(): void;
  74535. }
  74536. }
  74537. declare module BABYLON.GUI {
  74538. /**
  74539. * Class used to transport BABYLON.Vector3 information for pointer events
  74540. */
  74541. export class Vector3WithInfo extends BABYLON.Vector3 {
  74542. /** defines the current mouse button index */
  74543. buttonIndex: number;
  74544. /**
  74545. * Creates a new Vector3WithInfo
  74546. * @param source defines the vector3 data to transport
  74547. * @param buttonIndex defines the current mouse button index
  74548. */
  74549. constructor(source: BABYLON.Vector3,
  74550. /** defines the current mouse button index */
  74551. buttonIndex?: number);
  74552. }
  74553. }
  74554. declare module BABYLON.GUI {
  74555. /**
  74556. * Class used as base class for controls
  74557. */
  74558. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  74559. /** Defines the control name */
  74560. name?: string | undefined;
  74561. /** @hidden */
  74562. _host: GUI3DManager;
  74563. private _node;
  74564. private _downCount;
  74565. private _enterCount;
  74566. private _downPointerIds;
  74567. private _isVisible;
  74568. /** Gets or sets the control position in world space */
  74569. get position(): BABYLON.Vector3;
  74570. set position(value: BABYLON.Vector3);
  74571. /** Gets or sets the control scaling in world space */
  74572. get scaling(): BABYLON.Vector3;
  74573. set scaling(value: BABYLON.Vector3);
  74574. /** Callback used to start pointer enter animation */
  74575. pointerEnterAnimation: () => void;
  74576. /** Callback used to start pointer out animation */
  74577. pointerOutAnimation: () => void;
  74578. /** Callback used to start pointer down animation */
  74579. pointerDownAnimation: () => void;
  74580. /** Callback used to start pointer up animation */
  74581. pointerUpAnimation: () => void;
  74582. /**
  74583. * An event triggered when the pointer move over the control
  74584. */
  74585. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  74586. /**
  74587. * An event triggered when the pointer move out of the control
  74588. */
  74589. onPointerOutObservable: BABYLON.Observable<Control3D>;
  74590. /**
  74591. * An event triggered when the pointer taps the control
  74592. */
  74593. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  74594. /**
  74595. * An event triggered when pointer is up
  74596. */
  74597. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  74598. /**
  74599. * An event triggered when a control is clicked on (with a mouse)
  74600. */
  74601. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  74602. /**
  74603. * An event triggered when pointer enters the control
  74604. */
  74605. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  74606. /**
  74607. * Gets or sets the parent container
  74608. */
  74609. parent: BABYLON.Nullable<Container3D>;
  74610. private _behaviors;
  74611. /**
  74612. * Gets the list of attached behaviors
  74613. * @see http://doc.babylonjs.com/features/behaviour
  74614. */
  74615. get behaviors(): BABYLON.Behavior<Control3D>[];
  74616. /**
  74617. * Attach a behavior to the control
  74618. * @see http://doc.babylonjs.com/features/behaviour
  74619. * @param behavior defines the behavior to attach
  74620. * @returns the current control
  74621. */
  74622. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74623. /**
  74624. * Remove an attached behavior
  74625. * @see http://doc.babylonjs.com/features/behaviour
  74626. * @param behavior defines the behavior to attach
  74627. * @returns the current control
  74628. */
  74629. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  74630. /**
  74631. * Gets an attached behavior by name
  74632. * @param name defines the name of the behavior to look for
  74633. * @see http://doc.babylonjs.com/features/behaviour
  74634. * @returns null if behavior was not found else the requested behavior
  74635. */
  74636. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  74637. /** Gets or sets a boolean indicating if the control is visible */
  74638. get isVisible(): boolean;
  74639. set isVisible(value: boolean);
  74640. /**
  74641. * Creates a new control
  74642. * @param name defines the control name
  74643. */
  74644. constructor(
  74645. /** Defines the control name */
  74646. name?: string | undefined);
  74647. /**
  74648. * Gets a string representing the class name
  74649. */
  74650. get typeName(): string;
  74651. /**
  74652. * Get the current class name of the control.
  74653. * @returns current class name
  74654. */
  74655. getClassName(): string;
  74656. protected _getTypeName(): string;
  74657. /**
  74658. * Gets the transform node used by this control
  74659. */
  74660. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  74661. /**
  74662. * Gets the mesh used to render this control
  74663. */
  74664. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  74665. /**
  74666. * Link the control as child of the given node
  74667. * @param node defines the node to link to. Use null to unlink the control
  74668. * @returns the current control
  74669. */
  74670. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  74671. /** @hidden **/
  74672. _prepareNode(scene: BABYLON.Scene): void;
  74673. /**
  74674. * Node creation.
  74675. * Can be overriden by children
  74676. * @param scene defines the scene where the node must be attached
  74677. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  74678. */
  74679. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  74680. /**
  74681. * Affect a material to the given mesh
  74682. * @param mesh defines the mesh which will represent the control
  74683. */
  74684. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74685. /** @hidden */
  74686. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  74687. /** @hidden */
  74688. _onPointerEnter(target: Control3D): boolean;
  74689. /** @hidden */
  74690. _onPointerOut(target: Control3D): void;
  74691. /** @hidden */
  74692. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74693. /** @hidden */
  74694. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  74695. /** @hidden */
  74696. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  74697. /** @hidden */
  74698. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  74699. /** @hidden */
  74700. _disposeNode(): void;
  74701. /**
  74702. * Releases all associated resources
  74703. */
  74704. dispose(): void;
  74705. }
  74706. }
  74707. declare module BABYLON.GUI {
  74708. /**
  74709. * Class used as a root to all buttons
  74710. */
  74711. export class AbstractButton3D extends Control3D {
  74712. /**
  74713. * Creates a new button
  74714. * @param name defines the control name
  74715. */
  74716. constructor(name?: string);
  74717. protected _getTypeName(): string;
  74718. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74719. }
  74720. }
  74721. declare module BABYLON.GUI {
  74722. /**
  74723. * Class used to create a button in 3D
  74724. */
  74725. export class Button3D extends AbstractButton3D {
  74726. /** @hidden */
  74727. protected _currentMaterial: BABYLON.Material;
  74728. private _facadeTexture;
  74729. private _content;
  74730. private _contentResolution;
  74731. private _contentScaleRatio;
  74732. /**
  74733. * Gets or sets the texture resolution used to render content (512 by default)
  74734. */
  74735. get contentResolution(): BABYLON.int;
  74736. set contentResolution(value: BABYLON.int);
  74737. /**
  74738. * Gets or sets the texture scale ratio used to render content (2 by default)
  74739. */
  74740. get contentScaleRatio(): number;
  74741. set contentScaleRatio(value: number);
  74742. protected _disposeFacadeTexture(): void;
  74743. protected _resetContent(): void;
  74744. /**
  74745. * Creates a new button
  74746. * @param name defines the control name
  74747. */
  74748. constructor(name?: string);
  74749. /**
  74750. * Gets or sets the GUI 2D content used to display the button's facade
  74751. */
  74752. get content(): Control;
  74753. set content(value: Control);
  74754. /**
  74755. * Apply the facade texture (created from the content property).
  74756. * This function can be overloaded by child classes
  74757. * @param facadeTexture defines the AdvancedDynamicTexture to use
  74758. */
  74759. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74760. protected _getTypeName(): string;
  74761. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74762. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74763. /**
  74764. * Releases all associated resources
  74765. */
  74766. dispose(): void;
  74767. }
  74768. }
  74769. declare module BABYLON.GUI {
  74770. /**
  74771. * Abstract class used to create a container panel deployed on the surface of a volume
  74772. */
  74773. export abstract class VolumeBasedPanel extends Container3D {
  74774. private _columns;
  74775. private _rows;
  74776. private _rowThenColum;
  74777. private _orientation;
  74778. protected _cellWidth: number;
  74779. protected _cellHeight: number;
  74780. /**
  74781. * Gets or sets the distance between elements
  74782. */
  74783. margin: number;
  74784. /**
  74785. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  74786. * | Value | Type | Description |
  74787. * | ----- | ----------------------------------- | ----------- |
  74788. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  74789. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  74790. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  74791. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  74792. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  74793. */
  74794. get orientation(): number;
  74795. set orientation(value: number);
  74796. /**
  74797. * Gets or sets the number of columns requested (10 by default).
  74798. * The panel will automatically compute the number of rows based on number of child controls.
  74799. */
  74800. get columns(): BABYLON.int;
  74801. set columns(value: BABYLON.int);
  74802. /**
  74803. * Gets or sets a the number of rows requested.
  74804. * The panel will automatically compute the number of columns based on number of child controls.
  74805. */
  74806. get rows(): BABYLON.int;
  74807. set rows(value: BABYLON.int);
  74808. /**
  74809. * Creates new VolumeBasedPanel
  74810. */
  74811. constructor();
  74812. protected _arrangeChildren(): void;
  74813. /** Child classes must implement this function to provide correct control positioning */
  74814. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74815. /** Child classes can implement this function to provide additional processing */
  74816. protected _finalProcessing(): void;
  74817. }
  74818. }
  74819. declare module BABYLON.GUI {
  74820. /**
  74821. * Class used to create a container panel deployed on the surface of a cylinder
  74822. */
  74823. export class CylinderPanel extends VolumeBasedPanel {
  74824. private _radius;
  74825. /**
  74826. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  74827. */
  74828. get radius(): BABYLON.float;
  74829. set radius(value: BABYLON.float);
  74830. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74831. private _cylindricalMapping;
  74832. }
  74833. }
  74834. declare module BABYLON.GUI {
  74835. /** @hidden */
  74836. export var fluentVertexShader: {
  74837. name: string;
  74838. shader: string;
  74839. };
  74840. }
  74841. declare module BABYLON.GUI {
  74842. /** @hidden */
  74843. export var fluentPixelShader: {
  74844. name: string;
  74845. shader: string;
  74846. };
  74847. }
  74848. declare module BABYLON.GUI {
  74849. /** @hidden */
  74850. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  74851. INNERGLOW: boolean;
  74852. BORDER: boolean;
  74853. HOVERLIGHT: boolean;
  74854. TEXTURE: boolean;
  74855. constructor();
  74856. }
  74857. /**
  74858. * Class used to render controls with fluent desgin
  74859. */
  74860. export class FluentMaterial extends BABYLON.PushMaterial {
  74861. /**
  74862. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  74863. */
  74864. innerGlowColorIntensity: number;
  74865. /**
  74866. * Gets or sets the inner glow color (white by default)
  74867. */
  74868. innerGlowColor: BABYLON.Color3;
  74869. /**
  74870. * Gets or sets alpha value (default is 1.0)
  74871. */
  74872. alpha: number;
  74873. /**
  74874. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  74875. */
  74876. albedoColor: BABYLON.Color3;
  74877. /**
  74878. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  74879. */
  74880. renderBorders: boolean;
  74881. /**
  74882. * Gets or sets border width (default is 0.5)
  74883. */
  74884. borderWidth: number;
  74885. /**
  74886. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  74887. */
  74888. edgeSmoothingValue: number;
  74889. /**
  74890. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  74891. */
  74892. borderMinValue: number;
  74893. /**
  74894. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  74895. */
  74896. renderHoverLight: boolean;
  74897. /**
  74898. * Gets or sets the radius used to render the hover light (default is 1.0)
  74899. */
  74900. hoverRadius: number;
  74901. /**
  74902. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  74903. */
  74904. hoverColor: BABYLON.Color4;
  74905. /**
  74906. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  74907. */
  74908. hoverPosition: BABYLON.Vector3;
  74909. private _albedoTexture;
  74910. /** Gets or sets the texture to use for albedo color */
  74911. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  74912. /**
  74913. * Creates a new Fluent material
  74914. * @param name defines the name of the material
  74915. * @param scene defines the hosting scene
  74916. */
  74917. constructor(name: string, scene: BABYLON.Scene);
  74918. needAlphaBlending(): boolean;
  74919. needAlphaTesting(): boolean;
  74920. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  74921. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  74922. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  74923. getActiveTextures(): BABYLON.BaseTexture[];
  74924. hasTexture(texture: BABYLON.BaseTexture): boolean;
  74925. dispose(forceDisposeEffect?: boolean): void;
  74926. clone(name: string): FluentMaterial;
  74927. serialize(): any;
  74928. getClassName(): string;
  74929. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  74930. }
  74931. }
  74932. declare module BABYLON.GUI {
  74933. /**
  74934. * Class used to create a holographic button in 3D
  74935. */
  74936. export class HolographicButton extends Button3D {
  74937. private _backPlate;
  74938. private _textPlate;
  74939. private _frontPlate;
  74940. private _text;
  74941. private _imageUrl;
  74942. private _shareMaterials;
  74943. private _frontMaterial;
  74944. private _backMaterial;
  74945. private _plateMaterial;
  74946. private _pickedPointObserver;
  74947. private _tooltipFade;
  74948. private _tooltipTextBlock;
  74949. private _tooltipTexture;
  74950. private _tooltipMesh;
  74951. private _tooltipHoverObserver;
  74952. private _tooltipOutObserver;
  74953. private _disposeTooltip;
  74954. /**
  74955. * Rendering ground id of all the mesh in the button
  74956. */
  74957. set renderingGroupId(id: number);
  74958. get renderingGroupId(): number;
  74959. /**
  74960. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74961. */
  74962. set tooltipText(text: BABYLON.Nullable<string>);
  74963. get tooltipText(): BABYLON.Nullable<string>;
  74964. /**
  74965. * Gets or sets text for the button
  74966. */
  74967. get text(): string;
  74968. set text(value: string);
  74969. /**
  74970. * Gets or sets the image url for the button
  74971. */
  74972. get imageUrl(): string;
  74973. set imageUrl(value: string);
  74974. /**
  74975. * Gets the back material used by this button
  74976. */
  74977. get backMaterial(): FluentMaterial;
  74978. /**
  74979. * Gets the front material used by this button
  74980. */
  74981. get frontMaterial(): FluentMaterial;
  74982. /**
  74983. * Gets the plate material used by this button
  74984. */
  74985. get plateMaterial(): BABYLON.StandardMaterial;
  74986. /**
  74987. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74988. */
  74989. get shareMaterials(): boolean;
  74990. /**
  74991. * Creates a new button
  74992. * @param name defines the control name
  74993. */
  74994. constructor(name?: string, shareMaterials?: boolean);
  74995. protected _getTypeName(): string;
  74996. private _rebuildContent;
  74997. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74998. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74999. private _createBackMaterial;
  75000. private _createFrontMaterial;
  75001. private _createPlateMaterial;
  75002. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  75003. /**
  75004. * Releases all associated resources
  75005. */
  75006. dispose(): void;
  75007. }
  75008. }
  75009. declare module BABYLON.GUI {
  75010. /**
  75011. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  75012. */
  75013. export class MeshButton3D extends Button3D {
  75014. /** @hidden */
  75015. protected _currentMesh: BABYLON.Mesh;
  75016. /**
  75017. * Creates a new 3D button based on a mesh
  75018. * @param mesh mesh to become a 3D button
  75019. * @param name defines the control name
  75020. */
  75021. constructor(mesh: BABYLON.Mesh, name?: string);
  75022. protected _getTypeName(): string;
  75023. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  75024. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  75025. }
  75026. }
  75027. declare module BABYLON.GUI {
  75028. /**
  75029. * Class used to create a container panel deployed on the surface of a plane
  75030. */
  75031. export class PlanePanel extends VolumeBasedPanel {
  75032. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75033. }
  75034. }
  75035. declare module BABYLON.GUI {
  75036. /**
  75037. * Class used to create a container panel where items get randomized planar mapping
  75038. */
  75039. export class ScatterPanel extends VolumeBasedPanel {
  75040. private _iteration;
  75041. /**
  75042. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  75043. */
  75044. get iteration(): BABYLON.float;
  75045. set iteration(value: BABYLON.float);
  75046. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75047. private _scatterMapping;
  75048. protected _finalProcessing(): void;
  75049. }
  75050. }
  75051. declare module BABYLON.GUI {
  75052. /**
  75053. * Class used to create a container panel deployed on the surface of a sphere
  75054. */
  75055. export class SpherePanel extends VolumeBasedPanel {
  75056. private _radius;
  75057. /**
  75058. * Gets or sets the radius of the sphere where to project controls (5 by default)
  75059. */
  75060. get radius(): BABYLON.float;
  75061. set radius(value: BABYLON.float);
  75062. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  75063. private _sphericalMapping;
  75064. }
  75065. }
  75066. declare module BABYLON.GUI {
  75067. /**
  75068. * Class used to create a stack panel in 3D on XY plane
  75069. */
  75070. export class StackPanel3D extends Container3D {
  75071. private _isVertical;
  75072. /**
  75073. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  75074. */
  75075. get isVertical(): boolean;
  75076. set isVertical(value: boolean);
  75077. /**
  75078. * Gets or sets the distance between elements
  75079. */
  75080. margin: number;
  75081. /**
  75082. * Creates new StackPanel
  75083. * @param isVertical
  75084. */
  75085. constructor(isVertical?: boolean);
  75086. protected _arrangeChildren(): void;
  75087. }
  75088. }
  75089. declare module BABYLON {
  75090. /**
  75091. * Configuration for glTF validation
  75092. */
  75093. export interface IGLTFValidationConfiguration {
  75094. /**
  75095. * The url of the glTF validator.
  75096. */
  75097. url: string;
  75098. }
  75099. /**
  75100. * glTF validation
  75101. */
  75102. export class GLTFValidation {
  75103. /**
  75104. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  75105. */
  75106. static Configuration: IGLTFValidationConfiguration;
  75107. private static _LoadScriptPromise;
  75108. /**
  75109. * Validate a glTF asset using the glTF-Validator.
  75110. * @param data The JSON of a glTF or the array buffer of a binary glTF
  75111. * @param rootUrl The root url for the glTF
  75112. * @param fileName The file name for the glTF
  75113. * @param getExternalResource The callback to get external resources for the glTF validator
  75114. * @returns A promise that resolves with the glTF validation results once complete
  75115. */
  75116. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  75117. }
  75118. }
  75119. declare module BABYLON {
  75120. /**
  75121. * Mode that determines the coordinate system to use.
  75122. */
  75123. export enum GLTFLoaderCoordinateSystemMode {
  75124. /**
  75125. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  75126. */
  75127. AUTO = 0,
  75128. /**
  75129. * Sets the useRightHandedSystem flag on the scene.
  75130. */
  75131. FORCE_RIGHT_HANDED = 1
  75132. }
  75133. /**
  75134. * Mode that determines what animations will start.
  75135. */
  75136. export enum GLTFLoaderAnimationStartMode {
  75137. /**
  75138. * No animation will start.
  75139. */
  75140. NONE = 0,
  75141. /**
  75142. * The first animation will start.
  75143. */
  75144. FIRST = 1,
  75145. /**
  75146. * All animations will start.
  75147. */
  75148. ALL = 2
  75149. }
  75150. /**
  75151. * Interface that contains the data for the glTF asset.
  75152. */
  75153. export interface IGLTFLoaderData {
  75154. /**
  75155. * The object that represents the glTF JSON.
  75156. */
  75157. json: Object;
  75158. /**
  75159. * The BIN chunk of a binary glTF.
  75160. */
  75161. bin: Nullable<IDataBuffer>;
  75162. }
  75163. /**
  75164. * Interface for extending the loader.
  75165. */
  75166. export interface IGLTFLoaderExtension {
  75167. /**
  75168. * The name of this extension.
  75169. */
  75170. readonly name: string;
  75171. /**
  75172. * Defines whether this extension is enabled.
  75173. */
  75174. enabled: boolean;
  75175. /**
  75176. * Defines the order of this extension.
  75177. * The loader sorts the extensions using these values when loading.
  75178. */
  75179. order?: number;
  75180. }
  75181. /**
  75182. * Loader state.
  75183. */
  75184. export enum GLTFLoaderState {
  75185. /**
  75186. * The asset is loading.
  75187. */
  75188. LOADING = 0,
  75189. /**
  75190. * The asset is ready for rendering.
  75191. */
  75192. READY = 1,
  75193. /**
  75194. * The asset is completely loaded.
  75195. */
  75196. COMPLETE = 2
  75197. }
  75198. /** @hidden */
  75199. export interface IImportMeshAsyncOutput {
  75200. meshes: AbstractMesh[];
  75201. particleSystems: IParticleSystem[];
  75202. skeletons: Skeleton[];
  75203. animationGroups: AnimationGroup[];
  75204. lights: Light[];
  75205. transformNodes: TransformNode[];
  75206. }
  75207. /** @hidden */
  75208. export interface IGLTFLoader extends IDisposable {
  75209. readonly state: Nullable<GLTFLoaderState>;
  75210. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  75211. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  75212. }
  75213. /**
  75214. * File loader for loading glTF files into a scene.
  75215. */
  75216. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75217. /** @hidden */
  75218. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75219. /** @hidden */
  75220. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  75221. /**
  75222. * Raised when the asset has been parsed
  75223. */
  75224. onParsedObservable: Observable<IGLTFLoaderData>;
  75225. private _onParsedObserver;
  75226. /**
  75227. * Raised when the asset has been parsed
  75228. */
  75229. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  75230. /**
  75231. * 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.
  75232. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  75233. * Defaults to true.
  75234. * @hidden
  75235. */
  75236. static IncrementalLoading: boolean;
  75237. /**
  75238. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  75239. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  75240. * @hidden
  75241. */
  75242. static HomogeneousCoordinates: boolean;
  75243. /**
  75244. * The coordinate system mode. Defaults to AUTO.
  75245. */
  75246. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  75247. /**
  75248. * The animation start mode. Defaults to FIRST.
  75249. */
  75250. animationStartMode: GLTFLoaderAnimationStartMode;
  75251. /**
  75252. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  75253. */
  75254. compileMaterials: boolean;
  75255. /**
  75256. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  75257. */
  75258. useClipPlane: boolean;
  75259. /**
  75260. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  75261. */
  75262. compileShadowGenerators: boolean;
  75263. /**
  75264. * Defines if the Alpha blended materials are only applied as coverage.
  75265. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  75266. * If true, no extra effects are applied to transparent pixels.
  75267. */
  75268. transparencyAsCoverage: boolean;
  75269. /**
  75270. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  75271. * Enabling will disable offline support and glTF validator.
  75272. * Defaults to false.
  75273. */
  75274. useRangeRequests: boolean;
  75275. /**
  75276. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  75277. */
  75278. createInstances: boolean;
  75279. /**
  75280. * Function called before loading a url referenced by the asset.
  75281. */
  75282. preprocessUrlAsync: (url: string) => Promise<string>;
  75283. /**
  75284. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75285. */
  75286. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  75287. private _onMeshLoadedObserver;
  75288. /**
  75289. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  75290. */
  75291. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  75292. /**
  75293. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  75294. */
  75295. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  75296. private _onTextureLoadedObserver;
  75297. /**
  75298. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  75299. */
  75300. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  75301. /**
  75302. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  75303. */
  75304. readonly onMaterialLoadedObservable: Observable<Material>;
  75305. private _onMaterialLoadedObserver;
  75306. /**
  75307. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  75308. */
  75309. set onMaterialLoaded(callback: (material: Material) => void);
  75310. /**
  75311. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  75312. */
  75313. readonly onCameraLoadedObservable: Observable<Camera>;
  75314. private _onCameraLoadedObserver;
  75315. /**
  75316. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  75317. */
  75318. set onCameraLoaded(callback: (camera: Camera) => void);
  75319. /**
  75320. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  75321. * For assets with LODs, raised when all of the LODs are complete.
  75322. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75323. */
  75324. readonly onCompleteObservable: Observable<void>;
  75325. private _onCompleteObserver;
  75326. /**
  75327. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  75328. * For assets with LODs, raised when all of the LODs are complete.
  75329. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  75330. */
  75331. set onComplete(callback: () => void);
  75332. /**
  75333. * Observable raised when an error occurs.
  75334. */
  75335. readonly onErrorObservable: Observable<any>;
  75336. private _onErrorObserver;
  75337. /**
  75338. * Callback raised when an error occurs.
  75339. */
  75340. set onError(callback: (reason: any) => void);
  75341. /**
  75342. * Observable raised after the loader is disposed.
  75343. */
  75344. readonly onDisposeObservable: Observable<void>;
  75345. private _onDisposeObserver;
  75346. /**
  75347. * Callback raised after the loader is disposed.
  75348. */
  75349. set onDispose(callback: () => void);
  75350. /**
  75351. * Observable raised after a loader extension is created.
  75352. * Set additional options for a loader extension in this event.
  75353. */
  75354. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  75355. private _onExtensionLoadedObserver;
  75356. /**
  75357. * Callback raised after a loader extension is created.
  75358. */
  75359. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  75360. /**
  75361. * Defines if the loader logging is enabled.
  75362. */
  75363. get loggingEnabled(): boolean;
  75364. set loggingEnabled(value: boolean);
  75365. /**
  75366. * Defines if the loader should capture performance counters.
  75367. */
  75368. get capturePerformanceCounters(): boolean;
  75369. set capturePerformanceCounters(value: boolean);
  75370. /**
  75371. * Defines if the loader should validate the asset.
  75372. */
  75373. validate: boolean;
  75374. /**
  75375. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  75376. */
  75377. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  75378. private _onValidatedObserver;
  75379. /**
  75380. * Callback raised after a loader extension is created.
  75381. */
  75382. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  75383. private _loader;
  75384. /**
  75385. * Name of the loader ("gltf")
  75386. */
  75387. name: string;
  75388. /** @hidden */
  75389. extensions: ISceneLoaderPluginExtensions;
  75390. /**
  75391. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  75392. */
  75393. dispose(): void;
  75394. /** @hidden */
  75395. _clear(): void;
  75396. /** @hidden */
  75397. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75398. /** @hidden */
  75399. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  75400. /** @hidden */
  75401. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75402. meshes: AbstractMesh[];
  75403. particleSystems: IParticleSystem[];
  75404. skeletons: Skeleton[];
  75405. animationGroups: AnimationGroup[];
  75406. }>;
  75407. /** @hidden */
  75408. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75409. /** @hidden */
  75410. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75411. /** @hidden */
  75412. canDirectLoad(data: string): boolean;
  75413. /** @hidden */
  75414. directLoad(scene: Scene, data: string): any;
  75415. /**
  75416. * The callback that allows custom handling of the root url based on the response url.
  75417. * @param rootUrl the original root url
  75418. * @param responseURL the response url if available
  75419. * @returns the new root url
  75420. */
  75421. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  75422. /** @hidden */
  75423. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  75424. /**
  75425. * The loader state or null if the loader is not active.
  75426. */
  75427. get loaderState(): Nullable<GLTFLoaderState>;
  75428. /**
  75429. * Returns a promise that resolves when the asset is completely loaded.
  75430. * @returns a promise that resolves when the asset is completely loaded.
  75431. */
  75432. whenCompleteAsync(): Promise<void>;
  75433. private _validate;
  75434. private _getLoader;
  75435. private _parseJson;
  75436. private _unpackBinaryAsync;
  75437. private _unpackBinaryV1Async;
  75438. private _unpackBinaryV2Async;
  75439. private static _parseVersion;
  75440. private static _compareVersion;
  75441. private static readonly _logSpaces;
  75442. private _logIndentLevel;
  75443. private _loggingEnabled;
  75444. /** @hidden */
  75445. _log: (message: string) => void;
  75446. /** @hidden */
  75447. _logOpen(message: string): void;
  75448. /** @hidden */
  75449. _logClose(): void;
  75450. private _logEnabled;
  75451. private _logDisabled;
  75452. private _capturePerformanceCounters;
  75453. /** @hidden */
  75454. _startPerformanceCounter: (counterName: string) => void;
  75455. /** @hidden */
  75456. _endPerformanceCounter: (counterName: string) => void;
  75457. private _startPerformanceCounterEnabled;
  75458. private _startPerformanceCounterDisabled;
  75459. private _endPerformanceCounterEnabled;
  75460. private _endPerformanceCounterDisabled;
  75461. }
  75462. }
  75463. declare module BABYLON.GLTF1 {
  75464. /**
  75465. * Enums
  75466. * @hidden
  75467. */
  75468. export enum EComponentType {
  75469. BYTE = 5120,
  75470. UNSIGNED_BYTE = 5121,
  75471. SHORT = 5122,
  75472. UNSIGNED_SHORT = 5123,
  75473. FLOAT = 5126
  75474. }
  75475. /** @hidden */
  75476. export enum EShaderType {
  75477. FRAGMENT = 35632,
  75478. VERTEX = 35633
  75479. }
  75480. /** @hidden */
  75481. export enum EParameterType {
  75482. BYTE = 5120,
  75483. UNSIGNED_BYTE = 5121,
  75484. SHORT = 5122,
  75485. UNSIGNED_SHORT = 5123,
  75486. INT = 5124,
  75487. UNSIGNED_INT = 5125,
  75488. FLOAT = 5126,
  75489. FLOAT_VEC2 = 35664,
  75490. FLOAT_VEC3 = 35665,
  75491. FLOAT_VEC4 = 35666,
  75492. INT_VEC2 = 35667,
  75493. INT_VEC3 = 35668,
  75494. INT_VEC4 = 35669,
  75495. BOOL = 35670,
  75496. BOOL_VEC2 = 35671,
  75497. BOOL_VEC3 = 35672,
  75498. BOOL_VEC4 = 35673,
  75499. FLOAT_MAT2 = 35674,
  75500. FLOAT_MAT3 = 35675,
  75501. FLOAT_MAT4 = 35676,
  75502. SAMPLER_2D = 35678
  75503. }
  75504. /** @hidden */
  75505. export enum ETextureWrapMode {
  75506. CLAMP_TO_EDGE = 33071,
  75507. MIRRORED_REPEAT = 33648,
  75508. REPEAT = 10497
  75509. }
  75510. /** @hidden */
  75511. export enum ETextureFilterType {
  75512. NEAREST = 9728,
  75513. LINEAR = 9728,
  75514. NEAREST_MIPMAP_NEAREST = 9984,
  75515. LINEAR_MIPMAP_NEAREST = 9985,
  75516. NEAREST_MIPMAP_LINEAR = 9986,
  75517. LINEAR_MIPMAP_LINEAR = 9987
  75518. }
  75519. /** @hidden */
  75520. export enum ETextureFormat {
  75521. ALPHA = 6406,
  75522. RGB = 6407,
  75523. RGBA = 6408,
  75524. LUMINANCE = 6409,
  75525. LUMINANCE_ALPHA = 6410
  75526. }
  75527. /** @hidden */
  75528. export enum ECullingType {
  75529. FRONT = 1028,
  75530. BACK = 1029,
  75531. FRONT_AND_BACK = 1032
  75532. }
  75533. /** @hidden */
  75534. export enum EBlendingFunction {
  75535. ZERO = 0,
  75536. ONE = 1,
  75537. SRC_COLOR = 768,
  75538. ONE_MINUS_SRC_COLOR = 769,
  75539. DST_COLOR = 774,
  75540. ONE_MINUS_DST_COLOR = 775,
  75541. SRC_ALPHA = 770,
  75542. ONE_MINUS_SRC_ALPHA = 771,
  75543. DST_ALPHA = 772,
  75544. ONE_MINUS_DST_ALPHA = 773,
  75545. CONSTANT_COLOR = 32769,
  75546. ONE_MINUS_CONSTANT_COLOR = 32770,
  75547. CONSTANT_ALPHA = 32771,
  75548. ONE_MINUS_CONSTANT_ALPHA = 32772,
  75549. SRC_ALPHA_SATURATE = 776
  75550. }
  75551. /** @hidden */
  75552. export interface IGLTFProperty {
  75553. extensions?: {
  75554. [key: string]: any;
  75555. };
  75556. extras?: Object;
  75557. }
  75558. /** @hidden */
  75559. export interface IGLTFChildRootProperty extends IGLTFProperty {
  75560. name?: string;
  75561. }
  75562. /** @hidden */
  75563. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  75564. bufferView: string;
  75565. byteOffset: number;
  75566. byteStride: number;
  75567. count: number;
  75568. type: string;
  75569. componentType: EComponentType;
  75570. max?: number[];
  75571. min?: number[];
  75572. name?: string;
  75573. }
  75574. /** @hidden */
  75575. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  75576. buffer: string;
  75577. byteOffset: number;
  75578. byteLength: number;
  75579. byteStride: number;
  75580. target?: number;
  75581. }
  75582. /** @hidden */
  75583. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  75584. uri: string;
  75585. byteLength?: number;
  75586. type?: string;
  75587. }
  75588. /** @hidden */
  75589. export interface IGLTFShader extends IGLTFChildRootProperty {
  75590. uri: string;
  75591. type: EShaderType;
  75592. }
  75593. /** @hidden */
  75594. export interface IGLTFProgram extends IGLTFChildRootProperty {
  75595. attributes: string[];
  75596. fragmentShader: string;
  75597. vertexShader: string;
  75598. }
  75599. /** @hidden */
  75600. export interface IGLTFTechniqueParameter {
  75601. type: number;
  75602. count?: number;
  75603. semantic?: string;
  75604. node?: string;
  75605. value?: number | boolean | string | Array<any>;
  75606. source?: string;
  75607. babylonValue?: any;
  75608. }
  75609. /** @hidden */
  75610. export interface IGLTFTechniqueCommonProfile {
  75611. lightingModel: string;
  75612. texcoordBindings: Object;
  75613. parameters?: Array<any>;
  75614. }
  75615. /** @hidden */
  75616. export interface IGLTFTechniqueStatesFunctions {
  75617. blendColor?: number[];
  75618. blendEquationSeparate?: number[];
  75619. blendFuncSeparate?: number[];
  75620. colorMask: boolean[];
  75621. cullFace: number[];
  75622. }
  75623. /** @hidden */
  75624. export interface IGLTFTechniqueStates {
  75625. enable: number[];
  75626. functions: IGLTFTechniqueStatesFunctions;
  75627. }
  75628. /** @hidden */
  75629. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  75630. parameters: {
  75631. [key: string]: IGLTFTechniqueParameter;
  75632. };
  75633. program: string;
  75634. attributes: {
  75635. [key: string]: string;
  75636. };
  75637. uniforms: {
  75638. [key: string]: string;
  75639. };
  75640. states: IGLTFTechniqueStates;
  75641. }
  75642. /** @hidden */
  75643. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  75644. technique?: string;
  75645. values: string[];
  75646. }
  75647. /** @hidden */
  75648. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  75649. attributes: {
  75650. [key: string]: string;
  75651. };
  75652. indices: string;
  75653. material: string;
  75654. mode?: number;
  75655. }
  75656. /** @hidden */
  75657. export interface IGLTFMesh extends IGLTFChildRootProperty {
  75658. primitives: IGLTFMeshPrimitive[];
  75659. }
  75660. /** @hidden */
  75661. export interface IGLTFImage extends IGLTFChildRootProperty {
  75662. uri: string;
  75663. }
  75664. /** @hidden */
  75665. export interface IGLTFSampler extends IGLTFChildRootProperty {
  75666. magFilter?: number;
  75667. minFilter?: number;
  75668. wrapS?: number;
  75669. wrapT?: number;
  75670. }
  75671. /** @hidden */
  75672. export interface IGLTFTexture extends IGLTFChildRootProperty {
  75673. sampler: string;
  75674. source: string;
  75675. format?: ETextureFormat;
  75676. internalFormat?: ETextureFormat;
  75677. target?: number;
  75678. type?: number;
  75679. babylonTexture?: Texture;
  75680. }
  75681. /** @hidden */
  75682. export interface IGLTFAmbienLight {
  75683. color?: number[];
  75684. }
  75685. /** @hidden */
  75686. export interface IGLTFDirectionalLight {
  75687. color?: number[];
  75688. }
  75689. /** @hidden */
  75690. export interface IGLTFPointLight {
  75691. color?: number[];
  75692. constantAttenuation?: number;
  75693. linearAttenuation?: number;
  75694. quadraticAttenuation?: number;
  75695. }
  75696. /** @hidden */
  75697. export interface IGLTFSpotLight {
  75698. color?: number[];
  75699. constantAttenuation?: number;
  75700. fallOfAngle?: number;
  75701. fallOffExponent?: number;
  75702. linearAttenuation?: number;
  75703. quadraticAttenuation?: number;
  75704. }
  75705. /** @hidden */
  75706. export interface IGLTFLight extends IGLTFChildRootProperty {
  75707. type: string;
  75708. }
  75709. /** @hidden */
  75710. export interface IGLTFCameraOrthographic {
  75711. xmag: number;
  75712. ymag: number;
  75713. zfar: number;
  75714. znear: number;
  75715. }
  75716. /** @hidden */
  75717. export interface IGLTFCameraPerspective {
  75718. aspectRatio: number;
  75719. yfov: number;
  75720. zfar: number;
  75721. znear: number;
  75722. }
  75723. /** @hidden */
  75724. export interface IGLTFCamera extends IGLTFChildRootProperty {
  75725. type: string;
  75726. }
  75727. /** @hidden */
  75728. export interface IGLTFAnimationChannelTarget {
  75729. id: string;
  75730. path: string;
  75731. }
  75732. /** @hidden */
  75733. export interface IGLTFAnimationChannel {
  75734. sampler: string;
  75735. target: IGLTFAnimationChannelTarget;
  75736. }
  75737. /** @hidden */
  75738. export interface IGLTFAnimationSampler {
  75739. input: string;
  75740. output: string;
  75741. interpolation?: string;
  75742. }
  75743. /** @hidden */
  75744. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  75745. channels?: IGLTFAnimationChannel[];
  75746. parameters?: {
  75747. [key: string]: string;
  75748. };
  75749. samplers?: {
  75750. [key: string]: IGLTFAnimationSampler;
  75751. };
  75752. }
  75753. /** @hidden */
  75754. export interface IGLTFNodeInstanceSkin {
  75755. skeletons: string[];
  75756. skin: string;
  75757. meshes: string[];
  75758. }
  75759. /** @hidden */
  75760. export interface IGLTFSkins extends IGLTFChildRootProperty {
  75761. bindShapeMatrix: number[];
  75762. inverseBindMatrices: string;
  75763. jointNames: string[];
  75764. babylonSkeleton?: Skeleton;
  75765. }
  75766. /** @hidden */
  75767. export interface IGLTFNode extends IGLTFChildRootProperty {
  75768. camera?: string;
  75769. children: string[];
  75770. skin?: string;
  75771. jointName?: string;
  75772. light?: string;
  75773. matrix: number[];
  75774. mesh?: string;
  75775. meshes?: string[];
  75776. rotation?: number[];
  75777. scale?: number[];
  75778. translation?: number[];
  75779. babylonNode?: Node;
  75780. }
  75781. /** @hidden */
  75782. export interface IGLTFScene extends IGLTFChildRootProperty {
  75783. nodes: string[];
  75784. }
  75785. /** @hidden */
  75786. export interface IGLTFRuntime {
  75787. extensions: {
  75788. [key: string]: any;
  75789. };
  75790. accessors: {
  75791. [key: string]: IGLTFAccessor;
  75792. };
  75793. buffers: {
  75794. [key: string]: IGLTFBuffer;
  75795. };
  75796. bufferViews: {
  75797. [key: string]: IGLTFBufferView;
  75798. };
  75799. meshes: {
  75800. [key: string]: IGLTFMesh;
  75801. };
  75802. lights: {
  75803. [key: string]: IGLTFLight;
  75804. };
  75805. cameras: {
  75806. [key: string]: IGLTFCamera;
  75807. };
  75808. nodes: {
  75809. [key: string]: IGLTFNode;
  75810. };
  75811. images: {
  75812. [key: string]: IGLTFImage;
  75813. };
  75814. textures: {
  75815. [key: string]: IGLTFTexture;
  75816. };
  75817. shaders: {
  75818. [key: string]: IGLTFShader;
  75819. };
  75820. programs: {
  75821. [key: string]: IGLTFProgram;
  75822. };
  75823. samplers: {
  75824. [key: string]: IGLTFSampler;
  75825. };
  75826. techniques: {
  75827. [key: string]: IGLTFTechnique;
  75828. };
  75829. materials: {
  75830. [key: string]: IGLTFMaterial;
  75831. };
  75832. animations: {
  75833. [key: string]: IGLTFAnimation;
  75834. };
  75835. skins: {
  75836. [key: string]: IGLTFSkins;
  75837. };
  75838. currentScene?: Object;
  75839. scenes: {
  75840. [key: string]: IGLTFScene;
  75841. };
  75842. extensionsUsed: string[];
  75843. extensionsRequired?: string[];
  75844. buffersCount: number;
  75845. shaderscount: number;
  75846. scene: Scene;
  75847. rootUrl: string;
  75848. loadedBufferCount: number;
  75849. loadedBufferViews: {
  75850. [name: string]: ArrayBufferView;
  75851. };
  75852. loadedShaderCount: number;
  75853. importOnlyMeshes: boolean;
  75854. importMeshesNames?: string[];
  75855. dummyNodes: Node[];
  75856. forAssetContainer: boolean;
  75857. }
  75858. /** @hidden */
  75859. export interface INodeToRoot {
  75860. bone: Bone;
  75861. node: IGLTFNode;
  75862. id: string;
  75863. }
  75864. /** @hidden */
  75865. export interface IJointNode {
  75866. node: IGLTFNode;
  75867. id: string;
  75868. }
  75869. }
  75870. declare module BABYLON.GLTF1 {
  75871. /**
  75872. * Utils functions for GLTF
  75873. * @hidden
  75874. */
  75875. export class GLTFUtils {
  75876. /**
  75877. * Sets the given "parameter" matrix
  75878. * @param scene: the Scene object
  75879. * @param source: the source node where to pick the matrix
  75880. * @param parameter: the GLTF technique parameter
  75881. * @param uniformName: the name of the shader's uniform
  75882. * @param shaderMaterial: the shader material
  75883. */
  75884. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  75885. /**
  75886. * Sets the given "parameter" matrix
  75887. * @param shaderMaterial: the shader material
  75888. * @param uniform: the name of the shader's uniform
  75889. * @param value: the value of the uniform
  75890. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  75891. */
  75892. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  75893. /**
  75894. * Returns the wrap mode of the texture
  75895. * @param mode: the mode value
  75896. */
  75897. static GetWrapMode(mode: number): number;
  75898. /**
  75899. * Returns the byte stride giving an accessor
  75900. * @param accessor: the GLTF accessor objet
  75901. */
  75902. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  75903. /**
  75904. * Returns the texture filter mode giving a mode value
  75905. * @param mode: the filter mode value
  75906. */
  75907. static GetTextureFilterMode(mode: number): ETextureFilterType;
  75908. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  75909. /**
  75910. * Returns a buffer from its accessor
  75911. * @param gltfRuntime: the GLTF runtime
  75912. * @param accessor: the GLTF accessor
  75913. */
  75914. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  75915. /**
  75916. * Decodes a buffer view into a string
  75917. * @param view: the buffer view
  75918. */
  75919. static DecodeBufferToText(view: ArrayBufferView): string;
  75920. /**
  75921. * Returns the default material of gltf. Related to
  75922. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  75923. * @param scene: the Babylon.js scene
  75924. */
  75925. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  75926. private static _DefaultMaterial;
  75927. }
  75928. }
  75929. declare module BABYLON.GLTF1 {
  75930. /**
  75931. * Implementation of the base glTF spec
  75932. * @hidden
  75933. */
  75934. export class GLTFLoaderBase {
  75935. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  75936. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75937. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  75938. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75939. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  75940. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75941. }
  75942. /**
  75943. * glTF V1 Loader
  75944. * @hidden
  75945. */
  75946. export class GLTFLoader implements IGLTFLoader {
  75947. static Extensions: {
  75948. [name: string]: GLTFLoaderExtension;
  75949. };
  75950. static RegisterExtension(extension: GLTFLoaderExtension): void;
  75951. state: Nullable<GLTFLoaderState>;
  75952. dispose(): void;
  75953. private _importMeshAsync;
  75954. /**
  75955. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75956. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75957. * @param scene the scene the meshes should be added to
  75958. * @param forAssetContainer defines if the entities must be stored in the scene
  75959. * @param data gltf data containing information of the meshes in a loaded file
  75960. * @param rootUrl root url to load from
  75961. * @param onProgress event that fires when loading progress has occured
  75962. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75963. */
  75964. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75965. private _loadAsync;
  75966. /**
  75967. * Imports all objects from a loaded gltf file and adds them to the scene
  75968. * @param scene the scene the objects should be added to
  75969. * @param data gltf data containing information of the meshes in a loaded file
  75970. * @param rootUrl root url to load from
  75971. * @param onProgress event that fires when loading progress has occured
  75972. * @returns a promise which completes when objects have been loaded to the scene
  75973. */
  75974. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75975. private _loadShadersAsync;
  75976. private _loadBuffersAsync;
  75977. private _createNodes;
  75978. }
  75979. /** @hidden */
  75980. export abstract class GLTFLoaderExtension {
  75981. private _name;
  75982. constructor(name: string);
  75983. get name(): string;
  75984. /**
  75985. * Defines an override for loading the runtime
  75986. * Return true to stop further extensions from loading the runtime
  75987. */
  75988. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75989. /**
  75990. * Defines an onverride for creating gltf runtime
  75991. * Return true to stop further extensions from creating the runtime
  75992. */
  75993. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75994. /**
  75995. * Defines an override for loading buffers
  75996. * Return true to stop further extensions from loading this buffer
  75997. */
  75998. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75999. /**
  76000. * Defines an override for loading texture buffers
  76001. * Return true to stop further extensions from loading this texture data
  76002. */
  76003. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76004. /**
  76005. * Defines an override for creating textures
  76006. * Return true to stop further extensions from loading this texture
  76007. */
  76008. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  76009. /**
  76010. * Defines an override for loading shader strings
  76011. * Return true to stop further extensions from loading this shader data
  76012. */
  76013. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76014. /**
  76015. * Defines an override for loading materials
  76016. * Return true to stop further extensions from loading this material
  76017. */
  76018. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76019. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  76020. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  76021. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  76022. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  76023. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  76024. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  76025. private static LoadTextureBufferAsync;
  76026. private static CreateTextureAsync;
  76027. private static ApplyExtensions;
  76028. }
  76029. }
  76030. declare module BABYLON.GLTF1 {
  76031. /** @hidden */
  76032. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  76033. private _bin;
  76034. constructor();
  76035. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  76036. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76037. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  76038. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  76039. }
  76040. }
  76041. declare module BABYLON.GLTF1 {
  76042. /** @hidden */
  76043. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  76044. constructor();
  76045. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  76046. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  76047. private _loadTexture;
  76048. }
  76049. }
  76050. declare module BABYLON.GLTF2.Loader {
  76051. /**
  76052. * Loader interface with an index field.
  76053. */
  76054. export interface IArrayItem {
  76055. /**
  76056. * The index of this item in the array.
  76057. */
  76058. index: number;
  76059. }
  76060. /**
  76061. * Loader interface with additional members.
  76062. */
  76063. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  76064. /** @hidden */
  76065. _data?: Promise<ArrayBufferView>;
  76066. /** @hidden */
  76067. _babylonVertexBuffer?: Promise<VertexBuffer>;
  76068. }
  76069. /**
  76070. * Loader interface with additional members.
  76071. */
  76072. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  76073. }
  76074. /** @hidden */
  76075. export interface _IAnimationSamplerData {
  76076. input: Float32Array;
  76077. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  76078. output: Float32Array;
  76079. }
  76080. /**
  76081. * Loader interface with additional members.
  76082. */
  76083. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  76084. /** @hidden */
  76085. _data?: Promise<_IAnimationSamplerData>;
  76086. }
  76087. /**
  76088. * Loader interface with additional members.
  76089. */
  76090. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  76091. channels: IAnimationChannel[];
  76092. samplers: IAnimationSampler[];
  76093. /** @hidden */
  76094. _babylonAnimationGroup?: AnimationGroup;
  76095. }
  76096. /**
  76097. * Loader interface with additional members.
  76098. */
  76099. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  76100. /** @hidden */
  76101. _data?: Promise<ArrayBufferView>;
  76102. }
  76103. /**
  76104. * Loader interface with additional members.
  76105. */
  76106. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  76107. /** @hidden */
  76108. _data?: Promise<ArrayBufferView>;
  76109. /** @hidden */
  76110. _babylonBuffer?: Promise<Buffer>;
  76111. }
  76112. /**
  76113. * Loader interface with additional members.
  76114. */
  76115. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  76116. }
  76117. /**
  76118. * Loader interface with additional members.
  76119. */
  76120. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  76121. /** @hidden */
  76122. _data?: Promise<ArrayBufferView>;
  76123. }
  76124. /**
  76125. * Loader interface with additional members.
  76126. */
  76127. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  76128. }
  76129. /**
  76130. * Loader interface with additional members.
  76131. */
  76132. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  76133. }
  76134. /**
  76135. * Loader interface with additional members.
  76136. */
  76137. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  76138. baseColorTexture?: ITextureInfo;
  76139. metallicRoughnessTexture?: ITextureInfo;
  76140. }
  76141. /**
  76142. * Loader interface with additional members.
  76143. */
  76144. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  76145. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  76146. normalTexture?: IMaterialNormalTextureInfo;
  76147. occlusionTexture?: IMaterialOcclusionTextureInfo;
  76148. emissiveTexture?: ITextureInfo;
  76149. /** @hidden */
  76150. _data?: {
  76151. [babylonDrawMode: number]: {
  76152. babylonMaterial: Material;
  76153. babylonMeshes: AbstractMesh[];
  76154. promise: Promise<void>;
  76155. };
  76156. };
  76157. }
  76158. /**
  76159. * Loader interface with additional members.
  76160. */
  76161. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  76162. primitives: IMeshPrimitive[];
  76163. }
  76164. /**
  76165. * Loader interface with additional members.
  76166. */
  76167. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  76168. /** @hidden */
  76169. _instanceData?: {
  76170. babylonSourceMesh: Mesh;
  76171. promise: Promise<any>;
  76172. };
  76173. }
  76174. /**
  76175. * Loader interface with additional members.
  76176. */
  76177. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  76178. /**
  76179. * The parent glTF node.
  76180. */
  76181. parent?: INode;
  76182. /** @hidden */
  76183. _babylonTransformNode?: TransformNode;
  76184. /** @hidden */
  76185. _primitiveBabylonMeshes?: AbstractMesh[];
  76186. /** @hidden */
  76187. _babylonBones?: Bone[];
  76188. /** @hidden */
  76189. _numMorphTargets?: number;
  76190. }
  76191. /** @hidden */
  76192. export interface _ISamplerData {
  76193. noMipMaps: boolean;
  76194. samplingMode: number;
  76195. wrapU: number;
  76196. wrapV: number;
  76197. }
  76198. /**
  76199. * Loader interface with additional members.
  76200. */
  76201. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  76202. /** @hidden */
  76203. _data?: _ISamplerData;
  76204. }
  76205. /**
  76206. * Loader interface with additional members.
  76207. */
  76208. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  76209. }
  76210. /**
  76211. * Loader interface with additional members.
  76212. */
  76213. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  76214. /** @hidden */
  76215. _data?: {
  76216. babylonSkeleton: Skeleton;
  76217. promise: Promise<void>;
  76218. };
  76219. }
  76220. /**
  76221. * Loader interface with additional members.
  76222. */
  76223. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  76224. }
  76225. /**
  76226. * Loader interface with additional members.
  76227. */
  76228. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  76229. }
  76230. /**
  76231. * Loader interface with additional members.
  76232. */
  76233. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  76234. accessors?: IAccessor[];
  76235. animations?: IAnimation[];
  76236. buffers?: IBuffer[];
  76237. bufferViews?: IBufferView[];
  76238. cameras?: ICamera[];
  76239. images?: IImage[];
  76240. materials?: IMaterial[];
  76241. meshes?: IMesh[];
  76242. nodes?: INode[];
  76243. samplers?: ISampler[];
  76244. scenes?: IScene[];
  76245. skins?: ISkin[];
  76246. textures?: ITexture[];
  76247. }
  76248. }
  76249. declare module BABYLON.GLTF2 {
  76250. /**
  76251. * Interface for a glTF loader extension.
  76252. */
  76253. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  76254. /**
  76255. * Called after the loader state changes to LOADING.
  76256. */
  76257. onLoading?(): void;
  76258. /**
  76259. * Called after the loader state changes to READY.
  76260. */
  76261. onReady?(): void;
  76262. /**
  76263. * Define this method to modify the default behavior when loading scenes.
  76264. * @param context The context when loading the asset
  76265. * @param scene The glTF scene property
  76266. * @returns A promise that resolves when the load is complete or null if not handled
  76267. */
  76268. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  76269. /**
  76270. * Define this method to modify the default behavior when loading nodes.
  76271. * @param context The context when loading the asset
  76272. * @param node The glTF node property
  76273. * @param assign A function called synchronously after parsing the glTF properties
  76274. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  76275. */
  76276. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76277. /**
  76278. * Define this method to modify the default behavior when loading cameras.
  76279. * @param context The context when loading the asset
  76280. * @param camera The glTF camera property
  76281. * @param assign A function called synchronously after parsing the glTF properties
  76282. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  76283. */
  76284. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76285. /**
  76286. * @hidden
  76287. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  76288. * @param context The context when loading the asset
  76289. * @param primitive The glTF mesh primitive property
  76290. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  76291. */
  76292. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76293. /**
  76294. * @hidden
  76295. * Define this method to modify the default behavior when loading data for mesh primitives.
  76296. * @param context The context when loading the asset
  76297. * @param name The mesh name when loading the asset
  76298. * @param node The glTF node when loading the asset
  76299. * @param mesh The glTF mesh when loading the asset
  76300. * @param primitive The glTF mesh primitive property
  76301. * @param assign A function called synchronously after parsing the glTF properties
  76302. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76303. */
  76304. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76305. /**
  76306. * @hidden
  76307. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  76308. * @param context The context when loading the asset
  76309. * @param material The glTF material property
  76310. * @param assign A function called synchronously after parsing the glTF properties
  76311. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  76312. */
  76313. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76314. /**
  76315. * Define this method to modify the default behavior when creating materials.
  76316. * @param context The context when loading the asset
  76317. * @param material The glTF material property
  76318. * @param babylonDrawMode The draw mode for the Babylon material
  76319. * @returns The Babylon material or null if not handled
  76320. */
  76321. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76322. /**
  76323. * Define this method to modify the default behavior when loading material properties.
  76324. * @param context The context when loading the asset
  76325. * @param material The glTF material property
  76326. * @param babylonMaterial The Babylon material
  76327. * @returns A promise that resolves when the load is complete or null if not handled
  76328. */
  76329. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76330. /**
  76331. * Define this method to modify the default behavior when loading texture infos.
  76332. * @param context The context when loading the asset
  76333. * @param textureInfo The glTF texture info property
  76334. * @param assign A function called synchronously after parsing the glTF properties
  76335. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76336. */
  76337. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76338. /**
  76339. * @hidden
  76340. * Define this method to modify the default behavior when loading textures.
  76341. * @param context The context when loading the asset
  76342. * @param texture The glTF texture property
  76343. * @param assign A function called synchronously after parsing the glTF properties
  76344. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  76345. */
  76346. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76347. /**
  76348. * Define this method to modify the default behavior when loading animations.
  76349. * @param context The context when loading the asset
  76350. * @param animation The glTF animation property
  76351. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  76352. */
  76353. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76354. /**
  76355. * @hidden
  76356. * Define this method to modify the default behavior when loading skins.
  76357. * @param context The context when loading the asset
  76358. * @param node The glTF node property
  76359. * @param skin The glTF skin property
  76360. * @returns A promise that resolves when the load is complete or null if not handled
  76361. */
  76362. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  76363. /**
  76364. * @hidden
  76365. * Define this method to modify the default behavior when loading uris.
  76366. * @param context The context when loading the asset
  76367. * @param property The glTF property associated with the uri
  76368. * @param uri The uri to load
  76369. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76370. */
  76371. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76372. /**
  76373. * Define this method to modify the default behavior when loading buffer views.
  76374. * @param context The context when loading the asset
  76375. * @param bufferView The glTF buffer view property
  76376. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76377. */
  76378. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  76379. /**
  76380. * Define this method to modify the default behavior when loading buffers.
  76381. * @param context The context when loading the asset
  76382. * @param buffer The glTF buffer property
  76383. * @param byteOffset The byte offset to load
  76384. * @param byteLength The byte length to load
  76385. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  76386. */
  76387. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76388. }
  76389. }
  76390. declare module BABYLON.GLTF2 {
  76391. /**
  76392. * Helper class for working with arrays when loading the glTF asset
  76393. */
  76394. export class ArrayItem {
  76395. /**
  76396. * Gets an item from the given array.
  76397. * @param context The context when loading the asset
  76398. * @param array The array to get the item from
  76399. * @param index The index to the array
  76400. * @returns The array item
  76401. */
  76402. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  76403. /**
  76404. * Assign an `index` field to each item of the given array.
  76405. * @param array The array of items
  76406. */
  76407. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  76408. }
  76409. /**
  76410. * The glTF 2.0 loader
  76411. */
  76412. export class GLTFLoader implements IGLTFLoader {
  76413. /** @hidden */
  76414. _completePromises: Promise<any>[];
  76415. /** @hidden */
  76416. _forAssetContainer: boolean;
  76417. /** Storage */
  76418. _babylonLights: Light[];
  76419. private _disposed;
  76420. private _parent;
  76421. private _state;
  76422. private _extensions;
  76423. private _rootUrl;
  76424. private _fileName;
  76425. private _uniqueRootUrl;
  76426. private _gltf;
  76427. private _bin;
  76428. private _babylonScene;
  76429. private _rootBabylonMesh;
  76430. private _defaultBabylonMaterialData;
  76431. private _progressCallback?;
  76432. private _requests;
  76433. private static _RegisteredExtensions;
  76434. /**
  76435. * The default glTF sampler.
  76436. */
  76437. static readonly DefaultSampler: ISampler;
  76438. /**
  76439. * Registers a loader extension.
  76440. * @param name The name of the loader extension.
  76441. * @param factory The factory function that creates the loader extension.
  76442. */
  76443. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  76444. /**
  76445. * Unregisters a loader extension.
  76446. * @param name The name of the loader extension.
  76447. * @returns A boolean indicating whether the extension has been unregistered
  76448. */
  76449. static UnregisterExtension(name: string): boolean;
  76450. /**
  76451. * The loader state.
  76452. */
  76453. get state(): Nullable<GLTFLoaderState>;
  76454. /**
  76455. * The object that represents the glTF JSON.
  76456. */
  76457. get gltf(): IGLTF;
  76458. /**
  76459. * The BIN chunk of a binary glTF.
  76460. */
  76461. get bin(): Nullable<IDataBuffer>;
  76462. /**
  76463. * The parent file loader.
  76464. */
  76465. get parent(): GLTFFileLoader;
  76466. /**
  76467. * The Babylon scene when loading the asset.
  76468. */
  76469. get babylonScene(): Scene;
  76470. /**
  76471. * The root Babylon mesh when loading the asset.
  76472. */
  76473. get rootBabylonMesh(): Mesh;
  76474. /** @hidden */
  76475. constructor(parent: GLTFFileLoader);
  76476. /** @hidden */
  76477. dispose(): void;
  76478. /** @hidden */
  76479. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  76480. /** @hidden */
  76481. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76482. private _loadAsync;
  76483. private _loadData;
  76484. private _setupData;
  76485. private _loadExtensions;
  76486. private _checkExtensions;
  76487. private _setState;
  76488. private _createRootNode;
  76489. /**
  76490. * Loads a glTF scene.
  76491. * @param context The context when loading the asset
  76492. * @param scene The glTF scene property
  76493. * @returns A promise that resolves when the load is complete
  76494. */
  76495. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  76496. private _forEachPrimitive;
  76497. private _getMeshes;
  76498. private _getTransformNodes;
  76499. private _getSkeletons;
  76500. private _getAnimationGroups;
  76501. private _startAnimations;
  76502. /**
  76503. * Loads a glTF node.
  76504. * @param context The context when loading the asset
  76505. * @param node The glTF node property
  76506. * @param assign A function called synchronously after parsing the glTF properties
  76507. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  76508. */
  76509. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  76510. private _loadMeshAsync;
  76511. /**
  76512. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  76513. * @param context The context when loading the asset
  76514. * @param name The mesh name when loading the asset
  76515. * @param node The glTF node when loading the asset
  76516. * @param mesh The glTF mesh when loading the asset
  76517. * @param primitive The glTF mesh primitive property
  76518. * @param assign A function called synchronously after parsing the glTF properties
  76519. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  76520. */
  76521. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  76522. private _loadVertexDataAsync;
  76523. private _createMorphTargets;
  76524. private _loadMorphTargetsAsync;
  76525. private _loadMorphTargetVertexDataAsync;
  76526. private static _LoadTransform;
  76527. private _loadSkinAsync;
  76528. private _loadBones;
  76529. private _loadBone;
  76530. private _loadSkinInverseBindMatricesDataAsync;
  76531. private _updateBoneMatrices;
  76532. private _getNodeMatrix;
  76533. /**
  76534. * Loads a glTF camera.
  76535. * @param context The context when loading the asset
  76536. * @param camera The glTF camera property
  76537. * @param assign A function called synchronously after parsing the glTF properties
  76538. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  76539. */
  76540. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  76541. private _loadAnimationsAsync;
  76542. /**
  76543. * Loads a glTF animation.
  76544. * @param context The context when loading the asset
  76545. * @param animation The glTF animation property
  76546. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  76547. */
  76548. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  76549. /**
  76550. * @hidden Loads a glTF animation channel.
  76551. * @param context The context when loading the asset
  76552. * @param animationContext The context of the animation when loading the asset
  76553. * @param animation The glTF animation property
  76554. * @param channel The glTF animation channel property
  76555. * @param babylonAnimationGroup The babylon animation group property
  76556. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  76557. * @returns A void promise when the channel load is complete
  76558. */
  76559. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  76560. private _loadAnimationSamplerAsync;
  76561. private _loadBufferAsync;
  76562. /**
  76563. * Loads a glTF buffer view.
  76564. * @param context The context when loading the asset
  76565. * @param bufferView The glTF buffer view property
  76566. * @returns A promise that resolves with the loaded data when the load is complete
  76567. */
  76568. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  76569. private _loadAccessorAsync;
  76570. /** @hidden */
  76571. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  76572. private _loadIndicesAccessorAsync;
  76573. private _loadVertexBufferViewAsync;
  76574. private _loadVertexAccessorAsync;
  76575. private _loadMaterialMetallicRoughnessPropertiesAsync;
  76576. /** @hidden */
  76577. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  76578. private _createDefaultMaterial;
  76579. /**
  76580. * Creates a Babylon material from a glTF material.
  76581. * @param context The context when loading the asset
  76582. * @param material The glTF material property
  76583. * @param babylonDrawMode The draw mode for the Babylon material
  76584. * @returns The Babylon material
  76585. */
  76586. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  76587. /**
  76588. * Loads properties from a glTF material into a Babylon material.
  76589. * @param context The context when loading the asset
  76590. * @param material The glTF material property
  76591. * @param babylonMaterial The Babylon material
  76592. * @returns A promise that resolves when the load is complete
  76593. */
  76594. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76595. /**
  76596. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  76597. * @param context The context when loading the asset
  76598. * @param material The glTF material property
  76599. * @param babylonMaterial The Babylon material
  76600. * @returns A promise that resolves when the load is complete
  76601. */
  76602. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  76603. /**
  76604. * Loads the alpha properties from a glTF material into a Babylon material.
  76605. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  76606. * @param context The context when loading the asset
  76607. * @param material The glTF material property
  76608. * @param babylonMaterial The Babylon material
  76609. */
  76610. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  76611. /**
  76612. * Loads a glTF texture info.
  76613. * @param context The context when loading the asset
  76614. * @param textureInfo The glTF texture info property
  76615. * @param assign A function called synchronously after parsing the glTF properties
  76616. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  76617. */
  76618. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76619. /** @hidden */
  76620. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76621. /** @hidden */
  76622. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  76623. private _loadSampler;
  76624. /**
  76625. * Loads a glTF image.
  76626. * @param context The context when loading the asset
  76627. * @param image The glTF image property
  76628. * @returns A promise that resolves with the loaded data when the load is complete
  76629. */
  76630. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  76631. /**
  76632. * Loads a glTF uri.
  76633. * @param context The context when loading the asset
  76634. * @param property The glTF property associated with the uri
  76635. * @param uri The base64 or relative uri
  76636. * @returns A promise that resolves with the loaded data when the load is complete
  76637. */
  76638. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  76639. private _onProgress;
  76640. /**
  76641. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  76642. * @param babylonObject the Babylon object with metadata
  76643. * @param pointer the JSON pointer
  76644. */
  76645. static AddPointerMetadata(babylonObject: {
  76646. metadata: any;
  76647. }, pointer: string): void;
  76648. private static _GetTextureWrapMode;
  76649. private static _GetTextureSamplingMode;
  76650. private static _GetTypedArrayConstructor;
  76651. private static _GetTypedArray;
  76652. private static _GetNumComponents;
  76653. private static _ValidateUri;
  76654. private static _GetDrawMode;
  76655. private _compileMaterialsAsync;
  76656. private _compileShadowGeneratorsAsync;
  76657. private _forEachExtensions;
  76658. private _applyExtensions;
  76659. private _extensionsOnLoading;
  76660. private _extensionsOnReady;
  76661. private _extensionsLoadSceneAsync;
  76662. private _extensionsLoadNodeAsync;
  76663. private _extensionsLoadCameraAsync;
  76664. private _extensionsLoadVertexDataAsync;
  76665. private _extensionsLoadMeshPrimitiveAsync;
  76666. private _extensionsLoadMaterialAsync;
  76667. private _extensionsCreateMaterial;
  76668. private _extensionsLoadMaterialPropertiesAsync;
  76669. private _extensionsLoadTextureInfoAsync;
  76670. private _extensionsLoadTextureAsync;
  76671. private _extensionsLoadAnimationAsync;
  76672. private _extensionsLoadSkinAsync;
  76673. private _extensionsLoadUriAsync;
  76674. private _extensionsLoadBufferViewAsync;
  76675. private _extensionsLoadBufferAsync;
  76676. /**
  76677. * Helper method called by a loader extension to load an glTF extension.
  76678. * @param context The context when loading the asset
  76679. * @param property The glTF property to load the extension from
  76680. * @param extensionName The name of the extension to load
  76681. * @param actionAsync The action to run
  76682. * @returns The promise returned by actionAsync or null if the extension does not exist
  76683. */
  76684. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76685. /**
  76686. * Helper method called by a loader extension to load a glTF extra.
  76687. * @param context The context when loading the asset
  76688. * @param property The glTF property to load the extra from
  76689. * @param extensionName The name of the extension to load
  76690. * @param actionAsync The action to run
  76691. * @returns The promise returned by actionAsync or null if the extra does not exist
  76692. */
  76693. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  76694. /**
  76695. * Checks for presence of an extension.
  76696. * @param name The name of the extension to check
  76697. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  76698. */
  76699. isExtensionUsed(name: string): boolean;
  76700. /**
  76701. * Increments the indentation level and logs a message.
  76702. * @param message The message to log
  76703. */
  76704. logOpen(message: string): void;
  76705. /**
  76706. * Decrements the indentation level.
  76707. */
  76708. logClose(): void;
  76709. /**
  76710. * Logs a message
  76711. * @param message The message to log
  76712. */
  76713. log(message: string): void;
  76714. /**
  76715. * Starts a performance counter.
  76716. * @param counterName The name of the performance counter
  76717. */
  76718. startPerformanceCounter(counterName: string): void;
  76719. /**
  76720. * Ends a performance counter.
  76721. * @param counterName The name of the performance counter
  76722. */
  76723. endPerformanceCounter(counterName: string): void;
  76724. }
  76725. }
  76726. declare module BABYLON.GLTF2.Loader.Extensions {
  76727. /**
  76728. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  76729. */
  76730. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  76731. /**
  76732. * The name of this extension.
  76733. */
  76734. readonly name: string;
  76735. /**
  76736. * Defines whether this extension is enabled.
  76737. */
  76738. enabled: boolean;
  76739. private _loader;
  76740. private _lights?;
  76741. /** @hidden */
  76742. constructor(loader: GLTFLoader);
  76743. /** @hidden */
  76744. dispose(): void;
  76745. /** @hidden */
  76746. onLoading(): void;
  76747. /** @hidden */
  76748. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76749. private _loadLightAsync;
  76750. }
  76751. }
  76752. declare module BABYLON.GLTF2.Loader.Extensions {
  76753. /**
  76754. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  76755. */
  76756. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  76757. /**
  76758. * The name of this extension.
  76759. */
  76760. readonly name: string;
  76761. /**
  76762. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  76763. */
  76764. dracoCompression?: DracoCompression;
  76765. /**
  76766. * Defines whether this extension is enabled.
  76767. */
  76768. enabled: boolean;
  76769. private _loader;
  76770. /** @hidden */
  76771. constructor(loader: GLTFLoader);
  76772. /** @hidden */
  76773. dispose(): void;
  76774. /** @hidden */
  76775. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  76776. }
  76777. }
  76778. declare module BABYLON.GLTF2.Loader.Extensions {
  76779. /**
  76780. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  76781. */
  76782. export class KHR_lights implements IGLTFLoaderExtension {
  76783. /**
  76784. * The name of this extension.
  76785. */
  76786. readonly name: string;
  76787. /**
  76788. * Defines whether this extension is enabled.
  76789. */
  76790. enabled: boolean;
  76791. private _loader;
  76792. private _lights?;
  76793. /** @hidden */
  76794. constructor(loader: GLTFLoader);
  76795. /** @hidden */
  76796. dispose(): void;
  76797. /** @hidden */
  76798. onLoading(): void;
  76799. /** @hidden */
  76800. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76801. }
  76802. }
  76803. declare module BABYLON.GLTF2.Loader.Extensions {
  76804. /**
  76805. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  76806. */
  76807. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  76808. /**
  76809. * The name of this extension.
  76810. */
  76811. readonly name: string;
  76812. /**
  76813. * Defines whether this extension is enabled.
  76814. */
  76815. enabled: boolean;
  76816. /**
  76817. * Defines a number that determines the order the extensions are applied.
  76818. */
  76819. order: number;
  76820. private _loader;
  76821. /** @hidden */
  76822. constructor(loader: GLTFLoader);
  76823. /** @hidden */
  76824. dispose(): void;
  76825. /** @hidden */
  76826. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76827. private _loadSpecularGlossinessPropertiesAsync;
  76828. }
  76829. }
  76830. declare module BABYLON.GLTF2.Loader.Extensions {
  76831. /**
  76832. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  76833. */
  76834. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  76835. /**
  76836. * The name of this extension.
  76837. */
  76838. readonly name: string;
  76839. /**
  76840. * Defines whether this extension is enabled.
  76841. */
  76842. enabled: boolean;
  76843. /**
  76844. * Defines a number that determines the order the extensions are applied.
  76845. */
  76846. order: number;
  76847. private _loader;
  76848. /** @hidden */
  76849. constructor(loader: GLTFLoader);
  76850. /** @hidden */
  76851. dispose(): void;
  76852. /** @hidden */
  76853. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76854. private _loadUnlitPropertiesAsync;
  76855. }
  76856. }
  76857. declare module BABYLON.GLTF2.Loader.Extensions {
  76858. /**
  76859. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76860. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  76861. * !!! Experimental Extension Subject to Changes !!!
  76862. */
  76863. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  76864. /**
  76865. * The name of this extension.
  76866. */
  76867. readonly name: string;
  76868. /**
  76869. * Defines whether this extension is enabled.
  76870. */
  76871. enabled: boolean;
  76872. /**
  76873. * Defines a number that determines the order the extensions are applied.
  76874. */
  76875. order: number;
  76876. private _loader;
  76877. /** @hidden */
  76878. constructor(loader: GLTFLoader);
  76879. /** @hidden */
  76880. dispose(): void;
  76881. /** @hidden */
  76882. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76883. private _loadClearCoatPropertiesAsync;
  76884. }
  76885. }
  76886. declare module BABYLON.GLTF2.Loader.Extensions {
  76887. /**
  76888. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  76889. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76890. * !!! Experimental Extension Subject to Changes !!!
  76891. */
  76892. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  76893. /**
  76894. * The name of this extension.
  76895. */
  76896. readonly name: string;
  76897. /**
  76898. * Defines whether this extension is enabled.
  76899. */
  76900. enabled: boolean;
  76901. /**
  76902. * Defines a number that determines the order the extensions are applied.
  76903. */
  76904. order: number;
  76905. private _loader;
  76906. /** @hidden */
  76907. constructor(loader: GLTFLoader);
  76908. /** @hidden */
  76909. dispose(): void;
  76910. /** @hidden */
  76911. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76912. private _loadSheenPropertiesAsync;
  76913. }
  76914. }
  76915. declare module BABYLON.GLTF2.Loader.Extensions {
  76916. /**
  76917. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  76918. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  76919. * !!! Experimental Extension Subject to Changes !!!
  76920. */
  76921. export class KHR_materials_specular implements IGLTFLoaderExtension {
  76922. /**
  76923. * The name of this extension.
  76924. */
  76925. readonly name: string;
  76926. /**
  76927. * Defines whether this extension is enabled.
  76928. */
  76929. enabled: boolean;
  76930. /**
  76931. * Defines a number that determines the order the extensions are applied.
  76932. */
  76933. order: number;
  76934. private _loader;
  76935. /** @hidden */
  76936. constructor(loader: GLTFLoader);
  76937. /** @hidden */
  76938. dispose(): void;
  76939. /** @hidden */
  76940. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76941. private _loadSpecularPropertiesAsync;
  76942. }
  76943. }
  76944. declare module BABYLON.GLTF2.Loader.Extensions {
  76945. /**
  76946. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  76947. * [Playground Sample](//TODO)
  76948. * !!! Experimental Extension Subject to Changes !!!
  76949. */
  76950. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  76951. /**
  76952. * The name of this extension.
  76953. */
  76954. readonly name: string;
  76955. /**
  76956. * Defines whether this extension is enabled.
  76957. */
  76958. enabled: boolean;
  76959. private _loader;
  76960. /** @hidden */
  76961. constructor(loader: GLTFLoader);
  76962. /** @hidden */
  76963. dispose(): void;
  76964. /** @hidden */
  76965. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76966. }
  76967. }
  76968. declare module BABYLON.GLTF2.Loader.Extensions {
  76969. /**
  76970. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  76971. */
  76972. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  76973. /**
  76974. * The name of this extension.
  76975. */
  76976. readonly name: string;
  76977. /**
  76978. * Defines whether this extension is enabled.
  76979. */
  76980. enabled: boolean;
  76981. /** @hidden */
  76982. constructor(loader: GLTFLoader);
  76983. /** @hidden */
  76984. dispose(): void;
  76985. }
  76986. }
  76987. declare module BABYLON.GLTF2.Loader.Extensions {
  76988. /**
  76989. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  76990. * !!! Experimental Extension Subject to Changes !!!
  76991. */
  76992. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  76993. /** The name of this extension. */
  76994. readonly name: string;
  76995. /** Defines whether this extension is enabled. */
  76996. enabled: boolean;
  76997. private _loader;
  76998. /** @hidden */
  76999. constructor(loader: GLTFLoader);
  77000. /** @hidden */
  77001. dispose(): void;
  77002. /** @hidden */
  77003. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77004. }
  77005. }
  77006. declare module BABYLON.GLTF2.Loader.Extensions {
  77007. /**
  77008. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  77009. */
  77010. export class KHR_texture_transform implements IGLTFLoaderExtension {
  77011. /**
  77012. * The name of this extension.
  77013. */
  77014. readonly name: string;
  77015. /**
  77016. * Defines whether this extension is enabled.
  77017. */
  77018. enabled: boolean;
  77019. private _loader;
  77020. /** @hidden */
  77021. constructor(loader: GLTFLoader);
  77022. /** @hidden */
  77023. dispose(): void;
  77024. /** @hidden */
  77025. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  77026. }
  77027. }
  77028. declare module BABYLON.GLTF2.Loader.Extensions {
  77029. /**
  77030. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  77031. */
  77032. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  77033. /**
  77034. * The name of this extension.
  77035. */
  77036. readonly name: string;
  77037. /**
  77038. * Defines whether this extension is enabled.
  77039. */
  77040. enabled: boolean;
  77041. private _loader;
  77042. private _clips;
  77043. private _emitters;
  77044. /** @hidden */
  77045. constructor(loader: GLTFLoader);
  77046. /** @hidden */
  77047. dispose(): void;
  77048. /** @hidden */
  77049. onLoading(): void;
  77050. /** @hidden */
  77051. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77052. /** @hidden */
  77053. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77054. /** @hidden */
  77055. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  77056. private _loadClipAsync;
  77057. private _loadEmitterAsync;
  77058. private _getEventAction;
  77059. private _loadAnimationEventAsync;
  77060. }
  77061. }
  77062. declare module BABYLON.GLTF2.Loader.Extensions {
  77063. /**
  77064. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  77065. */
  77066. export class MSFT_lod implements IGLTFLoaderExtension {
  77067. /**
  77068. * The name of this extension.
  77069. */
  77070. readonly name: string;
  77071. /**
  77072. * Defines whether this extension is enabled.
  77073. */
  77074. enabled: boolean;
  77075. /**
  77076. * Defines a number that determines the order the extensions are applied.
  77077. */
  77078. order: number;
  77079. /**
  77080. * Maximum number of LODs to load, starting from the lowest LOD.
  77081. */
  77082. maxLODsToLoad: number;
  77083. /**
  77084. * Observable raised when all node LODs of one level are loaded.
  77085. * The event data is the index of the loaded LOD starting from zero.
  77086. * Dispose the loader to cancel the loading of the next level of LODs.
  77087. */
  77088. onNodeLODsLoadedObservable: Observable<number>;
  77089. /**
  77090. * Observable raised when all material LODs of one level are loaded.
  77091. * The event data is the index of the loaded LOD starting from zero.
  77092. * Dispose the loader to cancel the loading of the next level of LODs.
  77093. */
  77094. onMaterialLODsLoadedObservable: Observable<number>;
  77095. private _loader;
  77096. private _nodeIndexLOD;
  77097. private _nodeSignalLODs;
  77098. private _nodePromiseLODs;
  77099. private _materialIndexLOD;
  77100. private _materialSignalLODs;
  77101. private _materialPromiseLODs;
  77102. private _indexLOD;
  77103. private _bufferLODs;
  77104. /** @hidden */
  77105. constructor(loader: GLTFLoader);
  77106. /** @hidden */
  77107. dispose(): void;
  77108. /** @hidden */
  77109. onReady(): void;
  77110. /** @hidden */
  77111. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  77112. /** @hidden */
  77113. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77114. /** @hidden */
  77115. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  77116. /** @hidden */
  77117. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  77118. /** @hidden */
  77119. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  77120. private _loadBufferLOD;
  77121. /**
  77122. * Gets an array of LOD properties from lowest to highest.
  77123. */
  77124. private _getLODs;
  77125. private _disposeTransformNode;
  77126. private _disposeMaterials;
  77127. }
  77128. }
  77129. declare module BABYLON.GLTF2.Loader.Extensions {
  77130. /** @hidden */
  77131. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  77132. readonly name: string;
  77133. enabled: boolean;
  77134. private _loader;
  77135. constructor(loader: GLTFLoader);
  77136. dispose(): void;
  77137. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77138. }
  77139. }
  77140. declare module BABYLON.GLTF2.Loader.Extensions {
  77141. /** @hidden */
  77142. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  77143. readonly name: string;
  77144. enabled: boolean;
  77145. private _loader;
  77146. constructor(loader: GLTFLoader);
  77147. dispose(): void;
  77148. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  77149. }
  77150. }
  77151. declare module BABYLON.GLTF2.Loader.Extensions {
  77152. /**
  77153. * Store glTF extras (if present) in BJS objects' metadata
  77154. */
  77155. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  77156. /**
  77157. * The name of this extension.
  77158. */
  77159. readonly name: string;
  77160. /**
  77161. * Defines whether this extension is enabled.
  77162. */
  77163. enabled: boolean;
  77164. private _loader;
  77165. private _assignExtras;
  77166. /** @hidden */
  77167. constructor(loader: GLTFLoader);
  77168. /** @hidden */
  77169. dispose(): void;
  77170. /** @hidden */
  77171. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  77172. /** @hidden */
  77173. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  77174. /** @hidden */
  77175. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  77176. }
  77177. }
  77178. declare module BABYLON {
  77179. /**
  77180. * Class reading and parsing the MTL file bundled with the obj file.
  77181. */
  77182. export class MTLFileLoader {
  77183. /**
  77184. * Invert Y-Axis of referenced textures on load
  77185. */
  77186. static INVERT_TEXTURE_Y: boolean;
  77187. /**
  77188. * All material loaded from the mtl will be set here
  77189. */
  77190. materials: StandardMaterial[];
  77191. /**
  77192. * This function will read the mtl file and create each material described inside
  77193. * This function could be improve by adding :
  77194. * -some component missing (Ni, Tf...)
  77195. * -including the specific options available
  77196. *
  77197. * @param scene defines the scene the material will be created in
  77198. * @param data defines the mtl data to parse
  77199. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  77200. * @param forAssetContainer defines if the material should be registered in the scene
  77201. */
  77202. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  77203. /**
  77204. * Gets the texture for the material.
  77205. *
  77206. * If the material is imported from input file,
  77207. * We sanitize the url to ensure it takes the textre from aside the material.
  77208. *
  77209. * @param rootUrl The root url to load from
  77210. * @param value The value stored in the mtl
  77211. * @return The Texture
  77212. */
  77213. private static _getTexture;
  77214. }
  77215. }
  77216. declare module BABYLON {
  77217. /**
  77218. * Options for loading OBJ/MTL files
  77219. */
  77220. type MeshLoadOptions = {
  77221. /**
  77222. * Defines if UVs are optimized by default during load.
  77223. */
  77224. OptimizeWithUV: boolean;
  77225. /**
  77226. * Defines custom scaling of UV coordinates of loaded meshes.
  77227. */
  77228. UVScaling: Vector2;
  77229. /**
  77230. * Invert model on y-axis (does a model scaling inversion)
  77231. */
  77232. InvertY: boolean;
  77233. /**
  77234. * Invert Y-Axis of referenced textures on load
  77235. */
  77236. InvertTextureY: boolean;
  77237. /**
  77238. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77239. */
  77240. ImportVertexColors: boolean;
  77241. /**
  77242. * Compute the normals for the model, even if normals are present in the file.
  77243. */
  77244. ComputeNormals: boolean;
  77245. /**
  77246. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77247. */
  77248. SkipMaterials: boolean;
  77249. /**
  77250. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77251. */
  77252. MaterialLoadingFailsSilently: boolean;
  77253. };
  77254. /**
  77255. * OBJ file type loader.
  77256. * This is a babylon scene loader plugin.
  77257. */
  77258. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  77259. /**
  77260. * Defines if UVs are optimized by default during load.
  77261. */
  77262. static OPTIMIZE_WITH_UV: boolean;
  77263. /**
  77264. * Invert model on y-axis (does a model scaling inversion)
  77265. */
  77266. static INVERT_Y: boolean;
  77267. /**
  77268. * Invert Y-Axis of referenced textures on load
  77269. */
  77270. static get INVERT_TEXTURE_Y(): boolean;
  77271. static set INVERT_TEXTURE_Y(value: boolean);
  77272. /**
  77273. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  77274. */
  77275. static IMPORT_VERTEX_COLORS: boolean;
  77276. /**
  77277. * Compute the normals for the model, even if normals are present in the file.
  77278. */
  77279. static COMPUTE_NORMALS: boolean;
  77280. /**
  77281. * Defines custom scaling of UV coordinates of loaded meshes.
  77282. */
  77283. static UV_SCALING: Vector2;
  77284. /**
  77285. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  77286. */
  77287. static SKIP_MATERIALS: boolean;
  77288. /**
  77289. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  77290. *
  77291. * Defaults to true for backwards compatibility.
  77292. */
  77293. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  77294. /**
  77295. * Defines the name of the plugin.
  77296. */
  77297. name: string;
  77298. /**
  77299. * Defines the extension the plugin is able to load.
  77300. */
  77301. extensions: string;
  77302. /** @hidden */
  77303. obj: RegExp;
  77304. /** @hidden */
  77305. group: RegExp;
  77306. /** @hidden */
  77307. mtllib: RegExp;
  77308. /** @hidden */
  77309. usemtl: RegExp;
  77310. /** @hidden */
  77311. smooth: RegExp;
  77312. /** @hidden */
  77313. vertexPattern: RegExp;
  77314. /** @hidden */
  77315. normalPattern: RegExp;
  77316. /** @hidden */
  77317. uvPattern: RegExp;
  77318. /** @hidden */
  77319. facePattern1: RegExp;
  77320. /** @hidden */
  77321. facePattern2: RegExp;
  77322. /** @hidden */
  77323. facePattern3: RegExp;
  77324. /** @hidden */
  77325. facePattern4: RegExp;
  77326. /** @hidden */
  77327. facePattern5: RegExp;
  77328. private _forAssetContainer;
  77329. private _meshLoadOptions;
  77330. /**
  77331. * Creates loader for .OBJ files
  77332. *
  77333. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  77334. */
  77335. constructor(meshLoadOptions?: MeshLoadOptions);
  77336. private static get currentMeshLoadOptions();
  77337. /**
  77338. * Calls synchronously the MTL file attached to this obj.
  77339. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  77340. * Without this function materials are not displayed in the first frame (but displayed after).
  77341. * In consequence it is impossible to get material information in your HTML file
  77342. *
  77343. * @param url The URL of the MTL file
  77344. * @param rootUrl
  77345. * @param onSuccess Callback function to be called when the MTL file is loaded
  77346. * @private
  77347. */
  77348. private _loadMTL;
  77349. /**
  77350. * Instantiates a OBJ file loader plugin.
  77351. * @returns the created plugin
  77352. */
  77353. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  77354. /**
  77355. * If the data string can be loaded directly.
  77356. *
  77357. * @param data string containing the file data
  77358. * @returns if the data can be loaded directly
  77359. */
  77360. canDirectLoad(data: string): boolean;
  77361. /**
  77362. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  77363. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  77364. * @param scene the scene the meshes should be added to
  77365. * @param data the OBJ data to load
  77366. * @param rootUrl root url to load from
  77367. * @param onProgress event that fires when loading progress has occured
  77368. * @param fileName Defines the name of the file to load
  77369. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  77370. */
  77371. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  77372. meshes: AbstractMesh[];
  77373. particleSystems: IParticleSystem[];
  77374. skeletons: Skeleton[];
  77375. animationGroups: AnimationGroup[];
  77376. }>;
  77377. /**
  77378. * Imports all objects from the loaded OBJ data and adds them to the scene
  77379. * @param scene the scene the objects should be added to
  77380. * @param data the OBJ data to load
  77381. * @param rootUrl root url to load from
  77382. * @param onProgress event that fires when loading progress has occured
  77383. * @param fileName Defines the name of the file to load
  77384. * @returns a promise which completes when objects have been loaded to the scene
  77385. */
  77386. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  77387. /**
  77388. * Load into an asset container.
  77389. * @param scene The scene to load into
  77390. * @param data The data to import
  77391. * @param rootUrl The root url for scene and resources
  77392. * @param onProgress The callback when the load progresses
  77393. * @param fileName Defines the name of the file to load
  77394. * @returns The loaded asset container
  77395. */
  77396. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  77397. /**
  77398. * Read the OBJ file and create an Array of meshes.
  77399. * Each mesh contains all information given by the OBJ and the MTL file.
  77400. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  77401. *
  77402. * @param meshesNames
  77403. * @param scene Scene The scene where are displayed the data
  77404. * @param data String The content of the obj file
  77405. * @param rootUrl String The path to the folder
  77406. * @returns Array<AbstractMesh>
  77407. * @private
  77408. */
  77409. private _parseSolid;
  77410. }
  77411. }
  77412. declare module BABYLON {
  77413. /**
  77414. * STL file type loader.
  77415. * This is a babylon scene loader plugin.
  77416. */
  77417. export class STLFileLoader implements ISceneLoaderPlugin {
  77418. /** @hidden */
  77419. solidPattern: RegExp;
  77420. /** @hidden */
  77421. facetsPattern: RegExp;
  77422. /** @hidden */
  77423. normalPattern: RegExp;
  77424. /** @hidden */
  77425. vertexPattern: RegExp;
  77426. /**
  77427. * Defines the name of the plugin.
  77428. */
  77429. name: string;
  77430. /**
  77431. * Defines the extensions the stl loader is able to load.
  77432. * force data to come in as an ArrayBuffer
  77433. * we'll convert to string if it looks like it's an ASCII .stl
  77434. */
  77435. extensions: ISceneLoaderPluginExtensions;
  77436. /**
  77437. * Import meshes into a scene.
  77438. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  77439. * @param scene The scene to import into
  77440. * @param data The data to import
  77441. * @param rootUrl The root url for scene and resources
  77442. * @param meshes The meshes array to import into
  77443. * @param particleSystems The particle systems array to import into
  77444. * @param skeletons The skeletons array to import into
  77445. * @param onError The callback when import fails
  77446. * @returns True if successful or false otherwise
  77447. */
  77448. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  77449. /**
  77450. * Load into a scene.
  77451. * @param scene The scene to load into
  77452. * @param data The data to import
  77453. * @param rootUrl The root url for scene and resources
  77454. * @param onError The callback when import fails
  77455. * @returns true if successful or false otherwise
  77456. */
  77457. load(scene: Scene, data: any, rootUrl: string): boolean;
  77458. /**
  77459. * Load into an asset container.
  77460. * @param scene The scene to load into
  77461. * @param data The data to import
  77462. * @param rootUrl The root url for scene and resources
  77463. * @param onError The callback when import fails
  77464. * @returns The loaded asset container
  77465. */
  77466. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  77467. private _isBinary;
  77468. private _parseBinary;
  77469. private _parseASCII;
  77470. }
  77471. }
  77472. declare module BABYLON {
  77473. /**
  77474. * Class for generating OBJ data from a Babylon scene.
  77475. */
  77476. export class OBJExport {
  77477. /**
  77478. * Exports the geometry of a Mesh array in .OBJ file format (text)
  77479. * @param mesh defines the list of meshes to serialize
  77480. * @param materials defines if materials should be exported
  77481. * @param matlibname defines the name of the associated mtl file
  77482. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  77483. * @returns the OBJ content
  77484. */
  77485. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  77486. /**
  77487. * Exports the material(s) of a mesh in .MTL file format (text)
  77488. * @param mesh defines the mesh to extract the material from
  77489. * @returns the mtl content
  77490. */
  77491. static MTL(mesh: Mesh): string;
  77492. }
  77493. }
  77494. declare module BABYLON {
  77495. /** @hidden */
  77496. export var __IGLTFExporterExtension: number;
  77497. /**
  77498. * Interface for extending the exporter
  77499. * @hidden
  77500. */
  77501. export interface IGLTFExporterExtension {
  77502. /**
  77503. * The name of this extension
  77504. */
  77505. readonly name: string;
  77506. /**
  77507. * Defines whether this extension is enabled
  77508. */
  77509. enabled: boolean;
  77510. /**
  77511. * Defines whether this extension is required
  77512. */
  77513. required: boolean;
  77514. }
  77515. }
  77516. declare module BABYLON.GLTF2.Exporter {
  77517. /** @hidden */
  77518. export var __IGLTFExporterExtensionV2: number;
  77519. /**
  77520. * Interface for a glTF exporter extension
  77521. * @hidden
  77522. */
  77523. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  77524. /**
  77525. * Define this method to modify the default behavior before exporting a texture
  77526. * @param context The context when loading the asset
  77527. * @param babylonTexture The Babylon.js texture
  77528. * @param mimeType The mime-type of the generated image
  77529. * @returns A promise that resolves with the exported texture
  77530. */
  77531. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  77532. /**
  77533. * Define this method to get notified when a texture info is created
  77534. * @param context The context when loading the asset
  77535. * @param textureInfo The glTF texture info
  77536. * @param babylonTexture The Babylon.js texture
  77537. */
  77538. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77539. /**
  77540. * Define this method to modify the default behavior when exporting texture info
  77541. * @param context The context when loading the asset
  77542. * @param meshPrimitive glTF mesh primitive
  77543. * @param babylonSubMesh Babylon submesh
  77544. * @param binaryWriter glTF serializer binary writer instance
  77545. * @returns nullable IMeshPrimitive promise
  77546. */
  77547. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77548. /**
  77549. * Define this method to modify the default behavior when exporting a node
  77550. * @param context The context when exporting the node
  77551. * @param node glTF node
  77552. * @param babylonNode BabylonJS node
  77553. * @returns nullable INode promise
  77554. */
  77555. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  77556. [key: number]: number;
  77557. }): Promise<Nullable<INode>>;
  77558. /**
  77559. * Define this method to modify the default behavior when exporting a material
  77560. * @param material glTF material
  77561. * @param babylonMaterial BabylonJS material
  77562. * @returns nullable IMaterial promise
  77563. */
  77564. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  77565. /**
  77566. * Define this method to return additional textures to export from a material
  77567. * @param material glTF material
  77568. * @param babylonMaterial BabylonJS material
  77569. * @returns List of textures
  77570. */
  77571. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77572. /** Gets a boolean indicating that this extension was used */
  77573. wasUsed: boolean;
  77574. /** Gets a boolean indicating that this extension is required for the file to work */
  77575. required: boolean;
  77576. /**
  77577. * Called after the exporter state changes to EXPORTING
  77578. */
  77579. onExporting?(): void;
  77580. }
  77581. }
  77582. declare module BABYLON.GLTF2.Exporter {
  77583. /**
  77584. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  77585. * @hidden
  77586. */
  77587. export class _GLTFMaterialExporter {
  77588. /**
  77589. * Represents the dielectric specular values for R, G and B
  77590. */
  77591. private static readonly _DielectricSpecular;
  77592. /**
  77593. * Allows the maximum specular power to be defined for material calculations
  77594. */
  77595. private static readonly _MaxSpecularPower;
  77596. /**
  77597. * Mapping to store textures
  77598. */
  77599. private _textureMap;
  77600. /**
  77601. * Numeric tolerance value
  77602. */
  77603. private static readonly _Epsilon;
  77604. /**
  77605. * Reference to the glTF Exporter
  77606. */
  77607. private _exporter;
  77608. constructor(exporter: _Exporter);
  77609. /**
  77610. * Specifies if two colors are approximately equal in value
  77611. * @param color1 first color to compare to
  77612. * @param color2 second color to compare to
  77613. * @param epsilon threshold value
  77614. */
  77615. private static FuzzyEquals;
  77616. /**
  77617. * Gets the materials from a Babylon scene and converts them to glTF materials
  77618. * @param scene babylonjs scene
  77619. * @param mimeType texture mime type
  77620. * @param images array of images
  77621. * @param textures array of textures
  77622. * @param materials array of materials
  77623. * @param imageData mapping of texture names to base64 textures
  77624. * @param hasTextureCoords specifies if texture coordinates are present on the material
  77625. */
  77626. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  77627. /**
  77628. * Makes a copy of the glTF material without the texture parameters
  77629. * @param originalMaterial original glTF material
  77630. * @returns glTF material without texture parameters
  77631. */
  77632. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  77633. /**
  77634. * Specifies if the material has any texture parameters present
  77635. * @param material glTF Material
  77636. * @returns boolean specifying if texture parameters are present
  77637. */
  77638. _hasTexturesPresent(material: IMaterial): boolean;
  77639. /**
  77640. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  77641. * @param babylonStandardMaterial
  77642. * @returns glTF Metallic Roughness Material representation
  77643. */
  77644. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  77645. /**
  77646. * Computes the metallic factor
  77647. * @param diffuse diffused value
  77648. * @param specular specular value
  77649. * @param oneMinusSpecularStrength one minus the specular strength
  77650. * @returns metallic value
  77651. */
  77652. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  77653. /**
  77654. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  77655. * @param glTFMaterial glTF material
  77656. * @param babylonMaterial Babylon material
  77657. */
  77658. private static _SetAlphaMode;
  77659. /**
  77660. * Converts a Babylon Standard Material to a glTF Material
  77661. * @param babylonStandardMaterial BJS Standard Material
  77662. * @param mimeType mime type to use for the textures
  77663. * @param images array of glTF image interfaces
  77664. * @param textures array of glTF texture interfaces
  77665. * @param materials array of glTF material interfaces
  77666. * @param imageData map of image file name to data
  77667. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77668. */
  77669. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77670. private _finishMaterial;
  77671. /**
  77672. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77673. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  77674. * @param mimeType mime type to use for the textures
  77675. * @param images array of glTF image interfaces
  77676. * @param textures array of glTF texture interfaces
  77677. * @param materials array of glTF material interfaces
  77678. * @param imageData map of image file name to data
  77679. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77680. */
  77681. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77682. /**
  77683. * Converts an image typed array buffer to a base64 image
  77684. * @param buffer typed array buffer
  77685. * @param width width of the image
  77686. * @param height height of the image
  77687. * @param mimeType mimetype of the image
  77688. * @returns base64 image string
  77689. */
  77690. private _createBase64FromCanvasAsync;
  77691. /**
  77692. * Generates a white texture based on the specified width and height
  77693. * @param width width of the texture in pixels
  77694. * @param height height of the texture in pixels
  77695. * @param scene babylonjs scene
  77696. * @returns white texture
  77697. */
  77698. private _createWhiteTexture;
  77699. /**
  77700. * 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
  77701. * @param texture1 first texture to resize
  77702. * @param texture2 second texture to resize
  77703. * @param scene babylonjs scene
  77704. * @returns resized textures or null
  77705. */
  77706. private _resizeTexturesToSameDimensions;
  77707. /**
  77708. * Converts an array of pixels to a Float32Array
  77709. * Throws an error if the pixel format is not supported
  77710. * @param pixels - array buffer containing pixel values
  77711. * @returns Float32 of pixels
  77712. */
  77713. private _convertPixelArrayToFloat32;
  77714. /**
  77715. * Convert Specular Glossiness Textures to Metallic Roughness
  77716. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  77717. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  77718. * @param diffuseTexture texture used to store diffuse information
  77719. * @param specularGlossinessTexture texture used to store specular and glossiness information
  77720. * @param factors specular glossiness material factors
  77721. * @param mimeType the mime type to use for the texture
  77722. * @returns pbr metallic roughness interface or null
  77723. */
  77724. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  77725. /**
  77726. * Converts specular glossiness material properties to metallic roughness
  77727. * @param specularGlossiness interface with specular glossiness material properties
  77728. * @returns interface with metallic roughness material properties
  77729. */
  77730. private _convertSpecularGlossinessToMetallicRoughness;
  77731. /**
  77732. * Calculates the surface reflectance, independent of lighting conditions
  77733. * @param color Color source to calculate brightness from
  77734. * @returns number representing the perceived brightness, or zero if color is undefined
  77735. */
  77736. private _getPerceivedBrightness;
  77737. /**
  77738. * Returns the maximum color component value
  77739. * @param color
  77740. * @returns maximum color component value, or zero if color is null or undefined
  77741. */
  77742. private _getMaxComponent;
  77743. /**
  77744. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  77745. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77746. * @param mimeType mime type to use for the textures
  77747. * @param images array of glTF image interfaces
  77748. * @param textures array of glTF texture interfaces
  77749. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77750. * @param imageData map of image file name to data
  77751. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77752. * @returns glTF PBR Metallic Roughness factors
  77753. */
  77754. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  77755. private _getGLTFTextureSampler;
  77756. private _getGLTFTextureWrapMode;
  77757. private _getGLTFTextureWrapModesSampler;
  77758. /**
  77759. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  77760. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77761. * @param mimeType mime type to use for the textures
  77762. * @param images array of glTF image interfaces
  77763. * @param textures array of glTF texture interfaces
  77764. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  77765. * @param imageData map of image file name to data
  77766. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77767. * @returns glTF PBR Metallic Roughness factors
  77768. */
  77769. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  77770. /**
  77771. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  77772. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  77773. * @param mimeType mime type to use for the textures
  77774. * @param images array of glTF image interfaces
  77775. * @param textures array of glTF texture interfaces
  77776. * @param materials array of glTF material interfaces
  77777. * @param imageData map of image file name to data
  77778. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  77779. */
  77780. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  77781. private setMetallicRoughnessPbrMaterial;
  77782. private getPixelsFromTexture;
  77783. /**
  77784. * Extracts a texture from a Babylon texture into file data and glTF data
  77785. * @param babylonTexture Babylon texture to extract
  77786. * @param mimeType Mime Type of the babylonTexture
  77787. * @return glTF texture info, or null if the texture format is not supported
  77788. */
  77789. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77790. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  77791. /**
  77792. * Builds a texture from base64 string
  77793. * @param base64Texture base64 texture string
  77794. * @param baseTextureName Name to use for the texture
  77795. * @param mimeType image mime type for the texture
  77796. * @param images array of images
  77797. * @param textures array of textures
  77798. * @param imageData map of image data
  77799. * @returns glTF texture info, or null if the texture format is not supported
  77800. */
  77801. private _getTextureInfoFromBase64;
  77802. }
  77803. }
  77804. declare module BABYLON {
  77805. /**
  77806. * Class for holding and downloading glTF file data
  77807. */
  77808. export class GLTFData {
  77809. /**
  77810. * Object which contains the file name as the key and its data as the value
  77811. */
  77812. glTFFiles: {
  77813. [fileName: string]: string | Blob;
  77814. };
  77815. /**
  77816. * Initializes the glTF file object
  77817. */
  77818. constructor();
  77819. /**
  77820. * Downloads the glTF data as files based on their names and data
  77821. */
  77822. downloadFiles(): void;
  77823. }
  77824. }
  77825. declare module BABYLON {
  77826. /**
  77827. * Holds a collection of exporter options and parameters
  77828. */
  77829. export interface IExportOptions {
  77830. /**
  77831. * Function which indicates whether a babylon node should be exported or not
  77832. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  77833. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  77834. */
  77835. shouldExportNode?(node: Node): boolean;
  77836. /**
  77837. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  77838. * @param metadata source metadata to read from
  77839. * @returns the data to store to glTF node extras
  77840. */
  77841. metadataSelector?(metadata: any): any;
  77842. /**
  77843. * The sample rate to bake animation curves
  77844. */
  77845. animationSampleRate?: number;
  77846. /**
  77847. * Begin serialization without waiting for the scene to be ready
  77848. */
  77849. exportWithoutWaitingForScene?: boolean;
  77850. /**
  77851. * Indicates if coordinate system swapping root nodes should be included in export
  77852. */
  77853. includeCoordinateSystemConversionNodes?: boolean;
  77854. }
  77855. /**
  77856. * Class for generating glTF data from a Babylon scene.
  77857. */
  77858. export class GLTF2Export {
  77859. /**
  77860. * Exports the geometry of the scene to .gltf file format asynchronously
  77861. * @param scene Babylon scene with scene hierarchy information
  77862. * @param filePrefix File prefix to use when generating the glTF file
  77863. * @param options Exporter options
  77864. * @returns Returns an object with a .gltf file and associates texture names
  77865. * as keys and their data and paths as values
  77866. */
  77867. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77868. private static _PreExportAsync;
  77869. private static _PostExportAsync;
  77870. /**
  77871. * Exports the geometry of the scene to .glb file format asychronously
  77872. * @param scene Babylon scene with scene hierarchy information
  77873. * @param filePrefix File prefix to use when generating glb file
  77874. * @param options Exporter options
  77875. * @returns Returns an object with a .glb filename as key and data as value
  77876. */
  77877. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  77878. }
  77879. }
  77880. declare module BABYLON.GLTF2.Exporter {
  77881. /**
  77882. * @hidden
  77883. */
  77884. export class _GLTFUtilities {
  77885. /**
  77886. * Creates a buffer view based on the supplied arguments
  77887. * @param bufferIndex index value of the specified buffer
  77888. * @param byteOffset byte offset value
  77889. * @param byteLength byte length of the bufferView
  77890. * @param byteStride byte distance between conequential elements
  77891. * @param name name of the buffer view
  77892. * @returns bufferView for glTF
  77893. */
  77894. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  77895. /**
  77896. * Creates an accessor based on the supplied arguments
  77897. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  77898. * @param name The name of the accessor
  77899. * @param type The type of the accessor
  77900. * @param componentType The datatype of components in the attribute
  77901. * @param count The number of attributes referenced by this accessor
  77902. * @param byteOffset The offset relative to the start of the bufferView in bytes
  77903. * @param min Minimum value of each component in this attribute
  77904. * @param max Maximum value of each component in this attribute
  77905. * @returns accessor for glTF
  77906. */
  77907. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  77908. /**
  77909. * Calculates the minimum and maximum values of an array of position floats
  77910. * @param positions Positions array of a mesh
  77911. * @param vertexStart Starting vertex offset to calculate min and max values
  77912. * @param vertexCount Number of vertices to check for min and max values
  77913. * @returns min number array and max number array
  77914. */
  77915. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  77916. min: number[];
  77917. max: number[];
  77918. };
  77919. /**
  77920. * Converts a new right-handed Vector3
  77921. * @param vector vector3 array
  77922. * @returns right-handed Vector3
  77923. */
  77924. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  77925. /**
  77926. * Converts a Vector3 to right-handed
  77927. * @param vector Vector3 to convert to right-handed
  77928. */
  77929. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  77930. /**
  77931. * Converts a three element number array to right-handed
  77932. * @param vector number array to convert to right-handed
  77933. */
  77934. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  77935. /**
  77936. * Converts a new right-handed Vector3
  77937. * @param vector vector3 array
  77938. * @returns right-handed Vector3
  77939. */
  77940. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  77941. /**
  77942. * Converts a Vector3 to right-handed
  77943. * @param vector Vector3 to convert to right-handed
  77944. */
  77945. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  77946. /**
  77947. * Converts a three element number array to right-handed
  77948. * @param vector number array to convert to right-handed
  77949. */
  77950. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  77951. /**
  77952. * Converts a Vector4 to right-handed
  77953. * @param vector Vector4 to convert to right-handed
  77954. */
  77955. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  77956. /**
  77957. * Converts a Vector4 to right-handed
  77958. * @param vector Vector4 to convert to right-handed
  77959. */
  77960. static _GetRightHandedArray4FromRef(vector: number[]): void;
  77961. /**
  77962. * Converts a Quaternion to right-handed
  77963. * @param quaternion Source quaternion to convert to right-handed
  77964. */
  77965. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  77966. /**
  77967. * Converts a Quaternion to right-handed
  77968. * @param quaternion Source quaternion to convert to right-handed
  77969. */
  77970. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  77971. static _NormalizeTangentFromRef(tangent: Vector4): void;
  77972. }
  77973. }
  77974. declare module BABYLON.GLTF2.Exporter {
  77975. /**
  77976. * Converts Babylon Scene into glTF 2.0.
  77977. * @hidden
  77978. */
  77979. export class _Exporter {
  77980. /**
  77981. * Stores the glTF to export
  77982. */
  77983. _glTF: IGLTF;
  77984. /**
  77985. * Stores all generated buffer views, which represents views into the main glTF buffer data
  77986. */
  77987. _bufferViews: IBufferView[];
  77988. /**
  77989. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  77990. */
  77991. _accessors: IAccessor[];
  77992. /**
  77993. * Stores all the generated nodes, which contains transform and/or mesh information per node
  77994. */
  77995. _nodes: INode[];
  77996. /**
  77997. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  77998. */
  77999. private _scenes;
  78000. /**
  78001. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  78002. */
  78003. private _meshes;
  78004. /**
  78005. * Stores all the generated material information, which represents the appearance of each primitive
  78006. */
  78007. _materials: IMaterial[];
  78008. _materialMap: {
  78009. [materialID: number]: number;
  78010. };
  78011. /**
  78012. * Stores all the generated texture information, which is referenced by glTF materials
  78013. */
  78014. _textures: ITexture[];
  78015. /**
  78016. * Stores all the generated image information, which is referenced by glTF textures
  78017. */
  78018. _images: IImage[];
  78019. /**
  78020. * Stores all the texture samplers
  78021. */
  78022. _samplers: ISampler[];
  78023. /**
  78024. * Stores all the generated animation samplers, which is referenced by glTF animations
  78025. */
  78026. /**
  78027. * Stores the animations for glTF models
  78028. */
  78029. private _animations;
  78030. /**
  78031. * Stores the total amount of bytes stored in the glTF buffer
  78032. */
  78033. private _totalByteLength;
  78034. /**
  78035. * Stores a reference to the Babylon scene containing the source geometry and material information
  78036. */
  78037. _babylonScene: Scene;
  78038. /**
  78039. * Stores a map of the image data, where the key is the file name and the value
  78040. * is the image data
  78041. */
  78042. _imageData: {
  78043. [fileName: string]: {
  78044. data: Uint8Array;
  78045. mimeType: ImageMimeType;
  78046. };
  78047. };
  78048. /**
  78049. * Stores a map of the unique id of a node to its index in the node array
  78050. */
  78051. _nodeMap: {
  78052. [key: number]: number;
  78053. };
  78054. /**
  78055. * Specifies if the source Babylon scene was left handed, and needed conversion.
  78056. */
  78057. _convertToRightHandedSystem: boolean;
  78058. /**
  78059. * Specifies if a Babylon node should be converted to right-handed on export
  78060. */
  78061. _convertToRightHandedSystemMap: {
  78062. [nodeId: number]: boolean;
  78063. };
  78064. _includeCoordinateSystemConversionNodes: boolean;
  78065. /**
  78066. * Baked animation sample rate
  78067. */
  78068. private _animationSampleRate;
  78069. private _options;
  78070. private _localEngine;
  78071. _glTFMaterialExporter: _GLTFMaterialExporter;
  78072. private _extensions;
  78073. private static _ExtensionNames;
  78074. private static _ExtensionFactories;
  78075. private _applyExtension;
  78076. private _applyExtensions;
  78077. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  78078. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  78079. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78080. [key: number]: number;
  78081. }): Promise<Nullable<INode>>;
  78082. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  78083. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  78084. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  78085. private _forEachExtensions;
  78086. private _extensionsOnExporting;
  78087. /**
  78088. * Load glTF serializer extensions
  78089. */
  78090. private _loadExtensions;
  78091. /**
  78092. * Creates a glTF Exporter instance, which can accept optional exporter options
  78093. * @param babylonScene Babylon scene object
  78094. * @param options Options to modify the behavior of the exporter
  78095. */
  78096. constructor(babylonScene: Scene, options?: IExportOptions);
  78097. dispose(): void;
  78098. /**
  78099. * Registers a glTF exporter extension
  78100. * @param name Name of the extension to export
  78101. * @param factory The factory function that creates the exporter extension
  78102. */
  78103. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  78104. /**
  78105. * Un-registers an exporter extension
  78106. * @param name The name fo the exporter extension
  78107. * @returns A boolean indicating whether the extension has been un-registered
  78108. */
  78109. static UnregisterExtension(name: string): boolean;
  78110. /**
  78111. * Lazy load a local engine
  78112. */
  78113. _getLocalEngine(): Engine;
  78114. private reorderIndicesBasedOnPrimitiveMode;
  78115. /**
  78116. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  78117. * clock-wise during export to glTF
  78118. * @param submesh BabylonJS submesh
  78119. * @param primitiveMode Primitive mode of the mesh
  78120. * @param sideOrientation the winding order of the submesh
  78121. * @param vertexBufferKind The type of vertex attribute
  78122. * @param meshAttributeArray The vertex attribute data
  78123. * @param byteOffset The offset to the binary data
  78124. * @param binaryWriter The binary data for the glTF file
  78125. * @param convertToRightHandedSystem Converts the values to right-handed
  78126. */
  78127. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  78128. /**
  78129. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  78130. * clock-wise during export to glTF
  78131. * @param submesh BabylonJS submesh
  78132. * @param primitiveMode Primitive mode of the mesh
  78133. * @param sideOrientation the winding order of the submesh
  78134. * @param vertexBufferKind The type of vertex attribute
  78135. * @param meshAttributeArray The vertex attribute data
  78136. * @param byteOffset The offset to the binary data
  78137. * @param binaryWriter The binary data for the glTF file
  78138. * @param convertToRightHandedSystem Converts the values to right-handed
  78139. */
  78140. private reorderTriangleFillMode;
  78141. /**
  78142. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  78143. * clock-wise during export to glTF
  78144. * @param submesh BabylonJS submesh
  78145. * @param primitiveMode Primitive mode of the mesh
  78146. * @param sideOrientation the winding order of the submesh
  78147. * @param vertexBufferKind The type of vertex attribute
  78148. * @param meshAttributeArray The vertex attribute data
  78149. * @param byteOffset The offset to the binary data
  78150. * @param binaryWriter The binary data for the glTF file
  78151. * @param convertToRightHandedSystem Converts the values to right-handed
  78152. */
  78153. private reorderTriangleStripDrawMode;
  78154. /**
  78155. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  78156. * clock-wise during export to glTF
  78157. * @param submesh BabylonJS submesh
  78158. * @param primitiveMode Primitive mode of the mesh
  78159. * @param sideOrientation the winding order of the submesh
  78160. * @param vertexBufferKind The type of vertex attribute
  78161. * @param meshAttributeArray The vertex attribute data
  78162. * @param byteOffset The offset to the binary data
  78163. * @param binaryWriter The binary data for the glTF file
  78164. * @param convertToRightHandedSystem Converts the values to right-handed
  78165. */
  78166. private reorderTriangleFanMode;
  78167. /**
  78168. * Writes the vertex attribute data to binary
  78169. * @param vertices The vertices to write to the binary writer
  78170. * @param byteOffset The offset into the binary writer to overwrite binary data
  78171. * @param vertexAttributeKind The vertex attribute type
  78172. * @param meshAttributeArray The vertex attribute data
  78173. * @param binaryWriter The writer containing the binary data
  78174. * @param convertToRightHandedSystem Converts the values to right-handed
  78175. */
  78176. private writeVertexAttributeData;
  78177. /**
  78178. * Writes mesh attribute data to a data buffer
  78179. * Returns the bytelength of the data
  78180. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  78181. * @param meshAttributeArray Array containing the attribute data
  78182. * @param binaryWriter The buffer to write the binary data to
  78183. * @param indices Used to specify the order of the vertex data
  78184. * @param convertToRightHandedSystem Converts the values to right-handed
  78185. */
  78186. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  78187. /**
  78188. * Generates glTF json data
  78189. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  78190. * @param glTFPrefix Text to use when prefixing a glTF file
  78191. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  78192. * @returns json data as string
  78193. */
  78194. private generateJSON;
  78195. /**
  78196. * Generates data for .gltf and .bin files based on the glTF prefix string
  78197. * @param glTFPrefix Text to use when prefixing a glTF file
  78198. * @param dispose Dispose the exporter
  78199. * @returns GLTFData with glTF file data
  78200. */
  78201. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78202. /**
  78203. * Creates a binary buffer for glTF
  78204. * @returns array buffer for binary data
  78205. */
  78206. private _generateBinaryAsync;
  78207. /**
  78208. * Pads the number to a multiple of 4
  78209. * @param num number to pad
  78210. * @returns padded number
  78211. */
  78212. private _getPadding;
  78213. /**
  78214. * @hidden
  78215. */
  78216. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  78217. /**
  78218. * Sets the TRS for each node
  78219. * @param node glTF Node for storing the transformation data
  78220. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  78221. * @param convertToRightHandedSystem Converts the values to right-handed
  78222. */
  78223. private setNodeTransformation;
  78224. private getVertexBufferFromMesh;
  78225. /**
  78226. * Creates a bufferview based on the vertices type for the Babylon mesh
  78227. * @param kind Indicates the type of vertices data
  78228. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  78229. * @param binaryWriter The buffer to write the bufferview data to
  78230. * @param convertToRightHandedSystem Converts the values to right-handed
  78231. */
  78232. private createBufferViewKind;
  78233. /**
  78234. * The primitive mode of the Babylon mesh
  78235. * @param babylonMesh The BabylonJS mesh
  78236. */
  78237. private getMeshPrimitiveMode;
  78238. /**
  78239. * Sets the primitive mode of the glTF mesh primitive
  78240. * @param meshPrimitive glTF mesh primitive
  78241. * @param primitiveMode The primitive mode
  78242. */
  78243. private setPrimitiveMode;
  78244. /**
  78245. * Sets the vertex attribute accessor based of the glTF mesh primitive
  78246. * @param meshPrimitive glTF mesh primitive
  78247. * @param attributeKind vertex attribute
  78248. * @returns boolean specifying if uv coordinates are present
  78249. */
  78250. private setAttributeKind;
  78251. /**
  78252. * Sets data for the primitive attributes of each submesh
  78253. * @param mesh glTF Mesh object to store the primitive attribute information
  78254. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  78255. * @param binaryWriter Buffer to write the attribute data to
  78256. * @param convertToRightHandedSystem Converts the values to right-handed
  78257. */
  78258. private setPrimitiveAttributesAsync;
  78259. /**
  78260. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  78261. * @param node The node to check
  78262. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  78263. */
  78264. private isBabylonCoordinateSystemConvertingNode;
  78265. /**
  78266. * Creates a glTF scene based on the array of meshes
  78267. * Returns the the total byte offset
  78268. * @param babylonScene Babylon scene to get the mesh data from
  78269. * @param binaryWriter Buffer to write binary data to
  78270. */
  78271. private createSceneAsync;
  78272. /**
  78273. * Creates a mapping of Node unique id to node index and handles animations
  78274. * @param babylonScene Babylon Scene
  78275. * @param nodes Babylon transform nodes
  78276. * @param binaryWriter Buffer to write binary data to
  78277. * @returns Node mapping of unique id to index
  78278. */
  78279. private createNodeMapAndAnimationsAsync;
  78280. /**
  78281. * Creates a glTF node from a Babylon mesh
  78282. * @param babylonMesh Source Babylon mesh
  78283. * @param binaryWriter Buffer for storing geometry data
  78284. * @param convertToRightHandedSystem Converts the values to right-handed
  78285. * @param nodeMap Node mapping of unique id to glTF node index
  78286. * @returns glTF node
  78287. */
  78288. private createNodeAsync;
  78289. }
  78290. /**
  78291. * @hidden
  78292. *
  78293. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  78294. */
  78295. export class _BinaryWriter {
  78296. /**
  78297. * Array buffer which stores all binary data
  78298. */
  78299. private _arrayBuffer;
  78300. /**
  78301. * View of the array buffer
  78302. */
  78303. private _dataView;
  78304. /**
  78305. * byte offset of data in array buffer
  78306. */
  78307. private _byteOffset;
  78308. /**
  78309. * Initialize binary writer with an initial byte length
  78310. * @param byteLength Initial byte length of the array buffer
  78311. */
  78312. constructor(byteLength: number);
  78313. /**
  78314. * Resize the array buffer to the specified byte length
  78315. * @param byteLength
  78316. */
  78317. private resizeBuffer;
  78318. /**
  78319. * Get an array buffer with the length of the byte offset
  78320. * @returns ArrayBuffer resized to the byte offset
  78321. */
  78322. getArrayBuffer(): ArrayBuffer;
  78323. /**
  78324. * Get the byte offset of the array buffer
  78325. * @returns byte offset
  78326. */
  78327. getByteOffset(): number;
  78328. /**
  78329. * Stores an UInt8 in the array buffer
  78330. * @param entry
  78331. * @param byteOffset If defined, specifies where to set the value as an offset.
  78332. */
  78333. setUInt8(entry: number, byteOffset?: number): void;
  78334. /**
  78335. * Gets an UInt32 in the array buffer
  78336. * @param entry
  78337. * @param byteOffset If defined, specifies where to set the value as an offset.
  78338. */
  78339. getUInt32(byteOffset: number): number;
  78340. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78341. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  78342. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78343. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  78344. /**
  78345. * Stores a Float32 in the array buffer
  78346. * @param entry
  78347. */
  78348. setFloat32(entry: number, byteOffset?: number): void;
  78349. /**
  78350. * Stores an UInt32 in the array buffer
  78351. * @param entry
  78352. * @param byteOffset If defined, specifies where to set the value as an offset.
  78353. */
  78354. setUInt32(entry: number, byteOffset?: number): void;
  78355. }
  78356. }
  78357. declare module BABYLON.GLTF2.Exporter {
  78358. /**
  78359. * @hidden
  78360. * Interface to store animation data.
  78361. */
  78362. export interface _IAnimationData {
  78363. /**
  78364. * Keyframe data.
  78365. */
  78366. inputs: number[];
  78367. /**
  78368. * Value data.
  78369. */
  78370. outputs: number[][];
  78371. /**
  78372. * Animation interpolation data.
  78373. */
  78374. samplerInterpolation: AnimationSamplerInterpolation;
  78375. /**
  78376. * Minimum keyframe value.
  78377. */
  78378. inputsMin: number;
  78379. /**
  78380. * Maximum keyframe value.
  78381. */
  78382. inputsMax: number;
  78383. }
  78384. /**
  78385. * @hidden
  78386. */
  78387. export interface _IAnimationInfo {
  78388. /**
  78389. * The target channel for the animation
  78390. */
  78391. animationChannelTargetPath: AnimationChannelTargetPath;
  78392. /**
  78393. * The glTF accessor type for the data.
  78394. */
  78395. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  78396. /**
  78397. * Specifies if quaternions should be used.
  78398. */
  78399. useQuaternion: boolean;
  78400. }
  78401. /**
  78402. * @hidden
  78403. * Utility class for generating glTF animation data from BabylonJS.
  78404. */
  78405. export class _GLTFAnimation {
  78406. /**
  78407. * @ignore
  78408. *
  78409. * Creates glTF channel animation from BabylonJS animation.
  78410. * @param babylonTransformNode - BabylonJS mesh.
  78411. * @param animation - animation.
  78412. * @param animationChannelTargetPath - The target animation channel.
  78413. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  78414. * @param useQuaternion - Specifies if quaternions are used.
  78415. * @returns nullable IAnimationData
  78416. */
  78417. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  78418. private static _DeduceAnimationInfo;
  78419. /**
  78420. * @ignore
  78421. * Create node animations from the transform node animations
  78422. * @param babylonNode
  78423. * @param runtimeGLTFAnimation
  78424. * @param idleGLTFAnimations
  78425. * @param nodeMap
  78426. * @param nodes
  78427. * @param binaryWriter
  78428. * @param bufferViews
  78429. * @param accessors
  78430. * @param convertToRightHandedSystem
  78431. * @param animationSampleRate
  78432. */
  78433. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  78434. [key: number]: number;
  78435. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  78436. /**
  78437. * @ignore
  78438. * Create node animations from the animation groups
  78439. * @param babylonScene
  78440. * @param glTFAnimations
  78441. * @param nodeMap
  78442. * @param nodes
  78443. * @param binaryWriter
  78444. * @param bufferViews
  78445. * @param accessors
  78446. * @param convertToRightHandedSystemMap
  78447. * @param animationSampleRate
  78448. */
  78449. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  78450. [key: number]: number;
  78451. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  78452. [nodeId: number]: boolean;
  78453. }, animationSampleRate: number): void;
  78454. private static AddAnimation;
  78455. /**
  78456. * Create a baked animation
  78457. * @param babylonTransformNode BabylonJS mesh
  78458. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  78459. * @param animationChannelTargetPath animation target channel
  78460. * @param minFrame minimum animation frame
  78461. * @param maxFrame maximum animation frame
  78462. * @param fps frames per second of the animation
  78463. * @param inputs input key frames of the animation
  78464. * @param outputs output key frame data of the animation
  78465. * @param convertToRightHandedSystem converts the values to right-handed
  78466. * @param useQuaternion specifies if quaternions should be used
  78467. */
  78468. private static _CreateBakedAnimation;
  78469. private static _ConvertFactorToVector3OrQuaternion;
  78470. private static _SetInterpolatedValue;
  78471. /**
  78472. * Creates linear animation from the animation key frames
  78473. * @param babylonTransformNode BabylonJS mesh
  78474. * @param animation BabylonJS animation
  78475. * @param animationChannelTargetPath The target animation channel
  78476. * @param frameDelta The difference between the last and first frame of the animation
  78477. * @param inputs Array to store the key frame times
  78478. * @param outputs Array to store the key frame data
  78479. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78480. * @param useQuaternion Specifies if quaternions are used in the animation
  78481. */
  78482. private static _CreateLinearOrStepAnimation;
  78483. /**
  78484. * Creates cubic spline animation from the animation key frames
  78485. * @param babylonTransformNode BabylonJS mesh
  78486. * @param animation BabylonJS animation
  78487. * @param animationChannelTargetPath The target animation channel
  78488. * @param frameDelta The difference between the last and first frame of the animation
  78489. * @param inputs Array to store the key frame times
  78490. * @param outputs Array to store the key frame data
  78491. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  78492. * @param useQuaternion Specifies if quaternions are used in the animation
  78493. */
  78494. private static _CreateCubicSplineAnimation;
  78495. private static _GetBasePositionRotationOrScale;
  78496. /**
  78497. * Adds a key frame value
  78498. * @param keyFrame
  78499. * @param animation
  78500. * @param outputs
  78501. * @param animationChannelTargetPath
  78502. * @param basePositionRotationOrScale
  78503. * @param convertToRightHandedSystem
  78504. * @param useQuaternion
  78505. */
  78506. private static _AddKeyframeValue;
  78507. /**
  78508. * Determine the interpolation based on the key frames
  78509. * @param keyFrames
  78510. * @param animationChannelTargetPath
  78511. * @param useQuaternion
  78512. */
  78513. private static _DeduceInterpolation;
  78514. /**
  78515. * Adds an input tangent or output tangent to the output data
  78516. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  78517. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  78518. * @param outputs The animation data by keyframe
  78519. * @param animationChannelTargetPath The target animation channel
  78520. * @param interpolation The interpolation type
  78521. * @param keyFrame The key frame with the animation data
  78522. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  78523. * @param useQuaternion Specifies if quaternions are used
  78524. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  78525. */
  78526. private static AddSplineTangent;
  78527. /**
  78528. * Get the minimum and maximum key frames' frame values
  78529. * @param keyFrames animation key frames
  78530. * @returns the minimum and maximum key frame value
  78531. */
  78532. private static calculateMinMaxKeyFrames;
  78533. }
  78534. }
  78535. declare module BABYLON.GLTF2.Exporter {
  78536. /** @hidden */
  78537. export var textureTransformPixelShader: {
  78538. name: string;
  78539. shader: string;
  78540. };
  78541. }
  78542. declare module BABYLON.GLTF2.Exporter.Extensions {
  78543. /**
  78544. * @hidden
  78545. */
  78546. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  78547. private _recordedTextures;
  78548. /** Name of this extension */
  78549. readonly name: string;
  78550. /** Defines whether this extension is enabled */
  78551. enabled: boolean;
  78552. /** Defines whether this extension is required */
  78553. required: boolean;
  78554. /** Reference to the glTF exporter */
  78555. private _wasUsed;
  78556. constructor(exporter: _Exporter);
  78557. dispose(): void;
  78558. /** @hidden */
  78559. get wasUsed(): boolean;
  78560. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78561. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  78562. /**
  78563. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  78564. * @param babylonTexture
  78565. * @param offset
  78566. * @param rotation
  78567. * @param scale
  78568. * @param scene
  78569. */
  78570. private _textureTransformTextureAsync;
  78571. }
  78572. }
  78573. declare module BABYLON.GLTF2.Exporter.Extensions {
  78574. /**
  78575. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  78576. */
  78577. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  78578. /** The name of this extension. */
  78579. readonly name: string;
  78580. /** Defines whether this extension is enabled. */
  78581. enabled: boolean;
  78582. /** Defines whether this extension is required */
  78583. required: boolean;
  78584. /** Reference to the glTF exporter */
  78585. private _exporter;
  78586. private _lights;
  78587. /** @hidden */
  78588. constructor(exporter: _Exporter);
  78589. /** @hidden */
  78590. dispose(): void;
  78591. /** @hidden */
  78592. get wasUsed(): boolean;
  78593. /** @hidden */
  78594. onExporting(): void;
  78595. /**
  78596. * Define this method to modify the default behavior when exporting a node
  78597. * @param context The context when exporting the node
  78598. * @param node glTF node
  78599. * @param babylonNode BabylonJS node
  78600. * @param nodeMap Node mapping of unique id to glTF node index
  78601. * @returns nullable INode promise
  78602. */
  78603. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  78604. [key: number]: number;
  78605. }): Promise<Nullable<INode>>;
  78606. }
  78607. }
  78608. declare module BABYLON.GLTF2.Exporter.Extensions {
  78609. /**
  78610. * @hidden
  78611. */
  78612. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  78613. /** Name of this extension */
  78614. readonly name: string;
  78615. /** Defines whether this extension is enabled */
  78616. enabled: boolean;
  78617. /** Defines whether this extension is required */
  78618. required: boolean;
  78619. /** Reference to the glTF exporter */
  78620. private _textureInfos;
  78621. private _exportedTextures;
  78622. private _wasUsed;
  78623. constructor(exporter: _Exporter);
  78624. dispose(): void;
  78625. /** @hidden */
  78626. get wasUsed(): boolean;
  78627. private _getTextureIndex;
  78628. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  78629. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  78630. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  78631. }
  78632. }
  78633. declare module BABYLON {
  78634. /**
  78635. * Class for generating STL data from a Babylon scene.
  78636. */
  78637. export class STLExport {
  78638. /**
  78639. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  78640. * @param meshes list defines the mesh to serialize
  78641. * @param download triggers the automatic download of the file.
  78642. * @param fileName changes the downloads fileName.
  78643. * @param binary changes the STL to a binary type.
  78644. * @param isLittleEndian toggle for binary type exporter.
  78645. * @returns the STL as UTF8 string
  78646. */
  78647. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  78648. }
  78649. }
  78650. declare module "babylonjs-gltf2interface" {
  78651. export = BABYLON.GLTF2;
  78652. }
  78653. /**
  78654. * Module for glTF 2.0 Interface
  78655. */
  78656. declare module BABYLON.GLTF2 {
  78657. /**
  78658. * The datatype of the components in the attribute
  78659. */
  78660. const enum AccessorComponentType {
  78661. /**
  78662. * Byte
  78663. */
  78664. BYTE = 5120,
  78665. /**
  78666. * Unsigned Byte
  78667. */
  78668. UNSIGNED_BYTE = 5121,
  78669. /**
  78670. * Short
  78671. */
  78672. SHORT = 5122,
  78673. /**
  78674. * Unsigned Short
  78675. */
  78676. UNSIGNED_SHORT = 5123,
  78677. /**
  78678. * Unsigned Int
  78679. */
  78680. UNSIGNED_INT = 5125,
  78681. /**
  78682. * Float
  78683. */
  78684. FLOAT = 5126,
  78685. }
  78686. /**
  78687. * Specifies if the attirbute is a scalar, vector, or matrix
  78688. */
  78689. const enum AccessorType {
  78690. /**
  78691. * Scalar
  78692. */
  78693. SCALAR = "SCALAR",
  78694. /**
  78695. * Vector2
  78696. */
  78697. VEC2 = "VEC2",
  78698. /**
  78699. * Vector3
  78700. */
  78701. VEC3 = "VEC3",
  78702. /**
  78703. * Vector4
  78704. */
  78705. VEC4 = "VEC4",
  78706. /**
  78707. * Matrix2x2
  78708. */
  78709. MAT2 = "MAT2",
  78710. /**
  78711. * Matrix3x3
  78712. */
  78713. MAT3 = "MAT3",
  78714. /**
  78715. * Matrix4x4
  78716. */
  78717. MAT4 = "MAT4",
  78718. }
  78719. /**
  78720. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  78721. */
  78722. const enum AnimationChannelTargetPath {
  78723. /**
  78724. * Translation
  78725. */
  78726. TRANSLATION = "translation",
  78727. /**
  78728. * Rotation
  78729. */
  78730. ROTATION = "rotation",
  78731. /**
  78732. * Scale
  78733. */
  78734. SCALE = "scale",
  78735. /**
  78736. * Weights
  78737. */
  78738. WEIGHTS = "weights",
  78739. }
  78740. /**
  78741. * Interpolation algorithm
  78742. */
  78743. const enum AnimationSamplerInterpolation {
  78744. /**
  78745. * The animated values are linearly interpolated between keyframes
  78746. */
  78747. LINEAR = "LINEAR",
  78748. /**
  78749. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  78750. */
  78751. STEP = "STEP",
  78752. /**
  78753. * The animation's interpolation is computed using a cubic spline with specified tangents
  78754. */
  78755. CUBICSPLINE = "CUBICSPLINE",
  78756. }
  78757. /**
  78758. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78759. */
  78760. const enum CameraType {
  78761. /**
  78762. * A perspective camera containing properties to create a perspective projection matrix
  78763. */
  78764. PERSPECTIVE = "perspective",
  78765. /**
  78766. * An orthographic camera containing properties to create an orthographic projection matrix
  78767. */
  78768. ORTHOGRAPHIC = "orthographic",
  78769. }
  78770. /**
  78771. * The mime-type of the image
  78772. */
  78773. const enum ImageMimeType {
  78774. /**
  78775. * JPEG Mime-type
  78776. */
  78777. JPEG = "image/jpeg",
  78778. /**
  78779. * PNG Mime-type
  78780. */
  78781. PNG = "image/png",
  78782. }
  78783. /**
  78784. * The alpha rendering mode of the material
  78785. */
  78786. const enum MaterialAlphaMode {
  78787. /**
  78788. * The alpha value is ignored and the rendered output is fully opaque
  78789. */
  78790. OPAQUE = "OPAQUE",
  78791. /**
  78792. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  78793. */
  78794. MASK = "MASK",
  78795. /**
  78796. * 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)
  78797. */
  78798. BLEND = "BLEND",
  78799. }
  78800. /**
  78801. * The type of the primitives to render
  78802. */
  78803. const enum MeshPrimitiveMode {
  78804. /**
  78805. * Points
  78806. */
  78807. POINTS = 0,
  78808. /**
  78809. * Lines
  78810. */
  78811. LINES = 1,
  78812. /**
  78813. * Line Loop
  78814. */
  78815. LINE_LOOP = 2,
  78816. /**
  78817. * Line Strip
  78818. */
  78819. LINE_STRIP = 3,
  78820. /**
  78821. * Triangles
  78822. */
  78823. TRIANGLES = 4,
  78824. /**
  78825. * Triangle Strip
  78826. */
  78827. TRIANGLE_STRIP = 5,
  78828. /**
  78829. * Triangle Fan
  78830. */
  78831. TRIANGLE_FAN = 6,
  78832. }
  78833. /**
  78834. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78835. */
  78836. const enum TextureMagFilter {
  78837. /**
  78838. * Nearest
  78839. */
  78840. NEAREST = 9728,
  78841. /**
  78842. * Linear
  78843. */
  78844. LINEAR = 9729,
  78845. }
  78846. /**
  78847. * Minification filter. All valid values correspond to WebGL enums
  78848. */
  78849. const enum TextureMinFilter {
  78850. /**
  78851. * Nearest
  78852. */
  78853. NEAREST = 9728,
  78854. /**
  78855. * Linear
  78856. */
  78857. LINEAR = 9729,
  78858. /**
  78859. * Nearest Mip-Map Nearest
  78860. */
  78861. NEAREST_MIPMAP_NEAREST = 9984,
  78862. /**
  78863. * Linear Mipmap Nearest
  78864. */
  78865. LINEAR_MIPMAP_NEAREST = 9985,
  78866. /**
  78867. * Nearest Mipmap Linear
  78868. */
  78869. NEAREST_MIPMAP_LINEAR = 9986,
  78870. /**
  78871. * Linear Mipmap Linear
  78872. */
  78873. LINEAR_MIPMAP_LINEAR = 9987,
  78874. }
  78875. /**
  78876. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78877. */
  78878. const enum TextureWrapMode {
  78879. /**
  78880. * Clamp to Edge
  78881. */
  78882. CLAMP_TO_EDGE = 33071,
  78883. /**
  78884. * Mirrored Repeat
  78885. */
  78886. MIRRORED_REPEAT = 33648,
  78887. /**
  78888. * Repeat
  78889. */
  78890. REPEAT = 10497,
  78891. }
  78892. /**
  78893. * glTF Property
  78894. */
  78895. interface IProperty {
  78896. /**
  78897. * Dictionary object with extension-specific objects
  78898. */
  78899. extensions?: {
  78900. [key: string]: any;
  78901. };
  78902. /**
  78903. * Application-Specific data
  78904. */
  78905. extras?: any;
  78906. }
  78907. /**
  78908. * glTF Child of Root Property
  78909. */
  78910. interface IChildRootProperty extends IProperty {
  78911. /**
  78912. * The user-defined name of this object
  78913. */
  78914. name?: string;
  78915. }
  78916. /**
  78917. * Indices of those attributes that deviate from their initialization value
  78918. */
  78919. interface IAccessorSparseIndices extends IProperty {
  78920. /**
  78921. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78922. */
  78923. bufferView: number;
  78924. /**
  78925. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78926. */
  78927. byteOffset?: number;
  78928. /**
  78929. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  78930. */
  78931. componentType: AccessorComponentType;
  78932. }
  78933. /**
  78934. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  78935. */
  78936. interface IAccessorSparseValues extends IProperty {
  78937. /**
  78938. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  78939. */
  78940. bufferView: number;
  78941. /**
  78942. * The offset relative to the start of the bufferView in bytes. Must be aligned
  78943. */
  78944. byteOffset?: number;
  78945. }
  78946. /**
  78947. * Sparse storage of attributes that deviate from their initialization value
  78948. */
  78949. interface IAccessorSparse extends IProperty {
  78950. /**
  78951. * The number of attributes encoded in this sparse accessor
  78952. */
  78953. count: number;
  78954. /**
  78955. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  78956. */
  78957. indices: IAccessorSparseIndices;
  78958. /**
  78959. * 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
  78960. */
  78961. values: IAccessorSparseValues;
  78962. }
  78963. /**
  78964. * 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
  78965. */
  78966. interface IAccessor extends IChildRootProperty {
  78967. /**
  78968. * The index of the bufferview
  78969. */
  78970. bufferView?: number;
  78971. /**
  78972. * The offset relative to the start of the bufferView in bytes
  78973. */
  78974. byteOffset?: number;
  78975. /**
  78976. * The datatype of components in the attribute
  78977. */
  78978. componentType: AccessorComponentType;
  78979. /**
  78980. * Specifies whether integer data values should be normalized
  78981. */
  78982. normalized?: boolean;
  78983. /**
  78984. * The number of attributes referenced by this accessor
  78985. */
  78986. count: number;
  78987. /**
  78988. * Specifies if the attribute is a scalar, vector, or matrix
  78989. */
  78990. type: AccessorType;
  78991. /**
  78992. * Maximum value of each component in this attribute
  78993. */
  78994. max?: number[];
  78995. /**
  78996. * Minimum value of each component in this attribute
  78997. */
  78998. min?: number[];
  78999. /**
  79000. * Sparse storage of attributes that deviate from their initialization value
  79001. */
  79002. sparse?: IAccessorSparse;
  79003. }
  79004. /**
  79005. * Targets an animation's sampler at a node's property
  79006. */
  79007. interface IAnimationChannel extends IProperty {
  79008. /**
  79009. * The index of a sampler in this animation used to compute the value for the target
  79010. */
  79011. sampler: number;
  79012. /**
  79013. * The index of the node and TRS property to target
  79014. */
  79015. target: IAnimationChannelTarget;
  79016. }
  79017. /**
  79018. * The index of the node and TRS property that an animation channel targets
  79019. */
  79020. interface IAnimationChannelTarget extends IProperty {
  79021. /**
  79022. * The index of the node to target
  79023. */
  79024. node: number;
  79025. /**
  79026. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  79027. */
  79028. path: AnimationChannelTargetPath;
  79029. }
  79030. /**
  79031. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79032. */
  79033. interface IAnimationSampler extends IProperty {
  79034. /**
  79035. * The index of an accessor containing keyframe input values, e.g., time
  79036. */
  79037. input: number;
  79038. /**
  79039. * Interpolation algorithm
  79040. */
  79041. interpolation?: AnimationSamplerInterpolation;
  79042. /**
  79043. * The index of an accessor, containing keyframe output values
  79044. */
  79045. output: number;
  79046. }
  79047. /**
  79048. * A keyframe animation
  79049. */
  79050. interface IAnimation extends IChildRootProperty {
  79051. /**
  79052. * An array of channels, each of which targets an animation's sampler at a node's property
  79053. */
  79054. channels: IAnimationChannel[];
  79055. /**
  79056. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  79057. */
  79058. samplers: IAnimationSampler[];
  79059. }
  79060. /**
  79061. * Metadata about the glTF asset
  79062. */
  79063. interface IAsset extends IChildRootProperty {
  79064. /**
  79065. * A copyright message suitable for display to credit the content creator
  79066. */
  79067. copyright?: string;
  79068. /**
  79069. * Tool that generated this glTF model. Useful for debugging
  79070. */
  79071. generator?: string;
  79072. /**
  79073. * The glTF version that this asset targets
  79074. */
  79075. version: string;
  79076. /**
  79077. * The minimum glTF version that this asset targets
  79078. */
  79079. minVersion?: string;
  79080. }
  79081. /**
  79082. * A buffer points to binary geometry, animation, or skins
  79083. */
  79084. interface IBuffer extends IChildRootProperty {
  79085. /**
  79086. * 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
  79087. */
  79088. uri?: string;
  79089. /**
  79090. * The length of the buffer in bytes
  79091. */
  79092. byteLength: number;
  79093. }
  79094. /**
  79095. * A view into a buffer generally representing a subset of the buffer
  79096. */
  79097. interface IBufferView extends IChildRootProperty {
  79098. /**
  79099. * The index of the buffer
  79100. */
  79101. buffer: number;
  79102. /**
  79103. * The offset into the buffer in bytes
  79104. */
  79105. byteOffset?: number;
  79106. /**
  79107. * The lenth of the bufferView in bytes
  79108. */
  79109. byteLength: number;
  79110. /**
  79111. * The stride, in bytes
  79112. */
  79113. byteStride?: number;
  79114. }
  79115. /**
  79116. * An orthographic camera containing properties to create an orthographic projection matrix
  79117. */
  79118. interface ICameraOrthographic extends IProperty {
  79119. /**
  79120. * The floating-point horizontal magnification of the view. Must not be zero
  79121. */
  79122. xmag: number;
  79123. /**
  79124. * The floating-point vertical magnification of the view. Must not be zero
  79125. */
  79126. ymag: number;
  79127. /**
  79128. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  79129. */
  79130. zfar: number;
  79131. /**
  79132. * The floating-point distance to the near clipping plane
  79133. */
  79134. znear: number;
  79135. }
  79136. /**
  79137. * A perspective camera containing properties to create a perspective projection matrix
  79138. */
  79139. interface ICameraPerspective extends IProperty {
  79140. /**
  79141. * The floating-point aspect ratio of the field of view
  79142. */
  79143. aspectRatio?: number;
  79144. /**
  79145. * The floating-point vertical field of view in radians
  79146. */
  79147. yfov: number;
  79148. /**
  79149. * The floating-point distance to the far clipping plane
  79150. */
  79151. zfar?: number;
  79152. /**
  79153. * The floating-point distance to the near clipping plane
  79154. */
  79155. znear: number;
  79156. }
  79157. /**
  79158. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  79159. */
  79160. interface ICamera extends IChildRootProperty {
  79161. /**
  79162. * An orthographic camera containing properties to create an orthographic projection matrix
  79163. */
  79164. orthographic?: ICameraOrthographic;
  79165. /**
  79166. * A perspective camera containing properties to create a perspective projection matrix
  79167. */
  79168. perspective?: ICameraPerspective;
  79169. /**
  79170. * Specifies if the camera uses a perspective or orthographic projection
  79171. */
  79172. type: CameraType;
  79173. }
  79174. /**
  79175. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  79176. */
  79177. interface IImage extends IChildRootProperty {
  79178. /**
  79179. * 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
  79180. */
  79181. uri?: string;
  79182. /**
  79183. * The image's MIME type
  79184. */
  79185. mimeType?: ImageMimeType;
  79186. /**
  79187. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  79188. */
  79189. bufferView?: number;
  79190. }
  79191. /**
  79192. * Material Normal Texture Info
  79193. */
  79194. interface IMaterialNormalTextureInfo extends ITextureInfo {
  79195. /**
  79196. * The scalar multiplier applied to each normal vector of the normal texture
  79197. */
  79198. scale?: number;
  79199. }
  79200. /**
  79201. * Material Occlusion Texture Info
  79202. */
  79203. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  79204. /**
  79205. * A scalar multiplier controlling the amount of occlusion applied
  79206. */
  79207. strength?: number;
  79208. }
  79209. /**
  79210. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  79211. */
  79212. interface IMaterialPbrMetallicRoughness {
  79213. /**
  79214. * The material's base color factor
  79215. */
  79216. baseColorFactor?: number[];
  79217. /**
  79218. * The base color texture
  79219. */
  79220. baseColorTexture?: ITextureInfo;
  79221. /**
  79222. * The metalness of the material
  79223. */
  79224. metallicFactor?: number;
  79225. /**
  79226. * The roughness of the material
  79227. */
  79228. roughnessFactor?: number;
  79229. /**
  79230. * The metallic-roughness texture
  79231. */
  79232. metallicRoughnessTexture?: ITextureInfo;
  79233. }
  79234. /**
  79235. * The material appearance of a primitive
  79236. */
  79237. interface IMaterial extends IChildRootProperty {
  79238. /**
  79239. * 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
  79240. */
  79241. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  79242. /**
  79243. * The normal map texture
  79244. */
  79245. normalTexture?: IMaterialNormalTextureInfo;
  79246. /**
  79247. * The occlusion map texture
  79248. */
  79249. occlusionTexture?: IMaterialOcclusionTextureInfo;
  79250. /**
  79251. * The emissive map texture
  79252. */
  79253. emissiveTexture?: ITextureInfo;
  79254. /**
  79255. * 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
  79256. */
  79257. emissiveFactor?: number[];
  79258. /**
  79259. * The alpha rendering mode of the material
  79260. */
  79261. alphaMode?: MaterialAlphaMode;
  79262. /**
  79263. * The alpha cutoff value of the material
  79264. */
  79265. alphaCutoff?: number;
  79266. /**
  79267. * Specifies whether the material is double sided
  79268. */
  79269. doubleSided?: boolean;
  79270. }
  79271. /**
  79272. * Geometry to be rendered with the given material
  79273. */
  79274. interface IMeshPrimitive extends IProperty {
  79275. /**
  79276. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  79277. */
  79278. attributes: {
  79279. [name: string]: number;
  79280. };
  79281. /**
  79282. * The index of the accessor that contains the indices
  79283. */
  79284. indices?: number;
  79285. /**
  79286. * The index of the material to apply to this primitive when rendering
  79287. */
  79288. material?: number;
  79289. /**
  79290. * The type of primitives to render. All valid values correspond to WebGL enums
  79291. */
  79292. mode?: MeshPrimitiveMode;
  79293. /**
  79294. * 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
  79295. */
  79296. targets?: {
  79297. [name: string]: number;
  79298. }[];
  79299. }
  79300. /**
  79301. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  79302. */
  79303. interface IMesh extends IChildRootProperty {
  79304. /**
  79305. * An array of primitives, each defining geometry to be rendered with a material
  79306. */
  79307. primitives: IMeshPrimitive[];
  79308. /**
  79309. * Array of weights to be applied to the Morph Targets
  79310. */
  79311. weights?: number[];
  79312. }
  79313. /**
  79314. * A node in the node hierarchy
  79315. */
  79316. interface INode extends IChildRootProperty {
  79317. /**
  79318. * The index of the camera referenced by this node
  79319. */
  79320. camera?: number;
  79321. /**
  79322. * The indices of this node's children
  79323. */
  79324. children?: number[];
  79325. /**
  79326. * The index of the skin referenced by this node
  79327. */
  79328. skin?: number;
  79329. /**
  79330. * A floating-point 4x4 transformation matrix stored in column-major order
  79331. */
  79332. matrix?: number[];
  79333. /**
  79334. * The index of the mesh in this node
  79335. */
  79336. mesh?: number;
  79337. /**
  79338. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  79339. */
  79340. rotation?: number[];
  79341. /**
  79342. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  79343. */
  79344. scale?: number[];
  79345. /**
  79346. * The node's translation along the x, y, and z axes
  79347. */
  79348. translation?: number[];
  79349. /**
  79350. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  79351. */
  79352. weights?: number[];
  79353. }
  79354. /**
  79355. * Texture sampler properties for filtering and wrapping modes
  79356. */
  79357. interface ISampler extends IChildRootProperty {
  79358. /**
  79359. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  79360. */
  79361. magFilter?: TextureMagFilter;
  79362. /**
  79363. * Minification filter. All valid values correspond to WebGL enums
  79364. */
  79365. minFilter?: TextureMinFilter;
  79366. /**
  79367. * S (U) wrapping mode. All valid values correspond to WebGL enums
  79368. */
  79369. wrapS?: TextureWrapMode;
  79370. /**
  79371. * T (V) wrapping mode. All valid values correspond to WebGL enums
  79372. */
  79373. wrapT?: TextureWrapMode;
  79374. }
  79375. /**
  79376. * The root nodes of a scene
  79377. */
  79378. interface IScene extends IChildRootProperty {
  79379. /**
  79380. * The indices of each root node
  79381. */
  79382. nodes: number[];
  79383. }
  79384. /**
  79385. * Joints and matrices defining a skin
  79386. */
  79387. interface ISkin extends IChildRootProperty {
  79388. /**
  79389. * 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
  79390. */
  79391. inverseBindMatrices?: number;
  79392. /**
  79393. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  79394. */
  79395. skeleton?: number;
  79396. /**
  79397. * 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)
  79398. */
  79399. joints: number[];
  79400. }
  79401. /**
  79402. * A texture and its sampler
  79403. */
  79404. interface ITexture extends IChildRootProperty {
  79405. /**
  79406. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  79407. */
  79408. sampler?: number;
  79409. /**
  79410. * The index of the image used by this texture
  79411. */
  79412. source: number;
  79413. }
  79414. /**
  79415. * Reference to a texture
  79416. */
  79417. interface ITextureInfo extends IProperty {
  79418. /**
  79419. * The index of the texture
  79420. */
  79421. index: number;
  79422. /**
  79423. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  79424. */
  79425. texCoord?: number;
  79426. }
  79427. /**
  79428. * The root object for a glTF asset
  79429. */
  79430. interface IGLTF extends IProperty {
  79431. /**
  79432. * An array of accessors. An accessor is a typed view into a bufferView
  79433. */
  79434. accessors?: IAccessor[];
  79435. /**
  79436. * An array of keyframe animations
  79437. */
  79438. animations?: IAnimation[];
  79439. /**
  79440. * Metadata about the glTF asset
  79441. */
  79442. asset: IAsset;
  79443. /**
  79444. * An array of buffers. A buffer points to binary geometry, animation, or skins
  79445. */
  79446. buffers?: IBuffer[];
  79447. /**
  79448. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  79449. */
  79450. bufferViews?: IBufferView[];
  79451. /**
  79452. * An array of cameras
  79453. */
  79454. cameras?: ICamera[];
  79455. /**
  79456. * Names of glTF extensions used somewhere in this asset
  79457. */
  79458. extensionsUsed?: string[];
  79459. /**
  79460. * Names of glTF extensions required to properly load this asset
  79461. */
  79462. extensionsRequired?: string[];
  79463. /**
  79464. * An array of images. An image defines data used to create a texture
  79465. */
  79466. images?: IImage[];
  79467. /**
  79468. * An array of materials. A material defines the appearance of a primitive
  79469. */
  79470. materials?: IMaterial[];
  79471. /**
  79472. * An array of meshes. A mesh is a set of primitives to be rendered
  79473. */
  79474. meshes?: IMesh[];
  79475. /**
  79476. * An array of nodes
  79477. */
  79478. nodes?: INode[];
  79479. /**
  79480. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  79481. */
  79482. samplers?: ISampler[];
  79483. /**
  79484. * The index of the default scene
  79485. */
  79486. scene?: number;
  79487. /**
  79488. * An array of scenes
  79489. */
  79490. scenes?: IScene[];
  79491. /**
  79492. * An array of skins. A skin is defined by joints and matrices
  79493. */
  79494. skins?: ISkin[];
  79495. /**
  79496. * An array of textures
  79497. */
  79498. textures?: ITexture[];
  79499. }
  79500. /**
  79501. * The glTF validation results
  79502. * @ignore
  79503. */
  79504. interface IGLTFValidationResults {
  79505. info: {
  79506. generator: string;
  79507. hasAnimations: boolean;
  79508. hasDefaultScene: boolean;
  79509. hasMaterials: boolean;
  79510. hasMorphTargets: boolean;
  79511. hasSkins: boolean;
  79512. hasTextures: boolean;
  79513. maxAttributesUsed: number;
  79514. primitivesCount: number
  79515. };
  79516. issues: {
  79517. messages: Array<string>;
  79518. numErrors: number;
  79519. numHints: number;
  79520. numInfos: number;
  79521. numWarnings: number;
  79522. truncated: boolean
  79523. };
  79524. mimeType: string;
  79525. uri: string;
  79526. validatedAt: string;
  79527. validatorVersion: string;
  79528. }
  79529. /**
  79530. * The glTF validation options
  79531. */
  79532. interface IGLTFValidationOptions {
  79533. /** Uri to use */
  79534. uri?: string;
  79535. /** Function used to load external resources */
  79536. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  79537. /** Boolean indicating that we need to validate accessor data */
  79538. validateAccessorData?: boolean;
  79539. /** max number of issues allowed */
  79540. maxIssues?: number;
  79541. /** Ignored issues */
  79542. ignoredIssues?: Array<string>;
  79543. /** Value to override severy settings */
  79544. severityOverrides?: Object;
  79545. }
  79546. /**
  79547. * The glTF validator object
  79548. * @ignore
  79549. */
  79550. interface IGLTFValidator {
  79551. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79552. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  79553. }
  79554. }
  79555. declare module BABYLON {
  79556. /** @hidden */
  79557. export var cellPixelShader: {
  79558. name: string;
  79559. shader: string;
  79560. };
  79561. }
  79562. declare module BABYLON {
  79563. /** @hidden */
  79564. export var cellVertexShader: {
  79565. name: string;
  79566. shader: string;
  79567. };
  79568. }
  79569. declare module BABYLON {
  79570. export class CellMaterial extends BABYLON.PushMaterial {
  79571. private _diffuseTexture;
  79572. diffuseTexture: BABYLON.BaseTexture;
  79573. diffuseColor: BABYLON.Color3;
  79574. _computeHighLevel: boolean;
  79575. computeHighLevel: boolean;
  79576. private _disableLighting;
  79577. disableLighting: boolean;
  79578. private _maxSimultaneousLights;
  79579. maxSimultaneousLights: number;
  79580. private _renderId;
  79581. constructor(name: string, scene: BABYLON.Scene);
  79582. needAlphaBlending(): boolean;
  79583. needAlphaTesting(): boolean;
  79584. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79585. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79586. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79587. getAnimatables(): BABYLON.IAnimatable[];
  79588. getActiveTextures(): BABYLON.BaseTexture[];
  79589. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79590. dispose(forceDisposeEffect?: boolean): void;
  79591. getClassName(): string;
  79592. clone(name: string): CellMaterial;
  79593. serialize(): any;
  79594. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  79595. }
  79596. }
  79597. declare module BABYLON {
  79598. export class CustomShaderStructure {
  79599. FragmentStore: string;
  79600. VertexStore: string;
  79601. constructor();
  79602. }
  79603. export class ShaderSpecialParts {
  79604. constructor();
  79605. Fragment_Begin: string;
  79606. Fragment_Definitions: string;
  79607. Fragment_MainBegin: string;
  79608. Fragment_Custom_Diffuse: string;
  79609. Fragment_Before_Lights: string;
  79610. Fragment_Before_Fog: string;
  79611. Fragment_Custom_Alpha: string;
  79612. Fragment_Before_FragColor: string;
  79613. Vertex_Begin: string;
  79614. Vertex_Definitions: string;
  79615. Vertex_MainBegin: string;
  79616. Vertex_Before_PositionUpdated: string;
  79617. Vertex_Before_NormalUpdated: string;
  79618. Vertex_MainEnd: string;
  79619. }
  79620. export class CustomMaterial extends BABYLON.StandardMaterial {
  79621. static ShaderIndexer: number;
  79622. CustomParts: ShaderSpecialParts;
  79623. _isCreatedShader: boolean;
  79624. _createdShaderName: string;
  79625. _customUniform: string[];
  79626. _newUniforms: string[];
  79627. _newUniformInstances: any[];
  79628. _newSamplerInstances: BABYLON.Texture[];
  79629. _customAttributes: string[];
  79630. FragmentShader: string;
  79631. VertexShader: string;
  79632. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79633. ReviewUniform(name: string, arr: string[]): string[];
  79634. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines, attributes?: string[]): string;
  79635. constructor(name: string, scene: BABYLON.Scene);
  79636. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  79637. AddAttribute(name: string): CustomMaterial;
  79638. Fragment_Begin(shaderPart: string): CustomMaterial;
  79639. Fragment_Definitions(shaderPart: string): CustomMaterial;
  79640. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  79641. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  79642. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  79643. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  79644. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  79645. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  79646. Vertex_Begin(shaderPart: string): CustomMaterial;
  79647. Vertex_Definitions(shaderPart: string): CustomMaterial;
  79648. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  79649. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  79650. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  79651. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  79652. }
  79653. }
  79654. declare module BABYLON {
  79655. export class ShaderAlebdoParts {
  79656. constructor();
  79657. Fragment_Begin: string;
  79658. Fragment_Definitions: string;
  79659. Fragment_MainBegin: string;
  79660. Fragment_Custom_Albedo: string;
  79661. Fragment_Before_Lights: string;
  79662. Fragment_Custom_MetallicRoughness: string;
  79663. Fragment_Custom_MicroSurface: string;
  79664. Fragment_Before_Fog: string;
  79665. Fragment_Custom_Alpha: string;
  79666. Fragment_Before_FragColor: string;
  79667. Vertex_Begin: string;
  79668. Vertex_Definitions: string;
  79669. Vertex_MainBegin: string;
  79670. Vertex_Before_PositionUpdated: string;
  79671. Vertex_Before_NormalUpdated: string;
  79672. Vertex_MainEnd: string;
  79673. }
  79674. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  79675. static ShaderIndexer: number;
  79676. CustomParts: ShaderAlebdoParts;
  79677. _isCreatedShader: boolean;
  79678. _createdShaderName: string;
  79679. _customUniform: string[];
  79680. _newUniforms: string[];
  79681. _newUniformInstances: any[];
  79682. _newSamplerInstances: BABYLON.Texture[];
  79683. _customAttributes: string[];
  79684. FragmentShader: string;
  79685. VertexShader: string;
  79686. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  79687. ReviewUniform(name: string, arr: string[]): string[];
  79688. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines, attributes?: string[]): string;
  79689. constructor(name: string, scene: BABYLON.Scene);
  79690. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  79691. AddAttribute(name: string): PBRCustomMaterial;
  79692. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  79693. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  79694. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  79695. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  79696. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  79697. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  79698. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  79699. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  79700. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  79701. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  79702. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  79703. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  79704. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  79705. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  79706. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  79707. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  79708. }
  79709. }
  79710. declare module BABYLON {
  79711. /** @hidden */
  79712. export var firePixelShader: {
  79713. name: string;
  79714. shader: string;
  79715. };
  79716. }
  79717. declare module BABYLON {
  79718. /** @hidden */
  79719. export var fireVertexShader: {
  79720. name: string;
  79721. shader: string;
  79722. };
  79723. }
  79724. declare module BABYLON {
  79725. export class FireMaterial extends BABYLON.PushMaterial {
  79726. private _diffuseTexture;
  79727. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79728. private _distortionTexture;
  79729. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79730. private _opacityTexture;
  79731. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79732. diffuseColor: BABYLON.Color3;
  79733. speed: number;
  79734. private _scaledDiffuse;
  79735. private _renderId;
  79736. private _lastTime;
  79737. constructor(name: string, scene: BABYLON.Scene);
  79738. needAlphaBlending(): boolean;
  79739. needAlphaTesting(): boolean;
  79740. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79741. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79742. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79743. getAnimatables(): BABYLON.IAnimatable[];
  79744. getActiveTextures(): BABYLON.BaseTexture[];
  79745. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79746. getClassName(): string;
  79747. dispose(forceDisposeEffect?: boolean): void;
  79748. clone(name: string): FireMaterial;
  79749. serialize(): any;
  79750. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  79751. }
  79752. }
  79753. declare module BABYLON {
  79754. /** @hidden */
  79755. export var furPixelShader: {
  79756. name: string;
  79757. shader: string;
  79758. };
  79759. }
  79760. declare module BABYLON {
  79761. /** @hidden */
  79762. export var furVertexShader: {
  79763. name: string;
  79764. shader: string;
  79765. };
  79766. }
  79767. declare module BABYLON {
  79768. export class FurMaterial extends BABYLON.PushMaterial {
  79769. private _diffuseTexture;
  79770. diffuseTexture: BABYLON.BaseTexture;
  79771. private _heightTexture;
  79772. heightTexture: BABYLON.BaseTexture;
  79773. diffuseColor: BABYLON.Color3;
  79774. furLength: number;
  79775. furAngle: number;
  79776. furColor: BABYLON.Color3;
  79777. furOffset: number;
  79778. furSpacing: number;
  79779. furGravity: BABYLON.Vector3;
  79780. furSpeed: number;
  79781. furDensity: number;
  79782. furOcclusion: number;
  79783. furTexture: BABYLON.DynamicTexture;
  79784. private _disableLighting;
  79785. disableLighting: boolean;
  79786. private _maxSimultaneousLights;
  79787. maxSimultaneousLights: number;
  79788. highLevelFur: boolean;
  79789. _meshes: BABYLON.AbstractMesh[];
  79790. private _renderId;
  79791. private _furTime;
  79792. constructor(name: string, scene: BABYLON.Scene);
  79793. get furTime(): number;
  79794. set furTime(furTime: number);
  79795. needAlphaBlending(): boolean;
  79796. needAlphaTesting(): boolean;
  79797. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79798. updateFur(): void;
  79799. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79800. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79801. getAnimatables(): BABYLON.IAnimatable[];
  79802. getActiveTextures(): BABYLON.BaseTexture[];
  79803. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79804. dispose(forceDisposeEffect?: boolean): void;
  79805. clone(name: string): FurMaterial;
  79806. serialize(): any;
  79807. getClassName(): string;
  79808. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  79809. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  79810. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  79811. }
  79812. }
  79813. declare module BABYLON {
  79814. /** @hidden */
  79815. export var gradientPixelShader: {
  79816. name: string;
  79817. shader: string;
  79818. };
  79819. }
  79820. declare module BABYLON {
  79821. /** @hidden */
  79822. export var gradientVertexShader: {
  79823. name: string;
  79824. shader: string;
  79825. };
  79826. }
  79827. declare module BABYLON {
  79828. export class GradientMaterial extends BABYLON.PushMaterial {
  79829. private _maxSimultaneousLights;
  79830. maxSimultaneousLights: number;
  79831. topColor: BABYLON.Color3;
  79832. topColorAlpha: number;
  79833. bottomColor: BABYLON.Color3;
  79834. bottomColorAlpha: number;
  79835. offset: number;
  79836. scale: number;
  79837. smoothness: number;
  79838. private _disableLighting;
  79839. disableLighting: boolean;
  79840. private _renderId;
  79841. constructor(name: string, scene: BABYLON.Scene);
  79842. needAlphaBlending(): boolean;
  79843. needAlphaTesting(): boolean;
  79844. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79845. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79846. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79847. getAnimatables(): BABYLON.IAnimatable[];
  79848. dispose(forceDisposeEffect?: boolean): void;
  79849. clone(name: string): GradientMaterial;
  79850. serialize(): any;
  79851. getClassName(): string;
  79852. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  79853. }
  79854. }
  79855. declare module BABYLON {
  79856. /** @hidden */
  79857. export var gridPixelShader: {
  79858. name: string;
  79859. shader: string;
  79860. };
  79861. }
  79862. declare module BABYLON {
  79863. /** @hidden */
  79864. export var gridVertexShader: {
  79865. name: string;
  79866. shader: string;
  79867. };
  79868. }
  79869. declare module BABYLON {
  79870. /**
  79871. * The grid materials allows you to wrap any shape with a grid.
  79872. * Colors are customizable.
  79873. */
  79874. export class GridMaterial extends BABYLON.PushMaterial {
  79875. /**
  79876. * Main color of the grid (e.g. between lines)
  79877. */
  79878. mainColor: BABYLON.Color3;
  79879. /**
  79880. * Color of the grid lines.
  79881. */
  79882. lineColor: BABYLON.Color3;
  79883. /**
  79884. * The scale of the grid compared to unit.
  79885. */
  79886. gridRatio: number;
  79887. /**
  79888. * Allows setting an offset for the grid lines.
  79889. */
  79890. gridOffset: BABYLON.Vector3;
  79891. /**
  79892. * The frequency of thicker lines.
  79893. */
  79894. majorUnitFrequency: number;
  79895. /**
  79896. * The visibility of minor units in the grid.
  79897. */
  79898. minorUnitVisibility: number;
  79899. /**
  79900. * The grid opacity outside of the lines.
  79901. */
  79902. opacity: number;
  79903. /**
  79904. * Determine RBG output is premultiplied by alpha value.
  79905. */
  79906. preMultiplyAlpha: boolean;
  79907. private _opacityTexture;
  79908. opacityTexture: BABYLON.BaseTexture;
  79909. private _gridControl;
  79910. private _renderId;
  79911. /**
  79912. * constructor
  79913. * @param name The name given to the material in order to identify it afterwards.
  79914. * @param scene The scene the material is used in.
  79915. */
  79916. constructor(name: string, scene: BABYLON.Scene);
  79917. /**
  79918. * Returns wehter or not the grid requires alpha blending.
  79919. */
  79920. needAlphaBlending(): boolean;
  79921. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79922. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79923. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79924. /**
  79925. * Dispose the material and its associated resources.
  79926. * @param forceDisposeEffect will also dispose the used effect when true
  79927. */
  79928. dispose(forceDisposeEffect?: boolean): void;
  79929. clone(name: string): GridMaterial;
  79930. serialize(): any;
  79931. getClassName(): string;
  79932. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  79933. }
  79934. }
  79935. declare module BABYLON {
  79936. /** @hidden */
  79937. export var lavaPixelShader: {
  79938. name: string;
  79939. shader: string;
  79940. };
  79941. }
  79942. declare module BABYLON {
  79943. /** @hidden */
  79944. export var lavaVertexShader: {
  79945. name: string;
  79946. shader: string;
  79947. };
  79948. }
  79949. declare module BABYLON {
  79950. export class LavaMaterial extends BABYLON.PushMaterial {
  79951. private _diffuseTexture;
  79952. diffuseTexture: BABYLON.BaseTexture;
  79953. noiseTexture: BABYLON.BaseTexture;
  79954. fogColor: BABYLON.Color3;
  79955. speed: number;
  79956. movingSpeed: number;
  79957. lowFrequencySpeed: number;
  79958. fogDensity: number;
  79959. private _lastTime;
  79960. diffuseColor: BABYLON.Color3;
  79961. private _disableLighting;
  79962. disableLighting: boolean;
  79963. private _unlit;
  79964. unlit: boolean;
  79965. private _maxSimultaneousLights;
  79966. maxSimultaneousLights: number;
  79967. private _scaledDiffuse;
  79968. private _renderId;
  79969. constructor(name: string, scene: BABYLON.Scene);
  79970. needAlphaBlending(): boolean;
  79971. needAlphaTesting(): boolean;
  79972. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79973. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79974. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79975. getAnimatables(): BABYLON.IAnimatable[];
  79976. getActiveTextures(): BABYLON.BaseTexture[];
  79977. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79978. dispose(forceDisposeEffect?: boolean): void;
  79979. clone(name: string): LavaMaterial;
  79980. serialize(): any;
  79981. getClassName(): string;
  79982. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  79983. }
  79984. }
  79985. declare module BABYLON {
  79986. /** @hidden */
  79987. export var mixPixelShader: {
  79988. name: string;
  79989. shader: string;
  79990. };
  79991. }
  79992. declare module BABYLON {
  79993. /** @hidden */
  79994. export var mixVertexShader: {
  79995. name: string;
  79996. shader: string;
  79997. };
  79998. }
  79999. declare module BABYLON {
  80000. export class MixMaterial extends BABYLON.PushMaterial {
  80001. /**
  80002. * Mix textures
  80003. */
  80004. private _mixTexture1;
  80005. mixTexture1: BABYLON.BaseTexture;
  80006. private _mixTexture2;
  80007. mixTexture2: BABYLON.BaseTexture;
  80008. /**
  80009. * Diffuse textures
  80010. */
  80011. private _diffuseTexture1;
  80012. diffuseTexture1: BABYLON.Texture;
  80013. private _diffuseTexture2;
  80014. diffuseTexture2: BABYLON.Texture;
  80015. private _diffuseTexture3;
  80016. diffuseTexture3: BABYLON.Texture;
  80017. private _diffuseTexture4;
  80018. diffuseTexture4: BABYLON.Texture;
  80019. private _diffuseTexture5;
  80020. diffuseTexture5: BABYLON.Texture;
  80021. private _diffuseTexture6;
  80022. diffuseTexture6: BABYLON.Texture;
  80023. private _diffuseTexture7;
  80024. diffuseTexture7: BABYLON.Texture;
  80025. private _diffuseTexture8;
  80026. diffuseTexture8: BABYLON.Texture;
  80027. /**
  80028. * Uniforms
  80029. */
  80030. diffuseColor: BABYLON.Color3;
  80031. specularColor: BABYLON.Color3;
  80032. specularPower: number;
  80033. private _disableLighting;
  80034. disableLighting: boolean;
  80035. private _maxSimultaneousLights;
  80036. maxSimultaneousLights: number;
  80037. private _renderId;
  80038. constructor(name: string, scene: BABYLON.Scene);
  80039. needAlphaBlending(): boolean;
  80040. needAlphaTesting(): boolean;
  80041. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80042. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80043. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80044. getAnimatables(): BABYLON.IAnimatable[];
  80045. getActiveTextures(): BABYLON.BaseTexture[];
  80046. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80047. dispose(forceDisposeEffect?: boolean): void;
  80048. clone(name: string): MixMaterial;
  80049. serialize(): any;
  80050. getClassName(): string;
  80051. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  80052. }
  80053. }
  80054. declare module BABYLON {
  80055. /** @hidden */
  80056. export var normalPixelShader: {
  80057. name: string;
  80058. shader: string;
  80059. };
  80060. }
  80061. declare module BABYLON {
  80062. /** @hidden */
  80063. export var normalVertexShader: {
  80064. name: string;
  80065. shader: string;
  80066. };
  80067. }
  80068. declare module BABYLON {
  80069. export class NormalMaterial extends BABYLON.PushMaterial {
  80070. private _diffuseTexture;
  80071. diffuseTexture: BABYLON.BaseTexture;
  80072. diffuseColor: BABYLON.Color3;
  80073. private _disableLighting;
  80074. disableLighting: boolean;
  80075. private _maxSimultaneousLights;
  80076. maxSimultaneousLights: number;
  80077. private _renderId;
  80078. constructor(name: string, scene: BABYLON.Scene);
  80079. needAlphaBlending(): boolean;
  80080. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  80081. needAlphaTesting(): boolean;
  80082. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80083. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80084. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80085. getAnimatables(): BABYLON.IAnimatable[];
  80086. getActiveTextures(): BABYLON.BaseTexture[];
  80087. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80088. dispose(forceDisposeEffect?: boolean): void;
  80089. clone(name: string): NormalMaterial;
  80090. serialize(): any;
  80091. getClassName(): string;
  80092. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  80093. }
  80094. }
  80095. declare module BABYLON {
  80096. /** @hidden */
  80097. export var shadowOnlyPixelShader: {
  80098. name: string;
  80099. shader: string;
  80100. };
  80101. }
  80102. declare module BABYLON {
  80103. /** @hidden */
  80104. export var shadowOnlyVertexShader: {
  80105. name: string;
  80106. shader: string;
  80107. };
  80108. }
  80109. declare module BABYLON {
  80110. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  80111. private _renderId;
  80112. private _activeLight;
  80113. constructor(name: string, scene: BABYLON.Scene);
  80114. shadowColor: BABYLON.Color3;
  80115. needAlphaBlending(): boolean;
  80116. needAlphaTesting(): boolean;
  80117. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80118. get activeLight(): BABYLON.IShadowLight;
  80119. set activeLight(light: BABYLON.IShadowLight);
  80120. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80121. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80122. clone(name: string): ShadowOnlyMaterial;
  80123. serialize(): any;
  80124. getClassName(): string;
  80125. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  80126. }
  80127. }
  80128. declare module BABYLON {
  80129. /** @hidden */
  80130. export var simplePixelShader: {
  80131. name: string;
  80132. shader: string;
  80133. };
  80134. }
  80135. declare module BABYLON {
  80136. /** @hidden */
  80137. export var simpleVertexShader: {
  80138. name: string;
  80139. shader: string;
  80140. };
  80141. }
  80142. declare module BABYLON {
  80143. export class SimpleMaterial extends BABYLON.PushMaterial {
  80144. private _diffuseTexture;
  80145. diffuseTexture: BABYLON.BaseTexture;
  80146. diffuseColor: BABYLON.Color3;
  80147. private _disableLighting;
  80148. disableLighting: boolean;
  80149. private _maxSimultaneousLights;
  80150. maxSimultaneousLights: number;
  80151. private _renderId;
  80152. constructor(name: string, scene: BABYLON.Scene);
  80153. needAlphaBlending(): boolean;
  80154. needAlphaTesting(): boolean;
  80155. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80156. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80157. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80158. getAnimatables(): BABYLON.IAnimatable[];
  80159. getActiveTextures(): BABYLON.BaseTexture[];
  80160. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80161. dispose(forceDisposeEffect?: boolean): void;
  80162. clone(name: string): SimpleMaterial;
  80163. serialize(): any;
  80164. getClassName(): string;
  80165. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  80166. }
  80167. }
  80168. declare module BABYLON {
  80169. /** @hidden */
  80170. export var skyPixelShader: {
  80171. name: string;
  80172. shader: string;
  80173. };
  80174. }
  80175. declare module BABYLON {
  80176. /** @hidden */
  80177. export var skyVertexShader: {
  80178. name: string;
  80179. shader: string;
  80180. };
  80181. }
  80182. declare module BABYLON {
  80183. /**
  80184. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  80185. * @see https://doc.babylonjs.com/extensions/sky
  80186. */
  80187. export class SkyMaterial extends BABYLON.PushMaterial {
  80188. /**
  80189. * Defines the overall luminance of sky in interval ]0, 1[.
  80190. */
  80191. luminance: number;
  80192. /**
  80193. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  80194. */
  80195. turbidity: number;
  80196. /**
  80197. * Defines the sky appearance (light intensity).
  80198. */
  80199. rayleigh: number;
  80200. /**
  80201. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  80202. */
  80203. mieCoefficient: number;
  80204. /**
  80205. * Defines the amount of haze particles following the Mie scattering theory.
  80206. */
  80207. mieDirectionalG: number;
  80208. /**
  80209. * Defines the distance of the sun according to the active scene camera.
  80210. */
  80211. distance: number;
  80212. /**
  80213. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  80214. * "inclined".
  80215. */
  80216. inclination: number;
  80217. /**
  80218. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  80219. * an object direction and a reference direction.
  80220. */
  80221. azimuth: number;
  80222. /**
  80223. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  80224. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  80225. */
  80226. sunPosition: BABYLON.Vector3;
  80227. /**
  80228. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  80229. * .sunPosition property.
  80230. */
  80231. useSunPosition: boolean;
  80232. /**
  80233. * Defines an offset vector used to get a horizon offset.
  80234. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  80235. */
  80236. cameraOffset: BABYLON.Vector3;
  80237. private _cameraPosition;
  80238. private _renderId;
  80239. /**
  80240. * Instantiates a new sky material.
  80241. * This material allows to create dynamic and texture free
  80242. * effects for skyboxes by taking care of the atmosphere state.
  80243. * @see https://doc.babylonjs.com/extensions/sky
  80244. * @param name Define the name of the material in the scene
  80245. * @param scene Define the scene the material belong to
  80246. */
  80247. constructor(name: string, scene: BABYLON.Scene);
  80248. /**
  80249. * Specifies if the material will require alpha blending
  80250. * @returns a boolean specifying if alpha blending is needed
  80251. */
  80252. needAlphaBlending(): boolean;
  80253. /**
  80254. * Specifies if this material should be rendered in alpha test mode
  80255. * @returns false as the sky material doesn't need alpha testing.
  80256. */
  80257. needAlphaTesting(): boolean;
  80258. /**
  80259. * Get the texture used for alpha test purpose.
  80260. * @returns null as the sky material has no texture.
  80261. */
  80262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80263. /**
  80264. * Get if the submesh is ready to be used and all its information available.
  80265. * Child classes can use it to update shaders
  80266. * @param mesh defines the mesh to check
  80267. * @param subMesh defines which submesh to check
  80268. * @param useInstances specifies that instances should be used
  80269. * @returns a boolean indicating that the submesh is ready or not
  80270. */
  80271. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80272. /**
  80273. * Binds the submesh to this material by preparing the effect and shader to draw
  80274. * @param world defines the world transformation matrix
  80275. * @param mesh defines the mesh containing the submesh
  80276. * @param subMesh defines the submesh to bind the material to
  80277. */
  80278. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80279. /**
  80280. * Get the list of animatables in the material.
  80281. * @returns the list of animatables object used in the material
  80282. */
  80283. getAnimatables(): BABYLON.IAnimatable[];
  80284. /**
  80285. * Disposes the material
  80286. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  80287. */
  80288. dispose(forceDisposeEffect?: boolean): void;
  80289. /**
  80290. * Makes a duplicate of the material, and gives it a new name
  80291. * @param name defines the new name for the duplicated material
  80292. * @returns the cloned material
  80293. */
  80294. clone(name: string): SkyMaterial;
  80295. /**
  80296. * Serializes this material in a JSON representation
  80297. * @returns the serialized material object
  80298. */
  80299. serialize(): any;
  80300. /**
  80301. * Gets the current class name of the material e.g. "SkyMaterial"
  80302. * Mainly use in serialization.
  80303. * @returns the class name
  80304. */
  80305. getClassName(): string;
  80306. /**
  80307. * Creates a sky material from parsed material data
  80308. * @param source defines the JSON representation of the material
  80309. * @param scene defines the hosting scene
  80310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  80311. * @returns a new sky material
  80312. */
  80313. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  80314. }
  80315. }
  80316. declare module BABYLON {
  80317. /** @hidden */
  80318. export var terrainPixelShader: {
  80319. name: string;
  80320. shader: string;
  80321. };
  80322. }
  80323. declare module BABYLON {
  80324. /** @hidden */
  80325. export var terrainVertexShader: {
  80326. name: string;
  80327. shader: string;
  80328. };
  80329. }
  80330. declare module BABYLON {
  80331. export class TerrainMaterial extends BABYLON.PushMaterial {
  80332. private _mixTexture;
  80333. mixTexture: BABYLON.BaseTexture;
  80334. private _diffuseTexture1;
  80335. diffuseTexture1: BABYLON.Texture;
  80336. private _diffuseTexture2;
  80337. diffuseTexture2: BABYLON.Texture;
  80338. private _diffuseTexture3;
  80339. diffuseTexture3: BABYLON.Texture;
  80340. private _bumpTexture1;
  80341. bumpTexture1: BABYLON.Texture;
  80342. private _bumpTexture2;
  80343. bumpTexture2: BABYLON.Texture;
  80344. private _bumpTexture3;
  80345. bumpTexture3: BABYLON.Texture;
  80346. diffuseColor: BABYLON.Color3;
  80347. specularColor: BABYLON.Color3;
  80348. specularPower: number;
  80349. private _disableLighting;
  80350. disableLighting: boolean;
  80351. private _maxSimultaneousLights;
  80352. maxSimultaneousLights: number;
  80353. private _renderId;
  80354. constructor(name: string, scene: BABYLON.Scene);
  80355. needAlphaBlending(): boolean;
  80356. needAlphaTesting(): boolean;
  80357. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80358. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80359. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80360. getAnimatables(): BABYLON.IAnimatable[];
  80361. getActiveTextures(): BABYLON.BaseTexture[];
  80362. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80363. dispose(forceDisposeEffect?: boolean): void;
  80364. clone(name: string): TerrainMaterial;
  80365. serialize(): any;
  80366. getClassName(): string;
  80367. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  80368. }
  80369. }
  80370. declare module BABYLON {
  80371. /** @hidden */
  80372. export var triplanarPixelShader: {
  80373. name: string;
  80374. shader: string;
  80375. };
  80376. }
  80377. declare module BABYLON {
  80378. /** @hidden */
  80379. export var triplanarVertexShader: {
  80380. name: string;
  80381. shader: string;
  80382. };
  80383. }
  80384. declare module BABYLON {
  80385. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  80386. mixTexture: BABYLON.BaseTexture;
  80387. private _diffuseTextureX;
  80388. diffuseTextureX: BABYLON.BaseTexture;
  80389. private _diffuseTextureY;
  80390. diffuseTextureY: BABYLON.BaseTexture;
  80391. private _diffuseTextureZ;
  80392. diffuseTextureZ: BABYLON.BaseTexture;
  80393. private _normalTextureX;
  80394. normalTextureX: BABYLON.BaseTexture;
  80395. private _normalTextureY;
  80396. normalTextureY: BABYLON.BaseTexture;
  80397. private _normalTextureZ;
  80398. normalTextureZ: BABYLON.BaseTexture;
  80399. tileSize: number;
  80400. diffuseColor: BABYLON.Color3;
  80401. specularColor: BABYLON.Color3;
  80402. specularPower: number;
  80403. private _disableLighting;
  80404. disableLighting: boolean;
  80405. private _maxSimultaneousLights;
  80406. maxSimultaneousLights: number;
  80407. private _renderId;
  80408. constructor(name: string, scene: BABYLON.Scene);
  80409. needAlphaBlending(): boolean;
  80410. needAlphaTesting(): boolean;
  80411. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80412. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80413. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80414. getAnimatables(): BABYLON.IAnimatable[];
  80415. getActiveTextures(): BABYLON.BaseTexture[];
  80416. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80417. dispose(forceDisposeEffect?: boolean): void;
  80418. clone(name: string): TriPlanarMaterial;
  80419. serialize(): any;
  80420. getClassName(): string;
  80421. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  80422. }
  80423. }
  80424. declare module BABYLON {
  80425. /** @hidden */
  80426. export var waterPixelShader: {
  80427. name: string;
  80428. shader: string;
  80429. };
  80430. }
  80431. declare module BABYLON {
  80432. /** @hidden */
  80433. export var waterVertexShader: {
  80434. name: string;
  80435. shader: string;
  80436. };
  80437. }
  80438. declare module BABYLON {
  80439. export class WaterMaterial extends BABYLON.PushMaterial {
  80440. renderTargetSize: BABYLON.Vector2;
  80441. private _bumpTexture;
  80442. bumpTexture: BABYLON.BaseTexture;
  80443. diffuseColor: BABYLON.Color3;
  80444. specularColor: BABYLON.Color3;
  80445. specularPower: number;
  80446. private _disableLighting;
  80447. disableLighting: boolean;
  80448. private _maxSimultaneousLights;
  80449. maxSimultaneousLights: number;
  80450. /**
  80451. * @param {number}: Represents the wind force
  80452. */
  80453. windForce: number;
  80454. /**
  80455. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  80456. */
  80457. windDirection: BABYLON.Vector2;
  80458. /**
  80459. * @param {number}: Wave height, represents the height of the waves
  80460. */
  80461. waveHeight: number;
  80462. /**
  80463. * @param {number}: Bump height, represents the bump height related to the bump map
  80464. */
  80465. bumpHeight: number;
  80466. /**
  80467. * @param {boolean}: Add a smaller moving bump to less steady waves.
  80468. */
  80469. private _bumpSuperimpose;
  80470. bumpSuperimpose: boolean;
  80471. /**
  80472. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  80473. */
  80474. private _fresnelSeparate;
  80475. fresnelSeparate: boolean;
  80476. /**
  80477. * @param {boolean}: bump Waves modify the reflection.
  80478. */
  80479. private _bumpAffectsReflection;
  80480. bumpAffectsReflection: boolean;
  80481. /**
  80482. * @param {number}: The water color blended with the refraction (near)
  80483. */
  80484. waterColor: BABYLON.Color3;
  80485. /**
  80486. * @param {number}: The blend factor related to the water color
  80487. */
  80488. colorBlendFactor: number;
  80489. /**
  80490. * @param {number}: The water color blended with the reflection (far)
  80491. */
  80492. waterColor2: BABYLON.Color3;
  80493. /**
  80494. * @param {number}: The blend factor related to the water color (reflection, far)
  80495. */
  80496. colorBlendFactor2: number;
  80497. /**
  80498. * @param {number}: Represents the maximum length of a wave
  80499. */
  80500. waveLength: number;
  80501. /**
  80502. * @param {number}: Defines the waves speed
  80503. */
  80504. waveSpeed: number;
  80505. /**
  80506. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  80507. * will avoid calculating useless pixels in the pixel shader of the water material.
  80508. */
  80509. disableClipPlane: boolean;
  80510. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  80511. private _mesh;
  80512. private _refractionRTT;
  80513. private _reflectionRTT;
  80514. private _reflectionTransform;
  80515. private _lastTime;
  80516. private _lastDeltaTime;
  80517. private _renderId;
  80518. private _useLogarithmicDepth;
  80519. private _waitingRenderList;
  80520. private _imageProcessingConfiguration;
  80521. private _imageProcessingObserver;
  80522. /**
  80523. * Gets a boolean indicating that current material needs to register RTT
  80524. */
  80525. get hasRenderTargetTextures(): boolean;
  80526. /**
  80527. * Constructor
  80528. */
  80529. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  80530. get useLogarithmicDepth(): boolean;
  80531. set useLogarithmicDepth(value: boolean);
  80532. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80533. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  80534. addToRenderList(node: any): void;
  80535. enableRenderTargets(enable: boolean): void;
  80536. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  80537. get renderTargetsEnabled(): boolean;
  80538. needAlphaBlending(): boolean;
  80539. needAlphaTesting(): boolean;
  80540. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80541. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80542. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80543. private _createRenderTargets;
  80544. getAnimatables(): BABYLON.IAnimatable[];
  80545. getActiveTextures(): BABYLON.BaseTexture[];
  80546. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80547. dispose(forceDisposeEffect?: boolean): void;
  80548. clone(name: string): WaterMaterial;
  80549. serialize(): any;
  80550. getClassName(): string;
  80551. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  80552. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  80553. }
  80554. }
  80555. declare module BABYLON {
  80556. /** @hidden */
  80557. export var asciiartPixelShader: {
  80558. name: string;
  80559. shader: string;
  80560. };
  80561. }
  80562. declare module BABYLON {
  80563. /**
  80564. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  80565. *
  80566. * It basically takes care rendering the font front the given font size to a texture.
  80567. * This is used later on in the postprocess.
  80568. */
  80569. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  80570. private _font;
  80571. private _text;
  80572. private _charSize;
  80573. /**
  80574. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80575. */
  80576. get charSize(): number;
  80577. /**
  80578. * Create a new instance of the Ascii Art FontTexture class
  80579. * @param name the name of the texture
  80580. * @param font the font to use, use the W3C CSS notation
  80581. * @param text the caracter set to use in the rendering.
  80582. * @param scene the scene that owns the texture
  80583. */
  80584. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80585. /**
  80586. * Gets the max char width of a font.
  80587. * @param font the font to use, use the W3C CSS notation
  80588. * @return the max char width
  80589. */
  80590. private getFontWidth;
  80591. /**
  80592. * Gets the max char height of a font.
  80593. * @param font the font to use, use the W3C CSS notation
  80594. * @return the max char height
  80595. */
  80596. private getFontHeight;
  80597. /**
  80598. * Clones the current AsciiArtTexture.
  80599. * @return the clone of the texture.
  80600. */
  80601. clone(): AsciiArtFontTexture;
  80602. /**
  80603. * Parses a json object representing the texture and returns an instance of it.
  80604. * @param source the source JSON representation
  80605. * @param scene the scene to create the texture for
  80606. * @return the parsed texture
  80607. */
  80608. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  80609. }
  80610. /**
  80611. * Option available in the Ascii Art Post Process.
  80612. */
  80613. export interface IAsciiArtPostProcessOptions {
  80614. /**
  80615. * The font to use following the w3c font definition.
  80616. */
  80617. font?: string;
  80618. /**
  80619. * The character set to use in the postprocess.
  80620. */
  80621. characterSet?: string;
  80622. /**
  80623. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80624. * This number is defined between 0 and 1;
  80625. */
  80626. mixToTile?: number;
  80627. /**
  80628. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80629. * This number is defined between 0 and 1;
  80630. */
  80631. mixToNormal?: number;
  80632. }
  80633. /**
  80634. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  80635. *
  80636. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80637. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  80638. */
  80639. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  80640. /**
  80641. * The font texture used to render the char in the post process.
  80642. */
  80643. private _asciiArtFontTexture;
  80644. /**
  80645. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  80646. * This number is defined between 0 and 1;
  80647. */
  80648. mixToTile: number;
  80649. /**
  80650. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  80651. * This number is defined between 0 and 1;
  80652. */
  80653. mixToNormal: number;
  80654. /**
  80655. * Instantiates a new Ascii Art Post Process.
  80656. * @param name the name to give to the postprocess
  80657. * @camera the camera to apply the post process to.
  80658. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  80659. */
  80660. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  80661. }
  80662. }
  80663. declare module BABYLON {
  80664. /** @hidden */
  80665. export var digitalrainPixelShader: {
  80666. name: string;
  80667. shader: string;
  80668. };
  80669. }
  80670. declare module BABYLON {
  80671. /**
  80672. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  80673. *
  80674. * It basically takes care rendering the font front the given font size to a texture.
  80675. * This is used later on in the postprocess.
  80676. */
  80677. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  80678. private _font;
  80679. private _text;
  80680. private _charSize;
  80681. /**
  80682. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  80683. */
  80684. get charSize(): number;
  80685. /**
  80686. * Create a new instance of the Digital Rain FontTexture class
  80687. * @param name the name of the texture
  80688. * @param font the font to use, use the W3C CSS notation
  80689. * @param text the caracter set to use in the rendering.
  80690. * @param scene the scene that owns the texture
  80691. */
  80692. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  80693. /**
  80694. * Gets the max char width of a font.
  80695. * @param font the font to use, use the W3C CSS notation
  80696. * @return the max char width
  80697. */
  80698. private getFontWidth;
  80699. /**
  80700. * Gets the max char height of a font.
  80701. * @param font the font to use, use the W3C CSS notation
  80702. * @return the max char height
  80703. */
  80704. private getFontHeight;
  80705. /**
  80706. * Clones the current DigitalRainFontTexture.
  80707. * @return the clone of the texture.
  80708. */
  80709. clone(): DigitalRainFontTexture;
  80710. /**
  80711. * Parses a json object representing the texture and returns an instance of it.
  80712. * @param source the source JSON representation
  80713. * @param scene the scene to create the texture for
  80714. * @return the parsed texture
  80715. */
  80716. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  80717. }
  80718. /**
  80719. * Option available in the Digital Rain Post Process.
  80720. */
  80721. export interface IDigitalRainPostProcessOptions {
  80722. /**
  80723. * The font to use following the w3c font definition.
  80724. */
  80725. font?: string;
  80726. /**
  80727. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80728. * This number is defined between 0 and 1;
  80729. */
  80730. mixToTile?: number;
  80731. /**
  80732. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80733. * This number is defined between 0 and 1;
  80734. */
  80735. mixToNormal?: number;
  80736. }
  80737. /**
  80738. * DigitalRainPostProcess helps rendering everithing in digital rain.
  80739. *
  80740. * Simmply add it to your scene and let the nerd that lives in you have fun.
  80741. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  80742. */
  80743. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  80744. /**
  80745. * The font texture used to render the char in the post process.
  80746. */
  80747. private _digitalRainFontTexture;
  80748. /**
  80749. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  80750. * This number is defined between 0 and 1;
  80751. */
  80752. mixToTile: number;
  80753. /**
  80754. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  80755. * This number is defined between 0 and 1;
  80756. */
  80757. mixToNormal: number;
  80758. /**
  80759. * Instantiates a new Digital Rain Post Process.
  80760. * @param name the name to give to the postprocess
  80761. * @camera the camera to apply the post process to.
  80762. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  80763. */
  80764. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  80765. }
  80766. }
  80767. declare module BABYLON {
  80768. /** @hidden */
  80769. export var brickProceduralTexturePixelShader: {
  80770. name: string;
  80771. shader: string;
  80772. };
  80773. }
  80774. declare module BABYLON {
  80775. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  80776. private _numberOfBricksHeight;
  80777. private _numberOfBricksWidth;
  80778. private _jointColor;
  80779. private _brickColor;
  80780. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80781. updateShaderUniforms(): void;
  80782. get numberOfBricksHeight(): number;
  80783. set numberOfBricksHeight(value: number);
  80784. get numberOfBricksWidth(): number;
  80785. set numberOfBricksWidth(value: number);
  80786. get jointColor(): BABYLON.Color3;
  80787. set jointColor(value: BABYLON.Color3);
  80788. get brickColor(): BABYLON.Color3;
  80789. set brickColor(value: BABYLON.Color3);
  80790. /**
  80791. * Serializes this brick procedural texture
  80792. * @returns a serialized brick procedural texture object
  80793. */
  80794. serialize(): any;
  80795. /**
  80796. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  80797. * @param parsedTexture defines parsed texture data
  80798. * @param scene defines the current scene
  80799. * @param rootUrl defines the root URL containing brick procedural texture information
  80800. * @returns a parsed Brick Procedural BABYLON.Texture
  80801. */
  80802. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  80803. }
  80804. }
  80805. declare module BABYLON {
  80806. /** @hidden */
  80807. export var cloudProceduralTexturePixelShader: {
  80808. name: string;
  80809. shader: string;
  80810. };
  80811. }
  80812. declare module BABYLON {
  80813. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  80814. private _skyColor;
  80815. private _cloudColor;
  80816. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80817. updateShaderUniforms(): void;
  80818. get skyColor(): BABYLON.Color4;
  80819. set skyColor(value: BABYLON.Color4);
  80820. get cloudColor(): BABYLON.Color4;
  80821. set cloudColor(value: BABYLON.Color4);
  80822. /**
  80823. * Serializes this cloud procedural texture
  80824. * @returns a serialized cloud procedural texture object
  80825. */
  80826. serialize(): any;
  80827. /**
  80828. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  80829. * @param parsedTexture defines parsed texture data
  80830. * @param scene defines the current scene
  80831. * @param rootUrl defines the root URL containing cloud procedural texture information
  80832. * @returns a parsed Cloud Procedural BABYLON.Texture
  80833. */
  80834. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  80835. }
  80836. }
  80837. declare module BABYLON {
  80838. /** @hidden */
  80839. export var fireProceduralTexturePixelShader: {
  80840. name: string;
  80841. shader: string;
  80842. };
  80843. }
  80844. declare module BABYLON {
  80845. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  80846. private _time;
  80847. private _speed;
  80848. private _autoGenerateTime;
  80849. private _fireColors;
  80850. private _alphaThreshold;
  80851. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80852. updateShaderUniforms(): void;
  80853. render(useCameraPostProcess?: boolean): void;
  80854. static get PurpleFireColors(): BABYLON.Color3[];
  80855. static get GreenFireColors(): BABYLON.Color3[];
  80856. static get RedFireColors(): BABYLON.Color3[];
  80857. static get BlueFireColors(): BABYLON.Color3[];
  80858. get autoGenerateTime(): boolean;
  80859. set autoGenerateTime(value: boolean);
  80860. get fireColors(): BABYLON.Color3[];
  80861. set fireColors(value: BABYLON.Color3[]);
  80862. get time(): number;
  80863. set time(value: number);
  80864. get speed(): BABYLON.Vector2;
  80865. set speed(value: BABYLON.Vector2);
  80866. get alphaThreshold(): number;
  80867. set alphaThreshold(value: number);
  80868. /**
  80869. * Serializes this fire procedural texture
  80870. * @returns a serialized fire procedural texture object
  80871. */
  80872. serialize(): any;
  80873. /**
  80874. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  80875. * @param parsedTexture defines parsed texture data
  80876. * @param scene defines the current scene
  80877. * @param rootUrl defines the root URL containing fire procedural texture information
  80878. * @returns a parsed Fire Procedural BABYLON.Texture
  80879. */
  80880. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  80881. }
  80882. }
  80883. declare module BABYLON {
  80884. /** @hidden */
  80885. export var grassProceduralTexturePixelShader: {
  80886. name: string;
  80887. shader: string;
  80888. };
  80889. }
  80890. declare module BABYLON {
  80891. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  80892. private _grassColors;
  80893. private _groundColor;
  80894. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80895. updateShaderUniforms(): void;
  80896. get grassColors(): BABYLON.Color3[];
  80897. set grassColors(value: BABYLON.Color3[]);
  80898. get groundColor(): BABYLON.Color3;
  80899. set groundColor(value: BABYLON.Color3);
  80900. /**
  80901. * Serializes this grass procedural texture
  80902. * @returns a serialized grass procedural texture object
  80903. */
  80904. serialize(): any;
  80905. /**
  80906. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  80907. * @param parsedTexture defines parsed texture data
  80908. * @param scene defines the current scene
  80909. * @param rootUrl defines the root URL containing grass procedural texture information
  80910. * @returns a parsed Grass Procedural BABYLON.Texture
  80911. */
  80912. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  80913. }
  80914. }
  80915. declare module BABYLON {
  80916. /** @hidden */
  80917. export var marbleProceduralTexturePixelShader: {
  80918. name: string;
  80919. shader: string;
  80920. };
  80921. }
  80922. declare module BABYLON {
  80923. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  80924. private _numberOfTilesHeight;
  80925. private _numberOfTilesWidth;
  80926. private _amplitude;
  80927. private _jointColor;
  80928. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80929. updateShaderUniforms(): void;
  80930. get numberOfTilesHeight(): number;
  80931. set numberOfTilesHeight(value: number);
  80932. get amplitude(): number;
  80933. set amplitude(value: number);
  80934. get numberOfTilesWidth(): number;
  80935. set numberOfTilesWidth(value: number);
  80936. get jointColor(): BABYLON.Color3;
  80937. set jointColor(value: BABYLON.Color3);
  80938. /**
  80939. * Serializes this marble procedural texture
  80940. * @returns a serialized marble procedural texture object
  80941. */
  80942. serialize(): any;
  80943. /**
  80944. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  80945. * @param parsedTexture defines parsed texture data
  80946. * @param scene defines the current scene
  80947. * @param rootUrl defines the root URL containing marble procedural texture information
  80948. * @returns a parsed Marble Procedural BABYLON.Texture
  80949. */
  80950. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  80951. }
  80952. }
  80953. declare module BABYLON {
  80954. /** @hidden */
  80955. export var normalMapProceduralTexturePixelShader: {
  80956. name: string;
  80957. shader: string;
  80958. };
  80959. }
  80960. declare module BABYLON {
  80961. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  80962. private _baseTexture;
  80963. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80964. updateShaderUniforms(): void;
  80965. render(useCameraPostProcess?: boolean): void;
  80966. resize(size: any, generateMipMaps: any): void;
  80967. get baseTexture(): BABYLON.Texture;
  80968. set baseTexture(texture: BABYLON.Texture);
  80969. /**
  80970. * Serializes this normal map procedural texture
  80971. * @returns a serialized normal map procedural texture object
  80972. */
  80973. serialize(): any;
  80974. /**
  80975. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  80976. * @param parsedTexture defines parsed texture data
  80977. * @param scene defines the current scene
  80978. * @param rootUrl defines the root URL containing normal map procedural texture information
  80979. * @returns a parsed Normal Map Procedural BABYLON.Texture
  80980. */
  80981. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  80982. }
  80983. }
  80984. declare module BABYLON {
  80985. /** @hidden */
  80986. export var perlinNoiseProceduralTexturePixelShader: {
  80987. name: string;
  80988. shader: string;
  80989. };
  80990. }
  80991. declare module BABYLON {
  80992. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  80993. time: number;
  80994. timeScale: number;
  80995. translationSpeed: number;
  80996. private _currentTranslation;
  80997. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80998. updateShaderUniforms(): void;
  80999. render(useCameraPostProcess?: boolean): void;
  81000. resize(size: any, generateMipMaps: any): void;
  81001. /**
  81002. * Serializes this perlin noise procedural texture
  81003. * @returns a serialized perlin noise procedural texture object
  81004. */
  81005. serialize(): any;
  81006. /**
  81007. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  81008. * @param parsedTexture defines parsed texture data
  81009. * @param scene defines the current scene
  81010. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  81011. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  81012. */
  81013. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  81014. }
  81015. }
  81016. declare module BABYLON {
  81017. /** @hidden */
  81018. export var roadProceduralTexturePixelShader: {
  81019. name: string;
  81020. shader: string;
  81021. };
  81022. }
  81023. declare module BABYLON {
  81024. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  81025. private _roadColor;
  81026. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81027. updateShaderUniforms(): void;
  81028. get roadColor(): BABYLON.Color3;
  81029. set roadColor(value: BABYLON.Color3);
  81030. /**
  81031. * Serializes this road procedural texture
  81032. * @returns a serialized road procedural texture object
  81033. */
  81034. serialize(): any;
  81035. /**
  81036. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  81037. * @param parsedTexture defines parsed texture data
  81038. * @param scene defines the current scene
  81039. * @param rootUrl defines the root URL containing road procedural texture information
  81040. * @returns a parsed Road Procedural BABYLON.Texture
  81041. */
  81042. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  81043. }
  81044. }
  81045. declare module BABYLON {
  81046. /** @hidden */
  81047. export var starfieldProceduralTexturePixelShader: {
  81048. name: string;
  81049. shader: string;
  81050. };
  81051. }
  81052. declare module BABYLON {
  81053. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  81054. private _time;
  81055. private _alpha;
  81056. private _beta;
  81057. private _zoom;
  81058. private _formuparam;
  81059. private _stepsize;
  81060. private _tile;
  81061. private _brightness;
  81062. private _darkmatter;
  81063. private _distfading;
  81064. private _saturation;
  81065. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81066. updateShaderUniforms(): void;
  81067. get time(): number;
  81068. set time(value: number);
  81069. get alpha(): number;
  81070. set alpha(value: number);
  81071. get beta(): number;
  81072. set beta(value: number);
  81073. get formuparam(): number;
  81074. set formuparam(value: number);
  81075. get stepsize(): number;
  81076. set stepsize(value: number);
  81077. get zoom(): number;
  81078. set zoom(value: number);
  81079. get tile(): number;
  81080. set tile(value: number);
  81081. get brightness(): number;
  81082. set brightness(value: number);
  81083. get darkmatter(): number;
  81084. set darkmatter(value: number);
  81085. get distfading(): number;
  81086. set distfading(value: number);
  81087. get saturation(): number;
  81088. set saturation(value: number);
  81089. /**
  81090. * Serializes this starfield procedural texture
  81091. * @returns a serialized starfield procedural texture object
  81092. */
  81093. serialize(): any;
  81094. /**
  81095. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  81096. * @param parsedTexture defines parsed texture data
  81097. * @param scene defines the current scene
  81098. * @param rootUrl defines the root URL containing startfield procedural texture information
  81099. * @returns a parsed Starfield Procedural BABYLON.Texture
  81100. */
  81101. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  81102. }
  81103. }
  81104. declare module BABYLON {
  81105. /** @hidden */
  81106. export var woodProceduralTexturePixelShader: {
  81107. name: string;
  81108. shader: string;
  81109. };
  81110. }
  81111. declare module BABYLON {
  81112. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  81113. private _ampScale;
  81114. private _woodColor;
  81115. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  81116. updateShaderUniforms(): void;
  81117. get ampScale(): number;
  81118. set ampScale(value: number);
  81119. get woodColor(): BABYLON.Color3;
  81120. set woodColor(value: BABYLON.Color3);
  81121. /**
  81122. * Serializes this wood procedural texture
  81123. * @returns a serialized wood procedural texture object
  81124. */
  81125. serialize(): any;
  81126. /**
  81127. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  81128. * @param parsedTexture defines parsed texture data
  81129. * @param scene defines the current scene
  81130. * @param rootUrl defines the root URL containing wood procedural texture information
  81131. * @returns a parsed Wood Procedural BABYLON.Texture
  81132. */
  81133. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  81134. }
  81135. }